lundi 11 mai 2015

JNLP File Error; java.lang.NumberFormatException: For input string:

This is not my code. I'm just taking this for example because my real codes are long. I'm using Netbeans and i already enabled the Java Web Start on the project where this code located.

import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class Tester2 {

    /**
     * Create the GUI and show it. For thread safety, this method should be
     * invoked from the event-dispatching thread.
     */
    private static void createAndShowGUI() {
        //Make sure we have nice window decorations.
        JFrame.setDefaultLookAndFeelDecorated(true);

        //Create and set up the window.
        JFrame frame = new JFrame("HelloJWS");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //Add the "HelloJWS" label.
        JLabel label = new JLabel();
        label.setHorizontalAlignment(JLabel.CENTER);
        label.setFont(label.getFont().deriveFont(Font.PLAIN));
        frame.getContentPane().add(label);

        //Set label text after testing for Java Web Start.
        String text = null;
        try {
            Class sm = javax.jnlp.ServiceManager.class;

      //If we reach this line, we're running in an environment
            //such as Java Web Start that provides JNLP services.
            text = "<html>You're running an application "
                    + "using Java<font size=-2><sup>TM</sup></font> "
                    + "Web Start!</html>";
        } catch (java.lang.NoClassDefFoundError e) {
            //If no ServiceManager, we're not in Java Web Start.
            text = "<html>You're running an application, "
                    + "but <b>not</b> using "
                    + "Java<font size=-2><sup>TM</sup></font> "
                    + "Web Start!</html>";
        }
        label.setText(text);

        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }

    public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                createAndShowGUI();
            }
        });
    }
}

So when i run this code by pressing F6, it was always thrown to the catch. I don't know why. And when i try to build this code and open the Netbeans generated JNLP for this project, it shows Unable to launch the application. And when i click into Details it shows this two tab named Launch File, and Exception.

The Launch File has this log.

<jnlp codebase="file:/C:/Users/you/Documents/NetBeansProjects/Tester2/dist/" href="launch.jnlp" spec="1.0+">
  <information>
    <title>Tester2</title>
    <vendor>you</vendor>
    <homepage href=""/>
    <description>Tester2</description>
    <description kind="short">Tester2</description>
  </information>
  <update check="always"/>
  <security>
    <all-permissions/>
  </security>
  <resources>
    <j2se version="1.7+"/>
    <jar href="Tester2.jar" main="true"/>
  </resources>
  <application-desc main-class="Tester2,class"/>
</jnlp>

And the Exception tab has this log.

java.lang.NumberFormatException: For input string: "\Users\you\Documents\NetBeansProjects\Tester2\dist"
        at java.lang.NumberFormatException.forInputString(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at com.sun.deploy.security.DeployManifestChecker.verifyCodebaseEx(Unknown Source)
        at com.sun.deploy.security.DeployManifestChecker.verifyCodebase(Unknown Source)
        at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
        at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
        at com.sun.javaws.security.AppPolicy.grantUnrestrictedAccess(Unknown Source)
        at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResourcesHelper(Unknown Source)
        at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResources(Unknown Source)
        at com.sun.javaws.Launcher.prepareResources(Unknown Source)
        at com.sun.javaws.Launcher.prepareAllResources(Unknown Source)
        at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
        at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
        at com.sun.javaws.Launcher.launch(Unknown Source)
        at com.sun.javaws.Main.launchApp(Unknown Source)
        at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
        at com.sun.javaws.Main.access$000(Unknown Source)
        at com.sun.javaws.Main$1.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

How to get rid this problem?

Aucun commentaire:

Enregistrer un commentaire