File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Classpath question

 
Lubosh O
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am running JDK1.3.0_02 version on a win95 OS. At the beginning I do not have any classpath declared. My java works fine until I explicitly delcare the classpath in my command window. If I declare:
CLASSPATH=C:\JDK1.3.0_02 the execution of my classes with main methods will not work anymore.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The classpath should point to the \lib directory under that directory if you want the system to find any of the classes that are in the Sun jar files.
Do try to keep your stuff somewhere else, and add that directory to your classpath.
 
Chun Wong
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also don't understand CLASSPATH. I am using
win98 and I don't set up any CLASSPATH in
autoexec.bat or somewhere else. All I have
set up is just the path points to c:\jdk1.3.1\bin
that I can use "javac file.java" anywhere...
My question is how come "import java.io.*" works,
even I don't have CLASSPATH set up?
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somewhere along the way, they build the VM so that an environment reference back to the core class files wasn't necessary. That is, no matter what you did to the CLASSPATH, the VM would find its own rt.jar file -- assuming of course, you didn't move or delete it.
And this does make sense. The core classes are "trusted" in the VM above all else, so it shouldn't be possible to accidentally obscure their use.
 
FinnLady
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Path & Classpath W95/W98: in autoexec.bat (make backup before changes! Just in case!)
Path=C:\JDK1_3\bin;%PATH%;
if the jdk is in file c:\jdk1_3
classpath example below:
SET CLASSPATH=%CLASSPATH%;.;C:\JDK1_3\LIB\TOOLS.JAR;C:\JDK1_3
There can be several lines in autoexec.bat that "set classpath". In classpath you tell the PC where to find tools.jar and then remind it where you installed the jdk
In W2000, if you have installed the jdk to a local (not network) drive: you have to go to Settings, System, then the middle adjustment area (sorry, no W2000 machine here) and then at the top 1/2 of the page is user settings where you add or append the path and classpath. Path to where javac.exe is installed (Example: C:\jdk1_3\bin), classpath to the file tools.jar, starting with period and semicolon (indicarting installation on a local drive).
(Example: .;C:\jdk1_3\lib\tools.jar)
 
FinnLady
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
W2000
Sorry, the place for setting of class & classpath is System, Advanced, then that center button (sorry, can't remember its text), and that opens the page where you can set user & system values (the latter only if you have system admin status).
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lubosh O:
I am running JDK1.3.0_02 version on a win95 OS. At the beginning I do not have any classpath declared. My java works fine until I explicitly delcare the classpath in my command window. If I declare:
CLASSPATH=C:\JDK1.3.0_02 the execution of my classes with main methods will not work anymore.

Your CLASSPATH must point to the subdirectory where your classes are. I am referring to the class you are running (i.e. MyClass.class file).
Without a classpath, you get a default to the directory you are currently in. If you set it to CLASSPATH=C:\JDK1.3.0_02, your class won't run unless you have compiled it to that subdirectory (which most people usually don't do).
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic