Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Distributing as an Executable JAR File
Distributing as an Executable JAR File [message #446883] Sun, 05 December 2004 03:42 Go to next message
Daniel Spiewak is currently offline Daniel Spiewak
Messages: 263
Registered: July 2009
Senior Member
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="serif">I have an application that I wish to distribute for
all major platforms (Mac, Windows, GTK, Motif, probably FOX) as one
single executable JAR file.&nbsp; I want this file to be runnable on my Mac
and then I network the single file over and run it again on my Fedora
box <i>with no modifications.</i>&nbsp; I want all the dependencies
contained within the JAR file.&nbsp; And, just to make life fun, I'd also
like to keep the JAR file's size down. :-)&nbsp; Any thoughts?<br>
<br>
My idea originally was to simply use the java.util.jar API to
decompress all the dependencies on first run and then refer to them
using the JAR classpath and by dynamically setting the
java.library.path system property.&nbsp; However, because of the way that
class loaders work, the setting of the library path didn't actually get
set in the ClassLoader.&nbsp; Thus, the Display class (and all other classes
for that matter) got loaded without the proper library path.&nbsp; Thus, it
didn't run.&nbsp; So I dug out my javadoc and wrote some code which uses
JNDI to start a new JVM instance with the proper library path set.&nbsp;
This works great, believe it or not.&nbsp; It starts fast, and has limited
memory usage.&nbsp; The problem (a rather embarrassing one) is that I can't
seem to package it as an executable JAR file.&nbsp; I've used the JAR
command, file-roller, nothing works.&nbsp; Basically, the JVM isn't finding
the classes in the JAR when I try to run it using the java -jar
command.&nbsp; It works if I use java -cp Application.jar
com.mycomp.app.MainClass&nbsp; Any thoughts on that?<br>
<br>
I read somewhere that Azureus (<a class="moz-txt-link-freetext" href="http://azureus.sourceforge.net">http://azureus.sourceforge.net</a>) is
packaged as a single JAR file.&nbsp; How do they do it?&nbsp; Am I completely out
of my mind?&nbsp; Can this be done at all?<br>
<br>
Daniel<br>
</font>
</body>
</html>
Re: Distributing as an Executable JAR File [message #446886 is a reply to message #446883] Sun, 05 December 2004 11:37 Go to previous messageGo to next message
James Cooper is currently offline James Cooper
Messages: 4
Registered: July 2009
Junior Member
Are you specifying the Main-Class in the Jar's Manifest.mf?

This tells the java interpreter which class has the main() method.

Take a look at http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html
Re: Distributing as an Executable JAR File [message #446891 is a reply to message #446886] Mon, 06 December 2004 03:16 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel Spiewak
Messages: 263
Registered: July 2009
Senior Member
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="serif">Yes, I am.  I've tested further, and have realized
that it doesn't work using the java -cp &lt;&lt;jar file&gt;&gt;
&lt;&lt;main class&gt;&gt; either.  In both instances, I'm getting a
NoClassDefFoundError on the main class.<br>
<br>
By the way, I'd like to correct a mistake, it isn't JNDI that I used,
but JDI (Java Debugging Interface).  Whoops.<br>
<br>
Daniel<br>
</font><br>
James Cooper wrote:
<blockquote cite="midcourt0$b3e$1@www.eclipse.org" type="cite">Are you
specifying the Main-Class in the Jar's Manifest.mf?
<br>
<br>
This tells the java interpreter which class has the main() method.
<br>
<br>
Take a look at <a class="moz-txt-link-freetext" href="http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html">http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html</a>
<br>
<br>
</blockquote>
</body>
</html>
Re: Distributing as an Executable JAR File [message #446933 is a reply to message #446883] Mon, 06 December 2004 16:25 Go to previous messageGo to next message
Radu is currently offline Radu
Messages: 44
Registered: July 2009
Member
take a look at
http://fjep.sourceforge.net/


regards.


Daniel Spiewak wrote:
> I have an application that I wish to distribute for all major platforms
> (Mac, Windows, GTK, Motif, probably FOX) as one single executable JAR
> file. I want this file to be runnable on my Mac and then I network the
> single file over and run it again on my Fedora box /with no
> modifications./ I want all the dependencies contained within the JAR
> file. And, just to make life fun, I'd also like to keep the JAR file's
> size down. :-) Any thoughts?
>
> My idea originally was to simply use the java.util.jar API to decompress
> all the dependencies on first run and then refer to them using the JAR
> classpath and by dynamically setting the java.library.path system
> property. However, because of the way that class loaders work, the
> setting of the library path didn't actually get set in the ClassLoader.
> Thus, the Display class (and all other classes for that matter) got
> loaded without the proper library path. Thus, it didn't run. So I dug
> out my javadoc and wrote some code which uses JNDI to start a new JVM
> instance with the proper library path set. This works great, believe it
> or not. It starts fast, and has limited memory usage. The problem (a
> rather embarrassing one) is that I can't seem to package it as an
> executable JAR file. I've used the JAR command, file-roller, nothing
> works. Basically, the JVM isn't finding the classes in the JAR when I
> try to run it using the java -jar command. It works if I use java -cp
> Application.jar com.mycomp.app.MainClass Any thoughts on that?
>
> I read somewhere that Azureus (http://azureus.sourceforge.net) is
> packaged as a single JAR file. How do they do it? Am I completely out
> of my mind? Can this be done at all?
>
> Daniel
Re: Distributing as an Executable JAR File [message #446947 is a reply to message #446933] Mon, 06 December 2004 23:46 Go to previous message
Daniel Spiewak is currently offline Daniel Spiewak
Messages: 263
Registered: July 2009
Senior Member
Will that include native libraries and separate distributions of the
same Java API for different platforms dynamically selected? I'm
familiar with the plugin, in fact, it was a major inspiration for my
solution to the problem. I just can't figure out why the java command
won't recognize the classes in my JAR files.

Daniel

Radu Racariu wrote:

> take a look at
> http://fjep.sourceforge.net/
>
>
> regards.
>
>
> Daniel Spiewak wrote:
>
>> I have an application that I wish to distribute for all major
>> platforms (Mac, Windows, GTK, Motif, probably FOX) as one single
>> executable JAR file. I want this file to be runnable on my Mac and
>> then I network the single file over and run it again on my Fedora box
>> /with no modifications./ I want all the dependencies contained
>> within the JAR file. And, just to make life fun, I'd also like to
>> keep the JAR file's size down. :-) Any thoughts?
>>
>> My idea originally was to simply use the java.util.jar API to
>> decompress all the dependencies on first run and then refer to them
>> using the JAR classpath and by dynamically setting the
>> java.library.path system property. However, because of the way that
>> class loaders work, the setting of the library path didn't actually
>> get set in the ClassLoader. Thus, the Display class (and all other
>> classes for that matter) got loaded without the proper library path.
>> Thus, it didn't run. So I dug out my javadoc and wrote some code
>> which uses JNDI to start a new JVM instance with the proper library
>> path set. This works great, believe it or not. It starts fast, and
>> has limited memory usage. The problem (a rather embarrassing one) is
>> that I can't seem to package it as an executable JAR file. I've used
>> the JAR command, file-roller, nothing works. Basically, the JVM
>> isn't finding the classes in the JAR when I try to run it using the
>> java -jar command. It works if I use java -cp Application.jar
>> com.mycomp.app.MainClass Any thoughts on that?
>>
>> I read somewhere that Azureus (http://azureus.sourceforge.net) is
>> packaged as a single JAR file. How do they do it? Am I completely
>> out of my mind? Can this be done at all?
>>
>> Daniel
>
Previous Topic:ProgressBar SWT
Next Topic:Native splash screen?
Goto Forum:
  


Current Time: Thu Sep 18 19:46:42 GMT 2014

Powered by FUDForum. Page generated in 0.02818 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software