vendredi 8 août 2014

Déterminer à quelle version de Java (ou Eclipse), un programme est compatible à - Stack Overflow


In my coding environment I am normally working with the latest versions of Java and Eclipse. When I wrote source code I do not pay attention whether the API methods or classes I use are backward compatible to older version of Java or Eclipse. In the javadoc there exists the @since parameter that is set to the version number where a feature was newly introduced. So sometimes I check by hand, whether I use methods or classes which were introduced lately and try to replace them to stay backward compatible.


Is there any way to automatically check whether a Java program or Eclipse plugin will work with older version of Java or Eclipse?


I will make my question more precise: I am interested in a solution for which I need not install older version of Java or Eclipse. Maybe there is a tool, which checks for the javadoc comments and tell me when I use a method which is only available in a version greater than a predefined version number. I am aware of the fact that this method is not 1oo% reliable if the javadoc is not up to date.




Simply try to compile the application against an older version of the JDK.


In Eclipse, you can configure multiple JDKs under Windows -> Preferences -> Java -> Installed JREs. Then for an individual project, you can switch to the standard library of any of the installed JREs in the Libraries tab of the project's build path. This will cause a full recompile, and if the project uses any part of the standard API not present in that version, there will be errors.




Use the -source, -target & -bootclasspath options when compiling.


See the cross-compilation example in the Windows javac man page for more details.



In my coding environment I am normally working with the latest versions of Java and Eclipse. When I wrote source code I do not pay attention whether the API methods or classes I use are backward compatible to older version of Java or Eclipse. In the javadoc there exists the @since parameter that is set to the version number where a feature was newly introduced. So sometimes I check by hand, whether I use methods or classes which were introduced lately and try to replace them to stay backward compatible.


Is there any way to automatically check whether a Java program or Eclipse plugin will work with older version of Java or Eclipse?


I will make my question more precise: I am interested in a solution for which I need not install older version of Java or Eclipse. Maybe there is a tool, which checks for the javadoc comments and tell me when I use a method which is only available in a version greater than a predefined version number. I am aware of the fact that this method is not 1oo% reliable if the javadoc is not up to date.



Simply try to compile the application against an older version of the JDK.


In Eclipse, you can configure multiple JDKs under Windows -> Preferences -> Java -> Installed JREs. Then for an individual project, you can switch to the standard library of any of the installed JREs in the Libraries tab of the project's build path. This will cause a full recompile, and if the project uses any part of the standard API not present in that version, there will be errors.



Use the -source, -target & -bootclasspath options when compiling.


See the cross-compilation example in the Windows javac man page for more details.


0 commentaires:

Enregistrer un commentaire