jar and class-path problemm

K

Kordian

Hi,

I have problem with jar archive and Class-Path from Manifest.fm. I
have put all API class with one main-class into JAR archive.
Additionaly I use JDBC drivers for MSSQL which are located in
c:\mssql\lib path. So, my manifest file looks like this:

Manifest-Version: 1.0
Created-By: 1.4.0 (Sun Microsystems Inc.)
Main-Class: check4
Class-Path: c:\mssql\lib\mssqlserver.jar c:\mssql\lib\msbase.jar
c:\mssql\lib\msutil.jar

And when I run my JAR file I receive an error:
Exception in thread "main" java.lang.NoClassDefFoundError: check4

Java can not find my main class :( After removing line with Class-Path
i get an error:

Driver not found: java.lang.ClassNotFoundException:
com.microsoft.jdbc.sqlserver.SQLServerDriver
com.microsoft.jdbc.sqlserver.SQLServerDriver
Exception: java.sql.SQLException: No suitable driver
No suitable driver
Driver not found: java.lang.ClassNotFoundException:
com.microsoft.jdbc.sqlserver.SQLServerDriver
com.microsoft.jdbc.sqlserver.SQLServerDriver
Exception: java.sql.SQLException: No suitable driver
No suitable driver

What am I to do? What I do wrong?

Kordian
 
O

Oscar kind

Kordian said:
I have problem with jar archive and Class-Path from Manifest.fm. I
have put all API class with one main-class into JAR archive.
Additionaly I use JDBC drivers for MSSQL which are located in
c:\mssql\lib path. So, my manifest file looks like this:

Manifest-Version: 1.0
Created-By: 1.4.0 (Sun Microsystems Inc.)
Main-Class: check4
Class-Path: c:\mssql\lib\mssqlserver.jar c:\mssql\lib\msbase.jar
c:\mssql\lib\msutil.jar

This will not work, as Class-Path headers specify _relative_ URL's.
Solutions to this problem are:
- Installing the specific driver version for your application with
your application so you can use a relative URL in the Class-Path header
- Installing the driver system-wide in the lib/ext directory of the JVM

The first option has the advantage that you're certain of the driver
version and cannot break applications that depend on a specific driver
version.

The second option has the advantage that you don't have to specify a
Class-Path header at all.
 

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