Results 1 to 6 of 6
- 05-03-2012, 07:37 PM #1
- 05-03-2012, 08:43 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,604
- Rep Power
- 5
Re: Compiling with external libraries
Use the classpath command line option for java to point the jar's. Depending upon the licenses of the external libraries, you could also export the runnable jar from eclipse with the libraries packaged within your jar (when you exporta Runnable jar, you should be presented with an option to package required libraries).
- 05-03-2012, 10:29 PM #3
Re: Compiling with external libraries
Is this the only way of doing it? What I mean is there a way for me to double click on the jar and have it run?
- 05-03-2012, 11:16 PM #4
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,604
- Rep Power
- 5
Re: Compiling with external libraries
Specify the relative path to the libraries within the Manifest file. See Adding Classes to the JAR File's Classpath (The Java™ Tutorials > Deployment > Packaging Programs in JAR Files)
- 05-04-2012, 09:56 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: Compiling with external libraries
It's a runnable jar, so the -cp option is not useable if executed as 'java -jar'. Only the classpath in the manifest is used.
As for packaging them in the jar itself (ie unzipping them), though that can produce a working jar file, it's a real hack when they should simply be distributed with the jar file itself. It's not exactly complex to produce a distribution folder, and I'm sure Eclipse can do that.Please do not ask for code as refusal often offends.
- 05-04-2012, 06:17 PM #6
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,604
- Rep Power
- 5
Re: Compiling with external libraries
It is not ignored when not using the -jar option (eg passing the main class name instead) - I should have specified more clearly in my earlier post.It's a runnable jar, so the -cp option is not useable if executed as 'java -jar'. Only the classpath in the manifest is used.
Agreed. Hence post 4As for packaging them in the jar itself (ie unzipping them), though that can produce a working jar file, it's a real hack when they should simply be distributed with the jar file itself. It's not exactly complex to produce a distribution folder, and I'm sure Eclipse can do that.Last edited by doWhile; 05-04-2012 at 06:21 PM.
Similar Threads
-
Open external file with external program
By Wietse de Vries in forum New To JavaReplies: 1Last Post: 12-31-2011, 04:52 PM -
Compiling a Jar w/ a external lib
By ateixeira in forum New To JavaReplies: 12Last Post: 09-14-2011, 12:40 PM -
How to use libraries?
By Josep_16 in forum New To JavaReplies: 1Last Post: 09-06-2011, 01:50 PM -
Using libraries that others dont have(j3d)
By scorpion9 in forum Advanced JavaReplies: 7Last Post: 02-19-2010, 11:24 AM -
different external libraries for different OS and CVS
By jv_martin in forum EclipseReplies: 1Last Post: 11-04-2009, 02:45 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks