我有一个.bat文件,我需要从.jar可执行文件运行。我环顾四周,却找不到明显的方法......无论如何这可以做到吗?救命!这是我现有的.bat代码,如果它有帮助:
@ECHO OFF
:: When setting the memory below make sure to include the amount of ram
:: letter. M = MB, G = GB. Don't use 1GB for example, it's 1G ::
:: This is 64-bit memory ::
set memsixtyfour=2G
:: This is 32-bit memory - maximum 1.2G ish::
set memthirtytwo=1G
:: Don't edit past this point ::
if $SYSTEM_os_arch==x86 (
echo OS is 32
set mem=%memthirtytwo%
) else (
echo OS is 64
set mem=%memsixtyfour%
)
java -Xmx%mem% -XX:MaxPermSize=256M -jar forge-1.7.10-10.13.2.1277-universal.jar nogui
PAUSE
答案 0 :(得分:0)
我认为您正在寻找的是可以进行系统调用的Runtime类。
这是我将使用的代码:
operator()
答案 1 :(得分:0)
尝试将此添加到您的java代码中。
Runtime.getRuntime().exec("cmd /C start filename.bat");