用JAVA很久,但一直沒(méi)有了解JAVA.exe這個(gè)玩意兒
今天偶然用了一下,一點(diǎn)小小心得
1,參數(shù)傳遞
java命令使用 -D參數(shù)名=參數(shù)值 來(lái)傳遞
java -Dyourname="%JAVA_HOME%" yourclass
java程序中使用獲得
System.getProperty("yourname");
這個(gè)在很多應(yīng)用中有體現(xiàn)
2,設(shè)置初始堆棧
java有個(gè)命令可以看如何設(shè)置
java -X
E:>java -X
-Xmixed mixed mode execution (default)
-Xint interpreted mode execution only
-Xbootclasspath:<directories and zip/jar files separated by ;>
set search path for bootstrap classes and resources
-Xbootclasspath/a:<directories and zip/jar files separated by ;>
append to end of bootstrap class path
-Xbootclasspath/p:<directories and zip/jar files separated by ;>
prepend in front of bootstrap class path
-Xnoclassgc disable class garbage collection
-Xincgc enable incremental garbage collection
-Xloggc:<file> log GC status to a file with time stamps
-Xbatch disable background compilation
-Xms<size> set initial Java heap size
-Xmx<size> set maximum Java heap size
-Xss<size> set java thread stack size
-Xprof output cpu profiling data
-Xfuture enable strictest checks, anticipating future default
-Xrs reduce use of OS signals by Java/VM (see documentation)
-Xcheck:jni perform additional checks for JNI functions
-Xshare:off do not attempt to use shared class data
-Xshare:auto use shared class data if possible (default)
-Xshare:on require using shared class data, otherwise fail.
一目了然,以前只是看別人在應(yīng)用,但不知道出處,看來(lái)看書(shū)不仔細(xì)呀
3,設(shè)置路徑
使用 -classpath 設(shè)置所需要的jar文件
java -Dyourname="%JAVA_HOME%" -classpath ".;./yourjar.jar" yourclass
開(kāi)始忘記了那個(gè).號(hào),執(zhí)行時(shí)老是報(bào)類(lèi)找不到。
4,使用bat
這么多參數(shù)需要設(shè)置,每次都要打一大堆,使用批處理文件就方便多了
將上面那么長(zhǎng)的一段話(huà)寫(xiě)入批處理文件,直接執(zhí)行批處理文件。