Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrade a Java 6 Project to Java 7 in Eclipse

I have an old Java 6 Project in Eclipse. To use functionality of Java 7 I would like to switch to Java 7. I am not able to do it :

Goal->No compilation errors in my Java Code . See red underlinded the compilation error when using ZipFile with 2 parameters used for Java 7. The Constructor of ZipFile in Java 6 has one argument. In Java 7 there are 2 arguments: enter image description here

My Environment in my project: enter image description here

Compilation Error is:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    The constructor ZipFile(String, Charset) is undefined
    The constructor ZipFile(String, Charset) is undefined

    at ZipCompare.compare(ZipCompare.java:103)
    at ZipCompare.main(ZipCompare.java:77)

enter image description here

enter image description here

enter image description here

When I create a new Project from scratch, there are no compilation errors. I compared all settings from my old project and the new one and did not find any differences so far ?

Any help ?

like image 716
mcfly soft Avatar asked Nov 22 '25 17:11

mcfly soft


1 Answers

Here are the exact steps in case anyone in the future needs them:

  1. In the Package Explorer window, right-click your project and select "Properties" from the context menu, or go to File > Properties.

  2. In the Properties dialog window, select "Java Build Path" from the left sidebar menu, then click the Libraries tab on the right-hand side.

  3. Select your 'JRE System Library' and click the "Edit..." button. Assuming you have the latest JRE installed, you should be able to change the "Execution environment" there.

  4. If not, go to "Alternate JRE:" and click the "Installed JREs..." button.

  5. Assuming you don't see the one you want listed, click "Add...", ensure "Standard VM" is selected, click "Next", click "Directory" and navigate to your new JRE root folder (i.e., "C:\Program Files\Java\jre1.8.0_20").

  6. Once you click "Finish" and then "OK", you should be able to switch back to "Execution environment" and select the JRE you desire.

  7. Click "Finish" and then select "Java Compiler" from the left sidebar menu. Double check that under JDK Compliance you have "Use compliance from execution environment...." checked.

Now your project should compile and run under the new JDK/JRE.

like image 103
stoicfury Avatar answered Nov 25 '25 07:11

stoicfury