【发布时间】:2010-04-20 19:29:18
【问题描述】:
在 java jar 文件中的 Manifest 文件中是否必须包含类路径?我们可以在没有类路径的情况下工作吗?
我问这个的原因是因为我有一个服务器应用程序的 jar 文件。当我尝试与服务器连接许多连接时,服务器出现故障并且错误是“打开的文件过多”,当我搜索它时,我发现了一个 Sun Bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6446657 。然后我检查了一下,我在 Jar 文件中有一个类路径条目。所以就出现了这个问题。
编辑:我的 Filr 读取代码是:
// Creating a new File instance
File file= new File(fileName);
// Creates a DataInputStream that uses the specified underlying InputStream.
DataInputStream input = new DataInputStream(new FileInputStream(file));
Data = new byte[(int)file.length()];
// Reads bytes from the input stream and stores them into the buffer array Data.
input.read(Data);
// Closes this input stream and releases any system resources associated with the stream.
input.close();
是不是有什么问题导致笔文件太多?
【问题讨论】:
-
这个错误已经在 4 年前修复了。您的问题出在其他地方。
-
你试过没有?如果你的 jar 文件依赖于其他 jar 文件,你只需要类路径。
-
嗨,Baluc,我正在一个地方从文件中读取字节,这是唯一的文件读取操作。我有一个 ReadBytes 函数,它获取文件名,然后以字节为单位返回内容。那么我可以将其视为唯一的罪魁祸首,但无法找到确切的错误是什么。有什么建议吗?