开发者

Need help in Installing JRE?

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 fo开发者_如何转开发r 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/…


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_HOMEas is not actively used nowadays.

Example: Say you application name is 'A', you folder structure can look like:

A
|-> Run.bat
|- jre
   |- bin
   |- lib
|- lib
   |-> A.jar

You application main class is Main.java in package a. Your Run.batcan look like START "" jre\bin\javaw.exe -cp lib\A.jar a.Main

You only are calling the embedded jre in jre folder, by calling the bin\javaw.exe and passing the jar and main class. The jre folder can content and entire JRE as copied from c:\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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜