forked from verhas/License3j
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlicense3j.bat
198 lines (160 loc) · 5.4 KB
/
license3j.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
@ECHO OFF
REM ----------------------------------------------------------------------------
REM License3j command line batch script for Windows XP
REM
REM Required ENV vars:
REM JAVA_HOME - location of a JDK home dir
REM
REM Optional ENV vars
REM APP_HOME - location of APP2's installed home dir
REM JAVA_OPTS - parameters passed to the Java VM when running APP
REM e.g. to debug APP use
REM SET JAVA_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
REM ----------------------------------------------------------------------------
REM Configuration parameters.
REM
REM When using this batch script for any new application you should
REM alter only the lines that are between
REM <<CHANGE START>>
REM (this can be changed) and
REM <<CHANGE END>>
REM (this should not be changed)
SET ERROR_CODE=0
REM set local scope for the variables with windows NT shell
IF "%OS%"=="Windows_NT" @setlocal
IF "%OS%"=="WINNT" @setlocal
REM ==== START VALIDATION ====
IF NOT "%JAVA_HOME%" == "" GOTO JavaHomeIsOK
ECHO.
ECHO ERROR: JAVA_HOME not found in your environment.
ECHO Please SET the JAVA_HOME variable in your environment to match the
ECHO location of your Java installation
ECHO.
GOTO error
:JavaHomeIsOK
IF EXIST "%JAVA_HOME%\bin\java.exe" GOTO checkAppHome
ECHO.
ECHO ERROR: JAVA_HOME is SET to an invalid directory.
ECHO JAVA_HOME = "%JAVA_HOME%"
ECHO Please SET the JAVA_HOME variable in your environment to match the
ECHO location of your Java installation
ECHO.
GOTO error
:checkAppHome
IF NOT "%APP_HOME%"=="" GOTO valMHome
IF "%OS%"=="Windows_NT" SET "APP_HOME=%~dp0"
IF "%OS%"=="WINNT" SET "APP_HOME=%~dp0"
IF NOT "%APP_HOME%"=="" GOTO valMHome
ECHO.
ECHO ERROR: APP_HOME not found in your environment.
ECHO Please SET the APP_HOME variable in your environment to match the
ECHO location of the APP installation
ECHO.
GOTO error
:valMHome
IF EXIST "%APP_HOME%\%BATCH_FILE_NAME%" GOTO checkCpApp
ECHO.
ECHO ERROR: APP_HOME is SET to an invalid directory.
ECHO APP_HOME = "%APP_HOME%"
ECHO Please SET the APP_HOME variable in your environment to match the
ECHO location of the APP installation
ECHO.
GOTO error
:checkCpApp
IF EXIST "%APP_HOME%\cpapp.bat" GOTO init
REM oops.. cpapp.bat does not EXIST, try to create it
ECHO SET CLASSPATH=%%CLASSPATH%%;%%1> "%APP_HOME%\cpapp.bat"
IF EXIST "%APP_HOME%\cpapp.bat" GOTO init1
ECHO.
ECHO ERROR: APP_HOME directory does not contain the batch file cpapp.bat and
ECHO the script %BATCH_FILE_NAME% can not create it.
ECHO APP_HOME = "%APP_HOME%"
ECHO Either change the file permissions so that this bacth file can create
ECHO cpapp.bat or create the file. The file cpapp.bat should contain a
ECHO single line:
ECHO .
ECHO SET CLASSPATH=%%CLASSPATH%%;%%1
ECHO .
ECHO Note that there should NOT be any trailing space at the end of the
ECHO line.
ECHO.
GOTO error
REM ==== END VALIDATION ====
:init
:init1
cd %APP_HOME%
REM Decide how to startup depending on the version of windows
REM -- Windows NT with Novell Login
IF "%OS%"=="WINNT" GOTO WinNTNovell
REM -- Win98ME
IF NOT "%OS%"=="Windows_NT" GOTO Win9xArg
:WinNTNovell
REM -- 4NT shell
IF "%@eval[2+2]" == "4" GOTO 4NTArgs
REM -- Regular WinNT shell
SET APP_CMD_LINE_ARGS=%*
GOTO endInit
REM The 4NT Shell from jp software
:4NTArgs
SET APP_CMD_LINE_ARGS=%$
GOTO endInit
:Win9xArg
REM Slurp the command line arguments. This loop allows for an unlimited number
REM of agruments (up to the command line limit, anyway).
SET APP_CMD_LINE_ARGS=
:Win9xApp
IF %1a==a GOTO endInit
SET APP_CMD_LINE_ARGS=%APP_CMD_LINE_ARGS% %1
shift
GOTO Win9xApp
REM Reaching here means variables are defined and arguments have been captured
:endInit
SET JAVA_EXE="%JAVA_HOME%\bin\java.exe"
REM -- 4NT shell
IF "%@eval[2+2]" == "4" GOTO 4NTCWJars
REM -- Regular WinNT shell
SET CLASSPATH=""
for %%i in ("%APP_HOME%"lib\*.jar) do call "%APP_HOME%\cpapp.bat" "%%i"
GOTO runf2jp
REM The 4NT Shell from jp software
:4NTCWJars
SET CLASSPATH=""
for %%i in ("%APP_HOME%lib\*.jar") do call "%APP_HOME%\cpapp.bat" "%%i"
GOTO runf2jp
REM Start APP2
:runf2jp
REM <<CHANGE START>>
REM The name of the batch file. It is used to check that the home directory
REM is calculated correctly.
SET BATCH_FILE_NAME=license3j.bat
REM the location of the configuration file
REM the main class that is to be executed
SET MAIN_CLASS=License3j
REM local java options
SET LOCAL_JAVA_OPTS=-Xmx1024m
REM arguments to be passed to the Java program before the BAT file arguments
SET ARGS1=
REM arguments to be passed to the Java program after the BAT file arguments
SET ARGS2=
REM <<CHANGE END>>
%JAVA_EXE% %JAVA_OPTS% %LOCAL_JAVA_OPTS% -classpath %CLASSPATH% %MAIN_CLASS% %ARGS1% %APP_CMD_LINE_ARGS% %ARGS2%
IF ERRORLEVEL 1 GOTO error
GOTO end
:error
IF "%OS%"=="Windows_NT" @endlocal
IF "%OS%"=="WINNT" @endlocal
SET ERROR_CODE=1
:end
REM SET local scope for the variables with windows NT shell
IF "%OS%"=="Windows_NT" GOTO endNT
IF "%OS%"=="WINNT" GOTO endNT
REM For old DOS remove the SET variables from ENV - we assume they were not SET
REM before we started - at least we don't leave any baggage around
SET JAVA_EXE=
SET APP_CMD_LINE_ARGS=
GOTO postExec
:endNT
@endlocal & SET ERROR_CODE=%ERROR_CODE%
:postExec
IF "%APP_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
cmd /C exit /B %ERROR_CODE%