Solved

Class-Path manifest entry pointing to MySQL JDBC library

Posted on 2003-12-09
10
701 Views
Last Modified: 2010-03-31
I am working on JDBC project.
If the library will be located under the relative path URL lib/mysql.jar in the directory where my code is run, how do I contain Class-Path manifest entry pointing to MySQL JDBC library? (I am trying to make jar file, so it can be run from any directory location .)
0
Comment
Question by:dkim18
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 92

Expert Comment

by:objects
ID: 9910263
Class-Path: lib/mysql.jar
0
 

Author Comment

by:dkim18
ID: 9910449
Somehow the above didn't work.
I have tried this as well, but didn't work either.

Manifest-Version: 1.0
Main-Class: dkim18.jdbc.JDBCBook
Class-Path: lib/mysql.jar

0
 
LVL 35

Expert Comment

by:girionis
ID: 9910486
 The path of the jar files should be relative to the jar file that contains the manifest. To make the above work make sure the jar file with the above manifest is located in the root folder of the lib/mysql.jar. For example if you have a folder structure like:

/home/myfolder/lib/mysql.jar your jar file should be in

/home/myfolder

in order to be able to load the lib/mysql.jar
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 92

Expert Comment

by:objects
ID: 9910499
easiest would be to put them in same dir and use:

Class-Path: mysql.jar
0
 

Author Comment

by:dkim18
ID: 9910642
This is my manifest file.

Manifest-Version: 1.0
Main-Class: dkim18.jdbc.JDBCBook
Class-Path: lib/mysql.jar

I created jar file by typing the following.
 jar -cvmf myManiFest dkim18_JDBC.jar dkim18/

and I excute jar file by typing the following.
java -jar dkim18_JDBC.jar

Now, I have this error msg.
java -jar dkim18_JDBC.jar
Exception in thread "main" java.lang.NullPointerException
        at java.io.Reader.<init>(Reader.java:61)
        at java.io.InputStreamReader.<init>(InputStreamReader.java:80)
        at java.util.Properties.load(Properties.java:189)
        at dkim18.jdbc.JDBCBook.createConnection(JDBCBook.java:37)
        at dkim18.jdbc.JDBCBook.<init>(JDBCBook.java:29)
        at dkim18.jdbc.JDBCBook.main(JDBCBook.java:97)

If I run my run.bat file, it works
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 100 total points
ID: 9910670
 What is the line 37 of the JDBCBook java file? You are trying to use an object that is null.
0
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 9910696
looks like its not finding your properties file.
if you are using getResourceAsStream you should either include it in your jar, or include the directory in you Class-Path.
0
 
LVL 92

Expert Comment

by:objects
ID: 9910705
alternatively load it from a known location such as users home directory.
0
 
LVL 9

Expert Comment

by:Ovi
ID: 9911387
Check the way you are loading the resources. If there is used a file system path, this will not work inside a jar file.
0
 
LVL 92

Expert Comment

by:objects
ID: 9915816
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question