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.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
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 pathsin 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