Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrating java application from Java 8 to Java 11

Advance thanks, who are be going to help me.

Story: till date my application is using JDK8, but right now I am migrating my application to Open JDK11 and using IVY as dependency manager and Ant as a build tool.

Problem: I was facing compile-time issues in eclipse for javax, but then I change JRE lib in the build path, from classpath to Modulepath. Now everything is working fine. But now the main problem is, while running antbuild.xml using Ant, this still giving me the same compile-time errors. I think I know what to do now, but how to do I don't know. I have to add Open JDK11 as module path somewhere in antbuild.xml.

Main Question: How to set Open JDK11 as module path in antbuild.xml (BASICALLY ANT BUILD FILE).

if the question is still not understandable, please let me know.

like image 310
Dupinder Singh Avatar asked May 02 '19 06:05

Dupinder Singh


People also ask

Can Java 8 programs run on Java 11?

The class files created by Java 8 are still executable in Java 11; however, there have been other changes in the Java runtime (library changes, etc.) that might require modification of the code. These modifications may be made in Java 8 and compiled with Java 8 making it compatible with the Java 11 runtime.

Can I install Java 8 and Java 11 together?

I know you can install both. Java 8 and Java 11 and keep them at the same time...


1 Answers

After 11 months I am able to post the answer because I understand the actual problem and now I have a solution that I implement in my project and its working flawlessly, all the compile-time errors are fixed.

What solution I implement.

  • Open project in eclipse, Eclipse latest version mine is 2019-06 build
  • Right-click on project > properties > Java build path
  • From classpath remove Java 8 and above it, you will find Modulepath
  • Click on Modulepath then Add Library from right button pane
  • Now a dialog will open select JRE System Library press Next Button
  • Now you can select Installed JREs.. button to add the new version of java
  • Press Add button from Installed JREs dialog
  • Select Standard VM > press Next button.
  • Now Select JRE Home from your filesystem make sure you select path up to bin, not bin
  • Finish and apply all Changes
  • Now Let eclipse build the project, of course, you will have errors.

Reason for this problem

See Java changes its file structure, so a lot of packages moved here and there. Some new packages are used, some got replaced and renamed.

So the basic problem is just this.


Solution That We can implement to resolve compile-time errors

  • Open file which has errors, and sees which import is creating error, copies the file name which is not available, or not have error
  • press Ctrl + shift + t, paste file name and see which possible options now we have, actually now we have more than one lib which is providing the same class implementation. so now we have to choose one and remove another dependency from the dependency manager.
  • Now we have to add some more dependencies to support our code.
  • Clean the redundant dependency.
  • Now we just have to resolve the compile-time errors. that the solution we can do.

This solution helped me. If you are facing the same issue, please connected me, I might help you with this.

like image 111
Dupinder Singh Avatar answered Oct 13 '22 17:10

Dupinder Singh