Eclipse with Tomcat 7 on Ubuntu

Eclipse with Tomcat V7.0 in Ubuntu
1. Download Eclipse from the Eclipse web site. (J2EE version)
2. Download Tomcat version 7 or install it via apt-get
apt-get install tomcat7 tomcat7-admin tomcat7-common tomcat7-docs tomcat7-examples
3. Set the following configuration:

cd /usr/share/tomcat7
sudo ln -s /var/lib/tomcat7/conf conf
sudo ln -s /etc/tomcat7/policy.d/03catalina.policy conf/catalina.policy
sudo ln -s /var/log/tomcat7 logs
sudo chmod -R 777 /usr/share/tomcat7/conf

3. Run eclipse
4. Add a view ( Windows -> Show View -> Other -> Server -> Servers -> OK )
5. Go to the view
6. Add a Tomcat v7 (consider /user/share/tomcat7 as your path)
7. Enjoy Tomcat 7 in Eclipse.

Eclipse add Tomcat 7 blank server name

I was trying to add Tomcat 7 in my Eclipse in Ubuntu. When I click "Add new server" in Eclipse and select "Tomcat v7.0 Server", the field "Server Name" is blank and I cannot type in anything in that textbox as shown below:

0pHnn

It is a bug in Eclipse. I had exactly the same problem, also on Ubuntu with Eclipse Java EE Juno.

Here is the workaround that worked for me:

1.Close Eclipse
2.In {workspace-directory}/.metadata/.plugins/org.eclipse.core.runtime/.settings delete the following two files:
org.eclipse.wst.server.core.prefs
org.eclipse.jst.server.tomcat.core.prefs
3.Restart Eclipse

Tomcat在Mac平台安裝

到http://tomcat.apache.org下載tomcat版,例如apache-tomcat-7.0.42.tar.gz
将apache-tomcat-7.0.42.tar.gz 解压缩到目标目录
执行

 chmod a+x apache-tomcat-7.0.42/bin/*.sh

设置管理用户密码:
编辑 apache-tomcat-7.0.42/conf/tomcat-users.xml , 加入

<role rolename="manager-gui"/>
<user username="User" password="password" roles="manager-gui"/>

設定好後執行 apache-tomcat-7.0.42/bin/startup.sh , 再使用browser連到http://localhost:8080, 如果可以看到以下画面, Tomcat Server的安裝算是初步完成

Apache Tomcat_7.0.42_Default_Page

設定Launchd主要讓Mac OS X server啟動時, 也順便啟動Tomcat Server, Launchd有點類似Windows的NT Service使用Launchd來啟動Tomcat Server

1.到 apache-tomcat-7.0.42/bin/目錄下新增一個檔案 launchd_wrapper.sh, 內容如下

#!/bin/bash
function shutdown()
{
date
echo "Shutting down Tomcat"
$CATALINA_HOME/bin/catalina.sh stop
}
date
echo "Starting Tomcat Server"
export CATALINA_PID=/tmp/$$
# Uncomment to increase Tomcat's maximum heap allocation
# export JAVA_OPTS=-Xmx512M $JAVA_OPTS
export JAVA_OPTS="-Xms256m -Xmx512m -XX:MaxPermSize=256m"
export CATALINA_OPTS="-DHUDSON_HOME=/Users/admin/hudson"
. $CATALINA_HOME/bin/catalina.sh start
# Allow any signal which would kill a process to stop Tomcat
trap shutdown HUP INT QUIT ABRT KILL ALRM TERM TSTP

请注意 ,launchd_wrapper.sh要使用

chmod a+x launchd_wrapper.sh

使其具有执行权限

2. 加入tomcat for Launchd 文件, 到/Library/LaunchDaemons目录使用

 sudo touch tomcat.plist

新增tomcat.plist

3. 使用

sudo vi tomcat.plist

, 编辑tomcat.plist, 文件內容如下, 要注意的是/Users/admin为安装目录, 请改成你的目录

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>Disabled</key>
<false/><key>EnvironmentVariables</key><dict><key>CATALINA_HOME</key>
<string>/Users/admin/Library/apache-tomcat-7.0.42</string>
<key>JAVA_HOME</key>
<string>/Library/Java/Home</string>
</dict>
<key>Label</key>
<string>com.apache.tomcat</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/Users/admin/Library/apache-tomcat-7.0.42/bin/launchd_wrapper.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceDescription</key>
<string>Tomcat</string>
<key>StandardErrorPath</key>
<string>/Users/admin/apache-tomcat-7.0.42/logs/launchd.stderr</string>
<key>StandardOutPath</key>
<string>/Users/admin/apache-tomcat-7.0.42/logs/launchd.stdout</string>
<key>UserName</key>
<string>root</string>
</dict>
</plist>

4.手动测试Launchd

sudo launchctl load -w /Library/LauhchDaemons/tomcat.plist

停止指令

sudo launchctl unload -w /Library/LaunchDaemons/tomcat.plist

测试OK后, 下次重新开机Tomcat Server就会自己执行了.

ubuntu下安装Apache+PHP+Mysql

步骤一,安装apache2

sudo apt-get install apache2

安装完成。
运行如下命令重启下:

sudo /etc/init.d/apache2 restart

在浏览器里输入http://localhost或者是http://127.0.0.1,如果看到了It works!,那就说明Apache就成功的安装了,Apache的默认安装,会在/var下建立一个名为www的目录,这个就是Web目录了,所有要能过浏览器访问的Web文件都要放到这个目录里。

步骤二 ,安装php:

sudo apt-get install libapache2-mod-php5 php5

此外,建议安装扩展php5-gd php5-mysql,安装方式同上.

安装完后,我们要重新启动Apache,让它加载PHP模块:

sudo /etc/init.d/apache2 restart

接下来,我们就在Web目录下面新建一个test.php文件来测试PHP是否能正常的运行,命令:

sudo gedit /var/www/test.php

然后输入:

<?php echo  hello,world! ?>

接着保存文件,在浏览器里输入http://127.0.0.1/test.php,如果在网页中显示hello,world!!,那就说明PHP已经正常运行了。

步骤三,安装mysql数据库:

sudo apt-get install mysql-server mysql-client

apt-get程序会自动下载安装最新的mysql版本。在安装的最后,它会要求里输入root的密码,注意,这里的root密码可不是Ubuntu的root密码啊,是你要给MySQL设定的root密码。

步骤四,安装phpmyadmin-Mysql数据库管理

sudo apt-get install phpmyadmin

phpmyadmin设置:

在安装过程中会要求选择Web server:apache2或lighttpd,使用空格键选定apache2,按tab键然后确定。然后会要求输入设置的Mysql数据库密码连接密码Password of the database’s administrative user。

然后将phpmyadmin与apache2建立连接,以我的为例:www目录在/var/www,phpmyadmin在/usr/share /phpmyadmin目录,所以就用命令:

sudo ln -s /usr/share/phpmyadmin /var/www

建立链接。

phpmyadmin测试:在浏览器地址栏中打开http://localhost/phpmyadmin。

以上ALMP的基本组件就安装完毕了,下面我们再来看一些其他的设置:

步骤五,设置Ubuntu文件执行读写权限

LAMP组建安装好之后,PHP网络服务器根目录默认设置是在:/var/www。由于Linux系统的安全性原则,改目录下的文件读写权限是只允许root用户操作的,所以我们不能在www文件夹中新建php文件,也不能修改和删除,必须要先修改/var/www目录的读写权限。在界面管理器中通过右键属性不能修改文件权限,得执行root终端命令:

sudo chmod 777 /var/www

然后就可以写入html或php文件了。777是linux中的最高权限,表示可读,可写,可执行。

处理在64位Ubuntu使用jd-gui报错error while loading shared libraries: libgtk-x11-2.0.so.0

在64位Ubuntu中使用jd-gui反编译时出现错误:
error while loading shared libraries: libgtk-x11-2.0.so.0

此时,需要安装如下依赖包,即可:

(Ubuntu 13.04 x64)

$ sudo apt-get install ia32-libs-gtk libglib2.0-dev

(Ubuntu 13.10 x64)

$ sudo apt-get install libgtk2.0-0:i386 libxxf86vm1:i386 libsm6:i386 libglib2.0-dev libcanberra-gtk-module:i386 gtk2-engines-murrine:i386

Ubuntu 下远程桌面rdesktop的安装及配置

Rdesktop是Linux操作系统下的一款远程桌面工具,可以用来链接Windows系统
使用rdesktop来指定分辨率,让远程桌面刚好填充到空白区域:
在终端里敲:

rdesktop 远程ip -u 用户名 -p 密码 -a 16 -g 1024x768 -r sound:local -5

其中-g 参数就是指定分辨率。因为我是1280*800 所以我使用1024*768的分辨率是正好的。你可以根据你的情况来调整分辨率,找到一个最佳值。

其中-a参数指定的是16色。
但这有个缺点,就是每次都要敲一堆参数,太麻烦。所以,我们可以使用别名来简化这个命令。
打开~/.bashrc 这个文件。在里面可以添加别名(写在最后面就可以了):
例如:

rdesktop alias rdp='rdesktop -a 16 -g 1024x768 -r sound:local -5 '

注意1024x768之间的x别写成*或其他,否则分辨率设置不起作用。
关闭终端。重新打开终端,此时只要敲 rdp ip地址 -u 用户名 -p 密码 就可以了。
而且你还可以把你常用的远程连接写成别名:

alias rdp='rdesktop 192.168.111.231 -u Administrator -p 1 -a 16 -g 1024x728 -r sound:local -5 '

这样只要敲rdp就可以打开了。
PS:1、用户主目录下的.bashrc 文件会在终端启动的时候被终端读取。
2、此外,-g 还可以 以 百分比 的形式填写 如下:

rdesktop -g 80% -u dell 192.168.111.231

Example compiling the latest Audacity source code on Ubuntu

These simple steps have been tested building Audacity 2.x on Ubuntu 11.04 (natty) and onwards including 13.04 (raring). The steps should also work with appropriate modification on most other Debian-based systems and for most legacy 1.3 versions of Audacity.

Open a terminal and type the following commands:

sudo apt-get install subversion
svn checkout http://audacity.googlecode.com/svn/audacity-src/trunk/ audacity-read-only
sudo apt-get build-dep audacity
sudo apt-get install cmake (currently required for building Audacity 2.0.3-alpha from HEAD)
cd audacity-read-only
./configure
sudo make install

This should now give you the Audacity program at usr/local/bin and the plug-ins at usr/local/share/audacity.
On occasions, changes to latest Audacity HEAD may require you to regenerate the configure file before running it. To do this

sudo apt-get install autogen
chmod +x ./autogen.sh
./autogen.sh

Lion下编译WxWidgets

看了下WxWidgets的官方文档,看来它对Mac的支持还不是很好,所以问题还是蛮多的。

先下的最新的2.9,结果解压出来差一个文件,错误:

cannot find sources (wx-config.in)

看到这个,我翻了下目录,还真没这个文件,所以暂时放下这个版本,然后搞2.8。

这个倒是简单,解压之后,在docs/cocoa下面有install文档,照着做就行了。

不过在lion下面可能会有这两个问题:

1.

./src/common/dynlib.cpp:48:
./include/wx/mac/carbon/private.h:1459: error: ‘Cursor’ does not name a type
./include/wx/mac/carbon/private.h:1488: error: ‘ClassicCursor’ does not name a type

这个问题的答案就是lion去掉了一些过去使用的API,所以需要让系统link更早的Library就好了,解决办法是在configure的时候加入命令行:

--with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --with-macosx-version-min=10.6

2.第二个错误来自官方的文档说明,应该和平台有关系,看官方的解释:

Building on Snow Leopard for Snow Leopard

When trying to build wx under 10.6 you might - on certain machines - end up with errors like this:

./src/common/intl.cpp: In static member function ‘static int wxLocale::GetSystemLanguage()’:../src/common/intl.cpp:2060: error: ‘smScriptLang’ was not declared in this scope../src/common/intl.cpp:2060: error: ‘GetScriptVariable’ was not declared in this scope../src/common/intl.cpp:2061: warning: ‘GetScriptManagerVariable’ is deprecated (declared at /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Script.h:993)../src/common/intl.cpp:2061:warning:‘GetScriptManagerVariable’ is deprecated(declared at /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Script.h:993)make: *** [baselib_intl.o] Error 1

The reason is that the default compiler on 10.6 is gcc 4.2, and if you are on a Core 2 Duo which is 64-bit capable, you end up compiling Carbon-only 2.8 for 64 bits which fails, due to the lack of 64-bit Carbon support. If you want 64-bit wxWidgets on OS X you'll need 2.9+ and configure -with-osx_cocoa - see below; but remember that 2.9 is not an official, stable release and wxOSX/Cocoa is not yet complete.

So, to compile with 2.8 on a 64-bit Mac, you have to explicitly indicate the architectures you want:

arch_flags="-arch i386"../configure CFLAGS="$arch_flags" CXXFLAGS="$arch_flags" CPPFLAGS="$arch_flags" LDFLAGS="$arch_flags" OBJCFLAGS="$arch_flags" OBJCXXFLAGS="$arch_flags"

This makes the library and samples build nicely for Intel 32-bit targets, and you can also add -arch ppc to the arch_flags so that you can build universal binaries.

因此,我最后的配置命令行是:

../configure --enable-unicode --enable-debug --disable-shared --with-osx_cocoa --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --with-macosx-version-min=10.6 cflags="-arch i386" CXXFLAGS="-arch i386" CPPFLAGS="-arch i386" LDFLAGS="-arch i386" OBJCFLAGS="-arch i386" OBJCXXFLAGS="-arch i386"

最后配置完成,使用make编译。

进入sample目录编译两个小demo,截图:

ae9ec05069cc220984352444

再来一个运行时候的样子:

7cc657336c431c931b4cff7e

转载自 http://hi.baidu.com/dbfr2011818/item/d26f6820dc80e08c6f2cc30e

Why your Android NDK breakpoints might fail and how to fix them

Overview

 

First of all let's overview the structure of a typical Android app containing native code:

native1

The app code is stored inside an .apk file that is essentially a ZIP archive containing the classes.dex file (with all the Java code) and one or more native libraries in lib\<EABI name> subdirectory. The typical lifecycle of an application with native code is the following:

  1. The Android OS loads the Java code and starts executing it
  2. The Java code calls System.loadLibrary() to load a native library.
  3. The Java code starts calling functions from the native code.

Each native library exists in 2 versions:

  •  A "full" version debugging information that associates code addresses inside the library with source files and lines. This version resides in obj\local\armeabi under your project directory.
  • A "stripped" version without the debugging information that resides in libs\armeabi and gets packaged into the APK file.

While the Android device runs the smaller "stripped" version of the library, the GDB debugger needs the larger "non-stripped" version to map source files into addresses and vice versa:

native2

Setting breakpoints

 

When you set a breakpoint on a given line of a source file, the GDB debugger needs to perform certain computations before the breakpoint can be physically created and starts triggering. Assume libNative1 is loaded at address 0x10000 and the user is setting a breakpoint in line 24 of c:\main.cpp. GDB will do the following before it can set a breakpoint:

  1. GDB starts searching all loaded libraries for the file called "c:\main.cpp". In this example the Android OS only reports the libNative1.so library.
  2. GDB looks inside obj\local\armeabi for a file called libNative1.so which is the "non-stripped" version of the library containing the debug information. GDB reads the symbol table from it and finds c:\main.cpp inside it.
  3. Based on the symbol table GDB computes that line 24 corresponds to offset +0x2. It adds 0x2 to the load address of libNative1.so (0x10000) and sets the breakpoint at 0x10002.

If any of the 3 steps fail, the breakpoint will not be created, or will be created wrongly and will never be hit. The next section explains how to diagnose and fix the related problems.

Diagnosing the problems

This section provides detailed instructions how to check for the most common problems with breakpoints caused by non-standard configurations or missing files:

A. Ensure that the library is loaded

First thing to do is to determine if the native library has been actually loaded and if GDB knows about it. It is done by running the "info shared" command in GDB:

native-sharedlib

The output from the info shared command should include 3 important lines:

  1. Loaded symbols for "linker"
  2. Loaded symbols for "libc.so"
  3. Loaded symbols for all native libraries you want to debug.

Here's an example of those lines:

From       To         Syms Read       Shared Object Library
                       No com.visualgdb.example.MyAndroidApp
0xb0001000 0xb00069d0 Yes C:/.../AndroidBinaryCache/.../linker
0x40073300 0x400a12fc Yes C:/.../AndroidBinaryCache/.../libc.so
0x5148fccc 0x51491198 Yes E:/.../obj/local/armeabi/libMyAndroidApp.so

If some of the libraries are not present, you can force GDB to manually reload the symbols by running the following command in GDB:

sharedlibrary

If your .so library (e.g. libMyAndroidApp.so) is listed, but the symbols are not loaded ("Syms read" states "no"), GDB was not able to find a non-stripped version of the library. To fix it please run the "show solib-search-path" command in GDB:

native-solib

The obj/local/armeabi directory of your project should be present among the reported directories and it should contain the .so file with symbols. If not, copy the correct .so file into a directory listed here and rerun the "sharedlibrary" command.

You can alternatively force GDB to search additional directories for the .so file using the set solib-search-path command.

If your .so library is not present in the list, it has not been loaded by the Java code yet. Please ensure that System.loadLibrary() is called from your Java code and that it succeeds without any Java exceptions.

B. Ensure that you are using correct file paths

A common cause of many breakpoint problems is a configuration when the directories using for building and debugging your project are different. E.g. if the library was compiled from c:\projects and then the sources were moved to d:\projects, setting a breakpoint in d:\projects\main.cpp will fail, as GDB will not accept c:\projects\main.cpp as a substitute.

Those problems can be diagnosed by looking into the source file lists and comparing them with the file used to set a breakpoint. First of all, remove your breakpoint, try setting your breakpoint again and watch what GDB command is issued by your IDE:

native-break-insert

The -break-insert command used to set a breakpoint will specify a path to your source file.

Run the "info sources" command to see the source files discovered by GDB:

native-info-sources

Copy the output of the command to the clipboard (Ctrl-A, Ctrl-C), paste it into a text editor and search for the source file you are trying to debug (e.g. MyAndroidApp.c):

native-source-list

If the file is not present in the list, you have loaded a wrong version of the .so file (see previous section). If the file is present, but the path is different from the one used in -break-insert command, you have found the cause of your problem. Rebuild your app using the new path, or move the file back to an old location so that the path used for creating breakpoints matches the path reported by the "info sources" command.

Note that GDB requires the file path to be EXACTLY the same as reported by "info sources", including double slash before "jni".

C. Recheck file versions and do a clean build

If your breakpoints are set, but never hit, there is probably a mismatch between the .so file version loaded into the Android application and the .so file version used by GDB to compute addresses from source lines. The most common cause for it is the bug in the Android loader that loads the armeabi library instead of the armeabi-v7a version. If you suspect this to happen, change your build configuration to build either armeabi, or armeabi-v7a platform, but not both at the same time and rebuild your application.'

引用自  http://www.codeproject.com/Articles/493043/Why-your-Android-NDK-breakpoints-might-fail-and-ho

Linux SS5 socks 代理服务器安装

1. 配置 Socks5 编译环境

yum -y install gcc automake autoconf libtool make

2. 安装 Socks5 必要的包

yum -y install pam-devel openldap-devel cyrus-sasl-devel

3.下载,编译安装 Socks5 
到此下载 http://sourceforge.net/projects/ss5/files/

http://ss5.sourceforge.net/

官方实例

http://ss5.sourceforge.net/examples.htm

wget -c http://downloads.sourceforge.net/project/ss5/ss5/3.6.4-3/ss5-3.6.4-3.tar.gz
tar zxvf ss5-3.6.4-3.tar.gz
cd ss5-3.6.4
./configure  //notes:(默认是1080端口,如果想改端口的话,./configure –with-defaultport=10800
make
make install

有点 BUG 需要我们手工修正一下
# vi /etc/rc.d/init.d/ss5 找到38行

/usr/local/sbin/ss5

改为

/usr/sbin/ss5

# vi /etc/rc.d/init.d/ss5 找到40行

echo "done"
;;

改成

echo "done"
fi
;;

看下我修改后的对比

143A02955-2.jpg

143A02955-2.jpg

4. 启动ss5服务

/etc/init.d/ss5 start

5. 添加 ss5 到服务中,并随机启动

chkconfig --add ss5
chkconfig ss5 on

6. 删除Socks V4模块
改名为 mod_socks4.so.bk

mv /usr/lib/ss5/mod_socks4.so /usr/lib/ss5/mod_socks4.so.bk

7. 添加 SS5 用户
ss5 默认使用1080端口,并允许任何人使用。
我们可以修改 /etc/opt/ss5/ss5.conf 中的

# SHost SPort Authentication
#
auth 0.0.0.0/0 - -

# SHost SPort Authentication
#
auth 0.0.0.0/0 - u

/etc/opt/ss5/ss5.passwd 中添加 用户名和密码如:

test test

8. 设置允许范围

143A02955-2.jpg

使用用户验证,重启ss5服务

/etc/init.d/ss5 restart

8. 查看日志

more /var/log/ss5/ss5.log

ss5正常启动后,如果你使用的是10800(非默认端口),这时会发现1080和10800都开的了,

这时你需要去环境变量里手工指定端口

export SS5_SOCKS_PORT=10800