Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JAR Files with Class Paths

Reply
Thread Tools

JAR Files with Class Paths

 
 
Jonathan
Guest
Posts: n/a
 
      12-24-2004
Hello folks.

I realize that problems with classpaths are a pretty common theme here,
but I've been wrestling with this for days. I've been searching
newsgroups and websites but I can't find an answer to my problem.

I am trying to include the mysql JDBC driver with my application's JAR
file. I've only succeeded to run the application with the driver by
running the main class.

I have tried to include the Class-Path with the JAR's manifest, like
so:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.4.2_06-b03 (Sun Microsystems Inc.)
Main-Class: Scheduler
Class-Path: C:\physioclinic\mysql-connector-java-3.0.15-ga-bin.jar

However, when I include the Class-Path attribute, the JAR can no longer
find the Scheduler main class.

I've experimented with including the build and dist directories in the
Class-Path, but it will not find the main class when the Class-Path
attribute is included.

The only time it works is when I remove the Class-Path attribute. So
I've tried including the jar for the driver on the command-line
instead, running with

java -classpath C:\physioclinic\mysql-connector-java-3.0.15-ga-bin.jar
-jar dist\scheduler.jar

Which runs, but cannot find the driver. It does find the driver when I
do the same thing without the JAR file.

Can anyone shed some light on this? Should I post my build file from
ANT?

I usually find my answers scouting the newsgroups but this time I can't
seem to get anywhere. Thanks in advance.

 
Reply With Quote
 
 
 
 
ByteCoder
Guest
Posts: n/a
 
      12-24-2004
Jonathan wrote:
> Hello folks.
>
> I realize that problems with classpaths are a pretty common theme here,
> but I've been wrestling with this for days. I've been searching
> newsgroups and websites but I can't find an answer to my problem.
>
> I am trying to include the mysql JDBC driver with my application's JAR
> file. I've only succeeded to run the application with the driver by
> running the main class.
>
> I have tried to include the Class-Path with the JAR's manifest, like
> so:
>
> Manifest-Version: 1.0
> Ant-Version: Apache Ant 1.6.2
> Created-By: 1.4.2_06-b03 (Sun Microsystems Inc.)
> Main-Class: Scheduler
> Class-Path: C:\physioclinic\mysql-connector-java-3.0.15-ga-bin.jar


How about you put the mysql connector in the same directory as your jar
file and run it with java -classpath . -jar Scheduler.jar

--
-------------
- ByteCoder - ...I see stupid people
-------------
Curiosity *Skilled* the cat
 
Reply With Quote
 
 
 
 
Jonathan
Guest
Posts: n/a
 
      12-24-2004

Sure. It doesn't work--any ideas?

C:\physioclinic\dist>java -classpath . -jar scheduler.jar

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
java.sql.SQLException: No suitable driver
java.lang.NullPointerException

C:\physioclinic\dist>dir
Volume in drive C has no label.
Volume Serial Number is D3C5-D3CD

Directory of C:\physioclinic\dist

12/24/2004 02:41 PM <DIR> .
12/24/2004 02:41 PM <DIR> ..
12/24/2004 03:22 PM 75,404 scheduler.jar
09/04/2004 01:15 AM 235,712
mysql-connector-java-3.0.15-ga-bin.jar
2 File(s) 311,116 bytes
2 Dir(s) 6,225,215,488 bytes free
C:\physioclinic\dist>

 
Reply With Quote
 
kjc
Guest
Posts: n/a
 
      12-24-2004
How about putting the jar with contains com.mysql.jdbc.Driver
on out classpath

Jonathan wrote:
> Sure. It doesn't work--any ideas?
>
> C:\physioclinic\dist>java -classpath . -jar scheduler.jar
>
> java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
> java.sql.SQLException: No suitable driver
> java.lang.NullPointerException
>
> C:\physioclinic\dist>dir
> Volume in drive C has no label.
> Volume Serial Number is D3C5-D3CD
>
> Directory of C:\physioclinic\dist
>
> 12/24/2004 02:41 PM <DIR> .
> 12/24/2004 02:41 PM <DIR> ..
> 12/24/2004 03:22 PM 75,404 scheduler.jar
> 09/04/2004 01:15 AM 235,712
> mysql-connector-java-3.0.15-ga-bin.jar
> 2 File(s) 311,116 bytes
> 2 Dir(s) 6,225,215,488 bytes free
> C:\physioclinic\dist>
>


 
Reply With Quote
 
Jonathan
Guest
Posts: n/a
 
      12-24-2004
This doesn't seem to work?

C:\physioclinic\dist>java -classpath
mysql-connector-java-3.0.15-ga-bin.jar
-jar scheduler.jar

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
java.sql.SQLException: No suitable driver
java.lang.NullPointerException

 
Reply With Quote
 
Jonathan
Guest
Posts: n/a
 
      12-24-2004
The command-line I posted didn't come out right. I had scheduler.jar
at the end of that, and the program couldn't find com.mysql.jdbc.Driver

 
Reply With Quote
 
kjc
Guest
Posts: n/a
 
      12-24-2004
where is mysql-connector-java-3.0.15-ga-bin.jar
located. Absolute path.

Jonathan wrote:
> This doesn't seem to work?
>
> C:\physioclinic\dist>java -classpath
> mysql-connector-java-3.0.15-ga-bin.jar
> -jar scheduler.jar
>
> java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
> java.sql.SQLException: No suitable driver
> java.lang.NullPointerException
>


 
Reply With Quote
 
Jonathan
Guest
Posts: n/a
 
      12-24-2004

I printed the directory listing in a previous post.

C:\physioclinic\dist\mysql-connector-java-3.0.15-ga-bin.jar

The absolute path used on the classpath didn't work either. It only
works when I run from the class file.

 
Reply With Quote
 
kjc
Guest
Posts: n/a
 
      12-24-2004
C:\physioclinic\dist>java -cp
C:\physioclinic\dist\mysql-connector-java-3.0.15-ga-bin.jar
-jar scheduler.jar


kjc wrote:
> where is mysql-connector-java-3.0.15-ga-bin.jar
> located. Absolute path.
>
> Jonathan wrote:
>
>> This doesn't seem to work?
>>
>> C:\physioclinic\dist>java -classpath
>> mysql-connector-java-3.0.15-ga-bin.jar
>> -jar scheduler.jar
>>
>> java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
>> java.sql.SQLException: No suitable driver
>> java.lang.NullPointerException
>>

>


 
Reply With Quote
 
Jonathan
Guest
Posts: n/a
 
      12-24-2004
This is what I was doing:

C:\physioclinic\dist>java -cp
C:\physioclinic\dist\mysql-connector-java-3.0.15-g
a-bin.jar -jar scheduler.jar

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
java.sql.SQLException: No suitable driver
java.lang.NullPointerException
at DBConnection.query(DBConnection.java:49)
at DayPanel.<init>(DayPanel.java:123)
at MonthTable.mouseClicked(MonthTable.java:176)
at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown
Source)
at java.awt.LightweightDispatcher.processMouseEvent(U nknown
Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at
java.awt.EventDispatchThread.pumpOneEventForHierar chy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown
Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
C:\physioclinic\dist>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
java -cp a.jar -jar b.jar => Works on Windows, not on Debian cyberco Java 4 02-14-2006 06:27 AM
jaas.jar, jta.jar jdbc-stdext.jar missing from jdk1.5 RPM muttley Java 0 10-20-2005 02:40 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters Java 0 01-05-2005 10:59 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters XML 0 01-05-2005 10:59 PM
instanciate a class in a jar file with class.forname, while my main class is in another jar cyril Java 2 08-25-2004 06:55 AM



Advertisments