简体   繁体   中英

Running JAR in a computer that has no JRE. Making it portable

I have a JAR file that I wish to run on CentOS (university computer labs). But the problem is it has no JRE installed. The sys admin won't install the latest version of Java. Is there a way to run a JAR on a computer that has no JRE installed? And installing JRE isn't an option since the sysadmin denied that request.

Assumption: JAR files are generated with no trouble. Running is the issue.

The sys admin won't install the latest version of Java. Is there a way to run a JAR on a computer that has no JRE installed?

Basically, no.

Possible alternatives:

  • Install Java yourself in your home directory. (If you have enough disk space, and this doesn't violate the rules for your Lab.)
  • If the lab permits the running of virtual machines, launch one and install and run Java with the VM.
  • Run this application somewhere else; eg on your laptop, on an Amazon AWS server (costs money), etc.

If you had source code for the JAR, and if it only used pre-Java 5 APIs and language features, then the GNU GCJ compiler might be an option. But I would not recommend this.

(And you would need to convince the sys admin to install GCJ! And the resulting executable may not be portable, depending on what libraries it is linked against, processor types and versions, etc.)


Given that you do have source code and a development platform (Intellij), try changing your IDE's compiler settings to compile for the (older) version of Java installed on the Lab machines. The Intellij documention is here:

Read the linked pages as well.

But this won't work if you use newer APIs and language features.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM