call a class without using a jar file

M

martin

Hi

I have downloaded a java library fro my thesis. To call a class using
this Library i always have to call the method like:

java -classpath ..\..\lib\xyz.jar; test

This works fine for test purposes. but what can i do if i want to use
this libryry from a servlet? I have already added this jar file to the
class path.

Thank you very much for your help.

Martin
 
J

Joona I Palaste

martin said:
I have downloaded a java library fro my thesis. To call a class using
this Library i always have to call the method like:
java -classpath ..\..\lib\xyz.jar; test
This works fine for test purposes. but what can i do if i want to use
this libryry from a servlet? I have already added this jar file to the
class path.

Add the xyz.jar into the classpath of your servlet engine. How to do
this depends on the servlet engine.
Note that servlets can call the main() method of a class just like you
can. For example if you are using:

java test

Then in the servlet you can just write:

test.main(new String[0]);

--
/-- Joona Palaste ([email protected]) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"Life without ostriches is like coffee with milk."
- Mika P. Nieminen
 
H

Harald Hein

martin said:
I have downloaded a java library fro my thesis. To call a class
using this Library

Since this is your thesis, you might want to work on your terminology.
Your professor will appreciate it.

You do NOT call a class. You call - or invoke - methods. You
instantiate classes.
i always have to call the method like:

java -classpath ..\..\lib\xyz.jar; test

No, you could pack your "test" program into a jar itself. And in the
manifest file of that jar you could specify the additional xyz.jar. See
Sun's jar documentation.

You could place the xyz.jar in the extension directory of your java
installation, too.
This works fine for test purposes. but what can i do if i want to
use this libryry from a servlet?

So here comes the most frequent comp.lang.java.programmer answer: Read
the documentation. In this case the one of your servelet-server.
Especially the section about deployment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top