使用shell/bat脚本调试java程序示例

源址: https://www.cnblogs.com/jing1617/p/6429754.html

一、linux下shell启动java

#!/bin/sh

JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre

# JVM_OPT="$JVM_OPT -Xdebug -Xrunjdwp:transport=dt_socket,address=32044,server=y,suspend=n"

APP_HOME=/opt/test

APP_MAINCLASS=http.RuntimeCMD

CLASSPATH=$APP_HOME/classes
for i in "$APP_HOME"/lib/*.jar; do
CLASSPATH="$CLASSPATH":"$i"
done

#java虚拟机启动参数
JAVA_OPTS="-ms512m -mx512m -Xmn256m -Djava.awt.headless=true -XX:MaxPermSize=128m"

JAVA_CMD=" $JAVA_HOME/bin/java $JAVA_OPTS -classpath $CLASSPATH $APP_MAINCLASS"
echo $JAVA_CMD
su - root -c "$JAVA_CMD"

 

二、windows下bat启动java程序

@echo off
set SCRIPT_DIR=%~dp0

rem set DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=44444,server=y,suspend=y
set CLASS_PATH=%CLASS_PATH%;lib\\testhttpclient.jar
set CLASS_PATH=%CLASS_PATH%;lib\\httpcore-4.4.4.jar
set CLASS_PATH=%CLASS_PATH%;lib\\httpclient-4.5.2.jar
set CLASS_PATH=%CLASS_PATH%;lib\\commons-logging-1.2.jar
set CLASS_PATH=%CLASS_PATH%;lib\\commons-codec-1.9.jar

set MAIN_CLASS=http.TestHttps

rem set JAVA_HOME="C:/Program Files/Java/jdk1.7.0_17"

"C:/Program Files/Java/jdk1.7.0_17/bin/Java" -cp %CLASS_PATH% %DEBUG_OPTS% -Dcom.env.home=%CD% %MAIN_CLASS% %1

阅读更多

没有更多推荐了,返回首页