如何在Windows批处理文件中嵌入jar文件?

时间:2018-03-13 16:25:49

标签: java batch-file jar

我想在Windows中执行与https://coderwall.com/p/ssuaxa/how-to-make-a-jar-file-linux-executable类似的操作。

背景信息:我正在编写一个protoc插件,该插件需要使用一个且只能使用一个可执行文件。

我创建了一个stub.bat文件,其中包含以下内容:

@ECHO OFF
"C:\Program Files\Java\jdk1.8.0_161\bin\java" -jar %~dp0%0 %*

并遵循与Unix所描述的相似的说明,但在运行生成的批处理文件时,我看到了:

Hello, World
'□' is not recognized as an internal or external command, operable program or batch file.

" Hello,World"表明我正在做的事实上正在发挥作用。但最后如何消除垃圾呢?

1 个答案:

答案 0 :(得分:0)

结束stub.bat

exit /b

来自https://ss64.com/nt/exit.html

Syntax
      EXIT [/B] [exitCode]

Key
    /B        When used in a batch script, this option will exit 
              only the script (or subroutine) but not CMD.EXE

   exitCode   Sets the %ERRORLEVEL% to a numeric number.
              If quitting CMD.EXE, set the process exit code no.
相关问题