How do I get the javac compiler to compile a file in any directory from any directory?
I want to be able to compile a source file when I'm in neither the root directory for the source file nor the root directory for the compiler.
Printable View
How do I get the javac compiler to compile a file in any directory from any directory?
I want to be able to compile a source file when I'm in neither the root directory for the source file nor the root directory for the compiler.
Have you tried specifying the full pathsQuote:
in any directory from any directory
Depends on the OS. Not really a java programming problem.
Where would have been a more appropriate place to ask?
You need to set the path/classpath on your system, which is system dependent. I'd say do a web search for these keywords for instructions for you system. In windows, it has to do with going to your control panel->System->Advanced->Environmental Variables (I can't reproduce the instructions which again, you can find by doing a web search). Setting things up properly will allow you to call javac from any directory, which I believe is what you are asking.
OK this is very simple.... I AM USING WINDOWS VISTA
COPYING THE FILE LOCATION/ADDRESS OF javac
All you do is go to the bin file where javac program is kept.
Right click on the file to open the pop-up menu.
Choose properties.
Copy (Highlight, then Ctrl + C) the "Location" information, not the word "Location".
PASTING javac FILE ADDRESS AT THE END OF THE CURRENT PATH INFORMATION
Go to 'System, Advanced System Settings, Environment Variables.
In the "System Variables" part of the "Advanced" tab, select "Path" or "PATH" if it is capitalized.
Press "Edit".
In the "Edit System Variable" screen, in the "Variable Value:" text box, scroll to the end of the info already there, DO NOT DELETE ANYTHING, at the end, leave no space, but enter a ";" then press Ctrl + V to paste the info into the space next to the ";" you just entered, save and close.
FINAL STEP
You will have to reopen your "Run.." window because the change will not work until you do.
Now you can type in javac WhyIsThisSoDifficult.java, without having to add the file location of the javac first.
More info on the subject