Beginner Q on exporting to jar [message #248462] |
Sat, 09 February 2008 03:52  |
Eclipse User |
|
|
|
Originally posted by: man_kam.yahoo.com
In the welcome HelloWorld example, I can run it as Java Application in
Eclipse. After exporting it as jar file, I could also run by "java -jar
hw.jar"
On the other hand, tn the welcome HelloWorld SWT example,
I can only run it as Java Application in Eclipse. I cannot not run it by
"java -jar hwswt.jar" It fail to recognize the Display object. I guess
it fail to find the swt.jar even it is in the same directory. Futhermore,
I cannot solve the problem by "java -cp . -jar hw.jar" Does anyone has a
clue? Is there an environment setting I need to set?
There another question is that I download a Java program from the net.
Unzipping the archive is just one main jar file and 3 supporting jar file
in lib sub-directory. For this application, I could just run it
"example.jar" after unzipping. It is a graphical java porgram using
swing-layout-1.0.jar. Therefore, it is possible to build a jar file to
run all by itself and know how to search the supporting jar. Does it
require any special setup in Eclipse to do that? Most tutorial on the net
only give text-base java application as "java -jar hw.jar" I would
appreciate any help in this matter.
|
|
|
Re: Beginner Q on exporting to jar [message #248472 is a reply to message #248462] |
Sat, 09 February 2008 09:41  |
Eclipse User |
|
|
|
Mok Man Kam wrote:
> In the welcome HelloWorld example, I can run it as Java Application in
> Eclipse. After exporting it as jar file, I could also run by "java -jar
> hw.jar"
>
> On the other hand, tn the welcome HelloWorld SWT example,
> I can only run it as Java Application in Eclipse. I cannot not run it
> by "java -jar hwswt.jar" It fail to recognize the Display object. I
> guess it fail to find the swt.jar even it is in the same directory.
> Futhermore, I cannot solve the problem by "java -cp . -jar hw.jar" Does
> anyone has a clue? Is there an environment setting I need to set?
> There another question is that I download a Java program from the net.
> Unzipping the archive is just one main jar file and 3 supporting jar
> file in lib sub-directory. For this application, I could just run it
> "example.jar" after unzipping. It is a graphical java porgram using
> swing-layout-1.0.jar. Therefore, it is possible to build a jar file to
> run all by itself and know how to search the supporting jar. Does it
> require any special setup in Eclipse to do that? Most tutorial on the
> net only give text-base java application as "java -jar hw.jar" I would
> appreciate any help in this matter.
>
>
>
>
>
Hi Mok. I went through exactly this same issue a while ago.
On your first question, the reason you can't run the SWT example is that
SWT requires some native (non-Java) programs in order to run. On
Windows, for example, you need 4 (I think) DLL's, either in Windows /
System32 or in the same directory as the JAR file.
Here are some links that have detailed information.
http://www.eclipse.org/swt/examples.php#standaloneOutsideEcl ipse
http://www.javalobby.org/forums/thread.jspa?threadID=15338&a mp;tstart=0
On your second question, this information is located in the Manifest
file, which is built when you create the JAR file. The manifest tells
the JRE where to find other classes needed to run the application.
Here is a link to the newsgroup archive for my earlier question. It has
an example of what goes in the Manifest. You can create your own
manifest file and use that when you export to create the JAR.
http://dev.eclipse.org/newslists/news.eclipse.newcomer/msg15 800.html
Hope this helps. Mark
|
|
|
Powered by
FUDForum. Page generated in 0.08558 seconds