【发布时间】:2012-07-01 15:49:03
【问题描述】:
我是 ubuntu 10.10 的新手,并将其用作 VM。我尝试安装 jdk 1.7 以从终端运行 java 程序。我按照链接中的说明进行操作:How to Install Oracle Java on Ubuntu Linux。安装完成后,我尝试运行一个Hello World java程序。当我执行javac Hello.java 时,程序编译成功。但是,当我尝试使用java Hello 运行程序时,它没有在终端上提供任何输出,而是给了我以下信息:
无法启动应用程序。
例外:
CouldNotLoadArgumentException[ Could not load file/URL specified: Hello]
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:722)
包装异常
java.io.FileNotFoundException: Hello (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:97)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:722)
我还尝试使用java -version 检查我的版本java,它给出了以下输出:
Java(TM) Web Start 10.0.0.147-fcs
Usage: javaws [run-options] <jnlp-file>
javaws [control-options]
where run-options include:
-verbose display additional output
-offline run the application in offline mode
-system run the application from the system cache only
-Xnosplash run without showing a splash screen
-J<option> supply option to the vm
-wait start java process and wait for its exit
control-options include:
-viewer show the cache viewer in the java control panel
-clearcache remove all non-installed applications from the cache
-uninstall remove all applications from the cache
-uninstall <jnlp-file> remove the application from the cache
-import [import-options] <jnlp-file> import the application to the cache
import-options include:
-silent import silently (with no user interface)
-system import application into the system cache
-codebase <url> retrieve resources from the given codebase
-shortcut install shortcuts as if user allowed prompt
-association install associations as if user allowed prompt
当我尝试使用java 运行程序时,我在这里看到它使用javaws。
我不明白为什么会这样或出了什么问题。任何帮助将不胜感激。我只是 Ubuntu 的初学者。 提前致谢!!
编辑 1 你好.java:
public class Hello
{
public static void main(String... s)
{
System.out.println("Hello World.!!!");
}
}
【问题讨论】:
-
您需要显示
Hello.java。 -
我现在提供了它作为编辑。
-
奇怪,请问您为什么使用 Ubuntu 10.10(相当过时)?如果从安装目录中调用 java,输出是什么?
-
它给出以下输出:
Hello.java:1: error: error while writing Hello: Hello.class (Permission denied) public class Hello ^ 1 error是的,我知道它已经过时了,我很快就会升级。 -
抱歉,我的意思是从 Java 安装目录调用
java -version...