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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.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 如何使用桌面快捷方式启动.jar文件(针对特定的jre)_Java_Windows_Wix_Shortcut - Fatal编程技术网

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

Java 如何使用桌面快捷方式启动.jar文件(针对特定的jre),java,windows,wix,shortcut,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

我正在尝试创建一个桌面快捷方式来启动我们的.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
当快捷方式元素嵌套在文件元素下面时

但根据这一点:它应该起作用。我尝试在file元素之外创建一个快捷方式,作为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文件的shorcut。获取所需结果的最简单方法。

之所以会出现错误,是因为当快捷方式元素嵌套在文件中时,其目标被假定为文件本身


这不是您想要的,因此快捷方式元素应该与MyApp.jar并排或在另一个组件中。另外,当您将MyApp.jar作为参数传递给JRE时,您确实希望使用它的完整路径。

您是否考虑过部署该应用程序。使用?JWS不仅可以确保特定的JRE版本,还可以安装桌面快捷方式和菜单项来启动应用程序。在跨Windows、OS X和*nix的受支持操作系统上。该应用程序将安装在封闭系统上,无法访问外部internet,因此无法工作。谢谢你的建议。我目前刚刚创建了一个.bat文件,它通过指向我们包含的JRE javaw.exe文件来启动jar,并且在桌面上有一个指向.bat文件的shorcut。