File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Classpath" Watch "Classpath" New topic
Author

Classpath

Samir Ajgaonkar
Greenhorn

Joined: Jul 27, 2005
Posts: 3
I had set classpath to
CLASSPATH=".;c:\jdk1.3\jre\lib\servlet.jar;c:\jdk1.3\jre\lib\rt.jar;c:\jdk1.3\lib\tools.jar;c:\jdk1.3\lib\dt.jar"
in autoexec.bat on Win 98 system.

I always got the NOCLASSDEFFOUND error when I tried to run my java class. Compiling was fine.
So while searching on google i found info on how to setup textpad for compiling java. In that it was mentioned to set classpath to "."
when I did set it I could run the sample program i wanted to run.
Isn't classpath supposed to include all the possible class directories? So why just a "." works ? Also I had included "." in my setting which did not work ? Any clues?
thanks.
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Ok, you have to add a "." in the class path so that it includes the classes in the current working directory while executing a class.
So if you are in C:\java\> and if you give a java command then the classes in C:\java\> directory will also be added to your classpath if you include a "." in it.

First try to compile and run your java code in a command prompt. If you dint get any error ( NoClassDefFound error ) then check with the help in Textpad.
I've worked in it long back .There should be some way to set the classpath in it.

If you have any classes or jars in path like C:\Program files\java\myclass.jar then this path should be mentoined in double quotes ( "C:\Program files\java\myclass.jar" ) in the classpath, because of the space in "program files" .
[ July 27, 2005: Message edited by: Srinivasa Raghavan ]

Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Samir Ajgaonkar
Greenhorn

Joined: Jul 27, 2005
Posts: 3
Srini,
thanks for your reply. But as I had mentioned , I had included the "." in the beginning of the long classpath I had set. That did not work. Only when I removed everything else did it work for me. Also compiling was not a problem in both cases. So I am baffled.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
My understanding is that every jar in c:\jdk1.3\jre\lib is automatically included by the JVM in the "boot classpath". Perhaps by including it again in your classpath, it created the problem you mention (although I've never tried to include all the other stuff you included).


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Just try this..
Open a command prompt and give this command " Set classpath" this will now display the value of the system variable 'CLASSPATH'.
Check whether the the value of it has complete path.

As said by Marilyn every jar in c:\jdk\jre\lib is automatically included by the JVM. In my classpath i only have a jar file plus a '.'
[ July 28, 2005: Message edited by: Srinivasa Raghavan ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Classpath