简体   繁体   English

如何在Eclipse(已安装JDK1.7)中使用JDK1.3运行程序?

[英]How to run a program using JDK1.3 in Eclipse(installed JDK1.7)?

i want to run this program using JDK1.3 . 我想使用JDK1.3运行该程序。 . . How to run this code by using Eclipse as i installed JDK1.7. 我在安装JDK1.7时如何通过使用Eclipse运行此代码。 In this program "assert" cannot be used as identifier from JDK1.4 onwards, as it is changed to KEYWORD. 在此程序中,“ assert”不能用作从JDK1.4起的标识符,因为它已更改为KEYWORD。 So, I want to run as Identifier by using JDK1.3. 因此,我想通过使用JDK1.3作为标识符运行。 How to change JDKversion in Eclipse. 如何在Eclipse中更改JDKversion。 Is it necessary to install JDK1.3? 是否需要安装JDK1.3?

public class A
{
    public static void main(String[] args)
    {
        System.out.println(1);
        int assert = 10;
        System.out.println(2);
    }
}

Try this: 尝试这个:

  1. From the menu bar, choose Window -> Preferences . 从菜单栏中,选择Window > Preferences
  2. Select Java -> Compiler from the left panel. 从左侧面板中选择Java > Compiler
  3. Choose 1.3 as Compiler compliance level . 选择1.3作为Compiler compliance level
  4. Click Apply , then OK . 单击“ Apply ,然后OK

In Eclipse you can specify two things in the preferences : 在Eclipse中,您可以在首选项中指定两件事:

  • the compilation class format (preferences/java/compiler : compiler compliance level) 编译类格式(preferences / java / compiler:编译器符合级别)

  • the jdk used (preferences/java/installed jres) 使用的jdk(首选项/ java /已安装的jres)

You probably want to set both. 您可能要同时设置两者。 But in order to set the JDK used, you must install the JDK1.3 (you can have as many jdk as you want on your PC). 但是,为了设置使用的JDK,必须安装JDK1.3(可以在PC上安装任意数量的jdk)。

Unzip JDK1.3 somewhere in your files, then go to Eclipse, menu Window --> preferences, and select Java --> Installed JREs in the menu on the left. 将JDK1.3解压缩到文件中的某个位置,然后转到Eclipse,菜单窗口->首选项,然后在左侧菜单中选择Java->已安装JRE。

Choose button Add and then Standard VM. 选择按钮添加,然后选择标准VM。 There you can set the location of the JDK1.3 to be used. 您可以在此处设置要使用的JDK1.3的位置。

Then go to your project, right click, Properties, Java Compiler and JDK compliance to 1.3. 然后转到您的项目,右键单击Properties,Java Compiler和JDK符合1.3。 In the same Project Properties menu, look for Java Build Path and, in the Libraries tab, change the JRE System Library (remove it and add another library - JRE System library -- select JDK1.3 taht you just added). 在同一Project Properties菜单中,找到Java Build Path,然后在Libraries选项卡中更改JRE System Library(将其删除并添加另一个库-JRE System库-选择刚添加的JDK1.3)。

Done. 做完了

Yes, you need to install JDK 1.3 (Although you really need to think why would you and consider if it's better spending the time refactoring some codes and make it run on at least Java 6 and even better for Java 7), 1.3 is so old. 是的,您需要安装JDK 1.3(尽管您确实需要考虑为什么这样做,并考虑是否最好花一些时间重构某些代码并使之至少在Java 6上运行,甚至可以在Java 7上运行),但1.3太老了。

  1. Install JDK 1.3 to your machine 将JDK 1.3安装到您的计算机上
  2. In Eclipse, add JDK 1.3 in the list of installed JRE (Preferences -> Java -> Installed JREs) 在Eclipse中,在已安装的JRE列表中添加JDK 1.3(首选项-> Java->已安装的JRE)
  3. If you want to apply JDK 1.3 as DEFAULT for your eclipse, then go to Preferences -> Java -> Compiler and set the compiler compliance level to 1.3 (Note that if a project is already overriding the default, they will retain the setting) 如果要对日食应用JDK 1.3作为DEFAULT,请转到“首选项”->“ Java”->“编译器”,并将编译器的遵从性级别设置为1.3(请注意,如果项目已覆盖默认设置,则它们将保留设置)。
  4. If you want to change a specific Project compiler level, right click on the project, Properties -> Java Compiler - then check the "Enable Project Specific Settings" and choose 1.3 如果要更改特定的Project编译器级别,请右键单击该项目,然后单击Properties-> Java Compiler-然后选中“ Enable Project Specific Settings”并选择1.3

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

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