ubuntu安装java环境

 

apt-get install sun-javadb-javadoc sun-javadb-doc sun-javadb-demo  sun-javadb-core sun-javadb-common sun-javadb-client

  apt-get install  ecj default-jdk openjdk-7-jdk gcj-4.8-jdk


IDE

http://www.eclipse.org/downloads/

http://mirror.bit.edu.cn/eclipse/technology/epp/downloads/release/luna/SR1a/eclipse-java-luna-SR1a-linux-gtk-x86_64.tar.gz

https://yoxos.eclipsesource.com/downloadEclipse.html?JAVA-LINUX64


创建全局命令


   mv  /tmp/eclipse  /usr/lib/

  这样做是因为$PATH这个环境变量自动涵盖了/usr/lib这个目录,不用专门去修改环境变量。

    然后键入:

    ln -s /usr/lib/eclipse/eclipse /usr/bin/eclipse

创建图标 每行末尾不能有空格

 [Desktop Entry]

Encoding=UTF-8

Name=Eclipse Platfrom

Comment=Eclipse IDE

Exec=/usr/lib/eclipse/eclipse

Icon=/usr/lib/eclipse/icon.xpm

Terminal=false

StartupNotify=true

Type=Application

Categories=Application;Development;



 java -version

java version "1.7.0_75"

OpenJDK Runtime Environment (IcedTea 2.5.4) (7u75-2.5.4-1~trusty1)

OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)





 HelloWorld.java

public class HelloWorld

       {

            public static void main(String[] args)

            {

                 System.out.println("Hello,World!");

                 return;

             }

       }



javac  HelloWorld.java 

生成 

HelloWorld.class


文件名必须和方法名一致,否则报错

Hello.java:1: error: class HelloWorld is public, should be declared in a file named HelloWorld.java

public class HelloWorld 

       ^

1 error


你可能感兴趣的:(ubuntu安装java环境)