简体   繁体   English

从NSIS脚本传递参数到java vm

[英]Passing arguments to java vm from NSIS script

I'm developing my first java application using Eclipse. 我正在使用Eclipse开发我的第一个Java应用程序。 I've recently needed to adjust the amount of memory allocated by passing -Xmx256M to the JVM. 我最近需要通过将-Xmx256M传递给JVM来调整分配的内存量。 The application is currently package up as a runnable jar and installed using the NSIS. 该应用程序当前打包为可运行的jar并使用NSIS进行安装。

I'm having a problem passing arguments to the jar file once its installed. 一旦安装了jar文件,我就会遇到问题。 What is the common practice for doing this? 这样做的常见做法是什么? Here is what I'm currently doing in my nsi file: 这是我目前在我的nsi文件中做的事情:

CreateShortcut "$SMPROGRAMS\$StartMenuGroup\$(^Name).lnk" "$SYSDIR\javaw.exe" "-Xmx256M -jar $INSTDIR\Foo.jar"

This results in the following being created as the shortcut Target on windows: 这导致在Windows上创建以下快捷方式:

C:\WINDOWS\system32\javaw.exe -Xmx256M -jar  C:\Program Files\Foo\Foo.jar 

Unfortunately this does not work due to the space in C:\\Program Files, If I change the link created manually to include quotes all is well: 不幸的是,由于C:\\ Program Files中的空格,这不起作用,如果我更改手动创建的链接以包含引号一切都很好:

C:\WINDOWS\system32\javaw.exe -Xmx256M -jar "C:\Program Files\Foo\Foo.jar"

UPDATE: Ordering of -jar and -Xmx256M swapped. 更新:交换-jar和-Xmx256M的顺序。 The issue remains the same however. 但问题仍然存在。 The spaces in the path to the jar file are causing an issue. jar文件路径中的空格导致问题。 I think I either need to find a way of adding quotes into the command, as shown when I manually change the target, or change my approach completely! 我想我要么找到一种在命令中添加引号的方法,如手动更改目标时所示,或者完全改变我的方法!

NSIS strings can be quoted with single quotes, double quotes, or the backward single quote. 可以使用单引号,双引号或后向单引号引用NSIS字符串。 You can also escape with $\\ ($\\" etc) 你也可以用$ \\($ \\“等)逃脱

CreateShortcut "$SMPROGRAMS\$StartMenuGroup\$(^Name).lnk" '"$SYSDIR\javaw.exe"' '-Xmx256M -jar "$INSTDIR\Foo.jar"'

您是否尝试过保留引号但是转义路径分隔符?

C:\WINDOWS\system32\javaw.exe -Xmx256M -jar "C:\\Program Files\\Foo\\Foo.jar"

很确定你应该在“C:\\ WINDOWS \\ system32 \\ javaw.exe”周围加上引号,即使没有空格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM