0

I have the following problem: I wrote an application in java for my company. Now i have the problem that not every user has the jre installed on his pc. And due to company guidelines its not that easy to install it on every computer.

My question is: Can I write a batchfile which checks if the jre is already installed and if not copies the jre onto the computer? Would the jre work if I just copy it?

If you have another solution for my problem feel free to tell me.

Thank you for your answers

Eugene
  • 117,005
  • 15
  • 201
  • 306
wenzel267
  • 93
  • 1
  • 12
  • 2
    Where would you be copying it from? It's gonna have to be downloaded from somewhere. An USB stick? You could look into portable installations. – nbokmans May 15 '18 at 07:23
  • Any chance of making it a webapp? – Kayaman May 15 '18 at 07:24
  • 1
    Just copying not gonna work you have to add it to classpath – Abhishek Singh May 15 '18 at 07:24
  • 3
    It would probably be best to have it solved "officially" (via the company's IT department) rather than trying to bypass the company's security measures – UnholySheep May 15 '18 at 07:25
  • I would copy it from a server all user have access to. Thanks I will look into portable installations for this. Not sure about the webapp thing. never did one before and my programm is already finished. – wenzel267 May 15 '18 at 07:26
  • found something usefull for my case: https://stackoverflow.com/a/10199347/7862001 – wenzel267 May 15 '18 at 07:27
  • Already did this a lot of times (but under other circumstances). In case I need to set up a new server instance, I'm copying an "op"-folder containg a JDK, servers, etc. to the new server instance. – Flocke May 15 '18 at 07:33
  • 1
    Added to that you may also need to consider the Platform (Windows/Unix/AIX) and the bit(32bit/64bit) to add to the complexity. – piy26 May 15 '18 at 07:38

1 Answers1

2

Bundling a Java desktop application with a JRE is in fact nowadays considered good practice. How exactly to do that depends on the target operating system. But there's usually no need to come up with an individual solution as Oracle provides instructions on how to achieve this in a standardized way.

This is what Oracle says about the basics of "Self-Contained Application Packaging":

Each self-contained application package includes the following items:

Application code, packaged into a set of JAR files, plus any other application resources (data files, native libraries)

Copy of the JRE, to be used by this application only

Native launcher for the application, multiple launchers for a single package are supported

Metadata, such as icons

They provide detailed instructions for Java 8 and Java 9 on how exactly to create the package for different operating systems.

anothernode
  • 5,100
  • 13
  • 43
  • 62