在ubuntu 10.10上安装jdk1.7.0

时间:2012-07-01 15:49:04

标签: java ubuntu

我是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检查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

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

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


修改1 Hello.java:

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

2 个答案:

答案 0 :(得分: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”命令。

答案 1 :(得分:0)

当12.04可用时,我不确定你想要10.10。我安装了Sun / Oracle版本,它第一次运行。您所要做的就是下载它,解压缩并将其添加到您的路径中。

错误消息表明Java未正确安装。

我建议你也安装像IntelliJ CE这样的免费IDE。这将使您的应用程序的编写,编译,运行和调试变得更加容易。

相关问题