0

I've just wanted to get to know what these particular settings really do:

  1. Project Properties -> Libraries -> Java Platform
  2. Project Properties -> Sources -> Source/Binary Format

After a little bit of googling I know, that: [1] By choosing a Java Platform I declare the minimum Java version which can run my jar file. I can't run my jar with Java 6 when I set the project's JDK to 7 or 8. [2] Second option ensures that I compile my sources with specified java version. Moreover, netbeans will check if I do not use any syntax unavailable in a specified java.

If I set my project as compatible with min Java 7 (Java Platform and Source format set to 7) I will have problems while running my jar file using jre 6 (it will be impossible).

Let me know if my thinking is now correct.

However there is one thing I do not understand and it forces me to think, that I make somewhere a mistake... Namely, it is possible to set, for instance, Java 8 as a Java Platform (so my app is compatible with Java 8+) but in source/binary format I can choose Java 6 or even Java 5. Why such a configuration is possible? What are the advantages of writing a source code using syntax from Java 6 when I use a Java 8 as a project's Java Platform??

3
  • stackoverflow.com/a/15525251/839601
    – gnat
    Jun 7 '15 at 18:27
  • @gnat That's clear, sure. But I still don't understand when it is reasonable (and why) to compile my sources using Java6 when I specify that my app should be run on Java, for example, 7+. Any example? Jun 7 '15 at 18:36
  • 1
    Let's say you have inherited the care-and-feeding of an older application, one developed in Java 5 or 6. Part of your support strategy is to move to a newer platform, but you cannot do this all at once. So you upgrade the platform and run your tests to see if there are major code gotchas, or even library problems. Later, you will start upgrading the source. Jun 7 '15 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.