• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

assignment JAR problem

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Has anyone else experienced a problem with the assignment JAR? I get the message "Failure to load Main-Class manifest..." Was there anything that you could do to fix the problem besides wait for a response from Sun?
Thanks.
 
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Manuel Comnenus:
Has anyone else experienced a problem with the assignment JAR? I get the message "Failure to load Main-Class manifest..." Was there anything that you could do to fix the problem besides wait for a response from Sun?
Thanks.



Do you have a file called MANIFEST.MF in the META-INF directory of the jar file. If not you need to create this file and have a line in it as follows:

Main-Class: suncertify.MyPackage.MyMainMethodClass

Without this line the jar is not an executable jar and you will see the error you have specified. If you have this line in then the problem could be that on some windows platforms there must be a blank line at the end of the file (ie hit enter after typing in this line) or it wond load properly.

Hope this solves it,
Mark
 
Manuel Comnenus
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

Thanks for your help. The JAR was downloaded from Sun, rather than being something that I created. Your response helped me figure out the problem. I viewed the JAR contents and noticed that the manifest was indeed in the JAR. So, I used the JAR extraction tool. The problem was based on a bad assumption by me. The JAR is, on my pc, listed as an executable JAR. So, I had expected that I should be able to execute it and that it would programatically unzip itself.
 
Mark Smyth
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Manuel Comnenus:
Hi Mark,

Thanks for your help. The JAR was downloaded from Sun, rather than being something that I created. Your response helped me figure out the problem. I viewed the JAR contents and noticed that the manifest was indeed in the JAR. So, I used the JAR extraction tool. The problem was based on a bad assumption by me. The JAR is, on my pc, listed as an executable JAR. So, I had expected that I should be able to execute it and that it would programatically unzip itself.




Super!
 
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark, while making the runme.jar, must I use the Ant approach? If so, in writing the jar target, how to make sure that it will be a runnable jar file?Thanks.
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Of course you don't have to use ant. You can just use jar command with m option. If you want to use ant the jar task can contain manifest element - so you can configure manifest content.
 
Mark Smyth
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Zhixiong Pan:
Mark, while making the runme.jar, must I use the Ant approach? If so, in writing the jar target, how to make sure that it will be a runnable jar file?Thanks.



As per the above post you don't have to use ant. However if you have a build script anyway the ant task to create the executable jar is as follows:



Mark
 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,
One more problem. The runme.jar which generated by ant can't run when I double click it.
 
Mark Smyth
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Zhixiong Pan:
Hi Mark,
One more problem. The runme.jar which generated by ant can't run when I double click it.



Not sure about this one, firstly make sure that you can execute the jar from the command line.

If so another possibility I can think of off the top of my head is that that windows is using a different version of the jre than the one you used from the command line to try to execute the program by default.

Try Tools-> Folder Options -> File Types -> JAR and make sure that windows is using the latest version of the java command (in the bin dir where you installed java 5 / 6) to run the program.

Mark.
 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark, that problem might come from the package structure. Initially, my suncertify.property and db file lie in the same root as the folder of suncertify, while now they share the root with the folder of code which is the superior folder of suncertify. See my file as following
Should this be changed to . Similarly do change db file load path.Right?
Regards.
 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Undo my previous post firstly, cause that's not the crux or the matter.
I can run that jar file in command window. Hope this checking can help Mark go further on my question. Thank you.
 
Mark Smyth
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Zhixiong Pan:
Undo my previous post firstly, cause that's not the crux or the matter.
I can run that jar file in command window. Hope this checking can help Mark go further on my question. Thank you.



Have you installed a new version of java recently in order to complete the problem.

As per previous post open up a windows explorer window.


Click on Tools -> Folder Options in top menu menu.

Now click on File Types tab.

Scroll down to JAR file type.

Click on the Advanced button.

In the "action" textarea select open and press the edit button.

Under "application used to perform action" textfield verify that this points to the correct version of java and not an older version of the jre. If this is the case then change this to the correct path.

Should look something like the following if you are using java 5:

"C:\\Java\jre1.5.0_10\bin\javaw.exe" -jar "%1" %*

it should NOT be something like

C:\WINNT\system32\javaw.exe" -jar "%1" %*

Hope this helps.

Mark.
 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,
While double clicking runme.jar, means run the application with no parameter. And the command form without parameter is to launch network client. Consequently, double clicking runme.jar will not work since network client can not go without server started.
BTW, the following ant target is abstracted from one of your posts:

Why take action of excluding suncertify.properties without which application will not work at all.
Regards.
 
Mark Smyth
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Zhixiong Pan:

Why take action of excluding suncertify.properties without which application will not work at all.
Regards.



Because my instructions stated that the file should be stored in the current working directory, this is not the same as storing it in the jar file. Bear in mind the user is not necessarily running the application from the same directory that the jar file is in.

If the file does not exist in the current working directory when the application is executed a new one is created from the properties that the user specified, if one exists in the current working directory then the properties from this file are used to lanch the application (after giving the user the opporunity to edit them).

I am not sure if you can even change a file that is contained in a jar file without first extracting the files from the jar, editing it and then re-jaring the files. (open to correction on this).

Mark
 
Mark Smyth
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Zhixiong Pan:
[QB]Hi Mark,
While double clicking runme.jar, means run the application with no parameter. And the command form without parameter is to launch network client. Consequently, double clicking runme.jar will not work since network client can not go without server started.QB]



You would need to create a shorcut for each mode to get around this problem.
For alone mode you would create a shortcut called alone pointing to your jar file and then edit the target in shortcut properties to include the parameter.

ie change like this.

"D:\submission\runme.jar" to "D:\submission\runme.jar alone" or "D:\submission\runme.jar server" for server mode.

As you know default shortcut will do for for network mode.

Of course all this this is not nescessary for the project but if you are doing alot of testing then it is useful to be able to start the app in each mode quickly.

Mark.
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm getting something that I don't really understand. I'm using the command line of:

jar cmfv MANIFEST.MF runme.jar -C classes *

to build the jar file, where MANIFEST.MF is

Manifest-Version: 1.0
Created-By: 1.4.0_01 (Sun Microsystems Inc.)
Class-Path: ./classes
Main-Class: suncertify.gui.launcher.ApplicationLauncher

Now I have a .classpath in the directory where I'm building the jar file from where (I've used eclipse to do the project in) the contents are:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="code"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="src" path=".apt_generated">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="classes"/>
</classpath>

Since I wanted to build a "clean" runme.jar file I removed the .classpath, .apt_generated and other files from the directory structure so that they would not be in the runme.jar file. However I discovered that when the .classpath file is not in the runme.jar then when I invoke ">runme.jar alone" (or any other command-line option) it can't find the entry point. Now I thought that the mainfest file took care of that so I'm confused. Also am I being redundant with the -C classes and the manifest entry? Any help would be appreciated.
BTW I'm not using ant.
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy, Roy!

Champ, this thread is sort of old... how about opening a brand new thread, in order to show us your problem? Please avoid waking up such old threads.
 
Roy Pozarelli
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, just trying to keep related things together. Could you Roberto, however, give me some insight?
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic