Solved

Class-Path manifest entry pointing to MySQL JDBC library

Posted on 2003-12-09
10
699 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Html Table Looping (part 2) 5 39
Java array 10 83
Bitwise and to sum elements 2 46
Java import explained 4 43
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

740 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