使用Eclipse编译为特定的JRE [英] Compiling to a specific JRE with Eclipse

查看:174
本文介绍了使用Eclipse编译为特定的JRE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于在Eclipse中将项目编译为特定JRE,我有两个问题:



1)项目的属性窗口> Java构建路径> 库选项卡:



如果我想编译为JRE 6 - 窗口是否应显示JRE 6以及JRE 7包含在构建路径中?或者只有JRE 6足够?



我目前的情况 - 好还是坏?





2) I了解将项目编译为特定JRE的步骤:



a - 确保JRE位于Eclipse中已安装的JRE列表中。 / p>

b - 点击我展示的窗口中的添加图书馆,将其添加到项目的构建路径中。



c - 将项目的编译器合规性级别设置为与我希望我的应用程序能够运行的最旧的JRE相同(我添加的JRE)到了构建路径)。



这一切都很好,但我仍然不明白一件事: Java Build中的JRE之间的区别是什么路径和JRE版本设置为编译器合规级别?

解决方案

编译器合规级别是您从为项目设置的可用语言级别中选择的语言级别。



构建路径用于创建Java类路径。



在构建类路径中,它是构建项目时编译器可见或可用的路径的集合。



配置构建路径对话框用于处理项目中名为 .classpath 的文件。通常是隐藏的。



那么您选择项目的合规级别将用于执行特定的合规级别。


I have two questions regarding compiling a project in Eclipse to a specific JRE:

1) Properties window for project > Java Build Path > Libraries tab:

If I want to compile to JRE 6 - Should the window show JRE 6 and also JRE 7 as included in the build path? Or is only JRE 6 sufficient?

My current situation - good or bad?

2) I know the steps to compiling a project to a specific JRE:

a- Make sure the JRE is in the installed JREs list in Eclipse.

b- Add it to the Build Path of the project, by clicking 'Add Library' in the window I showed.

c- Setting the Compiler Compliance Level of the project to be the same as the oldest JRE I want my application to be able to run on (the JRE I added to the build path).

This is all good, but I still don't understand one thing: What's the difference is between the JREs in the Java Build Path, and the JRE version set as the Compiler Compliance Level?

解决方案

Compiler Compliance Level is What you have selected language level from the available one to set for your project.

While The Build Path is a used to create Java classpath.

In The build classpath it is a collection of paths visible or availabel to the compiler when building the project.

The Configure Build Path dialog is used to manipulate a file in your project called .classpath.Which is normally hidden.

So what the Compliance level you have selected your project will go for that particular compliance level execution.

这篇关于使用Eclipse编译为特定的JRE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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