lizongbo at 618119.com 工作,生活,Android,前端,Linode,Ubuntu,nginx,java,apache,tomcat,Resin,mina,Hessian,XMPP,RPC

2011年01月1日

获取Android的Java源代码并在Eclipse中关联查看的最新方法

Filed under: Android,Java,前端开发 — 标签:, , , , , , , , — lizongbo @ 01:59

在Google搜索“Android Eclipse 源代码”得到的结果并不合适,因为Google的Eclipse Android开发插件已经更新到了ADT 8.0.1.相应的lib关联java源代码的方式也变了。
以下是获取Android的Java源代码并在Eclipse中关联的最新操作方法和步骤:
1.首先下载Android的SDK安装文件:http://dl.google.com/android/android-sdk_r08-windows.zip
然后解压到:E:\Java\android\android-sdk-windows,运行目录中的SDK Manager.exe,下载好Android不同版本的API包。

2.然后下载或在线安装Eclipse插件ADT,
安装包地址为:http://dl.google.com/android/ADT-8.0.1.zip
在线安装地址:https://dl-ssl.google.com/android/eclipse/
来源:ttp://developer.android.com/sdk/eclipse-adt.html

2.ADT插件安装好之后,下载我已经打包好的Android 2.3(gingerbread)的java源代码压缩包:
下载地址:http://lizongbo.googlecode.com/files/android_gingerbread_javasrc.zip
来源:http://code.google.com/p/lizongbo/downloads/list
下载后复制到E:\Java\android\javasrc。

3.Android的Java源代码压缩包下载好之后,在Eclipse中设置好SDK配置:
操作步骤为:主菜单->Window–>Preferences–>选择Android,SDK Location设置为:E:\Java\android\android-sdk-windows,然后点右下角的Apply来生效。

4.开始进行关联Android的源代码,在Eclipse中新建一个Android工程,选中工程,主菜单 –>Project–>Properties–>选择Android,Project Build Target选中Android 2.3。
然后再点左边的“Java Build Path”,切换到 Libraries 面板,展开 Android2.3 这个lib,点击android.jar的Source attachment,再点Edit.在对话框中点“External File”,选择E:/Java/android/javasrc/android_gingerbread_javasrc.zip,点OK进行确认。这样就把Android的java代码关联好了。

5.在同一个工程中,选中工程,主菜单–>Project–>Properties–>选择 Android,Project Build Target分别选择Android1.5,Android1.6,Android2.01,Android2.1- update1,Android2.2,按上面第四步的操作重复设置关联。
以后在任何Android工程里按住Ctrl用鼠标点击Java类名都可以浏览到对应的java源代码。
Android各个版本对应的源代码为:
Android1.5对应android_cupcake_javasrc.zip
Android1.6对应android_donut_javasrc.zip
Android2.01和Android2.1-update1对应的是android_eclair_javasrc.zip
Android2.2对应android_froyo_javasrc.zip
Android2.3对应android_gingerbread_javasrc.zip

6.在Eclipse配置好源代码关联之后之后的信息会存储在:
E:\lizongbo\workspacenew\.metadata\.plugins\org.eclipse.core.resources\.root\.indexes\properties.index
E:\lizongbo\workspacenew\.metadata\.plugins\org.eclipse.jdt.core\variablesAndContainers.dat

同时记录Android的java源代码压缩包制作方法如下:
1.先在远程的Ubuntu Linux服务器(是Linode VPS)上安装以下组件(JDK1.6已经安装好了):
sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
信息来自Android官方:http://source.android.com/source/download.html
2.运行 sudo apt-get install lib32readline5-dev
3.安装Repo脚本:
我懒得配PATH了,于是直接安装到了/usr/local/bin。
root@lizongbo.com:~/bin# cd /usr/local/bin
root@lizongbo.com:/usr/local/bin# ls
geoip-lookup
root@lizongbo.com:/usr/local/bin# curl http://android.git.kernel.org/repo >/usr/local/bin/repo
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
100 17412  100 17412    0     0  27517      0 –:–:– –:–:– –:–:– 31148
root@lizongbo.com:/usr/local/bin# chmod a+x /usr/local/bin/repo
注意在下载该脚本的时候,可能会遇到服务器出错,下载的内容不对,运行命令的时候会提示错误“syntax error near unexpected token `newline’”。
root@lizongbo.com:/usr/local/bin# repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
/usr/local/bin/repo: line 1: syntax error near unexpected token `newline’
/usr/local/bin/repo: line 1: `<!DOCTYPE HTML PUBLIC “-//IETF//DTD HTML 2.0//EN”>’
root@lizongbo.com:/usr/local/bin# more repo
<!DOCTYPE HTML PUBLIC “-//IETF//DTD HTML 2.0//EN”>
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
webmaster@kernel.org and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
</body></html>
从内容看是服务器出错了,因此需要重新下载脚本.
4.建立mydroid目录,按代码分支下载对应版本的Android完整的源代码,比如下载Android2.3的代码:
root@lizongbo.com:~/mydroid# mkdir gingerbread
root@lizongbo.com:~/mydroid# cd gingerbread/
root@lizongbo.com:~/mydroid/gingerbread# repo init -u git://android.git.kernel.org/platform/manifest.git -b gingerbread
root@lizongbo.com:~/mydroid/gingerbread# repo sync
Android1.5的代码分支:
root@lizongbo.com:~/mydroid/cupcake# repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
root@lizongbo.com:~/mydroid/cupcake# repo sync
Android1.6的代码分支:
root@lizongbo.com:~/mydroid/donut# repo init -u git://android.git.kernel.org/platform/manifest.git -b donut
root@lizongbo.com:~/mydroid/donut# repo sync
Android2.0.1和2.1的代码分支:
root@lizongbo.com:~/mydroid/eclair# repo init -u git://android.git.kernel.org/platform/manifest.git -b eclair
root@lizongbo.com:~/mydroid/eclair# repo sync
Android2.2的代码分支:
root@lizongbo.com:~/mydroid/froyo# repo init -u git://android.git.kernel.org/platform/manifest.git -b froyo
root@lizongbo.com:~/mydroid/froyo# repo sync

如果遇到代码下载速度太慢,可以指定hosts,hosts配置不住为:
root@lizongbo.com:~/mydroid/gingerbread/.repo/projects# nslookup
> android.git.kernel.org
Server:         72.14.188.5
Address:        72.14.188.5#53
Non-authoritative answer:
android.git.kernel.org  canonical name = android.git.geo.kernel.org.
android.git.geo.kernel.org      canonical name = android.git.us.kernel.org.
Name:   android.git.us.kernel.org
Address: 149.20.20.141
Name:   android.git.us.kernel.org
Address: 204.152.191.45
> exit

root@lizongbo.com:/etc# vi hosts
204.152.191.45 android.git.us.kernel.org
204.152.191.45 android.git.kernel.org

网上有文章介绍使用提取java文件并打包的pytho脚本可以生成源代码包,参考:
http://android.opensourceror.org/2010/01/18/android-source/
http://blog.michael-forster.de/2008/12/view-android-source-code-in-eclipse.html
Python下载地址:http://www.python.org/ftp/python/2.6.6/python-2.6.6.msi
但是在Android2.2和Android2.3的代码里,Android写一了一些mock的类,比如android.webkit.WebView,使用python脚本打包的话,会把mock的源代码打进去,而不是真正的源代码,
因此我根据python脚本写了个java程序来提取java文件过滤冗余的java代码并打包。
生成的java源代码压缩:android_cupcake_javasrc.zip,android_donut_javasrc.zip,android_eclair_javasrc.zip,android_froyo_javasrc.zip,android_gingerbread_javasrc.zip
目前在code.google.com上传了android_gingerbread_javasrc.zip,欢迎下载。

以下是各版本的Android java source 下载地址:

Android2.3: http://lizongbo.googlecode.com/files/android_gingerbread_javasrc.zip

Android1.5: http://lizongbo.googlecode.com/files/android_cupcake_javasrc.zip
Android1.6: http://lizongbo.googlecode.com/files/android_donut_javasrc.zip
Android2.1: http://lizongbo.googlecode.com/files/android_eclair_javasrc.zip
Android2.2: http://lizongbo.googlecode.com/files/android_froyo_javasrc.zip

新年快乐!

2010年11月17日

在Ubuntu10.04上通过mysql源代码进行编译安装

Filed under: Linux,mysql — 标签:, , , , — lizongbo @ 00:10

在Ubuntu10.04上通过mysql源代码进行编译安装MySQL Community Server

操作系统是linode上的Ubuntu 10.04,
MySQL Community Server目前最新正式版为:mysql 5.1.51 GA.
源代码下载地址为:
http://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/MySQL-5.1/mysql-5.1.51.tar.gz

来源:http://www.mysql.com/downloads/mirror.php?id=394595#mirrors
http://www.mysql.com/downloads/

1.先下载源代码到本地:
root@618119.com:/usr/local/app# wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.51.tar.gz/from/http://www.mirrorservice.org/sites/ftp.mysql.com/
2.解压mysql-5.1.51.tar.gz到/usr/local/app/mysql-5.1.51:
root@618119.com:/usr/local/app# tar -zxvf mysql*
3.进入解压得到的源码目录中:
root@618119.com:/usr/local/app# cd mysql*
4.运行configure进行检查:
root@618119.com:/usr/local/app/mysql-5.1.51# ./configure -prefix=/usr/local/app/mysql -with-charset=utf8 -with-collation=utf8_general_ci -with-extra-charsets=latin1
提示信息:checking for termcap functions library… configure: error: No curses/termcap library found
5.安装libncurses5-dev进行解决:
root@618119.com:/usr/local/app/mysql-5.1.51# sudo apt-get install libncurses5-dev
6.在编译安装nginx时候已经安装了 gcc libc6-dev build-essential 组件
直接开始运行make编译源代码:
root@618119.com:/usr/local/app/mysql-5.1.51# make
7.等待一段时间后,源码编译完成,运行make install进行安装:
root@618119.com:/usr/local/app/mysql-5.1.51# make install
8.复制系统服务脚本:
root@618119.com:/usr/local/app/mysql# cp /usr/local/app/mysql/share/mysql/mysql.server  /etc/init.d/mysql
9.再运行命令: sudo /usr/sbin/update-rc.d -f mysql defaults,将mysql安装为默认服务。
root@618119.com:/usr/local/app/mysql# sudo /usr/sbin/update-rc.d -f mysql defaults
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = “zh_CN.UTF-8”
are supported and installed on your system.
perl: warning: Falling back to the standard locale (“C”).
Adding system startup for /etc/init.d/mysql …
/etc/rc0.d/K20mysql -> ../init.d/mysql
/etc/rc1.d/K20mysql -> ../init.d/mysql
/etc/rc6.d/K20mysql -> ../init.d/mysql
/etc/rc2.d/S20mysql -> ../init.d/mysql
/etc/rc3.d/S20mysql -> ../init.d/mysql
/etc/rc4.d/S20mysql -> ../init.d/mysql
/etc/rc5.d/S20mysql -> ../init.d/mysql
10.复制默认配置到/etc目录:
root@618119.com:/usr/local/app/mysql# cp /usr/local/app/mysql/share/mysql/my-medium.cnf /etc/my.cnf
11:添加名字为mysql的用户:
root@618119.com:/usr/local/app/nginx# sudo adduser –system –no-create-home –disabled-login –disabled-password –group mysql
12.初始化数据库(如果没初始化,启动mysql会提示“Manager of pid-file quit without updating file”):
root@618119.com:/usr/local/app/mysql/bin# ./mysql_install_db –user=mysql
Installing MySQL system tables…
101022 15:24:16 [Warning] ‘–skip-locking’ is deprecated and will be removed in a future release. Please use ‘–skip-external-locking’ instead.
OK
Filling help tables…
101022 15:24:16 [Warning] ‘–skip-locking’ is deprecated and will be removed in a future release. Please use ‘–skip-external-locking’ instead.
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/app/mysql/bin/mysqladmin -u root password ‘new-password’
/usr/local/app/mysql/bin/mysqladmin -u root -h 618119.com password ‘new-password’

Alternatively you can run:
/usr/local/app/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr/local/app/mysql ; /usr/local/app/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/app/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/app/mysql/bin/mysqlbug script!

13.启动mysql数据库.
root@618119.com:/usr/local/app/mysql/bin# sudo /etc/init.d/mysql start

14.命令行进入数据库进行测试:
root@618119.com:/usr/local/app/mysql/bin# ./mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.51-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> show databases;
+——————–+
| Database           |
+——————–+
| information_schema |
| mysql              |
| test               |
+——————–+
3 rows in set (0.00 sec)

mysql> quit
Bye

15.运行mysql自带的测试脚本需要等的时间比较久:
root@618119.com:/usr/local/app/mysql# cd /usr/local/app/mysql/mysql-test ; perl mysql-test-run.pl
测试结果是1000多项只有600项通过:
main.mysql_client_test                   [ fail ]
Test ended at 2010-10-22 15:35:39

CURRENT_TEST: main.mysql_client_test
mysqltest: At line 15: command “$MYSQL_CLIENT_TEST –getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1” failed

Output from before failure:
exec of ‘/usr/local/app/mysql/bin/mysql_client_test –defaults-file=/usr/local/app/mysql/mysql-test/var/my.cnf –testcase –vardir=/usr/local/app/mysql/mysql-test/var –getopt-ll-test=25600M >> /usr/local/app/mysql/mysql-test/var/log/mysql_client_test.out.log 2>&1’ failed, error: 256, status: 1, errno: 0

The result from queries just before the failure was:
SET @old_general_log= @@global.general_log;
SET @old_slow_query_log= @@global.slow_query_log;

– saving ‘/usr/local/app/mysql/mysql-test/var/log/main.mysql_client_test/’ to ‘/usr/local/app/mysql/mysql-test/var/log/main.mysql_client_test/’

Only  653  of 1415 completed.
mysql-test-run: *** ERROR: Not all tests completed
166.使用符号链接方便直接运行 mysql命令:
root@618119.com:/usr/local/app/mysql# sudo ln -s /usr/local/app/mysql/bin/mysql /usr/bin/
root@618119.com:/usr/local/app/mysql# sudo ln -s /usr/local/app/mysql/bin/mysqladmin /usr/bin/

开始在resin上安装phpMyAdmin:
phpMyAdmin最新版本 3.3.7:
下载地址:http://nchc.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.3.7/phpMyAdmin-3.3.7-all-languages.tar.gz
来源:
http://www.phpmyadmin.net/home_page/index.php

下载后解压到:lizongbo@618119.com:/etc/init.d$ cd /usr/local/app/resin/webapps
然后改名:
lizongbo@618119.com:/usr/local/app/resin/webapps$ mv phpMyAdmin-3.3.7-all-languages/ phpMyAdmin

尝试resin最新版跑phpMyAdmin跑不了。
还是想办法配置nginx吧,可以参考:
http://www.linuxidc.com/Linux/2010-03/25161.htm
mysql JDBC驱动:
最新正式版为:Connector/J 5.1.13
下载地址:http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector- java-5.1.13.tar.gz/from/http://www.mirrorservice.org/sites/ftp.mysql.com/
来源:http://www.mysql.com/downloads/connector/j/

root@618119.com:/usr/local/app# wget http://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/Connector-J/mysql-connector-java-5.1.13.tar.gz
root@618119.com:/usr/local/app# tar -zxvf mysql-c*
复制jdbc驱动到resin的lib目录:
root@618119.com:/usr/local/app/mysql-connector-java-5.1.13# cp /usr/local/app/mysql-connector-java-5.1.13/mysql-connector-java-5.1.13-bin.jar /usr/local/app/resin/lib

2010年11月14日

使用MyEnTunnel和WinSCP连接linode上的Ubuntu服务器

Filed under: Linux — 标签:, , , , , — lizongbo @ 17:34

使用MyEnTunnel和WinSCP连接linode上的Ubuntu服务器

先安装配置MyEnTunnel:
1.MyEnTunnel官方下载地址:http://nemesis2.qx.net/download.php?filename=myentunnel-unicode.zip
语言包: http://nemesis2.qx.net/download.php?filename=simplified_chinese_language.txt
来源: http://nemesis2.qx.net/pages/MyEnTunnel
由于官方下载地址限制了Referer信息,因此需要先打开上面的来源页面, 然后手工点击下载。

不过下载的版本是没附带pageant.exe,plink.exe,pscp.exe,psftp.exe,putty.exe,puttygen.exe,puttytel.exe这些文件的。

因此推荐下载别人整合好可以直接使用的版本:http://microembedded.googlecode.com/files/myentunnel-unicode.zip
来源:http://code.google.com/p/microembedded/updates/list
2.解压myentunnel-unicode.zip到:E:\Programs
3.运行E:\Programs\myentunnel-unicode\myentunnel.exe。
4.切换到“设定“面板,将启动时自动连接,失败时重新连接,冗余记录,启用慢速查询,不限制重试次数,启用动态套接字,隐藏断开连接,启用压缩这几项都选中,
只有使用私人密钥和禁用提示不需要打钩。
SSH服务器填上linode分配的ip地址,SSH端口保持默认值22,用户名填SSH账号,比如lizongbo,密码比如填:618119.com,重试延迟填10,本地端口填:7070.
5.点右下角的“连接“,不出一万就连接上了,在弹出的提示保存密钥时选是,连接就正常建立了。可以切换到“状态”面板查看日志。

6.在Firefox里使用7070端口:Firefox主菜单–>工具–>选项–>”高级”面板–>“网络”–>连接,点设置,选择手动配置代理,HTTP代理栏清空,SOCKS主机填:127.0.0.1,端口填7070,选中SOCKSv5。
确定保存之后,在Firefox地址栏输入about:config,回车后点“我保证会小心”,然在过滤器栏输入dns,双击network.proxy.socks_remote_dns,设置为true。

再安装配置WinSCP
7.WinSCP 4.3 Beta 绿色版官方下载地址:http://winscp.net/download/winscp430.zip
(实际下载地址:http://softlayer.dl.sourceforge.net/project/winscp/WinSCP/4.3%20beta/winscp430.zip
http://winscp.net/translations/dll/chs.zip
来源:http://winscp.net/eng/download.php
中文简体语言包下载:http://winscp.net/translations/dll/chs.zip
来源:http://winscp.net/eng/translations.php
8.解压winscp430.zip到E:\Programs\WinSCP;解压chs.zip到E:\Programs\WinSCP。
9.运行E:\Programs\WinSCP\WinSCP.exe,在会话栏添加连接配置:主机名为Linux服务器的ip地址,端口号默认22,用户名和密码参考MyEnTunnel的配置,点“登录”进行连接。

WinSCP具体使用可参考:http://618119.com/archives/2008/03/20/76.html

Older Posts »

Powered by WordPress