在ubuntu 10.10上安装jdk1.7.0

aka*_*man 5 java ubuntu

我是ubuntu 10.10的新手,并将其用作VM.我尝试安装jdk 1.7从终端运行java程序.我按照链接中的说明操作:如何在Ubuntu Linux上安装Oracle Java.安装完成后,我尝试测试运行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)    
Run Code Online (Sandbox Code Playgroud)

包裹异常

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)
Run Code Online (Sandbox Code Playgroud)

此外,我尝试检查我的版本java使用java -version,它给出了以下输出:

 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
Run Code Online (Sandbox Code Playgroud)

我在这里看到它javaws在我尝试运行程序时的使用java.

我不明白为什么会发生这种情况或出现什么问题.任何帮助将非常感谢.我只是Ubuntu的初学者.提前致谢!!


编辑1 Hello.java:

public class Hello
{
    public static void main(String... s)
    {
        System.out.println("Hello World.!!!");
    }
}
Run Code Online (Sandbox Code Playgroud)

Mar*_*ler 2

您的输出为java -version您提供了 javaws -version 的输出。所以这似乎是您的文件系统中的链接错误。如果您使用 update-alternatives,您将在二进制文件夹 (/usr/bin) 中创建一个符号链接。也许您在学习教程时遇到了一些拼写错误?我很确定它是类似的东西 sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0_05/bin/javaws" 1

您可以尝试重新输入“update-alternative”命令。