• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Executing jar file - Urgent (Max Help)

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Max and others
I am facing a very unusual problem. I have created an executable server jar file. I placed this file in the folder c:\amit.
I am able to run it using the
java -jar server.jar from the same directory where server.jar file is lying i.e. c:\amit.
However when i go to any other directory from prompt say
cd c:\xyz (REmember server.jar is still in c:\amit)
and execute java -jar server.jar it says :

Exception in thread "main" java.util.zip.ZipException: The system cannot find the file specified
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:110)
at java.util.jar.JarFile.<init>(JarFile.java:115)
at java.util.jar.JarFile.<init>(JarFile.java:57)
I have set the classpath as well in the prompt
using the command
set CLASSPATH=%CLASSPATH%;c:\server\server.jar;
But still not working
Important thing is that i can also start the server as
java -jar <install-dir>/server.jar no matter what is my current working directory on the command prompt
1) How to solve the above problem
2) if i run the server usung java -jar <install-dir>/server.jar and don ask the client to set any classpath, will i fulfill the exam requirement
becoz the requirement says:
*******************************************
How to execute the programs. You must provide exact command-line instructions. If any environmental setup is required, do not just say what needs to be done; provide instructions on how to perform the setup. For example, do not say something like "add server.jar to your classpath". You should document exactly how to add the jar file to the classpath. Note: your program must run correctly no matter what directory it is installed in.
********************************************
Amit
 
town drunk
( and author)
Posts: 4118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Amit,
In my opinion, you don't need to provide an executable jar. Sun would certainly have said so if you did. Your readme could simply state: "Unzip this jar. Next, change directories to the whatever/starting directory", etc. After all, they will have to unzip the jar to reach your readme file.
HTH,
M, author
The Sun Certified Java Developer Exam with J2SE 1.4
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


set CLASSPATH=%CLASSPATH%;c:\server\server.jar;


If your jar is in c:\amit\, why is it not part of your classpath?
Eugene.
 
Amit Kr Kumar
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Eugene actually its a typo mistake
The correct classpath command i used is
CLASSPATH=%CLASSPATH%;c:\amit\server.jar;

So any solution ???
[ July 28, 2002: Message edited by: Amit Kr Kumar ]
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The solution is to run your jar from the directory where it is located.
Eugene.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic