• Post Reply Bookmark Topic Watch Topic
  • New Topic

Upgrading from Java 6 to Java 9 in IntelliJ IDEA  RSS feed

 
Anna Jane Belk
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm new to Java and have recently become responsible for maintaining a code base of approximately 300 pages (8.5" x 11"). Any tips on how to estimate the expense and time required to update from Java 6 to Java 9 would be greatly appreciated. Would you recommend going from 6 to 7 to 8 and then 9 or is going straight from 6 to 9 the preferred path?
Thanks so much
 
Pete Letkeman
Ranch Foreman
Posts: 833
25
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch Anna.

I'm not too sure if I would go right to Java 9 as it just came out within that last week.
Most/much of Java is setup to be backwards compatible, however I'm sure that there are some breaking changes between versions.
How you manage the upgrade does depends somewhat on your environment and other system dependencies. For instance if you are running WebSphere with a specific version of Java then you may need to upgrade WebSphere first.
Even thought Java does try to be backwards compatible, the code that you are responsible for could be using third party libraries (pdf library, word library etc) which may break with newer versions of Java.

I do not think that there is a quick and easy process here, regardless of which IDE you are using.
Here are the broad steps:

A) Get a listing of system dependencies which are used in your environment that may need the code your are working with. For example if WebSphere is part of the equation then see if there is a reason that they are using the version Java that they are currently using. If they need to use a specific version of Java for whatever reason then maybe your job is done. Or maybe you have to do some extra testing with a newer version of the dependancy to see what happens with a newer version of Java.

B) Get a listing of libraries that the code is using to see how they would react to an upgrade of Java. Maybe these libraries cannot function in newer Java versions and your job is done. Or maybe you have a find alternatives.

Once you are 100% sure that you have both steps A and B from the above listing covered then I would suggest making a test environment with Java 8 to see what happens when compiled with Java 8.
- If this works then you would need to migrate that to the production systems/environment.
- If this does not work then try with Java 7. If it works with Java 7 then I would migrate the Java 7 to the reset of the production systems/environment.
- If it works with Java 7 but not Java 8 then you have to become a detective and find out why.

This whole process could be done within a week if everything goes smoothly and you have a small production systems/environment. However more then likely this process will take more then a week.

Hope this helps out,
Pete
 
Campbell Ritchie
Marshal
Posts: 56220
171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pete Letkeman wrote:Welcome to CodeRanch Anna.
Ditto
. . . there are some breaking changes between versions.  . . .
I don't think there are any breaking changes between Java5 and Java8.
 
Pete Letkeman
Ranch Foreman
Posts: 833
25
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:I don't think there are any breaking changes between Java5 and Java8.

I really do not know so I'll take your word on this Campbell. I know that you know Java better then me and have been exploring/programming it much longer then me as well.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37395
531
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Campbell that you should go from Java 6 to Java 8. (No need to stop of 7 in between).

You should be able to recompile your code with Java 8. Then you can look at updating the syntax to use new features. For example, loops and streams.
 
Campbell Ritchie
Marshal
Posts: 56220
171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:. . . look at updating the syntax to use new features. For example, loops and streams.
As long as you don't breach that important principle:-
If it ain't broke, don't fix it.
I would suggest you look for instances of finalize() methods and replace them with something else; you will find finalize() is hardly ever used any more and will be deprecated in Java9.
 
Simon Roberts
Author
Ranch Hand
Posts: 182
9
Java Linux Netbeans IDE Scala Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:As long as you don't breach that important principle:-
If it ain't broke, don't fix it.


But as a counterpoint--if it's messy, hard to understand, inflexible, low performance, or unscalable, it might very well be "broke" even if it works properly ;)

However, to the original point, I have it on reliable authority (Mark Reinhold) that more than half the effort involved in creating a new version of Java goes into ensuring it's backward compatible. You might come across something that doesn't work, but a) that's pretty darn rare, and b) it's quite likely that your code used something that wasn't "recommended" in the first place.

I have one piece of code that's caused me trouble, and that was using a pre-released version of transparent windows in Java 6. The code specifically used classes in packages sun.blahblah, rather than exclusively using java... and javax...

So, yeah, try it, you might like it.

And, you might even find you can get directly to Java 9, though I've not kept up so can't comment with confidence on whether things like the command line might change for that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!