简体   繁体   English

Java .jar在其他计算机上不起作用

[英]Java .jar doesn't work on other computer

I made a simple card game using Eclipse Kepler. 我使用Eclipse Kepler做了一个简单的纸牌游戏。 I then exported it to a runnable .jar file. 然后,我将其导出到可运行的.jar文件。

When I double click the .jar file, nothing happens. 当我双击.jar文件时, 没有任何反应 So I made a .bat file: java -jar CardGame.jar 所以我制作了一个.bat文件: java -jar CardGame.jar

When I run it, it works fine, but when my friend runs it on his computer (yes, both files in the same directory) the cmd.exe will tell him: 'java' is not recognized as an internal or external command 运行它时,它可以正常工作,但是当我的朋友在他的计算机上运行它(是的,两个文件都在同一目录中)时,cmd.exe会告诉他: 'java' is not recognized as an internal or external command

After some searching I read that I had to add %JAVA_HOME% in the .bat file. 经过一些搜索,我读到我必须在.bat文件中添加%JAVA_HOME% This made no difference for me , but it will still not run on my friend's computer. 这对没有影响,但仍无法在我朋友的计算机上运行。

So my questions are: 所以我的问题是:
- What is wrong with my .jar or .bat file? -我的.jar或.bat文件怎么了?
- Can I run it without the .bat file, if so how? -如果没有.bat文件,我可以运行它吗?

He needs to have Java installed in the default path. 他需要在默认路径中安装Java。

The easiest way to get that is to go to http://java.com/en/download/installed.jsp and follow instructions until Java is reported installed. 最简单的方法是访问http://java.com/en/download/installed.jsp并按照说明进行操作,直到报告已安装Java。

After that your friend should be able to run it. 之后,您的朋友应该可以运行它了。

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

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