Solved

NoClassDefFoundError with my jar-application using Oracle JDBC driver

Posted on 2002-03-22
5
560 Views
Last Modified: 2013-11-23
Hi ppl,

There's an application uses Oracle JDBC driver. When I run it  as .class-files thru java <mypackage.myMainClass> it works fine. Now I've made a jar-version of my application. But when I run it as java -jar <myjar> I've got Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver

My CLASSPATH is the same and it's correct. I'm not sure there's a problem with my jar file, Oracle JDBC driver or something else.

Just FYI:
J2SDK 1.4.0 under Windows XP
Oracle JDBC drivers (versions 8.1.7 and 9.0.1)

Andrew.
0
Comment
Question by:AndrewRodionov
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:heyhey_
ID: 6888021
post your CLASSPATH

0
 
LVL 2

Author Comment

by:AndrewRodionov
ID: 6888030
C:\PROJECTS>echo %CLASSPATH%
.;C:\ORACLE\8.1.7\jdbc\lib\classes12.jar;C:\PROGRA~1\freemarker\lib\freemarker.jar
0
 
LVL 16

Accepted Solution

by:
heyhey_ earned 100 total points
ID: 6888040
http://java.sun.com/j2se/1.3/docs/tooldocs/solaris/java.html


-jar
Execute a program encapsulated in a JAR file. The first
     argument is the name of a JAR file instead of a startup
     class name. In order for this option to work, the manifest of
        the JAR file must contain a line of the form
        Main-Class: classname.
        Here, classname identifies the class having the
        public static void main(String[] args) method that serves as your application's starting point. See
        the Jar tool reference page and
        the Jar trail of the
        Java
        Tutorial for information about working with Jar files and
        Jar-file manifests.
     
When you use this option, the
        JAR file is the source of all user classes, and other user class
        path settings are ignored.
       

so you have to put all needed classes inside the same .jar file (or use different startup method)
0
 
LVL 2

Author Comment

by:AndrewRodionov
ID: 6888046
C:\PROJECTS>echo %CLASSPATH%
.;C:\ORACLE\8.1.7\jdbc\lib\classes12.jar;C:\PROGRA~1\freemarker\lib\freemarker.jar
0
 
LVL 2

Author Comment

by:AndrewRodionov
ID: 6888069
I see.
I've found an info how classes are found. Here is a quote: "...The JAR archive specified by the -jar option, which overrides all other values. If this option is used, all user classes come from the specified archive."

Terrible... Anyway, thanks.
Andrew.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

759 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now