我正在尝试使用Eclipse的Web Start Plugin(http://webstart.sourceforge.net/)让Java Web Start处理应用程序。我尝试按照本教程进行操作,但是当我完成它并启动JNLP文件时,它失败并出现“应用程序错误”,并说“意外异常:java.util.NoSuchElementException。
显示的启动文件是:
<?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>
并且异常堆栈跟踪是:
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)
答案 0 :(得分:0)
java.util.NoSuchElementException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at ascllandgame.ASCLLand.main(ASCLLand.java:16)
您正在ascllandgame.ASCLLand
类的main()
类的第16行中调用Scanner#next()
。但是,没有更多可用的令牌,因此此调用将抛出此异常(根据链接的Javadoc;读取它)。您可能希望使用Scanner#hasNext()
预先检查它。
您可以在此处找到基本的Sun tutorial about the subject。