简体   繁体   English

在同一目录中使用java.exe运行Java程序,而无需安装

[英]Run a Java program with java.exe in the same directory without installing

I know there are lots of posts similar to this, but all of their answers require creating an .exe file. 我知道有很多与此类似的帖子,但是他们的所有答案都需要创建一个.exe文件。 I want to know how to run a program in a folder without installing java. 我想知道如何在不安装Java的情况下在文件夹中运行程序。

I don't want to install Java 8 as it breaks some of my programs. 我不想安装Java 8,因为它破坏了我的某些程序。 I want to run a java program in a folder using a start.bat file that points to the java.exe file in the same directory. 我想使用指向同一目录中的java.exe文件的start.bat文件在文件夹中运行Java程序。 Like this: 像这样:

"java.exe" -jar program.jar

The error is like this: 错误是这样的:

Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'

has value '1.7', but '1.8' is required.
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.

Since the command window is opened in the same directory, "java.exe" should point to the java runtime. 由于命令窗口是在同一目录中打开的,因此“ java.exe”应指向Java运行时。

Can I maybe copy java.dll to the directory to make it work? 我可以将java.dll复制到该目录以使其工作吗? How can I do this without installing java 8? 不安装Java 8怎么办? Could I use java ME? 我可以使用Java ME吗?

Why don't you create a .bat file that declares a new JAVA_HOME and appends to the PATH just for this DOS/batch session, then you can point to a place where you have the required JRE (however, you kind of have to install it... it's a Windows thing). 为什么不创建一个.bat文件来声明一个新的JAVA_HOME并仅为此DOS / batch会话追加到PATH,那么您可以指向一个具有所需JRE的位置(但是,您必须安装它是Windows的东西)。

I understand you are reluctant to install the JDK/JRE 8 on your Windows because of this: "I don't want to install Java 8 as it breaks some of my programs". 我知道您不愿意在Windows上安装JDK / JRE 8,因为:“我不想安装Java 8,因为它破坏了我的某些程序”。 But trust me, you can always change the JRE version on the Java Control Panel (windows >> control panel >> Java) and change the JAVA_HOME & PATH environment variables, you might have problems with your browser's plugins though, the Java install will affect them as well.. I guess, in that, case you can either try to skip this part of the install process or.. install JDK 7 again afterwards? 但是请相信我,您始终可以在Java控制面板(Windows >>控制面板>> Java)上更改JRE版本,并更改​​JAVA_HOME&PATH环境变量,尽管您的浏览器插件可能会出现问题,但是Java安装会影响他们也..我想在这种情况下,您可以尝试跳过安装过程的这一部分,或者..之后再安装JDK 7?

IF you just want to run this program, you can also install VirtualBox and create a VM with windows and install the JDK8 there, avoiding any problems in your OS. 如果您只想运行该程序,则还可以安装VirtualBox并使用Windows创建VM,然后在其中安装JDK8,从而避免OS中出现任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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