File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ @ Deprecated /* > nul 2 >& 1
2+
3+ :: self compiled java/.bat hybrid
4+ ::
5+ :: deprecated is the only one annotation that can be used outside the class definition
6+ :: and is needed for 'mute' start of multi-line java comment
7+ :: that will be not printed by the batch file.
8+ :: though it still created two files - the .class and the .java
9+ :: it still allows you to embed both batch and java code into one file
10+
11+ @ echo off
12+ setlocal
13+ java -version > nul 2 >& 1 || (
14+ echo java not found
15+ exit /b 1
16+ )
17+
18+ :: find class name
19+ for /f " usebackq tokens=3 delims=} " %%c in (`type %~f0 ^ |find /i " public class" ^ |findstr /v " for /f" `) do (
20+ set " javaFile = %%c "
21+ goto :skip
22+ )
23+ :skip
24+
25+ copy " %~f0 " " %javaFile% .java" > nul 2 >& 1
26+
27+ javac " %javaFile% .java"
28+ java " %javaFile% "
29+
30+ :: optional
31+ :: del %javaFile%.* >nul 2>&1
32+ end local
33+ exit /b 0
34+
35+ *******/
36+
37+
38+
39+ public class TestClass
40+ {
41+ public static void main(String args[])
42+ {
43+ System.out.println(" selfcompiled .bat/.java hybrid" );
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments