我需要读取当前 Web 应用程序的 CLASSPATH
条目。在 CLASSPATH
中,我有许多具有相同名称的文件。我想检查它们出现在类路径中的哪个位置。例如:path:\file.txt;path2:\file.txt...
。
感谢您的帮助。
亲切的问候 塞巴斯蒂安
最佳答案
试试这些:
// get the compact classpath value
String path = System.getProperty("java.class.path");
// the character : on windows and ; on unixes
String separator = System.getProperty("path.separator");
// the character \ on windows and / on unixes
String fileSep = System.getProperty("file.separator");
您需要 separator
和 fileSep
因为 :
和 \
高度依赖于系统。
关于java - 获取用于执行 Web 应用程序的类路径条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5272350/