Reputation: 249
Been struggling with this issue for a while already. I have a class, with a main method, which works perfectly fine when ran from Eclipse. No matter what, when i jar it (with maven-jar-plugin) to run it with my JNLP file i can't manage it to get to work.
The error im getting is as follows:
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)
My main method is in the right package, and the main method is public, static, returning type is void and has an array of strings as the parameter.
In order to generate the jar file, in the pom I include the following:
<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>
Finally, in my JNLP, I'm including the codebase correctly, all the required resources correctly, and the jar file with the main="true" attribute.
Furthermore, I even checked the manifest file on the jar and it says clearly Main-Class: my.package.ishere.MainClass. Could anyone give me a hint on what to check next? I'm going nuts!
(Obviously the package name and the class name ain't the real ones).
Thanks in advance!!
EDIT: MainClass code on request.
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();
}
}
}
It is an old applet I converted into a stand-alone application.
UPDATE:
Managed to make it work running the main jar; added the classpath from maven to the manifest and from the command prompt i ran java -jar name-of-the-jar.jar param1
and yay, it worked. No matter what, haven't managed to run it straight from the JNLP - still getting the "NoSuchMethodException".
Upvotes: 1
Views: 548
Reputation: 249
Finally got to solve it. The big deal was the JNLP syntax wasn't correct, therefore induced me to a "NoSuchMethodException" because it didn't get to read the whole parameters and got stuck in between them.
So, as a solution, what I had to do was rebuild completely my JNLP and re-set the parameters, and so it worked. Thanks to everyone who spent some time reading all that stuff!
Upvotes: 0