I have been working on something else for a while and have foolishly forgotten how to set up classpath/package structure properly as am getting class not found errors. I am on Windows NT.
I have altered autoexec.bat to include: set CLASSPATH = C:suncertify\db The files I am trying to execute are located at: C:\suncertify\db The package statement at the top of each file reads package suncertify.db;
Do I have to add another PATH or CLASSPATH statement to autoexec? along the lines of: set PATH =j2sdk1.4_01\bin;
Thanks - sorry for the thick question but have been doing non-Java stuff for 5 months and forgotten this rudimentary thing.
Joined: Apr 28, 2004
I should add that all is well when I compile with:
Originally posted by Peter Laurinec: Try include "." which points to the actual directory to the classpath. Usuall call to a class within the package is java package_name.subpackage.ClassName
Advice: Setting CLASSPATH to contain . or using -cp . will appear to fix all classpath sins, but it really just covers them up. The best approach is to build the jar file and run from it as specified in the project requirements.
To directly answer your question: if your code is in C:\suncertify\db and you use "package suncertify.db" in main file Test.java, your classpath should be C:\. To run this you would do: java -cp C:\ suncertify.db.Test
if your classes were in C:\javadev\build\classes\ and you had a mainprogram called URLyBird in package suncertify.gui and you were trying to run from F:\ you would use: F:\>java -cp c:\javadev\scjd\build\classes suncertify.gui.URLyBird alone
if you packaged all this up in a jar file called runme.jar in the build directory you would use F:\>java -jar c:\javadev\scjd\build\runme alone
and your manifest file would look like Manifest-Version: 1.0 Main-Class: suncertify.gui.URLyBird
hope this helps /pkw
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com