如何使用桌面快捷方式启动.jar文件(针对特定的jre)

时间:2012-06-06 19:34:34

标签: java windows wix shortcut

我正在尝试创建一个桌面快捷方式来启动我们的.jar文件。下面的当前WIX构建文件给出了错误:

 [exec] installMsgs.wxs
 [exec] C:\Users\ME\GIT_REPOS\APP\installer\installApp.wxs(43) :
          error CNDL0035 : The Shortcut/@Target attribute cannot be specified when attribute Advertise is present with value 'yes'.
 [exec] C:\Users\ME\GIT_REPOS\APP\installer\installApp.wxs(43) :
          error CNDL0062 : The Shortcut/@Target attribute cannot be specified

当Shortcut元素嵌套在File元素下时。

但根据这个:http://goo.gl/yoSTz它应该有效。我已经尝试在他的文件元素之外创建一个快捷方式作为javaw.exe文件的自己的组件但是这也没有用。谢谢你的帮助。

以下是我的构建文件中的部分:

<Directory Id='D_MyApp' Name='MyApp'>
                        <Component Id='c_myApp' Guid='4f909d90-e31c-44ce-a0af-7042f226611b'>
                            <File Id='myApp' Name='MyApp.jar'
                                Source='..\MyApp\target\Myapp.jar' KeyPath='yes'>
                                <Shortcut Id="s_myApp" Directory="DesktopFolder"
                                    Target="[INSTALLDIR]\jre6\bin\java.exe" 
                                    Arguments="-jar MyApp.jar"
                                    Name="My App" 
                                    WorkingDirectory='INSTALLDIR' 
                                    Icon="MyApp.exe"
                                    Advertise="yes" />
                            </File>
                        </Component>
                    </Directory>
                    <Directory Id='D_jre' Name='jre6'>
                        <Directory Id='D_lib' Name='lib'>
                            <Directory Id='D_ext' Name='ext'>
                                <Component Id='c_SerialIOjars' Guid='a4bc45fe-b62f-478e-ab57-ca5e3e16b42d'>
                                    <File Id='f_jspComm.jar' Name='jspComm.jar'
                                        Source='..\RadioServer\lib\SerialIO\jspComm.jar' KeyPath='no'>
                                    </File>
                                    <File Id='f_Serialio.jar' Name='Serialio.jar'
                                        Source='..\RadioServer\lib\SerialIO\Serialio.jar' KeyPath='no'>
                                    </File>
                                </Component>
                            </Directory>
                        </Directory>
                    </Directory>

2 个答案:

答案 0 :(得分:0)

我目前刚刚创建了一个.bat文件,该文件通过定位我们包含的JRE javaw.exe文件来启动jar,并对桌面上的.bat文件进行了缩减。最简单的方法来获得我需要的结果。

答案 1 :(得分:0)

您收到错误是因为当Shortcut元素嵌套在File中时,其Target被假定为文件本身。

这不是您想要的,因此Shortcut元素应与MyApp.jar或其他组件并排。另外,当您将其作为参数传递给JRE时,您真的想使用MyApp.jar的完整路径。

相关问题