What are the best development methods to support multiple versions of the JRE?

Our application must support versions 1.5 and 1.6 of the JVM. Support 1.5 should avoid any 1.6 JRE dependencies, while support 1.6 should take advantage of only 1.6.

When we change the Eclipse project to use the 1.5 JRE, we get all the dependencies marked as errors. This is useful to see where our dependencies are, but not useful for simple development. The source code with such compilation errors has been fixed.

What are the best support methods for this type of support for multiple JREs?

In C land, we had #ifdef compiler directives to solve such things quite cleanly. What is the purest equivalent of Java?

+3
source share
5 answers

If your software should run on both JRE 1.5 and 1.6, then why don't you just develop only 1.5? Is there a reason why you absolutely need to use features available only in Java 6? Are there any third-party libraries that run on Java 1.5 that contain equivalents for the 1.6 functions you want to use?

Maintenance of two basic codes, their synchronization, etc. - This is a lot of work and probably not worth the effort compared to what you get.

Java forcourse does not have a preprocessor, so you cannot (easily) conditionally compile, as you can do in C with preprocessor directives.

, , : , Java 5, Java 6, , , , , Java 5, ( - , , ).

+3

1.5. 1,6- . 1.6 1.5, . 1.6 1.5. 1.5 , null.

, root 1.6. , 1.6, ( -target 1.6` 1.6 ).

+2

, :

  • 1.6 , , ; , (1.4 1.3 ).
  • , , , , ; -
  • 1.5 1.6; - .

, 49.0 ( 1.5). , / .

+1

, , (git, svn Perforce ). , 1.5, 1.6, 1.5.

1.5 1.5, / 1.6 , 1.6.

, .

Eclipse , , , , , . ( ).

JVM / .

, .

(: , 1.5, 1.6)

0

- 3 .

, java.

java6 .

java5 .

, , . , .

Eclipse, java6 java6, - java5. JRE , - , .

By getting a little smart with your build files, you can build a common bit in both directions and depend on the correct version for deployment - although I'm not sure if this will be of great benefit.

You will have two separate versions of your application: one for java6, one for java5.

0
source

Source: https://habr.com/ru/post/1718453/


All Articles