从cmd运行jar [英] Running jar from cmd

查看:321
本文介绍了从cmd运行jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过很多帖子并在网上发现了很多关于此的数据,但我仍感到困惑。

I have seen a lot of posts and found lots of data on the net about this but I am still confused.

我已经下载了.jar文件而我需要增加其堆大小。我已经在Windows 64位路径中添加了jre1.6 / bin,并且我从cmd运行。

I have downloaded a .jar file and I need to increase its heap size. I have added the jre1.6/bin in the Path of Windows 64 bit and I run from cmd.

问题出现了,它说无法访问jar文件。

The problem arises that it says unable to access jar file.

任何人都可以详细解释如何从cmd运行它。我是否需要将jar文件的位置添加到Path中?另外我注意到在许多帖子中他们告诉我改变类路径,但我没有做过这样的事情。

Can anybody explain in some detail what should I do to run it from cmd. Do i need to add the location of jar file into the Path too ?? Also I have noticed that in many posts they tell to change the classpath but I have'nt done anything as such.

告诉您是否需要任何额外信息。

Do tell if you need any extra information.

----------- --------------------(更新)

------------------------------- (Update)

这真的很奇怪.....我做到了在这里提到的,现在程序加载然后退出并出现内存不足错误,说它需要更多的堆大小,即使它在128米堆大小之前工作。当我将它增加到1024米时会发生这种情况。 anybosy可以解释为什么错误可能会来。我有3GB Ram所以我不明白.....

This is really wierd ..... I did it what was mentioned in here and now the program loads and then exits with Out of memory error saying that it needs more heap size even though it was working before with 128 m heap size. This happens when I increase it to 1024m. Can anybosy explain why the error could have come. I have 3GB Ram so I don't understand it.....

推荐答案

以下应该运行jar:

java -Xmx1024m -jar /path/to/the/jar.jar

如果从Jar所在的目录运行命令,则可以按名称指定它。否则,您需要限定Jar的路径,以便Java能够找到它。

If you are running the command from the directory that the Jar is in, you can just specify it by name. Otherwise you need to qualify the path to the Jar in order for Java to be able to find it.

这篇关于从cmd运行jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆