Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/394.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 JNLP、Webstart和Maven_Java_Maven_Jnlp_Java Web Start - Fatal编程技术网

Java JNLP、Webstart和Maven

Java JNLP、Webstart和Maven,java,maven,jnlp,java-web-start,Java,Maven,Jnlp,Java Web Start,我创建了一个简单的Hello World Swing应用程序,它可以在Eclipse中编译并运行良好。我现在正试图将此应用程序转换为Maven包结构,并将其作为JavaWebStart应用程序运行,这给我带来了极大的痛苦。在运行“mvn clean install”之后,javaws似乎会加载几秒钟,然后退出 这里有一些东西可供参考。我的(非常简单的)项目应该是完全可复制的: 包结构(来自树): Primary pom.xml: <project xmlns="http://maven.a

我创建了一个简单的Hello World Swing应用程序,它可以在Eclipse中编译并运行良好。我现在正试图将此应用程序转换为Maven包结构,并将其作为JavaWebStart应用程序运行,这给我带来了极大的痛苦。在运行“mvn clean install”之后,javaws似乎会加载几秒钟,然后退出

这里有一些东西可供参考。我的(非常简单的)项目应该是完全可复制的:

包结构(来自树):

Primary pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.shaunabram.swingwebstartmaven</groupId>
    <artifactId>SwingWebstartMaven</artifactId>
    <packaging>pom</packaging>
    <version>1.0</version>
    <name>SwingWebstartMaven Project</name>

    <modules>
        <module>SwingWebstartMaven-Client</module>
        <module>SwingWebstartMaven-Web</module>
    </modules>

    <build>
        <pluginManagement>
            <plugins>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>tomcat-maven-plugin</artifactId>
                    <configuration>
                        <url>http://localhost:8080/manager</url>
                        <username>tomcat</username>
                        <password>tomcat</password>
                    </configuration>
                </plugin>

            </plugins>
        </pluginManagement>
    </build>

</project>
template.vm:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://localhost:8080/SwingWebstartMaven-Web/webstart" href="$outputFile">
 <information>
    <title>Swing Webstart Maven Project</title>
    <vendor>ShaunAbram</vendor>
 </information>
 <security>
 <all-permissions/>
 </security>
 <resources>
    <j2se version="1.5+" initial-heap-size="32m" max-heap-size="128m" />
    <property name="jnlp.versionEnabled" value="false"/>
    $dependencies
 </resources>
 <application-desc main-class="$mainClass">
 </application-desc>
</jnlp>
编辑:问题与此相同:除了在Ubuntu机器上。我很难理解作者的解决方案将如何转化为Ubuntu(我尝试将JAVAWS_HOME设置为我的jre bin并重新运行JAVAWS,但它给了我同样的问题(即Java6启动屏幕启动,然后停止,没有找到任何程序))。双击launch.jnlp在Java7中运行它(不是我想要的)并吐出

"Error: Unable to load resource: http://localhost:8080/SwingWebstartMaven-Web/webstart/launch.jnlp." 

在那之后,我尝试了其他一些事情。主pom.xml有tomcat插件,我没有使用它,所以我尝试删除它,但什么也没做。然后,我尝试实际创建一个tomcat服务器,并将项目文件夹放在/var/lib/tomcat7/webapps/中。这也不会影响错误的改变。

阅读Web Start的实际功能;它是一种读取描述符(例如,填充的
template.vm
)并从中下载和启动常规Java应用程序(与小程序相反)的机制。如果您是从命令行运行的,并且已经有了jar,那么它是多余的。如果您真的想使用它,您需要将
template.vm
编辑到本地代码库中,然后使用
javaws-sheet.jnlp
。请参阅
javaws
的手册页及其包含的链接


至于Maven问题,您似乎没有安装引用的父POM,因此Maven不知道从何继承。您需要在父POM上执行相同的更改,安装,然后在子POM上工作。

“失败”?您是否也在类的包名中替换了shaunabram?是的。我不好不提那件事;OP更新。如果你否决我,你能解释为什么吗?是免费的代码片段还是这真是一个愚蠢的问题?有什么更好的方法来表达这个问题呢?投票结果:我花了2天(和晚上)的时间用相同的组合(Swing、Maven和JNLP)来追踪bug。我最终在ANT中重写了maven webstart插件。。。因为无法更改所有依赖项中的清单文件。似乎Maven中对JNLP的所有支持对于生产使用来说都过于简单化了。@HeetK。我这样做是为了用新的清单属性“Permissions:all Permissions”和“Codebase:${URL}”更新所有依赖的JAR,这些属性是在Java7U25周围引入的。目前它们只会引起警告,但在将来的版本中可能会成为错误。Maven webstart插件有一个特定的bug(已经有一个补丁了),但是它还没有被集成。是的,我在大约半小时前意识到POM文件有什么问题。大德普时刻。至于javaws。。。在添加了所有旧的父文件并运行javaws launch.jnlp之后,我遇到了一个老问题:点击Java 6 splash动画,该动画在退出之前运行了大约18秒。早上我会用更多相关信息更新OP。
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.shaunabram.swingwebstartmaven</groupId>
        <artifactId>SwingWebstartMaven</artifactId>
        <version>1.0</version>
    </parent>

    <artifactId>SwingWebstartMaven-Web</artifactId>
    <packaging>war</packaging>
    <name>SwingWebstartMaven Web</name>

    <dependencies>

    </dependencies>

</project>
package com.shaunabram.swingwebstartmaven;

import javax.swing.JFrame;
import javax.swing.JLabel;

public class HelloWorldSwing {
  public static void main(String[] args) {
    JFrame frame = new JFrame("HelloWorldSwing");
    final JLabel label = new JLabel("Hello World");
    frame.getContentPane().add(label);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
  }
}
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://localhost:8080/SwingWebstartMaven-Web/webstart" href="$outputFile">
 <information>
    <title>Swing Webstart Maven Project</title>
    <vendor>ShaunAbram</vendor>
 </information>
 <security>
 <all-permissions/>
 </security>
 <resources>
    <j2se version="1.5+" initial-heap-size="32m" max-heap-size="128m" />
    <property name="jnlp.versionEnabled" value="false"/>
    $dependencies
 </resources>
 <application-desc main-class="$mainClass">
 </application-desc>
</jnlp>
[ERROR]   The project com.kothur.swingwebstartmaven:SwingWebstartMaven-Client:1.0 (/media/reivei/New Volume/Project Files/SwingWebstartMaven/SwingWebstartMaven-Client/pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM: Failure to find com.kothur.swingwebstartmaven:SwingWebstartMaven:pom:1.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 6, column 13 -> [Help 2]
"Error: Unable to load resource: http://localhost:8080/SwingWebstartMaven-Web/webstart/launch.jnlp."