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

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

问题描述

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


  1. 是如何JRE使用它(即是JVM直接读取该XML文件,或者是日食不知它送入它的内部编译器)?


  2. 是如何复杂的条目(如下面的常春藤路径)解析并纳入JVM的ClassLoader,当我从我的IDE运行我的课?


上下文:我有一个奇怪的错误是,Eclipse是使用一类的错误的版本,而我的常春藤/ Ant构建使用了正确的版本,所以我想的工具Eclipse来更好地模拟天生使用的类加载器在我的纯版本。为了做到这一点,我想我会看看Eclipse项目/ classpath中的文件。

 <?XML版本=1.0编码=UTF-8&GT?;
<&类路径GT;
    < classpathentry样=SRC路径=SRC/>
    < classpathentry样=SRCPATH =测试/>
    < classpathentry样=CON路径=org.eclipse.jdt.launching.JRE_CONTAINER/>
    < classpathentry样=LIB路径=CONF/>
    < classpathentry样=CON路径=org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER / ivyXmlPath =&的ivy.xml放大器;放大器; confs = */>
    < classpathentry样=输出路径=构建/>
< /类路径>


解决方案

有两种不同的东西:

1)项目的classpath用于编译使用Eclipse Java编译器(EJC)你的code,因此文件信息传递给EJC。

2)当你创建一个启动配置,你实际上是宣告类路径运行应用程序,它在默认情况下,是根据你的项目的类路径。此类路径作为参数传递给JVM就像你会做手工(java命令$ {} classpathentries yourmainclass)通过。如果你想找出什么是precisely启动配置的类路径,启动应用程序/班在调试模式,并在调试视图中选择你的进程,然后点击属性,你会看到完整的类路径(全被作为参数传递给JVM的罐子/目录)

注:我看不到你的常春藤路径的东西。

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

  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)?

  2. 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?

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>

解决方案

Two different things:

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

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天全站免登陆