วันอังคารที่ 6 มกราคม พ.ศ. 2558

การเขียนโปรแกรมภาษา Java บนระบบปฏิบัติการ Debian 7.7 GNU/Linux



       Java เป็นภาษาคอมพิวเตอร์ขั้นสูงที่ใช้เขียนโปรแกรมเชิงวัตถุ (Objective Oriented Programming)

submarine@Sotharavej:~$ which java
/usr/bin/java
submarine@Sotharavej:~$

submarine@Sotharavej:~$ java -version
java version "1.6.0_33"
OpenJDK Runtime Environment (IcedTea6 1.13.5) (6b33-1.13.5-2~deb7u1)
OpenJDK Server VM (build 23.25-b01, mixed mode)
submarine@Sotharavej:~$
submarine@Sotharavej:~$
submarine@Sotharavej:~$ which javac
submarine@Sotharavej:~$
submarine@Sotharavej:~$
submarine@Sotharavej:~$ javac -version
bash: javac: command not found
submarine@Sotharavej:~$


submarine@Debian77:~$ su
Password:
root@Debian77:/home/submarine# echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list
deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main
root@Debian77:/home/submarine# echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main
root@Debian77:/home/submarine# apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /tmp/tmp.x42gGcJpsQ --trustdb-name /etc/apt//trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-jessie-stable.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-squeeze-automatic.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-squeeze-stable.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-wheezy-automatic.gpg --keyring /etc/apt/trusted.gpg.d//debian-archive-wheezy-stable.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
gpg: requesting key EEA14886 from hkp server keyserver.ubuntu.com
gpg: key EEA14886: public key "Launchpad VLC" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
root@Debian77:/home/submarine#
root@Debian77:/home/submarine#
root@Debian77:/home/submarine# apt-get update
Hit http://dl.google.com stable Release.gpg
Hit http://dl.google.com stable Release                                                                      
Get:1 http://security.debian.org wheezy/updates Release.gpg [836 B]                                          
Hit http://dl.google.com stable/main i386 Packages                                                          
Get:2 http://security.debian.org wheezy/updates Release [102 kB]                                            
Get:3 http://ppa.launchpad.net trusty Release.gpg [316 B]                                      
Hit http://ftp.us.debian.org wheezy Release.gpg                                                              
Ign http://dl.google.com stable/main Translation-en_US                      
Get:4 http://ppa.launchpad.net trusty Release [14.6 kB]                    
Get:5 http://ftp.us.debian.org wheezy-updates Release.gpg [836 B]                                          
Ign http://dl.google.com stable/main Translation-en                                                  
Get:6 http://security.debian.org wheezy/updates/main Sources [146 kB]        
Hit http://ftp.us.debian.org wheezy Release                                          
Get:7 http://ftp.us.debian.org wheezy-updates Release [124 kB]                                    
Get:8 http://ppa.launchpad.net trusty/main Sources [1,296 B]              
Get:9 http://ppa.launchpad.net trusty/main i386 Packages [2,857 B]        
Hit http://ftp.us.debian.org wheezy/main Sources              
Hit http://ftp.us.debian.org wheezy/main i386 Packages
Hit http://ftp.us.debian.org wheezy/main Translation-en
Get:10 http://ftp.us.debian.org wheezy-updates/main Sources [1,805 B]
Hit http://ftp.us.debian.org wheezy-updates/main i386 Packages/DiffIndex
Hit http://ftp.us.debian.org wheezy-updates/main Translation-en/DiffIndex
Fetched 394 kB in 16s (23.6 kB/s)                                                                            
Reading package lists... Done
root@Debian77:/home/submarine#
root@Debian77:/home/submarine#
root@Debian77:/home/submarine#
root@Debian77:/home/submarine# apt-get install oracle-java8-installer
Reading package lists... Done
Building dependency tree    
Reading state information... Done
The following extra packages will be installed:
  gsfonts-x11
Suggested packages:
  visualvm ttf-baekmuk ttf-unfonts ttf-unfonts-core ttf-kochi-gothic ttf-sazanami-gothic ttf-kochi-mincho
  ttf-sazanami-mincho ttf-arphic-uming
The following NEW packages will be installed:
  gsfonts-x11 oracle-java8-installer
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 33.0 kB of archives.
After this operation, 291 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://ftp.us.debian.org/debian/ wheezy/main gsfonts-x11 all 0.22 [10.6 kB]
Get:2 http://ppa.launchpad.net/webupd8team/java/ubuntu/ trusty/main oracle-java8-installer all 8u25+8u6arm-1~webupd8~1 [22.4 kB]
Fetched 33.0 kB in 1s (29.7 kB/s)              
Preconfiguring packages ...
Selecting previously unselected package oracle-java8-installer.
(Reading database ... 153310 files and directories currently installed.)
Unpacking oracle-java8-installer (from .../oracle-java8-installer_8u25+8u6arm-1~webupd8~1_all.deb) ...
Selecting previously unselected package gsfonts-x11.
Unpacking gsfonts-x11 (from .../gsfonts-x11_0.22_all.deb) ...
Processing triggers for desktop-file-utils ...
Processing triggers for gnome-menus ...
Processing triggers for shared-mime-info ...
Unknown media type in type 'all/all'
Unknown media type in type 'all/allfiles'
Unknown media type in type 'uri/mms'
Unknown media type in type 'uri/mmst'
Unknown media type in type 'uri/mmsu'
Unknown media type in type 'uri/pnm'
Unknown media type in type 'uri/rtspt'
Unknown media type in type 'uri/rtspu'
Processing triggers for fontconfig ...
Setting up oracle-java8-installer (8u25+8u6arm-1~webupd8~1) ...
Downloading Oracle Java 8...
--2015-01-06 12:02:56--  http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-i586.tar.gz
Resolving download.oracle.com (download.oracle.com)... 203.153.50.34, 203.153.50.56
Connecting to download.oracle.com (download.oracle.com)|203.153.50.34|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-i586.tar.gz [following]
--2015-01-06 12:02:56--  https://edelivery.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-i586.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 23.40.152.49
Connecting to edelivery.oracle.com (edelivery.oracle.com)|23.40.152.49|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-i586.tar.gz?AuthParam=1420520701_b35590fac63826575ca50692b5d69715 [following]
--2015-01-06 12:03:00--  http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-i586.tar.gz?AuthParam=1420520701_b35590fac63826575ca50692b5d69715
Connecting to download.oracle.com (download.oracle.com)|203.153.50.34|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 162406866 (155M) [application/x-gzip]
Saving to: `jdk-8u25-linux-i586.tar.gz'

     0K ........ ........ ........ ........ ........ ........  1%  946K 2m44s
  3072K ........ ........ ........ ........ ........ ........  3% 1.03M 2m33s
  6144K ........ ........ ........ ........ ........ ........  5%  888K 2m36s
  9216K ........ ........ ........ ........ ........ ........  7% 1.01M 2m30s
 12288K ........ ........ ........ ........ ........ ........  9% 1014K 2m26s
 15360K ........ ........ ........ ........ ........ ........ 11% 1.02M 2m21s
 18432K ........ ........ ........ ........ ........ ........ 13% 1.03M 2m17s
 21504K ........ ........ ........ ........ ........ ........ 15% 1.03M 2m13s
 24576K ........ ........ ........ ........ ........ ........ 17%  926K 2m11s
 27648K ........ ........ ........ ........ ........ ........ 19% 1016K 2m8s
 30720K ........ ........ ........ ........ ........ ........ 21% 1.01M 2m4s
 33792K ........ ........ ........ ........ ........ ........ 23% 1.03M 2m1s
 36864K ........ ........ ........ ........ ........ ........ 25% 1.03M 1m57s
 39936K ........ ........ ........ ........ ........ ........ 27% 1.03M 1m54s
 43008K ........ ........ ........ ........ ........ ........ 29% 1.00M 1m51s
 46080K ........ ........ ........ ........ ........ ........ 30% 1.01M 1m48s
 49152K ........ ........ ........ ........ ........ ........ 32% 1012K 1m45s
 52224K ........ ........ ........ ........ ........ ........ 34% 1.01M 1m42s
 55296K ........ ........ ........ ........ ........ ........ 36%  908K 99s
 58368K ........ ........ ........ ........ ........ ........ 38%  784K 98s
 61440K ........ ........ ........ ........ ........ ........ 40% 1.00M 94s
 64512K ........ ........ ........ ........ ........ ........ 42%  985K 91s
 67584K ........ ........ ........ ........ ........ ........ 44%  903K 89s
 70656K ........ ........ ........ ........ ........ ........ 46% 1.02M 85s
 73728K ........ ........ ........ ........ ........ ........ 48% 1.01M 82s
 76800K ........ ........ ........ ........ ........ ........ 50% 1.02M 79s
 79872K ........ ........ ........ ........ ........ ........ 52%  995K 76s
 82944K ........ ........ ........ ........ ........ ........ 54%  729K 74s
 86016K ........ ........ ........ ........ ........ ........ 56% 1.21M 70s
 89088K ........ ........ ........ ........ ........ ........ 58% 1.01M 67s
 92160K ........ ........ ........ ........ ........ ........ 60%  902K 64s
 95232K ........ ........ ........ ........ ........ ........ 61% 1016K 61s
 98304K ........ ........ ........ ........ ........ ........ 63%  906K 58s
101376K ........ ........ ........ ........ ........ ........ 65%  745K 55s
104448K ........ ........ ........ ........ ........ ........ 67%  947K 52s
107520K ........ ........ ........ ........ ........ ........ 69% 1.03M 49s
110592K ........ ........ ........ ........ ........ ........ 71% 1.03M 46s
113664K ........ ........ ........ ........ ........ ........ 73% 1022K 43s
116736K ........ ........ ........ ........ ........ ........ 75%  965K 40s
119808K ........ ........ ........ ........ ........ ........ 77%  922K 36s
122880K ........ ........ ........ ........ ........ ........ 79% 1.02M 33s
125952K ........ ........ ........ ........ ........ ........ 81%  930K 30s
129024K ........ ........ ........ ........ ........ ........ 83% 1.03M 27s
132096K ........ ........ ........ ........ ........ ........ 85%  824K 24s
135168K ........ ........ ........ ........ ........ ........ 87% 1.03M 21s
138240K ........ ........ ........ ........ ........ ........ 89% 1.02M 18s
141312K ........ ........ ........ ........ ........ ........ 91%  968K 15s
144384K ........ ........ ........ ........ ........ ........ 92% 1.02M 11s
147456K ........ ........ ........ ........ ........ ........ 94%  978K 8s
150528K ........ ........ ........ ........ ........ ........ 96% 1.03M 5s
153600K ........ ........ ........ ........ ........ ........ 98% 1.02M 2s
156672K ........ ........ ........ ......                    100% 1.03M=2m41s

2015-01-06 12:05:42 (985 KB/s) - `jdk-8u25-linux-i586.tar.gz' saved [162406866/162406866]

Download done.
Removing outdated cached downloads...
update-alternatives: using /usr/lib/jvm/java-8-oracle/jre/bin/ControlPanel to provide /usr/bin/ControlPanel (ControlPanel) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/jre/bin/java to provide /usr/bin/java (java) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/jre/bin/jcontrol to provide /usr/bin/jcontrol (jcontrol) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/jre/bin/jjs to provide /usr/bin/jjs (jjs) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/jre/bin/keytool to provide /usr/bin/keytool (keytool) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/jre/bin/orbd to provide /usr/bin/orbd (orbd) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/jre/bin/pack200 to provide /usr/bin/pack200 (pack200) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/jre/bin/policytool to provide /usr/bin/policytool (policytool) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/jre/bin/rmid to provide /usr/bin/rmid (rmid) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/jre/bin/rmiregistry to provide /usr/bin/rmiregistry (rmiregistry) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/jre/bin/servertool to provide /usr/bin/servertool (servertool) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/jre/bin/tnameserv to provide /usr/bin/tnameserv (tnameserv) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/jre/bin/unpack200 to provide /usr/bin/unpack200 (unpack200) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/jre/lib/jexec to provide /usr/bin/jexec (jexec) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/appletviewer to provide /usr/bin/appletviewer (appletviewer) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/extcheck to provide /usr/bin/extcheck (extcheck) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/idlj to provide /usr/bin/idlj (idlj) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/jar to provide /usr/bin/jar (jar) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/jarsigner to provide /usr/bin/jarsigner (jarsigner) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/javac to provide /usr/bin/javac (javac) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/javadoc to provide /usr/bin/javadoc (javadoc) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/javafxpackager to provide /usr/bin/javafxpackager (javafxpackager) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/javah to provide /usr/bin/javah (javah) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/javap to provide /usr/bin/javap (javap) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/javapackager to provide /usr/bin/javapackager (javapackager) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/jcmd to provide /usr/bin/jcmd (jcmd) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/jconsole to provide /usr/bin/jconsole (jconsole) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/jdb to provide /usr/bin/jdb (jdb) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/jdeps to provide /usr/bin/jdeps (jdeps) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/jhat to provide /usr/bin/jhat (jhat) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/jinfo to provide /usr/bin/jinfo (jinfo) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/jmap to provide /usr/bin/jmap (jmap) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/jmc to provide /usr/bin/jmc (jmc) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/jps to provide /usr/bin/jps (jps) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/jrunscript to provide /usr/bin/jrunscript (jrunscript) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/jsadebugd to provide /usr/bin/jsadebugd (jsadebugd) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/jstack to provide /usr/bin/jstack (jstack) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/jstat to provide /usr/bin/jstat (jstat) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/jstatd to provide /usr/bin/jstatd (jstatd) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/jvisualvm to provide /usr/bin/jvisualvm (jvisualvm) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/native2ascii to provide /usr/bin/native2ascii (native2ascii) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/rmic to provide /usr/bin/rmic (rmic) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/schemagen to provide /usr/bin/schemagen (schemagen) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/serialver to provide /usr/bin/serialver (serialver) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/wsgen to provide /usr/bin/wsgen (wsgen) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/wsimport to provide /usr/bin/wsimport (wsimport) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/xjc to provide /usr/bin/xjc (xjc) in auto mode
update-binfmts: warning: current package is oracle-java8, but binary format already installed by openjdk-6
Oracle JDK 8 installed
update-alternatives: using /usr/lib/jvm/java-8-oracle/jre/lib/i386/libnpjp2.so to provide /usr/lib/mozilla/plugins/libjavaplugin.so (mozilla-javaplugin.so) in auto mode
Oracle JRE 8 browser plugin installed
Setting up gsfonts-x11 (0.22) ...
root@Debian77:/home/submarine#
root@Debian77:/home/submarine#
root@Debian77:/home/submarine#
root@Debian77:/home/submarine# exit
exit
submarine@Debian77:~$
submarine@Debian77:~$
submarine@Debian77:~$ java --version
Unrecognized option: --version
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
submarine@Debian77:~$
submarine@Debian77:~$
submarine@Debian77:~$
submarine@Debian77:~$ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) Client VM (build 25.25-b02, mixed mode)
submarine@Debian77:~$
submarine@Debian77:~$
submarine@Debian77:~$
submarine@Debian77:~$ javac -version
javac 1.8.0_25
submarine@Debian77:~$


submarine@Debian77:~$ mkdir Java
submarine@Debian77:~$ cd java
bash: cd: java: No such file or directory
submarine@Debian77:~$ cd Java/
submarine@Debian77:~/Java$
submarine@Debian77:~/Java$
submarine@Debian77:~/Java$ pico helloworld.java
submarine@Debian77:~/Java$
submarine@Debian77:~/Java$ javac helloworld.java
submarine@Debian77:~/Java$
submarine@Debian77:~/Java$ ls
HelloWorld.class  helloworld.java
submarine@Debian77:~/Java$
submarine@Debian77:~/Java$ java HelloWorld
Hello, World! ทดสอบภาษาไทยบน Java
submarine@Debian77:~/Java$
submarine@Debian77:~/Java$
submarine@Debian77:~/Java$


ไม่มีความคิดเห็น:

แสดงความคิดเห็น