###### tags: `Raspberry Pi` `Ubuntu` `Java` `系統安裝` `IoT` # **在Raspberry Pi上安裝Ubuntu Classic Server 16.04及Java** ## 硬體 Raspberry Pi 3 | | Raspberry Pi 3| |:---:|:-------| |SoC|Broadcom BCM2837(CPU,GPU DSP和SDRAM、USB) |CPU|ARM Cortex-A53 64位元 (ARMv8系列) 1.2GHz (四核心) |GPU|Broadcom VideoCore IV[43], OpenGL ES 2.0, 1080p 30 h.264/MPEG-4 AVC高畫質解碼器 |記憶體|1024 MB (LPDDR2) |影像輸出|畫面用RCA端子(PAL & NTSC)、HDMI,HDMI介面可使用14種解析度,分別從640×350到1920×1200之間 |板載儲存|MicroSD卡插槽 |網路介面|10/100Mbps 乙太網介面(RJ45介面),支援802.11n無線網路及藍牙4.1 --- ## 安裝作業系統(利用Windows安裝) 1. 官方連結下載OS: [下載連結](https://ubuntu-pi-flavour-maker.org/download/) 此處使用:Ubuntu Classic Server 16.04(Raspberry Pi 3)  2. 解壓縮下載下來的壓縮檔,得到一個img映像檔  3. 利用讀卡機將SD卡讀入電腦中 4. 使用[SD卡格式化工具SDFormatter](https://www.sdcard.org/cht/downloads/formatter_4/)將SD卡格式化。 此處使用SDFormatter V4.0  5. 使用[Win32 Disk Imager](https://sourceforge.net/projects/win32diskimager/)將img映像檔燒錄到SD卡中 此處使用Win32 Disk Imager V0.9.5  6. 將SD卡安全拔出,並插入PI 3中,接上HDML線 **PI3沒有開機鍵,接上電源線就開機** **沒接上乙太網路線將會出現** ==a start job is runnung for Raise network interfaces (1s / 5min 16s)== **由於要等五分鐘,因此推薦將網路線插上使用** --- ## 設定Ubuntu Classic Server 16.04 --- ### 網路設定 --- 1. **修改hosts:** 輸入指令: `sudo nano /etc/hosts` 修改如下所示(此以127.0.1.1): ``` 127.0.0.1 localhost 127.0.1.1 yourUserName ``` 2. **縮短開機時沒抓到網路的等待時間:** 利用指令打開networking.service檔案: ` sudo nano /etc/systemd/system/network-online.target.wants/networking.service ` 把這行改掉: ` TimeoutStartSec=5min ` 本次縮短成10秒: ` TimeoutStartSec=10sec ` 存檔跳出,並輸入下方指令: ` sudo systemctl daemon-reload ` 3. **有線網路** 預設開機就會自動開啟,因此網路線插上即能連線(dhcp)。 4. **無線網路(請先接網路線)** **(1) 安裝wireless-tools:** ` sudo apt-get install wireless-tools ` **(2) 安裝wpasupplicant:** ` sudo apt-get install wpasupplicant ` **(3) 更新:** ` sudo apt-get update ` **(4) 編輯interfaces文件:** ` sudo nano /etc/network/interfaces ` 如下所示: ``` auto lo iface lo inet loopback auto wlan0 iface wlan0 inet dhcp wpa-ssid "yourWifiName" wpa-psk "yourPassword" wireless-power off #此行是為了避免無線網路關閉 ``` - ==為了避免pi不要進入省電或自動將無線網路關掉修改:== `sudo nano /etc/kbd/config` 如下所示: ``` BLANK_TIME=0 POWERDOWN_TIME=0 ``` **(5) 重新開機:** `reboot` - ==想看現在wifi掃描到哪些AP== ` sudo iwlist wlan0 scan ` --- ### JAVA安裝 --- 1. 加入JAVA ppa: ` sudo add-apt-repository ppa:webupd8team/java ` 2. 更新: ` sudo apt-get update ` 3. 看有什麼java可以裝: ` apt-cache search oracle-java ` 4. 裝java jdk(此裝 java8): ` sudo apt-get install oracle-java8-installer ` 5. 測試是否成功(java): ` java -version ` 成功: ==java version "1.8.0_144"== 6. 測試是否成功(javac): ` javac -version ` 成功: ==javac 1.8.0_144== * 多版本java切換,如果有設定多個java ` sudo update-alternatives --config java ` * 如果要手動安裝,指令下載oracle的官網的java方式 ``` wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-arm64-vfp-hflt.tar.gz ``` * **推薦使用短網址** ``` wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://goo.gl/zzmjK9 -O jdk-8u144-linux-arm64-vfp-hflt.tar.gz ``` --- ## 參考文章 [有線 或 無線 的DHCP 設定或固定IP設定](https://sites.google.com/site/raspberypishare0918/home/di-yi-ci-qi-dong/1-6-you-xian-huo-wu-xian-dedhcp) [How to use onboard wifi on Raspberry Pi 3 with Ubuntu Server 16.04?](https://askubuntu.com/questions/775597/how-to-use-onboard-wifi-on-raspberry-pi-3-with-ubuntu-server-16-04) [A start job is running for raise network interfaces (5 mins 1 sec) in ubuntu16.04](https://ubuntuforums.org/showthread.php?t=2323253) [Ubuntu 16.04 - system boot waits saying “Raise network interfaces”](https://askubuntu.com/questions/773973/ubuntu-16-04-system-boot-waits-saying-raise-network-interfaces) [Setting up Wifi with the Command Line](https://learn.adafruit.com/adafruits-raspberry-pi-lesson-3-network-setup/setting-up-wifi-with-occidentalis) [想請問如何在ubuntu下執行JAVA [論壇 - 新手村]](https://www.ubuntu-tw.org/modules/newbb/viewtopic.php?viewmode=compact&topic_id=48704&forum=22) [[Linux] 如何在 Ubuntu 14.04 中安裝 Oracle/Open JDK](http://www.team-bob.org/linux-%E5%A6%82%E4%BD%95%E5%9C%A8-ubuntu-14-04-%E4%B8%AD%E5%AE%89%E8%A3%9D-oracleopen-jdk/) [Ubuntu:RaspberryPi](https://wiki.ubuntu.com/ARM/RaspberryPi)
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.