• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 705
  • Last Modified:

Class-Path manifest entry pointing to MySQL JDBC library

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
dkim18
Asked:
dkim18
  • 5
  • 2
  • 2
  • +1
2 Solutions
 
objectsCommented:
Class-Path: lib/mysql.jar
0
 
dkim18Author Commented:
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
 
girionisCommented:
 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 expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
objectsCommented:
easiest would be to put them in same dir and use:

Class-Path: mysql.jar
0
 
dkim18Author Commented:
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
 
girionisCommented:
 What is the line 37 of the JDBCBook java file? You are trying to use an object that is null.
0
 
objectsCommented:
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
 
objectsCommented:
alternatively load it from a known location such as users home directory.
0
 
OviCommented:
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
 
objectsCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 5
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now