0

在 Eclipse Indigo(在 Mac OSX 上)中,我有一个项目“测试”。在这个项目中,我有一个包“test1”。在这个包中,我有一个类 Test.java。

简而言之,文件结构是:Test/src/Test.java 和
Test/bin/Test.class

我在 lib 文件夹中有一个库mylib.jar 。

我还有一个名为info.dat的数据文件。在 info.dat 中,有关于要加载哪个类的信息。例如,在 info.dat 中,我指定:class=Test 然后,当我运行时:

$  java -jar lib/mylib.jar info.dat  

(NOTE: this works if I run this command in terminal and have class file in the same folder with info.dat)

mylib.jar 中的 main 函数将加载 Test.class。

我正在使用外部工具来实现这一点。这是我的外部工具设置:

Location: /usr/bin/java
Working Location: /path/to/Test_folder
Argument: -cp . -jar lib/mylib.jar bin/test1/info.dat

但是,当我尝试运行时,出现此错误:

LOADING INFO FROM FILE bin/test1/info.dat
=> Current directory=[not include because not important]
=> Full pathname=[not include because not important]
java.lang.ClassNotFoundException: Test

我也尝试在 info.dat 中更改class= test.Test 但遇到类似错误

java.lang.ClassNotFoundException: test1.Test

结果显示 info.dat 加载正常,但类文件的路径不正确。我应该如何配置外部工具来做我需要的事情?有人可以给我一些指导吗?

非常感谢,

4

1 回答 1

1

这是一个使用运行配置的简单解决方案。我只需要从 Java Application 中的 mylib.jar 中选择主类并将 info.dat 放入参数字段中。

很抱歉在这里浪费资源。

于 2012-09-04T16:04:09.023 回答