设置启动参数在Java类 [英] Setting Launch Parameters In Java Class

查看:849
本文介绍了设置启动参数在Java类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让它这样你就可以设置内存使用参数的 Java类,不使用Eclipse或Java程序的编译器,只是简单的code,你可以在里面一做类使用记事本什么的。
如果你不明白我的意思,这里有一个例子:

Is there a way to make it so you can set memory usage arguments inside a java class, not using eclipse or a java program compiler, just simple code that you can do inside a class using notepad or something. If you don't know what I mean, Here's an example:

public class Example {
   public Example() {
     -Xmx("1024M");
   }

   public static void main(String args[]) {
     new Example();
   }
}

请帮忙,谢谢!
注:我不想做一个cmd /批处理文件-Xmx运行

Please help, thank you! Note: I don't want to make a cmd/batch file to run it with -Xmx!

推荐答案

该内存不能在运行时(改由JRE到达您的code语句的时候,记忆已经设置&放;不能为改变)。实现不同的内存大小的唯一方法是重新发起应用程序。使用过程指定更大的内存(然后关闭原来的应用程序。即没有足够的)。

The memory cannot be changed at run-time (by the time the JRE gets to your code statement, the memory has been set & cannot be changed). The only way to achieve a different memory size is to relaunch the app. using a Process specifying larger memory (then close the original app. that does not have enough).

当然,最好只指定在启动过程中所需的内存(BAT文件, JWS 等等。)。

Of course, better to simply specify the required memory in the launch process (BAT file, JWS etc.).

这篇关于设置启动参数在Java类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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