[java] runnen van jar > gebruikmaking van andere jar

Pagina: 1
Acties:

  • bvp
  • Registratie: Maart 2005
  • Laatst online: 16-04 19:03
Ik probeer mijn app te runnen met:
java -jar test.jar

Hij runt nou wel ok, in de manifest is opgenomen dat de main-class TestClient is.

Echter, de TestClient maakt gebruik van een client-jar: namelijk een sql-client kit.

Nou geeft hij bij het runnen de melding:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

Hoe kan ik ervoor zorgen dat hij de client-kit gewoon ziet.

Ik heb tijdens het runnen van de jar al proberen te wijzen naar een classpath etc. maar allemaal geen goed resultaat.
Ook het runnen van de TestClient.class geeft het zelfde resultaat.
Vanuit Eclipse runnen werkt wel gewoon.

  • Gerco
  • Registratie: Mei 2000
  • Laatst online: 20-04 18:28

Gerco

Professional Newbie

Kun je niet dit doen?
code:
1
C:\> java -cp jar1.jar;jar2.jar nl.your.package.MainClass


Uit "man java":
-jar

Executes a program encapsulated in a JAR archive. The first argument is the name of a JAR file instead of a startup class name. In order for this option to work, the manifest of the JAR file must contain a line of the form Main-Class:classname. Here, classname identifies the class having the public static void main(String[] args) method that serves as your application's starting point. See the Jar tool reference page and the Jar trail of the Java Tutorial for information about working with Jar files and Jar-file manifests. When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.

[ Voor 82% gewijzigd door Gerco op 25-11-2005 13:13 ]

- "Als ik zou willen dat je het begreep, legde ik het wel beter uit!" | All number systems are base 10!


Verwijderd

code:
1
Class-Path: servlet.jar infobus.jar acme/beans.jar


zie:
http://java.sun.com/devel.../JAR/basics/manifest.html

en voor ant heb je bijvoorbeeld:
http://jakarta.apache.org...nt/ManifestClassPath.html

  • bvp
  • Registratie: Maart 2005
  • Laatst online: 16-04 19:03
Verwijderd schreef op vrijdag 25 november 2005 @ 13:12:
code:
1
Class-Path: servlet.jar infobus.jar acme/beans.jar
Thnx, dat hielp mij perfect verder!
Heb nu nl. aan myManifest.txt de regel:
code:
1
Class-Path: lib\mysql-connector-java-3.0.10-stable-bin.jar


Als ik hem nu run vind hij de classen wel.