How to set path in java?? I have installed java jdk compiler on my system. When i went to CMD to compile my java program, its showing the previous output. getting the same output oni..could sum1 please guide me how to do it?
Five answers:
timo
2011-06-21 16:04:39 UTC
Add the JAVA_HOME enviornment variable with the path to your JDK, then update the path environment variable to hold %JAVA_HOME%/bin;
Edit: Be sure to restart the CMD shell and echo the environment variables to see they have been correctly set.
Nighthawk0973
2011-06-25 13:18:07 UTC
To compile java programs you must do the following. This should work provided you set Java Development Kit Directories at default. Basically just save your .java as 'ClassName.java' (classname being whatever you put after you typed 'class' in your code) in the directory 'C:\Program Files\Java\' Than in your Command prompt type:
cd C:\Program Files\Java\
*hit enter*
javac FileName.java
*hit enter*
java FileName
I'm not for sure if this is EXACTLEY how you do it. You have to do a bunch of classpath stuff as well if I remember. Here's a good tutorial that will teach you on youtube: Java Programming Tutorial 2
you can also download an IDE (Interageted Development Environment) for java. It will make things much easier not only when your coding, but compiling your code too. Try out Eclipse: www.eclipse.org.
Free and brilliant.
2016-05-15 03:30:24 UTC
I could be wrong, but don't you set the Java path in the Advanced... Environmental setting of Windows? (hit the Windows-key + pause) (I could be off.. I only took one Java class)
Blackcompe
2011-06-21 16:45:44 UTC
I'm assuming that your on a Windows machine. See the link below. It's simple. If your on a Linux machine, "javac" is recognized directly after installing the JDK via synaptic.
2011-06-22 09:22:07 UTC
PATH is an environment variable to set path in windows :
set path=%C:\%
in Unix
export PATH=/home:/opt
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.