• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

jar niggles

Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After I jarred up my client and server in jar files, I found that I could not run them in any directory just using eg: java -jar server.jar
So I did some experiments with a simpler class.
I created a simple hello world program and put it in a jar file in a package hierarchy sun/hi/Hello.class I created the jar with a manifest pointing to the file eg:
Main-Class: sun.hi.Hello I named the jar file hello.jar and stored it in C:\jdk1.3 and added the jar to my classpath.
The problem that I am having with this too is that I cannot run the program with the command java -jar hello.jar unless it is in the C:\jdk1.3 directory.
I know that the jar file is in the classpath because I can call the class directly from any directory with the command java sun.hi.Hello
The only way I can get it to function correctly is to state the whole path to the jar eg:
java -jar C:\jdk1.3\hello.jar
What am I doing wrong? what do I have to do to run the program from any directory with just the command java -jar hello.jar like it states in the specs
I must be overlooking something very simple.
Is it a classloader thing.
I hate classpath issues!!
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you be more elaborate about how you created the JAR file? Did you use the jar command? Or did you use Winzip?
Also, the CLASSPATH setting shouldn't matter. On my windows machine here at home, I have only modified the PATH and CLASSPATH to include my Java path information. I didn't even add anything like server.jar or client.jar to my machine. And I can run the jar file from any directory using java -jar server.jar.
Any additional input would help!
Steve Marks
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created the jar from the command prompt window
jar cfm server.jar man.mf suncertify\server\*.class
You have only the java Path info, thats interesting, I couldd not do that on my machine
how have you entered in your classpath environment
and POOF! You're gone! But look, this tiny ad is still here:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic