今天在开发Eclipse插件时用到了Eclipse 文件资源,不知道在调试插件过程中如何调用自定义的图片,于是在网上查了许久,有如下说明:对路径的测试代码: System.out.println( Thread.currentThread().getContextClassLoader().getResource("")); System.out.println(PathTest.class.getClassLoader().getResource("")); System.out.println(ClassLoader.getSystemResource("")); System.out.println(PathTest.class.getResource("")); System.out.println(PathTest.class.getResource("/")); System.out.println(new File("").getAbsolutePath()); System.out.println(System.getProperty("user.dir"));结果如下: file:/E:/wxxr_projects2/wxxr-applications/wxxr-boss-connector/target/test-classes/ file:/E:/wxxr_projects2/wxxr-applications/wxxr-boss-connector/target/test-classes/ file:/E:/wxxr_projects2/wxxr-applications/wxxr-boss-connector/target/test-classes/ file:/E:/wxxr_projects2/wxxr-applications/wxxr-boss-connector/target/test-classes/com/wxxr/boss/config/ file:/E:/wxxr_projects2/wxxr-applications/wxxr-boss-connector/target/test-classes/ E:\wxxr_projects2\wxxr-applications\wxxr-boss-connector E:\wxxr_projects2\wxxr-applications\wxxr-boss-connector一般情况是使用ClassLoader.getSystemResource("");但是在调试插件时其返回结果为NULL,郁闷不已,于是又看到如下文章:从插件中获得绝对路径:
通过文件得到Project:
通过文件得到全路径:
得到整个Workspace的根:
从根来查找资源:
从Bundle来查找资源:
得到Appliaction workspace:
得到runtimeworkspace:
从编辑器来获得编辑文件
Copyright @ 哼哼 Powered by: .Text and ASP.NET Theme by: .NET Monster