4

I want my program to work for people with older versions of Java. My program doesn't need any special new features and it should be able to run fine in Java 6. I have Java 8 installed, and I want to know how I would go about compiling my program in Eclipse in an older version of Java without having to install Java 6.

1
  • 1
    Change your compliance version? Commented Apr 13, 2015 at 1:47

2 Answers 2

12
  • In the Project Explorer view, right-click on the project and then select Properties.
  • Select the Java Compiler page in the in the Properties window.
  • In the JDK Compliance section, select the desired Compiler compliance level.
  • Click Apply and then Ok.

It will automatically compile to the right version

Note this doesn't actually change the version, just that the compiler would be able to enforce the rules that another Java version would. So it should be compatible

For cross verfiying if it is compiled properly with the lower version, 1. Go to properties 2. go to java build path 3. go to libraries, 4. click on JRE System Library-- double click this to see if exceution environment is properly set.

Sign up to request clarification or add additional context in comments.

3 Comments

It should be noted that this doesn't change the version of Java that code compiles with. It will still compile using the given version of the JDK, but the compliance level tells the compiler to enforce the rules for the specified version as if it were being compiled with that version. Subtle point worth mentioning.
@RyanJ okay will put that on
@RyanJ's point is important because I've seen cases where Java-8-with-compliance-for-7 doesn't flag the same compile issues that a true java 7 compile will -- namely syntax subtleties with generic types and raw declarations
0

Another thing to consider is checking to see if your JRE matches the compiler version you are using in Eclipse. You'll have to download the JRE needed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.