This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Path to Java APIs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Path to Java APIs" Watch "Path to Java APIs" New topic
Author

Path to Java APIs

jignesh soni
Ranch Hand

Joined: Dec 10, 2007
Posts: 150
When we set path for jre, it sets path to the javac.exe file. So when we execute a class file, path will look in path variables and find javac.exe. How is the path to Java APIs set ? When we import a particular packagr, how does the computer locate where this package is located ? Is the path set automatically when we download and install jdk ?

Please explain.
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 685
The java API code is in jar files. For the javac and the java commands to find the API class definitions, the jar files must be on the CLASSPATH which is different from the PATH. Use a Search for CLASSPATH to get examples of how to set it for your OS. Also look at the API doc for the javac and java commands to see the syntax for the -classpath option
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37900
    
  22
In the Java� Tutorials, there is a page called Common Problems (here) and at the top its says something about "javac is not recognised."
That bit explains a bit about the PATH; there is a link in it to the installation instructions. Follow that link. There is tells you how to set the PATH permanently; follow those instructions to the letter. The tiniest spelling error and it won't work. Never mind that it says "optional;" do it!

There is probably no need to do anything with the CLASSPATH at this stage.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Path to Java APIs
 
Similar Threads
Newer version of java
how do save : set path= permenantly
how to run
Taking community college online course in Java 1
JAVAC not found ??? I cant compile - help