Migrating From 1.4 To 1.8
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I've been assigned the task of upgrading an application from Java 1.4 to 1.8. It's a rather extensive Java application that runs on a Unix server. The build tool is Ant and from checking its build.xml file I don't see anything in there that specifies what version of Java to use. I don't imagine that there will be too many changes that I have to make to the source code but as I've not handled a project like this before I was wondering if there are any guides or best practices to follow when migrating between different versions of Java. All suggestions would be welcome.
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
However... There have been huge changes to the Java programming language since Java 1.4. For example, generics and many other language features were added in Java 5, and more new language features in Java 6, 7 and 8. The source code of your old application is most likely hopelessly outdated, and if you want to modernize it it's going to be a LOT more work than just doing the minimal things to get it running on Java 8.
Is the software using any frameworks or libraries? It's probably using very old versions of these too.
Ant is also a very old build tool, most more modern Java projects use Maven (or maybe Gradle).
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
The compiled code (bytecode) should run on any version of Java® ≥ 1.4, probably without any changes.
How much effort are you going to put into updating the code? It sounds like a lot of hard work to refactor all your Collections to be generic, or change all your loops into Streams, or change all your synchronizeds to lock.lock(); try{...} finally{lock.unlock();}
I think you may consider that is more effort than it is worth.
Remember there is a risk of introducing errors by changing things.If it ain't broke, don't fix it.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Jesper de Jong wrote:The source code of your old application is most likely hopelessly outdated, and if you want to modernize it it's going to be a LOT more work than just doing the minimal things to get it running on Java 8.
The code behind the application is almost certainly outdated (I can't say with authority as I wouldn't consider myself an expert on Java 8 or 9 and I didn't write the application itself - it predated my arrival in the company by several years). However it isn't broken so there's no desire to fix it, or modernise its code. We've simply been told to ensure that it runs on a later version of Java, namely Java 8.
Jesper de Jong wrote:Is the software using any frameworks or libraries? It's probably using very old versions of these too.
Yes, it's using older versions of both Spring and Hibernate. Again, I'm very reluctant to go about changing those without extensive testing first and I don't think I have the time to be able to do that. I could be wrong in saying that but it's a large enough application and I doubt just swapping in newer JARs would be all that's needed to upgrade.
Campbell Ritchie wrote:You need to check for the use of assert and enum anywhere in that code. They are new keywords, so code containing those words as identifiers will no longer compile. Actually, that problem may only apply to enum because I think assert was already a keyword in JDK1.4. You can find out by the simple technique of compiling the entire code to run on Java8/9 and looking for compiler errors. You may also find that some API has been deprecated since JDK1.4.
I've checked and I haven't found any instances of assert or enum in the code, so that aspect at least should be okay, thanks.
I've taken a look at the application architecture. The application is triggered when a shell script is run that calls the application JAR and passes in a couple of arguments. The shell script contains a variable that indicates what version of Java to use when launching the application from the command line. The way our servers are set up, we have every version of Java going back to Java 1 in a utilities folder. Java 8 is already installed on the server so I think all I need to do is just update the shell script to point at Java 8 rather than Java 4. That is, I'll be updating the script in the Development environment and testing.
| I can't renounce my name. It's on all my stationery! And hinted in this tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |








