Bat execution script parsing of Java programs

Source: Internet
Author: User

Bat

To run a Java program, the main action in the script is to set classpath.
Features of the script:
(1) Set path: Java command can be found
(2) Setting splash (splash screen)
(3) Set Classpath: The main program runs to find the referenced class
(4) Set the relevant parameters required for remote debugging

@echo offif"%os%" = = "Windows_NT" @setlocalif"%os%" = = "WINNT" @setlocal@title RRU hotloadPatchToolSetWorkpath=%~dp0Set Path=%Path%;%workpath%\LibSetjava_home=%workpath%\jdk-windowsREMSet java_opts=%java_opts%-splash:%workpath%\img\welcome.gifSetjava_opts=%java_opts%-classpath%workpath%\lib\*;REMSet Java_opts=-classic-xdebug-xnoagent-djava.compiler=none-xrunjdwp:transport=dt_socket,address=3999,server =y,suspend=n%java_opts%%java_home%\bin\java%java_opts% Packagename.classname


Analyze:
[Email protected] off

(1). As a switch that controls whether the batch command displays the command line itself at execution time
Format: ECHO [on| OFF]
(2). Close the DOS command prompt
Type echo off at the DOS prompt to turn off the display of the DOS prompt so that the screen leaves only the cursor until you type echo on, and the prompt will appear again.

Http://network.51cto.com/art/201009/225457.htm
Use of @ See: http://www.cnblogs.com/softidea/p/4229829.html

2.%os% is a system variable.

3.setlocal

  The environment changes made after setlocal/   setlocal are limited to batch files endlocal   SETLOCALendlocal is executed.

eg

@echo off set test=testecho  %test%setlocalechosetlocal  echo  %test%set test=newcontentecho  %test%  Endlocalechoendlocalecho %test%

Output:

setlocalendlocaltest

Http://www.jb51.net/article/36043.htm

Extended:
Setlocal enabledelayedexpansion

eg

@echo off Set set a=5&echoecho ==========================setlocal  Set set a=5&echo   ! A!  Echo %a% Pause

Output:

4==========================55 Please press any key to continue ...

Http://www.jb51.net/article/29323.htm



4. Title

the title of the window that sets the command prompt window. The title [string]  string       Specifies the caption of the Command Prompt window. 

5,%~dp0
Http://www.cnblogs.com/softidea/p/4229829.html
6,-splash

Java-helpusage:java [-options] class [args... ]           (to execute a class)   or  java [-options]-jar jarfile [args... ]           (to execute a jar file)   -splash:<imagepath>                 show splash screens with Specified image

7,-xdebug-xnoagent-djava.compiler=none-xrunjdwp:transport=dt_socket,address=3999,server=y,suspend=n

-XDEBUG-XNOAGENT-DJAVA.COMPILER=NONE-XRUNJDWP: Transport=dt_socket,server=y,address=3999,suspend=  N-xdebug               enable debugging. -xnoagent             Disables the default Sun. Tools. Debug Debugger. -djava. compiler=NONE  Disables the loading of the JIT compiler. -XRUNJDWP             Loads the jdwp JPDA reference execution instance. Transport             is used to communicate between the debugger and the process used by the VM. Dt_socket             socket transmission. Dt_shmem              Shared memory transfers are limited to Windows. whether the server =y/n            VMs need to be executed as a debug server. Address=3999 The port number of the           debug server that the client uses to connect to the server. Suspend=y/n           whether to start the VM after the debugging client establishes the connection.

Http://www.blogjava.net/yongbing/articles/221179.html

Extension part:

Linux:

Echo"ADD The XXX ' s Lib path into the CLASSPATH ..."CLASSPATH=.:$JAVA _home/lib/dt.jar:$JAVA _home/lib/tools.Jaroldclspath=$CLASSPATHLippath=/opt/system/jakarta-tomcat-5.0. -/webapps/javaservice/web-inf/lib/*.Jar#Echo $LIPPATHcf=. forI in$LIPPATH DoCF=$CF:"$i"#Echo $CFDoneecho"The XXX ' s Lib path has been added into the CLASSPATH ..."#Echo $CFExport classpath=$CLASSPATH:$CFEcho$CLASSPATH#Ps:if want to run a Java application, you must is copy this. bat file to the class directory.JAVA-CP CLASSPATH PackageName.ClassName#OK

Windows:

@echo offif"%os%" = = "Windows_NT" @setlocalif"%os%" = = "WINNT" @setlocalsetlocalenabledelayedexpansionECHO.ECHO"Set CLASSPATH begin ..."Setcp=. for%%k in ("D:/program files/apache-tomcat-6.0.16/webapps/axis/web-inf"/lib/*.jar) Do Setcp=! cp!;%%kSetclasspath=%classpath%;%cp%ECHO"Set CLASSPATH is ok ..."ECHO"Show The CLASSPATH:"ECHO.ECHO%classpath%ECHO.REM"can add some code here."REMPs:if want to run a Java application, you must is copy this. bat file to the class directory.REMJAVA-CP CLASSPATH packagename.classnameREM ""REM ""PAUSE

http://blog.csdn.net/faye0412/article/details/2986516

Bat execution script parsing of Java programs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.