简体   繁体   中英

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

i want to run this program using JDK1.3 . . . How to run this code by using Eclipse as i installed JDK1.7. In this program "assert" cannot be used as identifier from JDK1.4 onwards, as it is changed to KEYWORD. So, I want to run as Identifier by using JDK1.3. How to change JDKversion in Eclipse. Is it necessary to install 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 .
  2. Select Java -> Compiler from the left panel.
  3. Choose 1.3 as Compiler compliance level .
  4. Click Apply , then OK .

In Eclipse you can specify two things in the preferences :

  • the compilation class format (preferences/java/compiler : compiler compliance level)

  • the jdk used (preferences/java/installed 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).

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.

Choose button Add and then Standard VM. There you can set the location of the JDK1.3 to be used.

Then go to your project, right click, Properties, Java Compiler and JDK compliance to 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).

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.

  1. Install JDK 1.3 to your machine
  2. In Eclipse, add JDK 1.3 in the list of installed JRE (Preferences -> Java -> Installed JREs)
  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)
  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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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