java kind con,如何从Eclipse classpathentry中读取所有JAR,其中kind =“con”

I have a .classpath file of a project which contains all classpath entries. Now it has following entry-

Now, from this entry , I want to find all jars which are associated with this library through java code programatically ? Is there any way to read all jars?

解决方案

The following was investigated running Eclipse JEE Kepler while reading source code that was checked out summer 2016 and debugging Eclipse on startup.

In your workspace root folder there is a file .metadata.plugins\org.eclipse.jdt.core\variablesAndContainers.dat.

This file is read by JavaModelManager from the method loadVariablesAndContainers.

Within variablesAndContainers.dat, I believe there is an entry for each project, and each project has a container. You can see the container name as a String in the file.

Flow continues to

JavaModelManager$VariablesAndContainersLoadHelper.loadContainers(IJavaProject)

From here, the file reads a count of the number of classpath entries. For each entry, it then reads the container with the method VariablesAndContainersLoadHelper.loadClasspathEntry. This creates an array of classpath entries which represents the Java container. This is held in memory as JavaModelManager.PersistedClasspathContainer.

This is what you are looking for if creating a standalone application.

If creating an Eclipse plugin, examine the behavior of JavaModelManager.getClasspathContainer.

You'll have to study the code, and maybe debug a lot of Eclipse startups to figure out the whole format of the file.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值