ubuntu中运行java程序
查找jdk
rivsidn@rivsidn:~/demo/java$ sudo apt-cache search jdk default-jdk - Standard Java or Java compatible Development Kit
安装
rivsidn@rivsidn:~/demo/java$ sudo apt-get install default-jdk
示例代码
rivsidn@rivsidn:~/demo/java$ cat Welcome.java public class Welcome { public static void main(String[] args) { String greeting = "Welcome to Core Java!"; System.out.println(greeting); } }
编译,执行
rivsidn@rivsidn:~/demo/java$ javac Welcome.java rivsidn@rivsidn:~/demo/java$ java Welcome Welcome to Core Java!