JNLP——NoSuchMethodException

JNLP - NoSuchMethodException

已经为这个问题苦苦挣扎了一段时间。我有一个带有主要方法的 class,当来自 Eclipse 的 运行 时,它工作得很好。无论如何,当我用我的 JNLP 文件将它(使用 maven-jar-plugin)压缩到 运行 时,我无法管理它开始工作。

我得到的错误如下:

java.lang.NoSuchMethodException: my.package.ishere.MainClass.main([Ljava.lang.String;)
    at java.lang.Class.getMethod(Unknown Source)
    at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
    at com.sun.javaws.Launcher.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

我的main方法在右包中,main方法是public,static,返回类型为void,参数为字符串数组

为了生成 jar 文件,我在 pom 中包含以下内容:

<plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <configuration>             
            <source>1.6</source>
            <target>1.6</target>
            <encoding>UTF-8</encoding> 
                <archive>
                        <manifestFile>${manifestFile}</manifestFile>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                            <mainClass>my.package.ishere.Mainclass</mainClass>
                        </manifest>
                        <addMavenDescriptor>false</addMavenDescriptor>
                    </archive>
                </configuration>
</plugin>

最后,在我的 JNLP 中,我正确地包含了代码库、所有必需的资源以及具有 main="true" 属性的 jar 文件。

此外,我什至检查了 jar 上的清单文件,它清楚地写着 Main-Class: my.package.ishere.MainClass。谁能给我提示下一步要检查什么?我要疯了!

(显然包名和 class 名称不是真实的)。

提前致谢!!

编辑:主要Class代码请求。

package my.package.ishere;

//HELLA long import list not going to add.

public class MainClass extends Frame implements WindowListener {

static String xmlParams;

public static void main(String[] args) {
    try {
            xmlParams = new String(base64Decoder.decodeBuffer(args[0]));
            MainClass mc = new MainClass();
            mc.setLayout(new FlowLayout());
            System.out.println(mc.getParameter("id"));
            mc.init();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

是我改成独立应用的旧小程序

更新:

设法让它工作 运行主 jar;添加了从 maven 到清单的 class 路径,并从命令提示符 i 运行 java -jar name-of-the-jar.jar param1 和是的,它起作用了。无论如何,都没有设法 运行 直接从 JNLP - 仍然得到 "NoSuchMethodException".

终于解决了。最重要的是 JNLP 语法不正确,因此导致我 "NoSuchMethodException" 因为它没有读取整个参数并卡在它们之间。

因此,作为一个解决方案,我必须做的是完全重建我的 JNLP 并重新设置参数,这样它就起作用了。感谢所有花时间阅读所有内容的人!