c*****t 发帖数: 1879 | 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 |
m**c 发帖数: 90 | 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
|
k*****c 发帖数: 6 | 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
|
c*****t 发帖数: 1879 | 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.
|
e***e 发帖数: 351 | 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
|
g*****g 发帖数: 34805 | 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(); : } : } : }
|
m******t 发帖数: 2416 | 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(); : } : } : }
|