jQuery in Action, 2nd edition*
The moose likes Java in General and the fly likes Setting the classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Setting the classpath" Watch "Setting the classpath" New topic
Author

Setting the classpath

Darrell Morello
Ranch Hand

Joined: Apr 28, 2005
Posts: 38
Hi all.

I'm having a problem with setting the classpath. I'm trying to use the SkinLookAndFeel thingy but for example if I use the



the compiler says "package not found". I've included the class path using the control panel like .;C:\Java\Skins\skinlf.jar but still its not working. However, it works if I put the *.jar files in the ext directory in the JDK../JRE folder. It also works if I include the path in the JDK profile of the compiler, but what if try to run it on another computer?

What am I doing wrong? Is it possible to set the class path in the code?
I've read some articles where they describe running the program like
java -classpath /java/MyClasses/myclasses.jar utility.myapp.app
How will I get it to work if I create an exe using an installer to run my program?

Also, does any of you guys know of an installer(I hope a free one) that would automatically detect the Java Home folder and place the Skin files in the ext folder?

Thanks
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
One possible solution to your problem is to pacakge your program as an executable JAR file. You need to include a manifest file in the JAR with Main-Class: and Classpath: attributes. This will make it so that the user can double-click on the JAR to run it, as long as the JVM is installed and configured correctly.

HTH

Layne


Java API Documentation
The Java Tutorial
Darrell Morello
Ranch Hand

Joined: Apr 28, 2005
Posts: 38
Is there any rules in how I include it in the manifest file? And this means that I have to create a jar file whenever I want to test it right?
Also, whenever I double-click on my jar files, WinRar always opens it, even though I have dis-associated jar files from it I havent found a way to get around it yet.

Thanks for the quick reply
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 685
Are you on Windows? It is possible to change the default open command by going into windows explorer, Tools | Folder Options | File types and scroll down to jar files. Edit that and you will get a list of commands, select one and click Set Default to change the default. You can add a new one if needed.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
A manifest file is simply a text file that gets packaged into the JAR file in a particular way. You need to use the -m option in order to specify your own manifest file. If you are using the command-line, type "jar" without any options to see the syntax for adding a manifest file.

HTH

Layne
 
 
subject: Setting the classpath
 
Similar Threads
"..could not load JDBC driver."
Classpath Problem
classpath
Class file not being made
Integrating jdk with netbeans?