Andreas Kruhlmann
Andreas Kruhlmann

Reputation: 161

What is the preferred method to ship a java program with an older version of java?

I have a task of fixing a program written in java, since it was crashing on start. I discovered that the problem was related to a discontinued class in the java library no longer available in 1.8. Eventually I will find an alternative to the library but for right now I need to ship the program with a reference to an old java version NOT installed on the clients computer. What would be the most appropriate way of doing so?

Upvotes: 2

Views: 159

Answers (3)

Puce
Puce

Reputation: 38142

You can use the new javapackager tool and specify the runtime option to include (bundle) a specific JRE.

Upvotes: 1

The JRE may be distributed with programs. So repackage your program to bundle a JRE and use the java binary from there to start your program.

If you use a wrapper script, this would be where to fix it.

Upvotes: 1

edjm
edjm

Reputation: 5522

Obviously you want minimal impact on the rest of the code base where you don't want to have to go modifying the imports that may be numerous in your code. So, if the Java version is not installed on the clients computer you'll need to include the class in the packaging of your application.

I would suggest that you create the package structure of wherever the missing class file currently resides such as java.io.x.y.z so you wont have to modify any of the import statements

e.g. import java.io.x.y.z.ClassName;

Then test test test to ensure it functions as you expect.

Upvotes: 1

Related Questions