Reputation: 1377
I have a java class "Test.java" which contains certain code.
public class Test {
public static void main(String[] args) throws Exception {
testMount();
}
public static void testMount() throws Exception {
System.out.println(System.getProperty("os.name"));
//Windows
String volumeToMount = "\\\\?\\Volume{****-****-******-********}\\";
String mountPoint = "C:\\temp\\";
mountFileSystem("", "", volumeToMount, mountPoint); //This carries out the operation
}
}
I have already compiled the code in Linux Operating System. I want to run the compiled code through a batch script ( .bat file). How do i do that? What is the syntax for that? If i have to add some external jars, where and how do I insert them in the syntax within the .bat file?
Upvotes: 1
Views: 2148
Reputation: 54258
.bat is for Windows; try to compile your Java codes in Windows to EXE (with your external libraries, as suggested by galchen), and add your EXE name along with relative / absolute path to the batch file.
For example, the output EXE is named as test.exe, the batch file should contain:
START C:\PATH\TO\YOUR\EXE\test.exe
Advantage of compiling to EXE is mainly for performance.
Upvotes: 0
Reputation: 31192
here is an example of bat file for executing a java code from the jar with external jars:
@echo off
if "X%JAVA_HOME%" == "X" goto setjavahome
goto setup
:setjavahome
rem #### MODIFY ##########
set JAVA_HOME=c:\program files\javasoft\jre\1.2
rem #######################
:setup
set JNDI_LIB=lib\ldap.jar;lib\jndi.jar;lib\providerutil.jar;lib\ldapbp.jar
set JSSE_LIB=lib\jsse.jar;lib\jnet.jar;lib\jcert.jar
set COMMON=.;%JNDI_LIB%;%JSSE_LIB%
set EXEC=browser.jar lbe.ui.BrowserApp
set CMD="%JAVA_HOME%\bin\java" -cp %COMMON%;%EXEC%
echo %CMD%
%CMD%
Upvotes: 3