aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Jar execution command Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Jar execution command" Watch "Jar execution command" New topic
Author

Jar execution command

Nicolas Kal
Ranch Hand

Joined: Sep 09, 2009
Posts: 69
Hi all!

I finished everything regarding the assignment and i am about to upload it. I was going through last minute check and noticed the following on the instructions:

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>]


To execute my application I use this :
java -cp runme.jar client.ApplicationController -standalone


The difference is on the -cp, does this indicate an automatic failure?


SCJP 6.0 , SBCD (Preparing..),
MSc Enterprise Systems Development, BSc Computer Science
Radi Hadzhiyski
Ranch Hand

Joined: Jun 30, 2009
Posts: 47
in my opinion yes!

but why you have to write the classpath?

when you create the jar file, you can give them an entry point like this:

jar cfev runme.jar suncertify.client.ApplicationController suncertify

assumed, your that is the right entry point, after that you can simply write:

java -jar runme.jar standalone

EDIT:

the entry point is like, when you have created a manifest file with a main-class clause, but it is easier, when you don't want to have
other things in the manifest file


SCJP 1.6 (91%), SCJD
Carlos Morillo
Ranch Hand

Joined: Jun 06, 2009
Posts: 221

To make an executable jar, first create a manifest that tells which class file is the main class.

Create a text file manifest.txt that contains a line like:


Main-Class: x.y.MyMainClass


and then build your jar file with:


jar -cvfm my_archive.jar manifest.txt *.class


Hope this helps,


Carlos.

SCSA, OCA, SCJP 5.0, SCJD http://www.linkedin.com/in/carlosamorillo
Nicolas Kal
Ranch Hand

Joined: Sep 09, 2009
Posts: 69
By entry-point you mean to specify which is the class with the "main" i suppose. But if understood correct, at least according to my instructions, the server should have a main too so it can be executed by the command line. is it possible to define two entry points?
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2247

Nicolas Kal wrote:is it possible to define two entry points?


No, champion. The main class must be unique, and it has to deal with the 3 different ways the application can be executed. The only difference is the arguments you provide in the command line.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Nicolas Kal
Ranch Hand

Joined: Sep 09, 2009
Posts: 69
Thanks for the clarification! I'll modify, retest and finally upload..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jar execution command
 
Similar Threads
java -jar XXX does nothing
Importing packages from jar files
Runtime error with AviceBean from HFE
how to connect to mysql database ?
java -cp