avatar
jar file question# Java - 爪哇娇娃
c*t
1
I have a jar file which I need to run with
java -mx300mb -jar mycode.jar
-mx300mb is needed to increase the heap size. Are there anways to
avoid this flag at run time w/o using shell script/batch files and
have this option build into the jar file?
I was looking at the menifest file but found no clues. Anyone
can help?
Thanks
avatar
m*c
2

Should it be "-Xmx300m"? It is not for increasing the heap size, it is
actually for limiting the heap size (maximum heap size). If you want to
increase initial heap size (minimum heap size), you need "-Xms128m". I don't
think you can build "-Xmx300m" option into either JVM or JAR files.

【在 c*****t 的大作中提到】
: I have a jar file which I need to run with
: java -mx300mb -jar mycode.jar
: -mx300mb is needed to increase the heap size. Are there anways to
: avoid this flag at run time w/o using shell script/batch files and
: have this option build into the jar file?
: I was looking at the menifest file but found no clues. Anyone
: can help?
: Thanks

avatar
k*c
3
Can you write a bootstrap class to create a new process, and in that new
process, you can run whatever you want.
And in the manifest file, you can set the bootstrap class as the startup class
for the jar file.

【在 c*****t 的大作中提到】
: I have a jar file which I need to run with
: java -mx300mb -jar mycode.jar
: -mx300mb is needed to increase the heap size. Are there anways to
: avoid this flag at run time w/o using shell script/batch files and
: have this option build into the jar file?
: I was looking at the menifest file but found no clues. Anyone
: can help?
: Thanks

avatar
c*t
4
Could you give an example? I didn't quite understand...
Thanks

【在 k*****c 的大作中提到】
: Can you write a bootstrap class to create a new process, and in that new
: process, you can run whatever you want.
: And in the manifest file, you can set the bootstrap class as the startup class
: for the jar file.

avatar
e*e
5
public class Test {
public static void main(String[] args) {
try {
Runtime.getRuntime().exe("javaw -Xmx800m -Djava.library.path=xxx -cp xxxx
abc");
} catch(Exception ex) {
ex.printStackTrace();
}
}
}
Do you mean by that?

【在 c*****t 的大作中提到】
: Could you give an example? I didn't quite understand...
: Thanks

avatar
g*g
6
Of course you can do this, but i can't find a case you should do this.
A shell/batch is 1000 times more convenient.

xxxx
class

【在 e***e 的大作中提到】
: public class Test {
: public static void main(String[] args) {
: try {
: Runtime.getRuntime().exe("javaw -Xmx800m -Djava.library.path=xxx -cp xxxx
: abc");
: } catch(Exception ex) {
: ex.printStackTrace();
: }
: }
: }

avatar
m*t
7
Note this relies on what's on the user's path and can get you in trouble
sometimes.
I would still suggest to provide shell scripts for the major platforms you
need to support. one cmd and one sh should take care of Windows and *nix
which account for about 99% of the cases.

【在 e***e 的大作中提到】
: public class Test {
: public static void main(String[] args) {
: try {
: Runtime.getRuntime().exe("javaw -Xmx800m -Djava.library.path=xxx -cp xxxx
: abc");
: } catch(Exception ex) {
: ex.printStackTrace();
: }
: }
: }

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。