aspose file tools*
The moose likes Java in General and the fly likes define the main class in a jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "define the main class in a jar " Watch "define the main class in a jar " New topic
Author

define the main class in a jar

chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 190
Hi,

I created a swing application.
I want to create a jar (I know how to do that) that will activate the application meaning, if the user will push on X.jar the application will start running.

How can I define the main class?

Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41872
    
  63
Like with all applications, you need a class with a main method to start the application. Then you need to add a manifest file to the jar which references the class with the main method; see JarFiles for more details.


Ping & DNS - my free Android networking tools app
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

You have to create a manifest file and include the following line:

Then, when creating the JAR file, specify that you want to include a manifest file, and use the one you just created/


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 190
Hi,

I add all the necessaries directories (also properties and .classpath) to the jar.
When I am trying to run the jar I get the fallowing error:

Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name rcyProperties, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(Unknown Source)
at java.util.ResourceBundle.getBundleImpl(Unknown Source)
at java.util.ResourceBundle.getBundle(Unknown Source)
at utils.RcyUtils.getResourceBundle(RcyUtils.java:27)
at utils.RcyUtils.getImageIcon(RcyUtils.java:31)
at gui.BootScreen.<init>(BootScreen.java:67)
at main.StartRcy.main(StartRcy.java:12)

The properties directory is define in the .classpath file.
Should I need to add this directory also into the manifest.txt (and how)?


Thanks
 
jQuery in Action, 2nd edition
 
subject: define the main class in a jar