Search code examples
javajarjnlpclassnotfoundexceptionjava-web-start

Deploying JNLP file on a server (NOT a localserver)


Configuring Web Start. I tried to look it up but could not find the answer to my error.

java.lang.ClassNotFoundException: Webstart.Main
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(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)

On my server I have:

test.jar
Webstart.jnlp

And here is my .jnlp file

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://www.[mywebsite].com/_webstart/" href="webstart.jnlp">
  <information>
    <title>JFrame Deom</title>
    <vendor>[ME]</vendor>
    <homepage href="http://www.[mywebsite].com" />
    <description>A Java Webstart Test</description>
    <offline-allowed />
  </information>
  <resources>
    <j2se version="1.7" />
    <jar href="Webstart.jar" />
  </resources>
  <security>
    <all-permissions />
  </security>
  <application-desc main-class="Webstart.Main" />
</jnlp>

And here is my Java Class:

import java.awt.BorderLayout;
import javax.swing.*;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        JFrame f = new JFrame("My Frame");
        f.setSize(250,250);
        f.setLocation(300,300);
        f.getContentPane().add(BorderLayout.CENTER, new JTextArea(10,40));
        f.setVisible(true);
    }
} 

The way I run the file is by typing the name into web browser URL.

I am new to it so would really appreciate any help or supportive comments. Thank you in advance.


Solution

  • Two problems I see right off the bat.

    1. In your JNLP file you specified your JAR as Webstart.jar, but in your deployment its called test.jar
    2. In your JNLP file you specified your main class as Webstart.Main, but your Main class is not in any package (that you included in your posted code).