• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX- About Launching the application

 
Mehmet Atlihan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Before uploading the project, I want to confirm something about a specification
When you submit your assignment, each part (client and server) must be executable using a command of this exact form:
java -jar <path_and_filename> [<mode>]


So what exactly does this refer to? After unzipping the submitted "jar" file
can we launch the application from console by giving the fullpath of "runme.jar" like this :
java -jar D:\home\Certification Studies\SCJD\sr1538587\runme.jar alone
If so do we have to do something special to support this behavior ?
Thanks
Mehmet
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Running programs from a JAR is supported by the "java" command. You just have to package it correctly in order for this to be supported. Specifically, you need to put a few things in your manifest file in the JAR. You can read the SDK docs to find out more information about that.
 
Mehmet Atlihan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nathaniel
Thanks for your quick reply.
Can you be a little bit specific about Manifest File. Cause I can launch the application within the directory where runme.jar is located. The problem occurs when I try to launch it with a fullpath. So do you mean
it has to do with the Manifest file and I should look for information about that ?
Regards
Mehmet
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mehmet,
What problem occurs when you run it from another directory?
If you can run the program using java -jar runme.jar from the directory that contains the jar file, then you probably have the manifest correct. But if you want to read up on it, the Sun tutorial on Jar files is at http://java.sun.com/docs/books/tutorial/jar/index.html
Regards, Andrew
 
Mehmet Atlihan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew . Thanks for giving your time
Yes I guess Manifest File is correct as I can succesffuly build and launch runme.jar.
When I try to execute from a different directory I got the error
>java -jar D:\home\Certification Studies\SCJD\sr1538587\runme.jar alone
exception in thread "main" java.util.zip.ZipException: The system cannot find file specified
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:112)
at java.util.jar.JarFile.<init>(JarFile.java:127)
at java.util.jar.JarFile.<init>(JarFile.java:65)
I am probably making a stupid syntax error. But thats what the specification says :
java -jar <path_name_and_filename> [<mode>]
so it should be executed from a different directory as well right
Thanks
Mehmet
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mehmet,
A common cause of that error is a typo in the path / filename. Your problem is because of the space in your directory structure. Java is trying to run the jar file named "D:\home\Certification", passing it the parameters "Studies\SCJD\sr1538587\runme.jar"
Try running:

Regards, Andrew
 
Mehmet Atlihan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Andrew
It worked. I appreciate giving your time. I learnt a tiny but a vital detail. I can comfortably upload the project now.
Regards,
Mehmet
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic