了解 Eclipse 类路径声明 [英] Understanding the Eclipse classpath declarations

查看:27
本文介绍了了解 Eclipse 类路径声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试了解 Eclipse 类路径文件,特别是,我想知道这一点:

I'm trying to understand the Eclipse classpath file, in particular, I want to know this:

  1. JRE 如何使用它(即 JVM 是直接读取这个 xml 文件,还是 eclipse 以某种方式将它馈送到其内部编译器)?

  1. How is the JRE using it (i.e. is the JVM reading this xml file directly, or is eclipse somehow feeding it into its internal compiler)?

当我从 IDE 运行我的类时,复杂的条目(如下面的常春藤路径)如何解析并合并到 JVM 类加载器中?

How are the complex entries (like the ivy path below) parsed and incorporated into the JVM ClassLoader when I run my classes from my IDE?

上下文:我有一个奇怪的错误,即 Eclipse 使用的是错误"版本的类,而我的 ivy/ant 构建使用的是正确的版本,因此我想使用 Eclipse 来更好地模仿使用的类加载器在我纯粹的构建中.为了做到这一点,我想我必须查看 Eclipse 项目/类路径文件.

Context: I have a strange bug which is that eclipse is using the "wrong" version of a class, whereas my ivy / ant build is using the correct version, and I thus want to tool Eclipse to better mimick the classloader used in my pure build. In order to do this, I'm thinking I will have to look at the Eclipse project/classpath files.

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="src" path="test"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    <classpathentry kind="lib" path="conf"/>
    <classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?ivyXmlPath=ivy.xml&amp;confs=*"/>
    <classpathentry kind="output" path="build"/>
</classpath>

推荐答案

两个不同的东西:

1) 项目类路径用于使用 Eclipse Java Compiler (ejc) 编译您的代码,因此将文件信息传递给 EJC.

1) Project classpath is used to compile your code using Eclipse Java Compiler (ejc), so the file information is passed to the EJC.

2) 当您创建启动配置时,您实际上是在声明运行应用程序的类路径,默认情况下,该类路径基于您的项目类路径.该类路径作为参数传递给 JVM,就像您手动执行它一样 (java -cp ${classpathentries} yourmainclass).如果您想找出启动配置的类路径,请在调试模式下启动您的应用程序/类,然后在调试"视图中,选择您的进程并单击属性",您将在其中看到完整的类路径(所有 jars/作为参数传递给 JVM 的目录)

2) When you create a launch configuration, you are actually declaring the classpath to run your application, which, by default, is based on your project classpath. This classpath is passed as an argument to the JVM like you would do it manually (java -cp ${classpathentries} yourmainclass). If you want to find out what is precisely the classpath of your launch configuration, launch your app/classes in debug mode, and in the Debug view, select your process and click on Properties where you will see the full classpath (all the jars/directories that are passed as argument to the JVM)

注意:我看不到你的常春藤路径.

NB: I cannot see your ivy path stuff.

这篇关于了解 Eclipse 类路径声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆