Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JNLP and Web Start and the fly likes Is web start my best answer? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JNLP and Web Start
Bookmark "Is web start my best answer?" Watch "Is web start my best answer?" New topic
Author

Is web start my best answer?

Nick Jp George
Greenhorn

Joined: Oct 08, 2010
Posts: 18
Let me start this question by simply stating that right now I'm so angry I could spit. I'm going to try to be as calm as I can.

All I want to do is to have some form of my program, which currently runs in eclipse using jars and native code (it's JoGL, FWIW) that allows me to send it to run on a different computer, i.e. share it. Is java web start the only answer here? I've tried looking up a lot of tutorials, and they all seem so unbelievably disproportionately byzantine and complicated and multi-step for something that seems to me to ought to be so simple. Is there a simple, step by step tutorial for doing this in eclipse, that a reasonably intelligent person can just follow?

I can't be the first person to want to share a program, and I can't be the first person who say it seems crazy to have to download and install ANT, make and edit a jnlp file and an xml file and an html, and some nonsense called a wrapper feature, and signed jars and unsigned jars and then you just upload to your handy dandy FTP server that everyone of course has and if not well then you can just use TOMCAT... just to share a program. What am I missing here? I remember in c when you compiled to an exe and sent it.

Thanks to anyone who read my rant. Your reward is my argument summed up by the Onion.
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
I can't be the first person to want to share a program, and I can't be the first person who say it seems crazy to have to download and install ANT, make and edit a jnlp file and an xml file and an html, and some nonsense called a wrapper feature, and signed jars and unsigned jars and then you just upload to your handy dandy FTP server that everyone of course has and if not well then you can just use TOMCAT... just to share a program. What am I missing here? I remember in c when you compiled to an exe and sent it.


Ant is not necessary for creating a Webstart app, but the rest is pretty much what the required steps for a Webstart app containing native code are. It would be somewhat easier if it was pure Java - no signing of jar files.

Uploading files, of course, is only required if you want to serve it from a web server; if mailing stuff around is acceptable (as the sentence about C executables seems to indicate) then you can make it a regular desktop app - no need for Webstart, no need for HTML/JNLP files, no need for the wrapper, no need for signing anything (since desktop apps by default have no security restrictions). Obviously, all benefits of Webstart would be lost (like easy upgrading, handling of native code for different platforms, etc.)

Did you get the basic example I posted in the other thread to work? That might be a good starting point.
Nick Jp George
Greenhorn

Joined: Oct 08, 2010
Posts: 18
I would LOVE a desktop application. Maybe someday down the road I'll be enlightened to the benefits of wrapper features, but for now, I just want to email my game to my friend. Can you talk a little about how to make a desktop application? I haven't gotten the example in the other thread to work, I'll keep trying (as I said, all I did was copy the jnlp file and change the jars, say a quick prayer and double click.)

Thanks a lot for the reply
Kevin Workman
Ranch Hand

Joined: Sep 28, 2010
Posts: 151
Nick Jp George wrote:I would LOVE a desktop application. Maybe someday down the road I'll be enlightened to the benefits of wrapper features, but for now, I just want to email my game to my friend. Can you talk a little about how to make a desktop application? I haven't gotten the example in the other thread to work, I'll keep trying (as I said, all I did was copy the jnlp file and change the jars, say a quick prayer and double click.)

Thanks a lot for the reply


You should be able to just create an runnable Jar. You should read through this so you understand what's going on: http://download.oracle.com/javase/tutorial/deployment/jar/

But you can do it automatically in eclipse just by going to file -> export -> Runnable JAR File. Depending on what you want and how your project is setup, you might want to look into creating a Fat Jar: http://fjep.sourceforge.net/

The good news is, once you have the runnable Jar, it should be pretty easy to create the webstart version, if that's the road you choose to go down.
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
There isn't much to a desktop application. I'm sure you already know about the main method. You'd package all classes into a jar file. That jar file's manifest needs a Main-Class attribute and a Class-Path attribute for the JOGL jar files that you'd send along with your own jar file.

The trickiest part are probably the native libraries - they need to be in the PATH of the machine they're running on, and it's not entirely clear what that is for any given machine. It may be sufficient to keep them in the same directory as the other jar files, or it may be necessary to put them into one of the directories listed in the PATH. Start by experimenting on your own machine to see what works.
Nick Jp George
Greenhorn

Joined: Oct 08, 2010
Posts: 18
I posted this question on the JogAmp forum, and they answered. But, they're a little less... noob-friendly... than this site. Tell me if this makes sense to you:

It has nothing to do with JOGL. Since Java 1.6 update 21, the JARs are handled a bit differently, it is hardly possible to mix signed and unsigned JARs.

What you intend to do is impossible because JOGL uses native libraries, not only JARs. Rather use Java Web Start if you want to create a very simple installer. The user has just to click on "OK", it is not difficult

I use Ant to deploy my project, everything is automatized. The Ant script (build.xml) compiles the source code, make several JARs, sign them, generate the JNLP files. At the end, I only have to copy the content of the "target" directory onto my FTP server on Sourceforge.net and my friends only have to click onto a JNLP link to launch the installation.


Certainly I know how to make an executable jar, but I haven't found any way to make that work with the native libaries. I've put the jar in the same folder as the libraries, I've put the native libraries themselves in the jar... the guy from the JogAmp forum seems to think it's just plain not possible. And about the last bit... I tried to download ANT, but, what I downloaded isn't actually an application, like eclipse, and to be honest, I have no idea what I'm doing with it.

EDIT: neither eclipse's automatic exporter or fatjar can handle the native code.
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
I can't tell from the last post whether you're now trying to make a WebStart app or a standard desktop app. If the latter, then no signing or bundling in jar files of the native libraries is necessary (and neither is Ant, as I said before). The native libraries must be in the PATH.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

I think that the problem is that you are trying to run a JOGL application, and by default the bindings are not available on most computers. In Microsoft Windows terms, you would get around this by packaging various DLLs with your application (with all the heartache that comes with that) or having the DLLs available as a separate download (which has it's own set of problems).

The folks at JogAmp have tried to find a solution that will work in almost all scenarios - by specifying that JOGL applications will use WebStart, they can ensure that anytime someone tries to start a JOGL application, they will get the benefits of WebStart (you control updates to the software, etc) and WebStart will also ensure that the computer in question has the necessary JOGL binding libraries downloaded for the operating system and architecture that the user is running.

It might be possible to side step this by having your friend run some other JOGL application (e.g. running one of the demos on the JogAmp site) which would result in the bindings being downloaded to their computer. Your application might then be able to work with those bindings. I have not tried this.

Nick Jp George wrote:
It has nothing to do with JOGL. Since Java 1.6 update 21, the JARs are handled a bit differently, it is hardly possible to mix signed and unsigned JARs.

This is from the perspective of the other writer - they are looking at WebStart being the "one true way", and if you are going down that route then you will need to sign your own Jars.

Nick Jp George wrote:
What you intend to do is impossible because JOGL uses native libraries, not only JARs. Rather use Java Web Start if you want to create a very simple installer. The user has just to click on "OK", it is not difficult

It is not impossible. His second statement talks about Java Web Start providing a very simple installer. By implication it is possible to have a not-so-simple installer that will bypass Java Web Start. Therefore not impossible, but it may not be so simple. JOGL JAR Bundeling gives a very high level overview of what is needed for different distribution mechanisms, including manual deployment. It would be nice if there was a proper explanation there though.

Nick Jp George wrote:
I use Ant to deploy my project, everything is automatized. The Ant script (build.xml) compiles the source code, make several JARs, sign them, generate the JNLP files. At the end, I only have to copy the content of the "target" directory onto my FTP server on Sourceforge.net and my friends only have to click onto a JNLP link to launch the installation.

Which is a very reasonable way to proceed if you have the requisite knowledge. If you are interested in exploring this, then I think you will find lots of people here who are willing to go through the steps of doing most of this. If you do this, I would recommend you take it step-by-step. So first off get ant installed. Then have a separate topic for getting an ant build script compiling your classes. Then another topic for making jar files. Then another topic for signing them. Etc. That way each topic will attract the people who are interested in helping on that topic. Plus no one topic will get so long that people will tune out.

Nick Jp George wrote:EDIT: neither eclipse's automatic exporter or fatjar can handle the native code.

I would suspect that if you put the native libraries described in JOGL JAR Bundeling into a separate directory within your Eclipse project, and told it that this directory is on the runtime path, then Eclipse should just take whatever is in that directory verbatim.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Is web start my best answer?
 
Similar Threads
Including external jar (fobs4jmf) in generated jar
Looking for someone to help me change a .class file in a .jar file
Need help opening file with eclipse plugin
JoGL 2.0
Drools runtime environment