Thursday, November 5, 2015

Run java code in server&terminal

simple:
java -jar test.jar
if you have store the printout into a text, use the following command:
java -jar test.jar >log.txt

The main class is defined when the code is exported from eclipse.

question:
1. how to run different main classes in a same jar file?
2. how to define the memory usage for executing the jar?
 -Xms<size>
JVM default heap size. 
eg: -Xms6400K,-Xms256M
-Xmx<size>
JVM max heap size
eg: -Xmx81920K,-Xmx80M
so the command can be: java -jar test.jar >log.txt -Xms<size> -Xmx<size>

if you don't name main class when export, you can name main class flexibly.

java -cp myjar.jar MyClass

how to import extra jar package into jar file
http://www.cnblogs.com/youxin/archive/2012/06/03/2532914.html

simple ways to export jar with library
export ->runnable jar file-> launch configuration(decide which is main class, which means a jar can only have 1 main class to run ), fill the export destination(eg. a.jar)->finish


 nohup java -Xms4g -Xmx4g -jar centrality.jar 8edges.txt output.txt 10 100&

No comments:

Post a Comment