【发布时间】:2012-06-25 13:34:20
【问题描述】:
我在运行可执行 .jar 文件时遇到问题。我创建了一个包含 .properties 文件的项目。当我从 eclipse 启动它时它工作得很好,但是当我将它导出到可执行的 .jar 文件并尝试运行它时:
java -jar myfile.jar
我得到以下异常:
(无法在此处发布图片) http://imageshack.us/photo/my-images/824/29583616.png/
我检查了 .jar 中的清单文件,其中包含
Class-Path: .
这是加载的属性文件:
properties = new Properties();
properties.load(new FileInputStream(
"src/com/resources/treeView.properties"));
知道是什么导致了这个异常吗?
【问题讨论】:
-
尝试 "properties = new Properties(); properties.load(new FileInputStream( "/com/resources/treeView.properties"));"路径中没有“src”。
标签: java jar executable-jar properties-file