| Author |
Passing cmd line arg to Jar
|
K. Merritt
Greenhorn
Joined: Jun 22, 2004
Posts: 3
|
|
I exported my source code to a jar file and moved it to a folder under the cdrive. I can execute the jar on the cmd line by typing name.jar. I can execute the jar specifying java and the classpath. However at no time can I execute AND pass an argument. I know the syntax is java [-options] -jar Name.jar [args...] but when I add the [args...] to the working syntax I receive the following error: C:\MQCLient_TM>java -cp C:\ProgramFiles\IBM\WebSphereMQ\Java\lib;C:\Oracle9.2 -jar c:\MQClient_TM\LCDirectory.jar [kim] Exception in thread "main" java.lang.NoClassDefFoundError: com/ibm/mq/MQExceptio n at net.LCDirectory.EY_LCDirectory.main(EY_LCD irectory.java:31) Sorry for the wrapping. Again if I leave off [kim] the line executes but not what I need for my pgm. Please advise how to execute jar and pass parameter when [args...] not working. Thank you, Kim
|
 |
Pavel Kubal
Ranch Hand
Joined: Mar 13, 2004
Posts: 356
|
|
Here is example of executing jar file with parameters java -jar MainFrame.jar first Mabel 25 But it seems, that your jar cannot be executed. I mean problem is somewhere else than in passing params.
|
 |
Ripan Karmakar
Greenhorn
Joined: Jul 28, 2004
Posts: 16
|
|
hi pavel, u r wright.......i have tried with a tiny program....... but the following command does not work: making jar command:C:\j2sdk1.4.2_03\bin>jar -cvf Char.jar Char.class [no error] executing jar file:C:\j2sdk1.4.2_03\bin>java -jar Char.jar Failed to load Main-Class manifest attribute from Char.jar plz anyone help me 2 solve this........ ripank
|
"Strenght is Life and Weakness is Death"<br />Java/J2EE Developer<br />UshaComm Pvt. Ltd, Kolkata, INDIA
|
 |
Stefan Wagner
Ranch Hand
Joined: Jun 02, 2003
Posts: 1923
|
|
Ripan: Your problem is different. You need to add a line: Main-class: Char to your Manifest. But K. tells us, it works, without arguments, but not with.
|
http://home.arcor.de/hirnstrom/bewerbung
|
 |
Marilyn de Queiroz
Sheriff
Joined: Jul 22, 2000
Posts: 9033
|
|
Originally posted by K. Merritt: java -cp C:\ProgramFiles\IBM\WebSphereMQ\Java\lib;C:\Oracle9.2 -jar c:\MQClient_TM\LCDirectory.jar [kim] Have you tried running without the square brackets on the arg? [ July 29, 2004: Message edited by: Marilyn de Queiroz ]
|
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
|
 |
 |
|
|
subject: Passing cmd line arg to Jar
|
|
|