Solved

Class-Path manifest entry pointing to MySQL JDBC library

Posted on 2003-12-09
10
698 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

756 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