安裝Java
關閉所有視窗,同時按下Ctrl + Alt + T 打開終端畫面,
接著安裝JDK,下列的方式是安裝1.6.x版本。
Installing the JDK
下載 jdk-6uXX-linux-x64.bin
$ sudo apt-get purge openjdk*
$ chmod +x jdk-6u32-linux-x64.bin <--將bin檔設定可執行
$ ./jdk-6u32-linux-x64.bin
$ sudo mv jdk1.6.0_32 /usr/lib/jvm/
Install new java source in system:
$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_32/bin/javac 1
$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_32/bin/java 1
Choose default java:
$ sudo update-alternatives --config javac <--設定預設Javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-7-oracle/bin/javac 1 auto mode
1 /usr/lib/jvm/java-7-oracle/bin/javac 1 manual mode
2 /usr/lib/jvm/jdk1.6.0_32/bin/javac 1 manual mode
Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk1.6.0_32/bin/javac to provide /usr/bin/javac (javac) in manual mode.
$ sudo update-alternatives --config java <--設定預設Java
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-7-oracle/bin/java 1 auto mode
1 /usr/lib/jvm/java-7-oracle/bin/java 1 manual mode
2 /usr/lib/jvm/jdk1.6.0_32/bin/java 1 manual mode
Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk1.6.0_32/bin/java to provide /usr/bin/java (java) in manual mode.
安裝完成後執行java -version指令看到如下訊息出現表示安裝完成。
$ java -version
java version "1.6.0_32"
Java(TM) SE Runtime Environment (build 1.6.0_32-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.7-b02, mixed mode)
參考:http://cheng-min-i-taiwan.blogspot.com/2012/05/ubuntu-1204-lts-android-sdk.html
FLYing's Computer Information
我的備忘錄!!
2012年5月17日 星期四
Auto mount partitions using Storage Device Manager (pysdm)
sudo apt-get install pysdm
sudo pysdm
select the partition you want to be automatically mounded on startup and click the "Assistant" button.
- check the box next to "The file system is mounted at boot time" (it's probably already be checked),
- make sure the "Mount file system in read-only mode" is unchecked (this is automatically checked for NTFS partitions),
- check the "Allow any user to mount the file system" box,
- check the "Allow a user to mount and unmount the filesystem" box,
Once you're done, click OK and "Apply" (important - if you don't click the "Apply" button on the Storage Device Manager window, the settings won't be applied). Follow the same steps for each partition (be it NTFS, EXT3/4, etc.) and click "Apply" when done.
If you've messed up something, you can restore the original fstab file which we've backed up above, using this command:
sudo cp /etc/fstab.old /etc/fstab
參考:http://www.webupd8.org/2011/11/how-to-mount-partitions-automatically.html
2012年5月11日 星期五
about broadcast(C#)
接收:
Socket sock = new Socket(AddressFamily.InterNetwork,SocketType.Dgram, ProtocolType.Udp);
sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 100);
sock.EnableBroadcast = true;
sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
sock.ReceiveTimeout = 1000;
IPEndPoint iep = new IPEndPoint(IPAddress.Any/*IPAddress.Parse("192.168.1.220")*/, 8027);
sock.Bind(iep);
EndPoint ep = (EndPoint)iep;
Console.WriteLine("Ready to receive..." + sock.LocalEndPoint.ToString());
while (runTD)
{
Console.WriteLine("Waiting for data..");
try
{
byte[] data = new byte[1024];
int recv = sock.ReceiveFrom(data, ref ep);
//int recv = sock.Receive(data);
string stringData = Encoding.ASCII.GetString(data, 0, recv);
//dosomething
Console.WriteLine(stringData.Trim());
}
catch
{
Console.WriteLine("timeout!!");
}
}
sock.Close();
發送:
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
sock.EnableBroadcast = true;
sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
IPEndPoint iep1 = new IPEndPoint(IPAddress.Broadcast, 8028);
string str = tb_send.Text.ToString();
byte[] data = Encoding.ASCII.GetBytes(str);
sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 100);
sock.SendTo(data, iep1);
sock.Close();
Socket sock = new Socket(AddressFamily.InterNetwork,SocketType.Dgram, ProtocolType.Udp);
sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 100);
sock.EnableBroadcast = true;
sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
sock.ReceiveTimeout = 1000;
IPEndPoint iep = new IPEndPoint(IPAddress.Any/*IPAddress.Parse("192.168.1.220")*/, 8027);
sock.Bind(iep);
EndPoint ep = (EndPoint)iep;
Console.WriteLine("Ready to receive..." + sock.LocalEndPoint.ToString());
while (runTD)
{
Console.WriteLine("Waiting for data..");
try
{
byte[] data = new byte[1024];
int recv = sock.ReceiveFrom(data, ref ep);
//int recv = sock.Receive(data);
string stringData = Encoding.ASCII.GetString(data, 0, recv);
//dosomething
Console.WriteLine(stringData.Trim());
}
catch
{
Console.WriteLine("timeout!!");
}
}
sock.Close();
發送:
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
sock.EnableBroadcast = true;
sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
IPEndPoint iep1 = new IPEndPoint(IPAddress.Broadcast, 8028);
string str = tb_send.Text.ToString();
byte[] data = Encoding.ASCII.GetBytes(str);
sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 100);
sock.SendTo(data, iep1);
sock.Close();
2012年5月10日 星期四
JSON in JAVA
JSON(JavaScript Object Notation)
json jar download : https://docs.google.com/open?id=0B2Mp2cW7CWo5V183dUpsLUVIQUU
json api doc : http://www.json.org/java/index.html
參考資料 :
http://werdna1222coldcodes.blogspot.com/2009/01/json-in-java.html
json jar download : https://docs.google.com/open?id=0B2Mp2cW7CWo5V183dUpsLUVIQUU
json api doc : http://www.json.org/java/index.html
參考資料 :
http://werdna1222coldcodes.blogspot.com/2009/01/json-in-java.html
about broadcast (java、android)
(廣播) broadcast 和群播( multicast ) 兩者皆基於UDP的協議 。
廣播(broadcast)
Code寫法與單播一樣,區別在於目的地址不同。單播使用的是特定ip地址,而廣播顧名思義就是要向其他的客戶端發送消息,所以使用的是255.255.255.255(ipv4)。
JAVA:
public static final String broadip = "255.255.255.255";
public static final int broadport = 8027;
DatagramSocket socket= new DatagramSocket( broadport );
address = InetAddress.getByName(broadip);
socket.setBroadcast(true);
socket Saddress = new InetSocketAddress(broadip, broadport);
socket .bind(Saddress);//接收時需要bind
byte[] SendBuf = InMsg.getBytes();//String InMsg為要傳送的字串
int length = InMsg.getBytes().length;
packet = new DatagramPacket(SendBuf, length,address,broadport);
socket .send(packet);
群播(multicast)
稍微則稍微複雜一點。 Java提供了一個MulticastSocket的類來進行multicast,該類繼承於DatagramSocket。
多播地址一般為224.0.0.0 - 239.255.255.255(ipv4)。
JAVA:
InetAddress address = InetAddress.getByName("224.0.0.0");
if (!address.isMulticastAddress()) {
throw new Exception("this is not multi address");
}
packet = new DatagramPacket(byteToSend, byteToSend.length,address, 9999);
與廣播不同,它使用的是一個 群播 組。接收方需要加入這個組以告知對該組上的數據有興趣。所以接收方有一個joinGroup的操作,
JAVA:
MulticastSocket socket = new MulticastSocket();
socket.joinGroup(address);
demo download : https://docs.google.com/open?id=0B2Mp2cW7CWo5am9HSlozanZVc1k
Output To Console In Windows Forms Application
using System.Runtime.InteropServices;
public class Win32
{ ///
[DllImport("kernel32.dll")]
public static extern Boolean AllocConsole(); ///
[DllImport("kernel32.dll")]
public static extern Boolean FreeConsole();
}
public Form1()
{
InitializeComponent();
Win32.AllocConsole();
}
}
在需要的地方插入下Code:
Console.WriteLine("Waiting for data..");
參考:http://www.thereforesystems.com/output-to-console-in-windows-forms-application/
參考:http://www.thereforesystems.com/output-to-console-in-windows-forms-application/
2010年9月3日 星期五
GPhone 1 升級經驗 - Android 2.2 - 使用CyanogenMod-6 ROM
測試環境 :
手機 : google developer phone 1
原本的Android版本 :1.6 (HTC官方) http://developer.htc.com/adp.html
預先準備工作 :
升級工作 :
完成圖欣賞 :
已安裝了一些APP
手機 : google developer phone 1
Android Developer Phone 1 |
預先準備工作 :
- 獲取Root權限
Universal Androot
使用Universal Androot
- 下載適合自己Radio 本文採用
http://sapphire-port-dream.googlecode.com/files/ota-radio-2_22_19_26I.zip - 安裝Clockwork Recovery
在Android Market上搜索安裝ROM Manager程序(下方有QR code 使用 Barcode Scanner 掃描前往下載),通過ROM Manager程序安裝Clockwork Recovery(在ROM Manager程序裡點擊’Install ROM from SD Car’會自動提醒你下載安裝Clockwork Recovery)
- 下載Danger SPL
http://sapphire-port-dream.googlecode.com/files/spl-signed.zip
安裝DangerSPL前必須先檢查手機目前是否已經運行正確的版本,關閉手機同時按電源鍵和照相鍵進入fastboot模式,第二行是SPL的版本,如果結尾是2005(比如我的版本是 ‘HBOOT-1.33.2005(dream0000)‘),那麼恭喜你已經正確安裝SPL可以直接跳過這一步
- 通過Nandroid backup備份你的系統設置和程序
參考http://blog.roodo.com/DavidLanz/archives/13311927.html
(需先安裝ROM Manager) - 下載CyanogenMod-6 ROM http://mirror.kanged.net/cm/stable/update-cm-6.0.0-DS-signed.zip
- 下載Google Addon http://mirror.kanged.net/gapps/gapps-mdpi-tiny-20100816-signed.zip
ROM Manager |
- 將下載好的DangerSPL文件和Radio文件放到SD卡根目錄,使用ROM Manager程序選擇Reboot into Recovery進入ClockworkMod Recovery模式,選擇install zip from sdcard,選擇Radio文件安裝,完成安裝後重啟到這個界面,同樣的方法安裝DangerSPL文件,安裝後也會重啟到ClockworkMod Recovery模式,到這裡你已經完成了最危險的DangerSPL操作,進入安裝ROM環節
- 使用ROM Manager程序選擇Reboot into Recovery進入ClockworkMod Recovery模式,選擇wipe(兩個都要),此步驟會清除所以資料,記得先備份資料,完成安裝後重啟到這個界面。
- 按照同樣的辦法安裝CyanogenMod-6 ROM文件,安裝完成後就可以重啟手機進入系統,欣賞一下超酷的啟動動畫後就可以進入系統享受完美的 Android 2.2系統。
- 你會發現新系統沒有Google內置的程序,別擔心,再按照上面的辦法安裝Google Addon文件重啟手機後熟悉的程序又都回來了。
完成圖欣賞 :
已安裝了一些APP
訂閱:
文章 (Atom)