views:

101

answers:

1

I'm attempting to get Java Web Start to work on an application by using the Web Start Plugin for Eclipse (http://webstart.sourceforge.net/). I tried following the tutorial, but when I completed it and went to launch the JNLP file, it failed with an Application Error, saying "Unexpected exception: java.util.NoSuchElementException.

The launch file displayed is:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp
        codebase="file:/C:/Documents and Settings/10boyedevi/Desktop/School/AP Computer Science/Eclipse Workspace/ACSLLand/localhost/club/" href="file:/C:/Documents and Settings/10boyedevi/Desktop/School/AP Computer Science/Eclipse Workspace/ACSLLand/localhost/club/_local_club.jnlp">
        <information>
                <title>ACSLLand</title>
                <vendor>AP Comp Sci 2009-2010</vendor>
                <description kind="default">A game.</description>
        </information>
        <security>
                <all-permissions/>
        </security>
        <resources arch="x86" os="Windows">
                <j2se version="1.3+"/>
                <jar href="ASCLLand.jar" main="true"/>
        </resources>
        <application-desc main-class="ascllandgame.ASCLLand"/>
</jnlp>

and the exception stack trace is:

java.util.NoSuchElementException
 at java.util.Scanner.throwFor(Unknown Source)
 at java.util.Scanner.next(Unknown Source)
 at ascllandgame.ASCLLand.main(ASCLLand.java:16)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at com.sun.javaws.Launcher.executeApplication(Unknown Source)
 at com.sun.javaws.Launcher.executeMainClass(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)
A: 
java.util.NoSuchElementException
 at java.util.Scanner.throwFor(Unknown Source)
 at java.util.Scanner.next(Unknown Source)
 at ascllandgame.ASCLLand.main(ASCLLand.java:16)

You're calling Scanner#next() in line 16 of your ascllandgame.ASCLLand class, inside the main() method. However, there are no more tokens available, so this call will throw this exception (as per the linked Javadoc; read it). Probably you want to check it beforehand using Scanner#hasNext().

You can find here a basic Sun tutorial about the subject.

BalusC
Now is there a reason this only cropped up now when I tried to export it as a Java Web Start app, as I've run the app (console based keyboard input) successfully before (i.e., within Eclipse).
Devin