This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Executing jar file - Urgent  (Max Help) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Executing jar file - Urgent  (Max Help)" Watch "Executing jar file - Urgent  (Max Help)" New topic
Author

Executing jar file - Urgent (Max Help)

Amit Kr Kumar
Ranch Hand

Joined: Feb 08, 2002
Posts: 100
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
Max Habibi
town drunk
( and author)
Sheriff

Joined: Jun 27, 2002
Posts: 4118
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


Java Regular Expressions
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

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

Joined: Feb 08, 2002
Posts: 100
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

Joined: Oct 08, 2001
Posts: 2937
The solution is to run your jar from the directory where it is located.
Eugene.
 
GeeCON Prague 2014
 
subject: Executing jar file - Urgent (Max Help)