Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 执行.bat文件和手动输入命令之间的区别_Java_Windows_Batch File_H2 - Fatal编程技术网

Java 执行.bat文件和手动输入命令之间的区别

Java 执行.bat文件和手动输入命令之间的区别,java,windows,batch-file,h2,Java,Windows,Batch File,H2,我在Windows10(早期版本7)中使用H2数据库已有相当长的一段时间了。在C:\ProgramFiles(x86)\H2\bin文件夹中,我有一个H2.bat,第一行如下 @java-cp“h2-1.3.176.jar;%H2DRIVERS%;%CLASSPATH%”org.h2.tools.Console%* 当我执行这个文件时,H2会按需要启动。现在我尝试打开Windows命令窗口。当我进入同一行并按return键时,我得到结果 Starts the H2 Console (web-)

我在Windows10(早期版本7)中使用H2数据库已有相当长的一段时间了。在
C:\ProgramFiles(x86)\H2\bin
文件夹中,我有一个
H2.bat
,第一行如下

@java-cp“h2-1.3.176.jar;%H2DRIVERS%;%CLASSPATH%”org.h2.tools.Console%*

当我执行这个文件时,H2会按需要启动。现在我尝试打开Windows命令窗口。当我进入同一行并按return键时,我得到结果

Starts the H2 Console (web-) server, as well as the TCP and PG server.
Usage: java org.h2.tools.Console <options>
When running without options, -tcp, -web, -browser and -pg are started.
Options are case sensitive. Supported options are:
[-help] or [-?]  Print the list of options
[-url]           Start a browser and connect to this URL
[-driver]        Used together with -url: the driver
[-user]          Used together with -url: the user name
[-password]      Used together with -url: the password
[-web]           Start the web server with the H2 Console
[-tool]          Start the icon or window that allows to start a browser
[-browser]       Start a browser connecting to the web server
[-tcp]           Start the TCP server
[-pg]            Start the PG server
For each Server, additional options are available;
 for details, see the Server tool.
If a service can not be started, the program
 terminates with an exit code of 1.
See also http://h2database.com/javadoc/org/h2/tools/Console.html
Exception in thread "main" org.h2.jdbc.JdbcSQLException: Feature not supported: "%*" [50100-176]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
        at org.h2.message.DbException.get(DbException.java:178)
        at org.h2.message.DbException.get(DbException.java:154)
        at org.h2.util.Tool.throwUnsupportedOption(Tool.java:69)
        at org.h2.util.Tool.showUsageAndThrowUnsupportedOption(Tool.java:58)
        at org.h2.tools.Console.runTool(Console.java:205)
        at org.h2.tools.Console.main(Console.java:100)
启动H2控制台(web-)服务器以及TCP和PG服务器。
用法:java org.h2.tools.Console
在没有选项的情况下运行时,会启动-tcp、-web、-browser和-pg。
选项区分大小写。支持的选项包括:
[-help]或[-?]打印选项列表
[-url]启动浏览器并连接到此url
[-driver]与-url:驱动程序一起使用
[-user]与-url一起使用:用户名
[-password]与-url一起使用:密码
[-web]使用H2控制台启动web服务器
[-tool]启动允许启动浏览器的图标或窗口
[-browser]启动连接到web服务器的浏览器
[-tcp]启动tcp服务器
[-pg]启动pg服务器
对于每台服务器,都有其他选项可用;
有关详细信息,请参阅服务器工具。
如果无法启动服务,则程序
以退出代码1终止。
另见http://h2database.com/javadoc/org/h2/tools/Console.html
线程“main”org.h2.jdbc.JdbcSQLException中出现异常:不支持功能:“%*”[50100-176]
位于org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
位于org.h2.message.DbException.get(DbException.java:178)
位于org.h2.message.DbException.get(DbException.java:154)
位于org.h2.util.Tool.throwUnsupportedOption(Tool.java:69)
位于org.h2.util.Tool.showUsageAndThrowUnsupportedOption(Tool.java:58)
位于org.h2.tools.Console.runTool(Console.java:205)
位于org.h2.tools.Console.main(Console.java:100)
您可以看到我得到了一个java异常。你能解释一下为什么它是通过执行
.bat
文件来工作的,以及如何更改以手动执行它吗?我看不出有什么区别。顺便说一下:当然,我首先在命令窗口中浏览了
C:\ProgramFiles(x86)\H2\bin

@java -cp "h2-1.3.176.jar;%H2DRIVERS%;%CLASSPATH%" org.h2.tools.Console %*
末尾的
%*
表示“提供给此bat文件的所有参数”

所以如果你打电话

h2.bat param1 param2
然后将调用以下命令

@java -cp "h2-1.3.176.jar;%H2DRIVERS%;%CLASSPATH%" org.h2.tools.Console param1 param2

但是,在没有bat文件的情况下运行时,字符串
%*
将直接传递给应用程序
%*
不是
org.h2.tools.Console

%*支持的选项之一,表示其余参数在批处理文件之外不起作用。正如错误消息所示。