java - 获取用于执行 Web 应用程序的类路径条目

标签 java web-applications classpath

我需要读取当前 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");

您需要 separatorfileSep 因为 :\ 高度依赖于系统。

关于java - 获取用于执行 Web 应用程序的类路径条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5272350/

相关文章:

java - 如何通过 jtextfield 迭代和打印矩阵?

java - NetBeans 制作的 jar 文件不起作用

java - Spring MVC - 设置 byte[] @ResponseBody 的内容类型

java - 我正在运行 RMI 应用程序但没有安全管理器 : RMI class loader disabled exception comes

java - URLClassLoader 和包私有(private)方法的可访问性

java - Java中读取JSON文本数据

java - e4 将 ESelectionService 设置为空

asp.net - 为 Azure 存储帐户连接字符串构建连接字符串

java - 我们可以在 webservice 方法中调用 servlet

java - 如何编译JUnit测试类?