• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problems with aJAR file built using one-jar

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am just learning how to build JAR files...

In the course of my research i found information on here about using one-jar to create executable jar files...

I have that process mastered (more or less) when I invoke the fished jar file it executes but does not invoke the GUI...

This is confusing to me because GUI works just fine when I invoke the program outside of the JAR file.

Any help will be appreciated.
 
Ranch Hand
Posts: 344
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any errors on the console (screen)? How do you run the jar (command line)? Any dependant jar files you perhaps need to include in the classpath?
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
. . . and welcome to the Ranch
 
Allan Clapp
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Koen, Thank you for your prompt reply.

Any errors on the console (screen)?

There are no errors.

How do you run the jar (command line)?

I am not sure what you are referring to. I use the

ant

procedure that I found on the Scott Tuffs SourceForge page to build the jar file and java -jar Jar File name to execute it.

Any dependent jar files you perhaps need to include in the classpath? No I transfer all of the jar files that I built into the lib directory before I build the jar file. The system jar files ar already on the classpath.

Perhaps I should restart this from the beginning...

I am using one-jar-appgen-0.97 version of one-jar.

I found the instructions for preparing the project using the

Application Generator Approach

section of the site under

Quick Start

.

I have just discovered the

CVS

source download section of the site. While I am waiting on your next reply I will also research that section.

@Campbell Richie, Thank you for the welcome. It is great to be apart of a community where greenhorns like myself are treated with kindness and understanding. I hope in the future I will have knowledge that I can share with others.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have taken the liberty of converting all the text to black because some people have difficulty reading colours.
If you are new to .jars, have you read the Java Tutorials section? The command-line approach might be easier than a tool.
 
Allan Clapp
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for converting the color back to black. Frankly I was not sure as to how well that would work out. I will take time to read over that tutorial now. I read over what is listed in the jar section of the oracle site... Alas it confused me!

Thank you for your help.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You’re welcome
How did you get on with the tutorial?
 
Allan Clapp
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It was the same tutorial as i looked at previously (only with a different entry point).

I will make one more attempt after I have caught up on my sleep. Whatever happens with that i will post my results.

If I am still having troubles I will post the entire process that I am using from the tree structure to pertinent source files and jar / java output so that you can see what I am doing (and hopefully what I am doing wrong).

Some additional information about my learning style... I often takes me a little longer to figure something out... But I do figure it out I refer back to my past successes so that I rarely have to ask the same question twice.

Thank you again for your help.

Allan
 
Allan Clapp
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is where things stand...

The Build tree is:

AdminClient/*.class
JarFiles/*.jar


The AdminClient folder contains:

AdminClient.class
AdminClient.java
ClassicSFBShipEntry.class
ClassicSFBShipEntry.java
MainForm.class
MainForm.class


The JarFiles folder contains:

Dialogs.jar
GlobalConfig.jar
LocalConfig.jar
SupportCode.jar


The Manifext add-on file is:

Class-Path: JarFiles/*.jar
Main-Class: AdminClient.AdminClient


When I use this comand line:

jar cvmf AdminClient.jar AdminClient.MF AdminClient/*.class

I get the following as an error message:

allan@INetMach:~/DevSFB$ jar cvmf AdminClient.jar AdminClient.MF AdminClient/AdminClient
java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Attributes.java:406)
at java.util.jar.Manifest.read(Manifest.java:199)
at java.util.jar.Manifest.<init>(Manifest.java:69)
at sun.tools.jar.Main.run(Main.java:169)
at sun.tools.jar.Main.main(Main.java:1167)


It works when I use this command line:

jar cvef AdminClient.jar AdminClient.AdminClient AdminClient/*.class

But when I go to invoke it using:

java -jar AdminClient.jar


I get:

Exception in thread "main" java.lang.NoClassDefFoundError: AdminClient/AdminClient$1
Caused by: java.lang.ClassNotFoundException: AdminClient.AdminClient$1
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
Could not find the main class: AdminClient.AdminClient. Program will exit.

At this point I am totally frustrated with this process.

Any help you can give me will be appreciated.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Allan Clapp wrote:allan@INetMach:~/DevSFB$ jar cvmf AdminClient.jar AdminClient.MF AdminClient/AdminClient
java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Attributes.java:406)
at java.util.jar.Manifest.read(Manifest.java:199)
at java.util.jar.Manifest.<init>(Manifest.java:69)
at sun.tools.jar.Main.run(Main.java:169)
at sun.tools.jar.Main.main(Main.java:1167)


The Class-Path entry cannot have wildcards in it. You really must specify all separate JAR files. You must also make sure the lines are of the right length; you will have to add some line breaks and indentation to the Class-Path value.
Lines cannot be any longer than 70 characters. If a single entry would exceed 70 characters, you must add a linebreak at exactly 70 characters and then indent the next line with one single space. Repeat until no line is longer than 70 characters. This may mean that you cut off a JAR file name in the middle, but that's how it works.

Exception in thread "main" java.lang.NoClassDefFoundError: AdminClient/AdminClient$1
Caused by: java.lang.ClassNotFoundException: AdminClient.AdminClient$1
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
Could not find the main class: AdminClient.AdminClient. Program will exit.


Your code tries to access class AdminClient.AdminClient$1. That's an anonymous inner class. However, its class file doesn't appear to be in your folder. Try recompiling your class and recreating the JAR file.
 
Allan Clapp
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank to Rob's suggestions and tips. I am closer to a solution. My classpath problem seems to be corrected. But the java -jar command is still not finding my entry point.

I am sure the solution is simple I am just not seeing it.

Here is the manifest file I am currently using:

Class-Path: GlobalConfig/GlobalConfig.jar
LocalConfig/LocalConfig.jar Dialogs/Dialogs.jar
SupportCode/SupportCode.jar
Main-Class: AdminClient




Here is the compile commands and output:

javac Dialogs/TheServerConnectionInfoScreen.java
javac GlobalConfig/DomainInfo.java
javac GlobalConfig/UserInfo.java
jar cf GlobalConfig/GlobalConfig.jar GlobalConfig/DomainInfo.class \
GlobalConfig/UserInfo.class
javac LocalConfig/SystemAreaConfig.java
javac LocalConfig/AdminAreaConfig.java
javac LocalConfig/PlayerAreaConfig.java
javac LocalConfig/MonitorAreaConfig.java
javac LocalConfig/ShipAreaConfig.java
javac LocalConfig/AdminUserInfo.java
javac LocalConfig/PlayerUserInfo.java
jar cf LocalConfig/LocalConfig.jar LocalConfig/*.class
javac Dialogs/UserLoginScreen.java
javac Dialogs/AdminUserLoginScreen.java
javac Dialogs/PlayerUserLoginScreen.java
javac Dialogs/UserDefinedErrorMessage.java
javac Dialogs/UserStatusMessage.java
javac Dialogs/ServerConnectionInfoScreen.java
jar cf Dialogs/Dialogs.jar Dialogs/*.class
javac SupportCode/PanelHelper.java
javac SupportCode/ListenerHelper.java
javac SupportCode/MenuItemMouseListener.java
javac SupportCode/ButtonMouseListener.java
javac SupportCode/TextFieldKeyListener.java
javac SupportCode/NewListenerHelper.java
javac SupportCode/LoadListenerHelper.java
javac SupportCode/SaveListenerHelper.java
javac SupportCode/UpdateListenerHelper.java
javac SupportCode/DisplaySSDListenerHelper.java
javac SupportCode/RaceListenerHelper.java
javac SupportCode/ShipTypeListenerHelper.java
javac SupportCode/RefitTypeListenerHelper.java
javac SupportCode/SensorListenerHelper.java
javac SupportCode/ScannerListenerHelper.java
javac SupportCode/DamageControlListenerHelper.java
javac SupportCode/PhasersListenerHelper.java
javac SupportCode/PhotonsListenerHelper.java
javac SupportCode/PlasmasListenerHelper.java
javac SupportCode/PlasmasListenerHelper.java
javac SupportCode/FusionBeamsListenerHelper.java
javac SupportCode/HellboresListenerHelper.java
javac SupportCode/PPDsListenerHelper.java
javac SupportCode/DisruptorsListenerHelper.java
javac SupportCode/ChangeFrameICON.java
jar cf SupportCode/SupportCode.jar SupportCode/*.class
javac AdminClientForms/ClassicSFBShipEntry.java
javac AdminClientForms/MainForm.java
jar cf AdminClientForms/AdminClientForms.jar AdminClientForms/MainForm.class \
AdminClientForms/ClassicSFBShipEntry.class
javac AdminClient.java
jar cmf AdminClient.mf AdminClient.jar AdminClient.class
javac ServerTest/ServerTest.java


And here is what happens when I invoke the jar file:

allan@INetMach:~/DevSFB$ java -jar AdminClient.jar
Exception in thread "main" java.lang.NoClassDefFoundError: AdminClient$1
Caused by: java.lang.ClassNotFoundException: AdminClient$1
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
Could not find the main class: AdminClient. Program will exit.


Thank you all in advance for your help.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, now you're getting somewhere. If I'm not mistaken then this command:

creates a jar file containing only the single class AdminClient.class, am I right? But your AdminClient class appears to have an anonymous inner class whose name when compiled is AdminClient$1.class, and you aren't including that inner class in this jar or any other, as far as I can see. So try this version instead:
 
Allan Clapp
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul,

No in fact the entry point class is: AdminClient. I was getting the "anonymous inner class" because of attempting to run the jar file when my AdminClient was in a package called

AdminClient

which now it is not.
 
This tiny ad is guaranteed to be gluten free.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic