I expected to see some output, however, nothing happened.
What does this mean ? Does this mean that
1) The jar command is failing due to bad syntax --- I assume this is NOT the case ?
or
2) The jar command syntax valid, but for some reason, it does not call the main method in my class.
Thanks for any feedback.
PS I have tried exporting the jar with and without a defined executable run class...
here is the jar creation script description below
This message was edited 2 times. Last update was at by Bear Bibeault
jay vas
Ranch Hand
Joined: Aug 30, 2005
Posts: 405
posted
0
The strange thing is, however, that I CAN integrate this jar into an application and use it, perfectly.... i just cant invoke its services via that "java -jar xxx" method..... Ive never noticed anything like this.... I wonder if there an "Executable" attribute to jars or something, that can be turned on or off via some type of configuration ???
Well, again, java -jar jarfile ClassName isn't correct syntax either, but it's closer. That should run the main class defined in your manifest file and pass it ClassName as an argument ... an argument it most likely won't understand though. If you think that command should be running the ClassName class, you're probably going to be disappointed.
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 2499
posted
0
jay vas wrote:I'm sorry I tried java -jar xxx.jar ClassName and tha failed. My first post was a typo.....
The command has no effect. Very strange .!!!
Any class name specified on the command line when using the -jar option is ignored. As Greg said, when you use the -jar option the main method that will be run is the one in the class specified in the Main-Class entry in your jar's manifest file which, in your case, is jmolwrap.JayMolScript. If this is wrong then you need to change your manifest file.
Joanne
jay vas
Ranch Hand
Joined: Aug 30, 2005
Posts: 405
posted
0
Thats strange that you cannot run a main class of your choosing when invoking via the java -jar command .... is there any reason why this is the case ? It seems only natural that invocations of a "java -jar" command might require, in certain circumstances, the use of a different main class . At the very least, I wouldnt be surprised if people have requested this feature in the past ?
This message was edited 2 times. Last update was at by jay vas
jay vas wrote:Thats strange that you cannot run a main class of your choosing when invoking via the java -jar command .... is there any reason why this is the case ? It seems only natural that invocations of a "java -jar" command might require, in certain circumstances, the use of a different main class . At the very least, I wouldnt be surprised if people have requested this feature in the past ?
That is how it is defined... When you use the -jar option, it gets the main class from the manifest. If you don't want to use the class specified in the manifest, then use the -cp option, and specify the main class.
Okay.... well then for clarity, I guess there is an EXCEPTION to Joann's comment 'when you use jars, any Class Name is ignored', which is that the "cp" flag causes the java -jar command to pay attention to a class name you specify at the end, and use that class as the main class, regardless of what is in the manifest.
For beginners : Java -jar -cp com.mypackage.hello.HelloWorld will run HellWorld.
Thanks guys for all your help my issue is resolved........
jay vas wrote:Okay.... well then for clarity, I guess there is an EXCEPTION to Joann's comment 'when you use jars, any Class Name is ignored', which is that the "cp" flag causes the java -jar command to pay attention to a class name you specify at the end, and use that class as the main class, regardless of what is in the manifest.
It is not an EXCEPTION, you are not supposed to mix the -jar and -cp options. If you want to specify a class that is in a jar file, then you use -cp to specify the jar file, and you also need to specify the class.\