• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing cmd line arg to Jar

 
K. Merritt
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 360
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic