[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools] Re: Basic Java development question
|
- From: Michael Taege <m-taege@xxxxxxxxxxx>
- Date: Thu, 19 Jun 2003 11:16:28 +0200
- Newsgroups: eclipse.tools
- Organization: EclipseCorner
- User-agent: Opera7.11/Win32 M2 build 2887
Hi Scott,
external libraries has to be within the classpath of the Java virtual
maschine if you are executing your
Java application. Therefore you have to tell the VM where to find the
external libraries with the '-cp' or '-classpath' option of the java
command.
Assuming that you have the external jars 'a.jar' and 'b.jar' the java
command will look like this
java -cp "a.jar;b.jar;your.jar" com.yourapp.YourMain
It's a common practice to put external libraries in a folder with the name
'lib' to make clear what external jars are needed by an application. Then
you have to tell the VM the relative path to the libraries.
java -cp "./lib/a.jar;./lib/b.jar;your.jar" com.yourapp.YourMain
If you don't want to use the classpath option you can add an external jar
to your jar. I have no idea if this is possible with Eclipse, but you can
handle a jar file as a zip file (actually a jar-file is nothing else as a
zip-file, rename the file extension from *.jar to *.zip and open it with
WinZip or WinRar). But I think thats no good idea, because if the vendor of
the external library publishes a new version or a bug-fix you can run into
trouble (well, if the vendor changes package-, class-or method-names, you
can run into trouble too, but that's another question).
Take care
Michael
Am Thu, 19 Jun 2003 03:03:36 -0400 hat Scott <scott@xxxxxxxxxx>
geschrieben:
I have a really basic Java question - I'm building an application using
Eclipse that makes use of a couple of libraries that are located in
external JAR files. I've added them as external JARs to the Libraries
tab
of the Java Build Path, and everything works fine in Eclipse. My program
compiles and access those libraries as expected. However, when I export
my project as a JAR file, and try to execute it outside of Eclipse, it
gives me an error telling me that it can't find those libraries. How
should I proceed? I can import the source code of those libraries into
my
project, and then it works fine during export, but it bloats my code and
is really unncessary as I won't be altering any of that code. Is there a
better way (i.e. A way to tell Eclipse to include those external JARs in
my JAR during export, or something?) I would definately appreciate any
guidance, as you have already surmised I am a bit of a beginner at all
this. Thanks!
Scott
--
-----------------------------------
Dipl. Ing. Michael Täge
Bauschlotterstr. 36
75177 Pforzheim
Fon: 07231 51278
Mobil: 0171 8067809
m-taege@xxxxxxxxxxx