Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Jar Bundler Problems

Hi, I'm learning Java and I have my own application. It works perfectly when I open the jarfile, but when I use Jar Bundler to convert it to an app, it quits before it opens. The icon appears in the Dock and then disappears. Also, when I try to choose "Main class" the file never appears after I choose it. Does anyone know how to fix this or any other alternatives? Thanks.

Posted on Apr 28, 2013 2:38 AM

Reply
59 replies

Jul 5, 2013 4:01 AM in response to Arc676

No problem that you are late: I have been very ill and I cound not respond to anything.


Indeed, the class path is essential: it is the starting point of the application.

In principle it could differ from the jar name, but better not.

The "Main-Class:" should point to the .class file with the


public static void main(String[] commandline)


in it.

How did you create your manifest?

;JOOP!

Jul 5, 2013 4:06 AM in response to Arc676

Very funny: after all those years I find that I automated jar-creation in a java program.

I have been creating manifest files without knowing it.

Automation is smooth, but bad for knowledge.

Anyway I recovered most of the rules for manifest files.


You might however follow this procedure:


http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks %2Ftasks-35.htm


;JOOP!

Jul 9, 2013 1:09 AM in response to Arc676

You said you already had one app working and (I guess) several .jar files you can start with a double click.

In that case, a manifest file of any working set is an example to you.

All you have to do is pick one (from a .jar), edit the contents and put it in a new .jar.

Rule of thumb: if you can start the .jar, then it is OK for an app.

;JOOP!

Jul 9, 2013 2:38 AM in response to Sciuriware

Unless the definition of "rule of thumb" has changed since the last time I checked, it means "always applys" and your rule of thumb does not seem to work for my situation. I can double-click start ANY of my apps, but not all of them can be turned into apps. A funny aspect of this problem is that all the jars I have tried to convert to apps that have SUCCEEDED (only one) have the main class in the DEFAULT package, while the others have the main class in a package.

Jul 9, 2013 3:30 AM in response to Arc676

I meant: when a .jar can be started, it can also be started from the application stub that sits inside the app

in the MacOS directory.

So, a runnable .jar is a mandatory condition for further app bundling.

A runnable .jar seems to have a good manifest, I guess.


You gave important info: I always place my application sources into the "blank" (default) package.

Then any part of the application can access non-private (but still non-public) stuff inside the application.

Only libraries I give a package name.

Now, I wonder if you could remove the package line from your application sources without introducing problems.

And, of course, if that solves your first problem.

;JOOP!

Jul 9, 2013 5:14 AM in response to Sciuriware

I have discovered why Eclipse discourages use of the default package: source code saved in the default package cannot be imported into other classes because the default package has no name, and "import ;" does not work. I created a new class in the default package and set that as the main class, but the manifest was the same and Jar Bundler still does not find the main class. I even removed all references to the other packages and exported ONLY the default package, but Jar Bundler still does not allow me to create the app.


My last resort is to download Xcode 3.1.3 and transfer everything there, because Xcode 3.1.3 allows you to develop in Java. This is getting incredibly frustrating.

Jul 9, 2013 5:16 AM in response to Arc676

I did another try today to create an app.

The app was created, but the .jar I gave was missing in the app.

Adding the .jar to the correct (!?) place did not help: app doesn't work from Finder.

I looked at the plist file, but I just can not find any error.

May be it wants to run on 1.6, but the .jar by itself runs OK on 1.7 (installed 1.6 AND 1.7).

Can you exactly state what application you got bundled and running:

- the structure of the source(s)

- the contents of the app-tree in files,

- the contents of the plist,

- the JAVA versions you had involved.


Note: I am not very depending on app's as one of my .jar's starts all the others

(a program manager a la Windows3),

and that .jar itself I fixed into the dock: ugly, but as the dock auto-hides I don't see it.


Nevertheless I won't give up, theres more to solve than just this.

;JOOP!

Jul 9, 2013 6:33 AM in response to Sciuriware

In order to make the source neater, I keep the source code for different parts of the application in separate packages.


I use JDK 7, and in Terminal java -version gives:

Java(TM) SE Runtime Environment (build 1.7.0_21-b12)

Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)


I do not have a plist because the "create application" button is always grayed out.


I do not understand what you mean by "structure of sources"


By app-tree I'm not sure what you mean

Jul 9, 2013 7:12 AM in response to Arc676

- in that case only your 'main' class has to be "packageless"; that will be no problem.

but please lets first observe the simple program you got working.

- I use JAVA 7u25, almost the same; again no possible cause of problems or differences.

- if Jar Bundler does not work at all for you, how did you make that working app??

b.t.w.: I'm using JarBundler.app found at /usr/share/java/Tools; that does not gray out anything.

- structure of sources: of how many pieces consists that working app?

- app is a directory, a tree is a directory-tree; so, what's in your working app?

;JOOP!

Jul 10, 2013 6:57 AM in response to Sciuriware

I tried moving the main class to the default package, but it didn't solve anything.


I don't know of any apps that can replace jar bundler, but I moved jar bundler to applications. Do you think this is a problem?


My working app only has one class, the others have many


My working app is just a jar with a class file in it, basically

Jul 10, 2013 9:05 AM in response to Arc676

Hi,

first of all, the Jar Bundler.app could stand anywhere in any directory; that's a freedom of OSX.

I have a few applications I downloaded, put in different places and they start up (e.g. from Finder) just the same.

It's your computer and you may put any file where you like.


During last week I was busy repairing one of my own applications, so I spent little time on this.

However, your last observation puts me to action.


Say we conclude that a single-class-jar seems to work.

Then we may assume that the .jar is executed, whatever is in it: it was the bundler that got confused,

and it seems it only 'understands' simple .jar's.

Then, I suppose, you might replace the .jar by hand (file manager, or Finder) by the .jar you want to run.

Procedure:

- create a single class .jar with the name, classname and blank package like the complex jar you want to run.

- check that it works (again)

- replace the .jar by your own.

- verify that it runs again.


I could write down what the inside structure of an app is, but, besides that you already might know,

I found a few very interesting documents that explain everything.

... and you might be right: many articles say that Jar Bundler works no more and that you must use Ant.

To me that means that you could do everything yourself, by editor and filemanager, with a working app

as an example.


Here those are:


https://developer.apple.com/legacy/library/documentation/Java/Conceptual/Jar_Bun dler/Jar_Bundler.pdf

https://developer.apple.com/library/mac/documentation/Java/Reference/Java_Infopl istRef/Java_InfoplistRef.pdf

http://alvinalexander.com/apple/mac/java-jar-bundler/java-on-mac.shtml

http://informagen.com/JarBundler/

http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.h tml

http://supunmali-myexperience.blogspot.nl/2012/10/jar-bundler-mac-os-x.html


I guess this will help us both.

;JOOP!

Jul 11, 2013 9:49 AM in response to Arc676

Today I created single class application that only fires a dialog and made a runnable (tested) .jar out of it.

I run Jar Builder, but it did not incorporate the .jar file.

After placing the .jar file in the right place it would not run at all.

So tomorrow I must revert to Ant; I don't like that.


Again: how did you create that runnable single-class app (details please).

- then: can you create a copy of the app and then replace the .jar in it by a .jar by the same name

and with a main class by the same name?

;JOOP!

Jar Bundler Problems

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.