简体   繁体   English

使用在Eclipse中使用其他Java版本的JAR包

[英]Using a JAR package that uses a different Java version in eclipse

I have Java 8 and I've been trying to use a JAR package that uses JRE 6. In 'Create a Java Project' I used the 'Use a project specific JRE' and also created a run configuration but when I try to set the alternate JRE to 6, the 'run' button gets blocked out. 我有Java 8,并且一直在尝试使用使用JRE 6的JAR包。在“创建Java项目”中,我使用了“使用项目特定的JRE”,还创建了运行配置,但是当我尝试设置如果将JRE替换为6,则“运行”按钮将被阻止。 Are they not compatible or am I missing a step? 它们不兼容,还是我错过了一步? I've also tried changing the PATH destination, though I'm not sure if that is even relevant to my problem. 我也尝试过更改PATH目标,尽管我不确定这是否与我的问题有关。

EDIT: I am using a JAR package from an online source that is Java 6 compatible and am trying to integrate it into Eclipse Mars with Java 8 installed. 编辑:我正在使用Java 6兼容的在线资源中的JAR包,并尝试将其集成到安装了Java 8的Eclipse Mars中。

Did you try just adding the external JAR to the project? 您是否尝试过仅将外部JAR添加到项目中? Most (non-executable) JARs that were originally made for older versions of java should still work today. 最初为较旧的Java版本制作的大多数(不可执行)JAR仍应在今天运行。

To add an external JAR: right-click on your project in the package explorer and go to Build Path >> Add External Archives... then select your JAR from there. 要添加外部JAR,请执行以下操作:在包资源管理器中右键单击您的项目,然后转到Build Path >> Add External Archives...然后从那里选择您的JAR。 Be sure to leave the project set up for JRE8. 确保将项目设置为JRE8。

The reason that your run button is blocked out when you switched to JRE6 was because Eclipse detected that it was not installed and therefore cannot run it as JRE6. 切换到JRE6时, run按钮被阻止的原因是Eclipse检测到未安装它,因此无法将其作为JRE6运行。

A few items to check, under Project settings: (most of these can be set workspace-wide as well) 在“ 项目设置”下需要检查的几项:(其中大多数都可以在工作区范围内进行设置)

  • Java Build Path > Libraries. Java构建路径>库。 Replace JRE System Library with a jdk6 execution environment or alternate JRE 用jdk6执行环境或备用JRE替换JRE系统库
  • Java Compiler > JDK compliance. Java编译器> JDK合规性。 Set to 1.6 设为1.6

System: 系统:

Check Installed JREs and Execution environments. 检查已安装的JRE和执行环境。 Make sure a JRE is linked to the Execution Environment for JavaSE-1.6 (with the checkbox). 确保将JRE链接到JavaSE-1.6执行环境(带有复选框)。

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

相关问题 OS X中的Eclipse使用不同于CLI的Java版本 - Eclipse in OS X uses different version of Java than CLI Eclipse中的Ant脚本使用不正确的Java版本 - Ant script in Eclipse uses the incorrect version of Java 在不同的Java版本中运行带有depedency jar的jar - Running a jar with depedency jar at a different java version Eclipse Java版本与已编译的Jar不同 - Eclipse Java version not same as compiled Jar 如何告诉Eclipse使用来自不同库的不同版本的软件包进行构建? - How to I tell Eclipse to build using a different version of a package from a different library? 如何使用ANT构建具有不同Java版本的jar - How to build a jar with different java version with ANT 共享(Eclipse)Java项目-不同的Java版本 - shared (eclipse) java project - different java version 如何从使用“类路径”中添加的 *.jar 文件的 eclipse java 项目创建 jar 文件 - How to create a jar file from an eclipse java project that uses *.jar files added in “Classpath” 尽管战争子项目包含最新的jar版本,为什么Maven耳包仍使用项目的旧jar版本? - Why Maven ear package uses project's old jar version despite war subprojects contains latest jar version? Java JAR / Eclipse中顶层目录(不是包)中的参考资源 - Reference resource in top directory (not package) in Java JAR/Eclipse
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM