Home > Archive > Java Help > February 2005 > compile/run locations
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
compile/run locations
|
|
|
| i am a bit on something and i'm just looking for some
clarification..... i just installed JAVA SDK 1.4.2 on my laptop w/XP
on it.... on the JAVA 2 SDK 1.4.2 installation notes for Microsoft
Windows, it says"set the PATH variable if you want to be able to
conveniently run the JAVA 2 SDK executables (javac.exe, java.exe,
javadoc.exe, etc.) from any directory without having to type the full
path of the command. If you don't set the PATH variable, you need to
specify the full path to the executable every time you run it such as:
c:>j2sdk1.4.2_<version>\bin\javac MyClass.java" and this makes complete
sense to me....
i have my java programs here:
c:\javaprograms
my sdk is here:
c:\j2sdk1.4.2_07
on my laptop i do not have my PATH variable set, yet i am still able to
execute java.exe without specifying the path to the java.exe program
(as required by the installation notes) such as:
c:\>java -classpath "javaprograms" helloWorld
Hello World!
however, i am not able to use the compiler in the same way, such as:
c:\>javac -classpath "javaprograms" helloWorld.java
'javac' is not recognized as an internal or external command,
operable program or batch file.
the fact that i'm able to execute JAVA programs in the foregoing manner
is inconsistent with the JAVA 2 SDK 1.4.2 installation notes for
Microsoft Windows, but consistent with regard to compilation, i.e. it
doesn't work.... does anyone know how or why the java.exe would work
and not the javac.exe program, in the preceding context, that is,
without the PATH variable set and without a specified full path to the
executable???
second, if i wanted to get the compiler to work, the only command that
works for me is:
c:\>j2sdk1.4.2_07\bin\javac javaprograms\helloWorld.java
but the next one doesn't work:
c:\>j2sdk1.4.2_07\bin\javac -classpath "javaprograms" helloWorld.java
error: cannot read: helloWorld.java
1 error
why would the first one work and not the second???
Thanks!!!!
Pete
| |
| klynn47@comcast.net 2005-02-27, 3:59 am |
| My guess about the first question, why is java.exe working, is that
somehow you have the JRE installed somewhere probably from the
installation of a browser.
The JRE is the Java Runtime Environment.
The JSDK is the Java Software Development Kit.
The first just lets you run Java program.
The second lets you both compile and run Java programs.
I'm not sure if you can use the CLASSPATH in the way that you want in
order to compile the program.
| |
| arvind via JavaKB.com 2005-02-27, 9:00 am |
| For compiling ur java source code, u need to set the path environmental
variable to ur Java SDK bin folder. By setting the path variable, u
instruct the OS to search for .exe files in the directories to which ur
path variable is set. Going by this, u need to set the path to ur java sdk
bin folder both for compiling and running ur java program. Am not sure how
u r able to run the program without setting the path . As pointed out, u
might have a JRE installed somewhere and the path has been to set to it.
For ur second question,
[ c:\>j2sdk1.4.2_07\bin\javac javaprograms\helloWorld.java
but the next one doesn't work:
c:\>j2sdk1.4.2_07\bin\javac -classpath "javaprograms" helloWorld.java
error: cannot read: helloWorld.java ]
ur working directory is "c:\>j2sdk1.4.2_07\bin\javac"...and u have ur src
codein in "c:\javaprograms"....when u try to compile ur src code from the
bin folder u have to give the full path location of ur src in order for the
OS to find the file...(which is what u've done in the first case)
else set the path to ur java bin folder and u can conveniently compile &
run from the locn where u have ur src...
Hope this clarifies things....
--
Message posted via http://www.javakb.com
|
|
|
|
|