Java忽略了类路径 [英] Java ignores classpath

查看:149
本文介绍了Java忽略了类路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个使用Oracle JDBC驱动程序的java程序。我已经在我的类路径中进行了设置。当我在IDE中运行程序(作为库添加为jdbc)时,程序运行正常。当我尝试部署它时,它总是忽略类路径中的列表并给我一个NoClassDefFoundError。

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.

我想使用客户端的JDBC驱动程序(安装的那个)并且不要不提供我自己的。我从JDeveloper打包程序,部署为JAR文件。

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.

运行:java -jar test.jar

Running with: java -jar test.jar

当我将库放在%JAVA_HOME%/ lib / ext中时,它可以正常工作。

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

任何人都知道如何解决这个问题?

Anyone knows how to resolve this issue?

推荐答案

使用 java -jar 运行时,将忽略类路径。

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

您需要使用 Class-Path 清单属性。

来自 http://download.oracle.com/javase/tutorial/deployment/jar/downman。 html


您可以指定要包含在applet或应用程序清单文件的Class-Path头字段中的类。 Class-Path标头采用以下形式:

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

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


-jar

...

使用此选项时,JAR文件是所有用户类的源,并忽略其他用户类路径设置。

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

这篇关于Java忽略了类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆