i have to install JRE Programmability if the System does not have JRE, i had dected JRE is installed in the system or not, but i have no idea how to install JRE programmtically, some people said you can use installer, but i donot know how to use installer for this purpose i searched in sun documnet, installing JRE in slient mode, there's also i donot know how to use that command iie.fing.edu.uy/ense/asign/…
相关问题
- Delete Messages from a Topic in Apache Kafka
- How does the setup bootstrapper detect if prerequi
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
In order to run your Java program, you can do that without installing the JRE, that its, you can run the application in a computer without JRE, we do that every day.
The way is to deploy you application with an embedded JRE and use a script (.bar, .sh) to execute you application using the embedded JRE. So your application is self-contained and no requires external JRE. You need to copy the entire JRE folder into your application and start removing unused files using the test-error approach. You can also decrease the file sizes removing not needed classes, like in rt.jar (you can decompress, remove unused classes and zip again).
The problem with this approach is that you are violating the Oracle/SUN JRE distribution policy as you are distributing a JRE with fewer files. If the application is for internal use, I think it's OK, if you want to redistribute the application, you are in trouble.
Another question is how to install the JRE by code, you can try to ship the JRE with your application, using an installer detect if JRE is already installed and install it id needed. Doing that in Java code is not trivial, you can use
Runtime
to exec external programs...Do not rely on
JAVA_HOME
as is not actively used nowadays.Example: Say you application name is 'A', you folder structure can look like:
You application main class is Main.java in package a. Your
Run.bat
can look likeSTART "" jre\bin\javaw.exe -cp lib\A.jar a.Main
You only are calling the embedded jre in
jre
folder, by calling thebin\javaw.exe
and passing the jar and main class. Thejre
folder can content and entire JRE as copied fromc:\Program Files (x86)\Java\jre6\
(Windows 7).If you can have a web based solution you can use deployjava
http://download.oracle.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html