簡體   English   中英

如何使用桌面快捷方式啟動.jar文件(針對特定的jre)

[英]How do I launch a .jar file with desktop shortcut (targeting a specific jre)

我正在嘗試創建一個桌面快捷方式,它將啟動我們的.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>

我目前剛剛創建了一個.bat文件,該文件通過定位我們包含的JRE javaw.exe文件來啟動jar,並在桌面上對該.bat文件進行了快捷方式。 獲得所需結果的最簡單方法。

之所以會出現錯誤,是因為當Shortcut元素嵌套在File ,它的Target被假定為文件本身。

這不是您想要的,因此Shortcut元素應該與MyApp.jar或另一個組件並排MyApp.jar 另外,當您將MyApp.jar的完整路徑作為參數傳遞給JRE時,您真的很想使用它的完整路徑。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM