开发者

Java ignores classpath

I'm writing a开发者_运维百科 java program which uses the Oracle JDBC driver. I've set it up in my classpath. When I run the program inside my IDE (added as jdbc as library) the program runs fine. When I try to deploy it, it totaly ignores the listing in classpath and gives me a NoClassDefFoundError.

I want to use the client's JDBC driver (the one installed) and don't supply my own. I package the program from JDeveloper, deployment as JAR File.

Running with: java -jar test.jar

When I put the library in %JAVA_HOME%/lib/ext it works properly.

Anyone knows how to resolve this issue?


When you run with java -jar, the classpath is ignored.

You need to use the Class-Path manifest property.

From http://download.oracle.com/javase/tutorial/deployment/jar/downman.html

You specify classes to include in the Class-Path header field in the manifest file of an applet or application. The Class-Path header takes the following form:

Class-Path: jar1-name jar2-name directory-name/jar3-name

From http://download.oracle.com/javase/1.4.2/docs/tooldocs/linux/java.html

-jar

...

When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜