简体   繁体   English

从cmd运行jar

[英]Running jar from cmd

I have seen a lot of posts and found lots of data on the net about this but I am still confused. 我看过很多帖子,并在网上发现了很多关于此的数据,但我仍感到困惑。

I have downloaded a .jar file and I need to increase its heap size. 我已经下载了一个.jar文件,我需要增加它的堆大小。 I have added the jre1.6/bin in the Path of Windows 64 bit and I run from cmd. 我已经在Windows 64位路径中添加了jre1.6 / bin,并且我从cmd运行。

The problem arises that it says unable to access jar file. 出现的问题是它无法访问jar文件。

Can anybody explain in some detail what should I do to run it from cmd. 任何人都可以详细解释我应该怎么做才能从cmd运行它。 Do i need to add the location of jar file into the Path too ?? 我是否需要将jar文件的位置添加到Path中? 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) -------------------------------(更新)

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. 这真的很奇怪.....我做了这里提到的,现在程序加载然后退出内存不足错误,说它需要更多的堆大小,即使它在128米堆大小之前工作。 This happens when I increase it to 1024m. 当我将其增加到1024米时会发生这种情况。 Can anybosy explain why the error could have come. anybosy可以解释为什么错误可能会来。 I have 3GB Ram so I don't understand it..... 我有3GB Ram所以我不明白.....

The following should run the jar: 以下应该运行jar:

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

If you are running the command from the directory that the Jar is in, you can just specify it by name. 如果从Jar所在的目录运行命令,则可以按名称指定它。 Otherwise you need to qualify the path to the Jar in order for Java to be able to find it. 否则,您需要限定Jar的路径,以便Java能够找到它。

从“C:\\ Program Files \\ Weka-3-6”文件夹:

java -Xmx1024m -jar weka.jar

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

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