简体   繁体   English

Windows和OS X之间缺少Java构建路径

[英]Java build path missing between Windows and OS X

I've been trying to use Eclipse to work on a Java project both in OS X and Windows, but I'm having a bit of a time with the Java build path. 我一直在尝试使用Eclipse在OS X和Windows中的Java项目上工作,但是我在Java构建路径上花了一些时间。

If I create the project in Windows, it's missing the build path in OS X, and conversely, if I create the project in OS X, it's missing the build path in OS X. 如果我在Windows中创建项目,则缺少OS X中的构建路径,反之,如果我在OS X中创建项目,则缺少OS X中的构建路径。

This did happen to one of my other projects and I used this to get it working again, but it's not working this time: Eclipse - Mac Os Default JRE missing 这确实发生在我的其他项目之一中,我使用它来使其再次运行,但这次却不起作用: Eclipse-Mac Os默认JRE丢失

In Windows I'm using JRE7 with Java SE 1.7 (according to the settings), on OS X I'm using Java SE 8 (1.8.0_05). 在Windows中,我使用带有Java SE 1.7的JRE7(根据设置),在OS X上,我正在使用Java SE 8(1.8.0_05)。 I cannot for the life of me get the same build path on both without spending an hour trying to get the build path to work. 我一生都无法在没有花费一个小时的时间来获得正常工作的情况下获得相同的构建路径。

Any idea what I need to do to get the build path working on both? 知道我需要做什么才能使构建路径在两者上都起作用吗?

Cheers Omar 干杯奥马尔

This happens every time I post a question... I solve it 2 seconds after. 每当我发布问题时都会发生这种情况……2秒后我将其解决。

I installed JDK 7 for OSX, and made sure the execution environments in Eclipse matched those in Windows. 我安装了用于OSX的JDK 7,并确保Eclipse中的执行环境与Windows中的执行环境匹配。

EDIT: 编辑:

I found something else as well. 我也找到了其他东西。 The order that the packages are in are important. 包的顺序很重要。 I looked at the classpath file in the project folder (it's a hidden file) and I had to make sure the order was the same. 我查看了项目文件夹中的classpath文件(这是一个隐藏文件),我必须确保顺序相同。 I only realised this when I committed it to Bitbucket and kept seeing the changes in the classpath file, which made me think that despite all the build paths being there, the order of which they load is important. 我只有在将其提交给Bitbucket并不断看到classpath文件中的更改时才意识到这一点,这使我认为尽管存在所有构建路径,但它们的加载顺序仍然很重要。

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v8.0">
    <attributes>
        <attribute name="owner.project.facets" value="jst.web"/>
    </attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="build/classes"/>

The JRE had to load last JRE必须最后加载

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM