Question:
How can i set the path in java program?
Pinjrapoli
2008-04-16 11:45:49 UTC
I installed jdk1.5.0 update 2 and wanted to set permanent path so that i can write programs in java but when i wrote javac in command prompt answer was ' javac is not recognized as internal or external program.
Three answers:
2008-04-16 11:51:13 UTC
i'm assuming you're on windows. If you are you can include the path to this .exe in the path parameters.



From the command prompt:

set path = %path%;[path to folder containing .exe]



i'm not sure how to do it on other platforms, but it should be something similar regarding setting environment variables
2008-04-16 12:54:52 UTC
I think it is good to make sure you type in the path correctly. It want to tell you about .bat file. I will automate your coding.



Open Notepad, type in:

javac C:\Program Files\Java\jdk1.6.0\bin\javac MyClass.java



save that file as "compile.bat" into your folder with your current work project.



Start another file in Notepad, type in:

java .\;C:\ProgramFiles\Java\jdk1.6.0\bin\java MyClass



Note, just after java the .\; that is look here first, java, this folder. The semicolon is the DOS end-of-line. The rest is the path to the java engine, a space the Java program you compiled.



Save that as "run.bat" in the same folder.



Now, you can double-click the .bat file. If it fails, make sure the path points to the bin folder inside JDK folder. It can be tricky. You see, in DOS the folders are \ (backslash). In java, in the internet, everywhere else, the path folders are "/".



If you .bat files work, great. Change your environment variable. You can then make your next bat files without the path.

javac MyJava.java



java MyJava



And finally, the NetBeans IDE does this bat file automatically for you every time you run code. NetBeans is a great editor, colors the keywords and helps you code.
smithwick
2016-10-24 04:46:44 UTC
i'd properly be incorrect, yet do not you positioned the Java route in the stepped ahead... Environmental putting of domicile windows? (hit the domicile windows-key + pause) (i'd properly be off.. I purely took one Java class)


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...