Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Export runnable jar files wizard - library handling (Indigo)
icon5.gif  Export runnable jar files wizard - library handling (Indigo) [message #880233] Fri, 01 June 2012 17:20 Go to next message
Robert Lockwood is currently offline Robert LockwoodFriend
Messages: 39
Registered: October 2010
Location: Riverside, CA, USA
Member
Using the wizard one gets to the "Runnable JAR File Specification" page. On it is an area "LibraryHandling" with three opitions. What's the difference between:
"Extract required libraries into generated JAR" and
"Package required libraries into generated JAR" ?

When is the last option that copies required libraries to a sub folder useful?

Thanks

Re: Export runnable jar files wizard - library handling (Indigo) [message #881558 is a reply to message #880233] Mon, 04 June 2012 20:37 Go to previous messageGo to next message
Jorge Antonio Díaz-Benito Soriano is currently offline Jorge Antonio Díaz-Benito SorianoFriend
Messages: 10
Registered: May 2012
Junior Member
I guess the last option is useful when you don't want to include a library in a JAR file, mainly because that would considerably increase the file size (even more if your project requires several libraries). But if just a part of your project needs from those libraries, you could just let them out, making the main part of your project (the JAR file) much smaller than with them and, therefore, much faster to download, and allowing some limited usage of it while, in the meantime, a background thread is downloading the required libraries to activate all the functionalities of your project.

This is only a personal opinion.
Re: Export runnable jar files wizard - library handling (Indigo) [message #881911 is a reply to message #881558] Tue, 05 June 2012 13:36 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
"Extract required libraries into generated JAR" will inflate the jar and copy the classes into the jar.
"Package required libraries into generated JAR" will copy the jar as it is.
Re: Export runnable jar files wizard - library handling (Indigo) [message #882146 is a reply to message #881911] Tue, 05 June 2012 23:38 Go to previous messageGo to next message
Robert Lockwood is currently offline Robert LockwoodFriend
Messages: 39
Registered: October 2010
Location: Riverside, CA, USA
Member
Thanks.

The reason I ask is that I have exported a runnable Jar which I try to run from another class (in eclipse) as a process and nothing happens. I can run it by opening it (Ubuntu) from the file "explorer" and from terminal.

The main class uses some other of my classes and I assume that they are included using the copy packages option, is this correct?

I'm not new at programming in general but new to Java and Eclipse (and Ubuntu).
Re: Export runnable jar files wizard - library handling (Indigo) [message #882346 is a reply to message #882146] Wed, 06 June 2012 09:34 Go to previous messageGo to next message
Jorge Antonio Díaz-Benito Soriano is currently offline Jorge Antonio Díaz-Benito SorianoFriend
Messages: 10
Registered: May 2012
Junior Member
First, although I'm not sure about it, maybe, to be run from another application, the JAR file has to have some special permissions. Give them to it with the command

sudo chmod 777 jarfileyouwanttorunfromyourjavacode.jar


If this doesn't work, are you sure that you're referring to the JAR in a proper way? Remember that paths in Linux are written different than they are in Windows. So do kind of a test by writing a program that lists all the files in the directory where the JAR you're trying to run is supposed to be, indicating the path exactly the same as you're indicating it now when trying to run it.
If the files are properly listed, it would be nice if you could post here how do you try to run the JAR file from the Java code so I can fetch it for any kind of errors.
Re: Export runnable jar files wizard - library handling (Indigo) [message #882363 is a reply to message #882346] Wed, 06 June 2012 09:58 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
If it works from the file "explorer" and not from the other process, it probably means that the jar is good and there could be a problem with your program. Are you sure you are launching this jar using the command
'java -jar <path-to-jar>'
Re: Export runnable jar files wizard - library handling (Indigo) [message #882588 is a reply to message #882363] Wed, 06 June 2012 19:49 Go to previous message
Robert Lockwood is currently offline Robert LockwoodFriend
Messages: 39
Registered: October 2010
Location: Riverside, CA, USA
Member
I found the problem! (Have yet to implement the solution!)
Here's my first attempt at a simpler test where test is a shell script that creates a file.
String newCommand =  "/home/programmer/var/jars/test" };

Process p;
try {
    p = Runtime.getRuntime().exec(command);
} catch (IOException e1) { 
    e1.printStackTrace();
} 

This doesn't work because there are no environmental paths. In addition the command string is parsed into separate strings at spaces and that might destroy the logic.

This works!
// path to sh is included (and the string are broken by me)
String [] newCommand = {"/bin/sh", "/home/programmer/var/jars/test" };

Process p;
try {
	p = Runtime.getRuntime().exec(command);
} catch (IOException e1) { 
	e1.printStackTrace();
} 

Breaking up the command string into an array of strings is overkill for this simple test.

I need to include the full path, to java if I can find it. This could be a pain since it needs to be the same for all computers but perhaps it can be computed. Here is what I was doing that didn't work at all.
// my computed command String
java -jar /home/programmer/var/jars/ImageDisplay.jar "/media/sdb1/images/PR-640/PR-640_0004.raw"

I'll need to prepend the path to java to "java" and distribute the strings into a string array. At least I now understand and here's my reference:
http://www.ensta-paristech.fr/~diam/java/online/io/javazine.html

Thanks for your help.
Previous Topic:Can't get my webapps to deploy from Eclipse
Next Topic:convert c# to java tool
Goto Forum:
  


Current Time: Tue Nov 25 23:14:09 GMT 2014

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

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