Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / February 2005

Tip: Looking for answers? Try searching our database.

compile/run locations

Thread view: 
Pete - 27 Feb 2005 03:42 GMT
i am a bit confused 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 - 27 Feb 2005 03:54 GMT
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 - 27 Feb 2005 08:08 GMT
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....


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.