2009-10-30 17:17
安装前的准备,先下载以下两个文件,不知道是不是版本原因,刚开始试过另外一个版本,结果不成功,就换了新点的版本,推荐以下两个版本
1、java版本jdk-6u1-linux-i586.bin
2、tomcat版本apache-tomcat-6.0.16.tar.gz
首先安装java,如果要安装在/usr/local/ 里就把jdk-6u1-linux-i586.bin复制到/usr/local/这个目录,然后输入命令#chmod 755 jdk-6u1-linux-i586-rpm.bin,添加执行的权限,在执行命令#./jdk-6u1-linux-i586-rpm.bin在这个过程中,要按几次回车,然后输入YES就安装完成了,会在/usr/local/这个目录下多了一jdk1.6.0_01的目录,这个目录就是java的安装目录了。然后设置环境变量,有两种,1. 修改/etc/profile文件,用文本编辑器打开/etc/profile在profile文件末尾加入:
JAVA_HOME=/usr/local/jdk1.6.0_01
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib
export JAVA_HOME
export PATH
export CLASSPATH
export CATALINA_BASE=/usr/local/tomcat
export CATALINA_HOME=/usr/local/tomcat
·注解
a. 你要将/usr/local/jdk1.6.0_01改为你的jdk安装目录
b. linux下用冒号“:”来分隔路径
c. $PATH / $CLASSPATH / $JAVA_HOME 是用来引用原来的环境变量的值
在设置环境变量时特别要注意不能把原来的值给覆盖掉了,这是一种
常见的错误。
d. CLASSPATH中当前目录“.”不能丢,把当前目录丢掉也是常见的错误。
e. export是把这三个变量导出为全局变量。
f. 大小写必须严格区分。
2. 修改.bashrc文件
这种方法更为安全,它可以把使用这些环境变量的权限控制到用户级别,如果你需要给某个用户权限使用这些环境变量,你只需要修改其个人用户主目录下的.bashrc文件就可以了。
·用文本编辑器打开用户目录下的.bashrc文件
·在.bashrc文件末尾加入:
export JAVA_HOME=/usr/local/j2sdk1.4.2_04
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin
export CATALINA_BASE=/usr/local/tomcat
export CATALINA_HOME=/usr/local/tomcat
最后安装tomcat,首先解压#tar zxvf apache-tomcat-6.0.10.tar.gz ;//解压 ;#cp -R apache-tomcat-6.0.10 /usr/local/tomcat ;//拷贝apache-tomcat-6.0.10到/usr/local/下并重命名为tomcat
/usr/local/tomcat/bin/startup.sh; //启动tomcat
显示 Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TEMDIR: /usr/local/tomcat/temp
Using JAVA_HOME: /usr/java/jdk1.6.0_01
到此tomcat已经安装完成,现在使用浏览器访问 http://localhost:8080,出现tomcat默认页面,说明已经安装成功
如果我想让Tomcat开机自动加载怎么办呢?好,往下看吧!
Tomcat安装目录下的bin目录有两个脚本分别用来启动和停止Tomcat,分别是startup.sh, shutdown.sh,你可以用这两个脚本来手工启动和停止Tomcat服务并进行安装后的测试。
我们最简单的方法就是通过startup.sh来自动启动Tomcat,编辑/etc/rc.d/rc.local 增加内容(假设JDK目录是/usr/jdk,Tomcat目录是/apache/tomcat)
export JDK_HOME=/usr/jdk
export JAVA_HOME=/usr/jdk
/apache/tomcat/bin/startup.sh
[root@tpwb ~]# vi /etc/rc.d/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
export JDK_HOME=/usr/java/j2sdk1.4.2_04
export JAVA_HOME=/usr/java/j2sdk1.4.2_04
/usr/local/jakarta-tomcat-5.0.28/bin/startup.sh
这个是我的目录的
这样在系统重启后就可以自动启动Tomcat
Wednesday, September 22, 2010
Thursday, September 16, 2010
How to convert your laptop into a Wireless HotSpot?
What do I need to set a HotSpot?
1. Active Cable Internet
2. Laptop
3. WiFi on Laptop
4. Wired net connection
Once you have all the above things mentioned, you are all set to follow the steps:
How to setup HotSpot on Windows Vista:
1. Got to Control Panel
2. Click on “Network and Sharing Centre”
3. Under Tasks choose “Setup New Connection”
4. Wireless “Ad-hoc network”
5. Now type in a “Network Name”
6. Choose “WEP” password if you don’t want to share the connection with the entire world
7. Click “Internet connection sharing”
8. Done!
Now a WiFi enabled machine will be able to connect to the network you have just setup with the WEP password
Lets setup a HotSpot on a Windows XP machine:
1. Go into Control panel
2. Open “Network Connections”
3. Right click on "Wireless Connection" and click on "Properties"
4. Click on the "Wireless Networks" tab and select the check-box which says “Use Windows to configure my wireless network settings”
5. Under “Prefered networks” click “Add”
6. Type a name in “Network name” text box
7. Select “Shared” from the options under “Network Authentication”
8. Under Data encryption select “WEP” and type in your password in “Network Key” field and now click "OK"
9. Now the new HotSpot should show in the list of preferred networks.
10. Click on the “Advance” button and select “Computer-to-computer (ad hoc) networks only" and press close
11. Hit “OK”, we are done with the wireless connection properties
One more step, we have to change something in the wired connection setting so that it knows that it has to share connection with the computers accessing our HotSpot.
1. Go to local Area Connections, right click it and select properties
2. Go to the “Advanced” tab and under Internet Connection Sharing check the box which says “Allow other network users to connect through this computer’s internet connection” and make sure the box under that is NOT selected so that no one can disable the network remotely.
3. Hit “OK”
I hope this helps setting up a wireless connection without a WiFi router. Have FuN!
1. Active Cable Internet
2. Laptop
3. WiFi on Laptop
4. Wired net connection
Once you have all the above things mentioned, you are all set to follow the steps:
How to setup HotSpot on Windows Vista:
1. Got to Control Panel
2. Click on “Network and Sharing Centre”
3. Under Tasks choose “Setup New Connection”
4. Wireless “Ad-hoc network”
5. Now type in a “Network Name”
6. Choose “WEP” password if you don’t want to share the connection with the entire world
7. Click “Internet connection sharing”
8. Done!
Now a WiFi enabled machine will be able to connect to the network you have just setup with the WEP password
Lets setup a HotSpot on a Windows XP machine:
1. Go into Control panel
2. Open “Network Connections”
3. Right click on "Wireless Connection" and click on "Properties"
4. Click on the "Wireless Networks" tab and select the check-box which says “Use Windows to configure my wireless network settings”
5. Under “Prefered networks” click “Add”
6. Type a name in “Network name” text box
7. Select “Shared” from the options under “Network Authentication”
8. Under Data encryption select “WEP” and type in your password in “Network Key” field and now click "OK"
9. Now the new HotSpot should show in the list of preferred networks.
10. Click on the “Advance” button and select “Computer-to-computer (ad hoc) networks only" and press close
11. Hit “OK”, we are done with the wireless connection properties
One more step, we have to change something in the wired connection setting so that it knows that it has to share connection with the computers accessing our HotSpot.
1. Go to local Area Connections, right click it and select properties
2. Go to the “Advanced” tab and under Internet Connection Sharing check the box which says “Allow other network users to connect through this computer’s internet connection” and make sure the box under that is NOT selected so that no one can disable the network remotely.
3. Hit “OK”
I hope this helps setting up a wireless connection without a WiFi router. Have FuN!
Monday, August 16, 2010
How to get device IMEI number using JavaME for different vendors?
The International Mobile Equipment Identity (IMEI) is a number unique to every GSM, WCDMA, and iDEN mobile phone, as well as some satellite phones. It is usually found printed inside the battery compartment of the phone. It can also be displayed on the screen of the phone by entering *#06# into the keypad on most phones.
To retreive same information using JavaME is as follows:
As you all know that, MIDP (Mobile Information Device Profile) when combined with CLDC provides a Java Runtime Environment and a rich set of Java APIS for cell phones. MIDP defines some System properties that are available to the midlet with java.lang.System.getProperty(...) method. As IMEI is manufacturer specifc so there are few manufacturer specific APIs using which you can retrieve this info. Here's how to get IMEI number from mobile devices of different manufacturers:
1. Nokia
* System.getProperty("phone.imei");
* System.getProperty("com.nokia.imei");
* System.getProperty("com.nokia.mid.imei"); //especially for S40 devices
2. Note: Requires signed MIDlet. S60 3rd edition device does not requires signing to fetch this info.On Series 40 phones this requires that your MIDlet is signed to either operator or manufacturer domain, and this is only available in Series 40 3rd Edition, FP1 devices and newer. Sony Ericsson
* System.getProperty("com.sonyericsson.imei");
3. Samsung
* System.getProperty("com.samsung.imei");
4. Motorola
* System.getProperty("IMEI");
* System.getProperty("com.motorola.IMEI");
5. Siemens
* System.getProperty("com.siemens.IMEI");
6. LG
* System.getProperty("com.lge.imei");
In addition to this, there are some generic information about the device that can be retrieved by using System.getProperty(propertyString) method call, where value of propertyString can be vary as per your requirement. Few of them are listed as below:-
1. microedition.profiles
2. microedition.configuration
3. microedition.locale
4. microedition.platform
For more information see MIDP System Properties & J2ME Defined System Properties
To retreive same information using JavaME is as follows:
As you all know that, MIDP (Mobile Information Device Profile) when combined with CLDC provides a Java Runtime Environment and a rich set of Java APIS for cell phones. MIDP defines some System properties that are available to the midlet with java.lang.System.getProperty(...) method. As IMEI is manufacturer specifc so there are few manufacturer specific APIs using which you can retrieve this info. Here's how to get IMEI number from mobile devices of different manufacturers:
1. Nokia
* System.getProperty("phone.imei");
* System.getProperty("com.nokia.imei");
* System.getProperty("com.nokia.mid.imei"); //especially for S40 devices
2. Note: Requires signed MIDlet. S60 3rd edition device does not requires signing to fetch this info.On Series 40 phones this requires that your MIDlet is signed to either operator or manufacturer domain, and this is only available in Series 40 3rd Edition, FP1 devices and newer. Sony Ericsson
* System.getProperty("com.sonyericsson.imei");
3. Samsung
* System.getProperty("com.samsung.imei");
4. Motorola
* System.getProperty("IMEI");
* System.getProperty("com.motorola.IMEI");
5. Siemens
* System.getProperty("com.siemens.IMEI");
6. LG
* System.getProperty("com.lge.imei");
In addition to this, there are some generic information about the device that can be retrieved by using System.getProperty(propertyString) method call, where value of propertyString can be vary as per your requirement. Few of them are listed as below:-
1. microedition.profiles
2. microedition.configuration
3. microedition.locale
4. microedition.platform
For more information see MIDP System Properties & J2ME Defined System Properties
Thursday, August 5, 2010
Call Javascript from a Java applet
Netscape only, using the javascript: protocol
A Javascript function is called from Java by using the showDocument method. A URL is needed with "javascript:" as the protocol.
[Java applet]
[Javascript and HTML]
Try it here Netscape and IE ok, using the netscape.javascript.JSObject package
How to compile when using the netscape.javascript.JSObject package ?
For Java 1.4.2 and later: add plugin.jar to your classpath. It can be found in the lib directory of your JRE installation, e.g. C:\Program Files\Java\jre1.5.0\lib\plugin.jar
For Java 1.4.0/1.4.1: use jaws.jar (same directory).
In the following example, you type in the TextField a Javascript function and press the button to execute the function. For example, try alert('Hello from JAVA'). Or you can execute function defined on the same page as the Applet. The Applet must contains the MAYSCRIPT parameter to be able to use JSObject.
Netscape and IE Ok.
Try it here Another way is to use the Reflection API. That way you don't need to modify your CLASSPATH for compilation or even import the netscape.jsobject package.
A Javascript function is called from Java by using the showDocument method. A URL is needed with "javascript:" as the protocol.
[Java applet]
import java.applet.*;
import java.net.*;
public class InJava4 extends Applet{
public void init(){
String msg = "Hello from Java (using javascript alert)";
try {
getAppletContext().showDocument
(new URL("javascript:doAlert(\"" + msg +"\")"));
}
catch (MalformedURLException me) { }
}
}How to compile when using the netscape.javascript.JSObject package ?
For Java 1.4.2 and later: add plugin.jar to your classpath. It can be found in the lib directory of your JRE installation, e.g. C:\Program Files\Java\jre1.5.0\lib\plugin.jar
For Java 1.4.0/1.4.1: use jaws.jar (same directory).
In the following example, you type in the TextField a Javascript function and press the button to execute the function. For example, try alert('Hello from JAVA'). Or you can execute function defined on the same page as the Applet. The Applet must contains the MAYSCRIPT parameter to be able to use JSObject.
Netscape and IE Ok.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import netscape.javascript.*;
public class InJava5 extends Applet implements ActionListener {
Button b;
TextField t;
public void init() {
t = new TextField(20);
add(t);
b = new Button("execute Javascript");
add(b);
b.addActionListener(this);
}
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == b) {
JSObject win = (JSObject) JSObject.getWindow(this);
win.eval(t.getText());
}
}
}// posted by C Werner on the realhowto list
import java.lang.reflect.*;
...
// Somewhere in the applet class ...
...
String jscmd = "window.close()"; /* JavaScript command */
String jsresult = null;
boolean success = false;
try {
Method getw = null, eval = null;
Object jswin = null;
Class c =
Class.forName("netscape.javascript.JSObject"); /* does it in IE too */
Method ms[] = c.getMethods();
for (int i = 0; i < ms.length; i++) {
if (ms[i].getName().compareTo("getWindow") == 0)
getw = ms[i];
else if (ms[i].getName().compareTo("eval") == 0)
eval = ms[i];
}
}
Object a[] = new Object[1];
a[0] = this; /* this is the applet */
jswin = getw.invoke(c, a); /* this yields the JSObject */
a[0] = jscmd;
Object result = eval.invoke(jswin, a);
if (result instanceof String)
jsresult = (String) result;
else
jsresult = result.toString();
success = true;
}
catch (InvocationTargetException ite) {
jsresult = "" + ite.getTargetException();
}
catch (Exception e) {
jsresult = "" + e;
}
if (success)
System.out.println("eval succeeded, result is " + jsresult);
else
System.out.println("eval failed with error " + jsresult);3 easy steps to self-sign a Applet Jar file
From link .
1. keytool -genkey -keystore myKeyStore -alias me
2. keytool -selfcert -keystore myKeyStore -alias me
3. jarsigner -keystore myKeyStore jarfile.jar me
1. keytool -genkey -keystore myKeyStore -alias me
2. keytool -selfcert -keystore myKeyStore -alias me
3. jarsigner -keystore myKeyStore jarfile.jar me
Monday, August 2, 2010
What Is - Appropriate version of the BlackBerry JDE
Description
When creating and building your application, it is important to choose the correct version of the BlackBerry JDE to make sure that the application is compatible with the target BlackBerry smartphones. Applications built in the BlackBerry JDE are forward-compatible with newer BlackBerry Device Software versions, but they are not backward-compatible with older versions.
For example, an application built in BlackBerry JDE 4.1 runs on a BlackBerry smartphones running BlackBerry® Device Software 4.1 and later. It does not run on a BlackBerry smartphones running BlackBerry Device Software 4.0. Thus, when building applications, you should use a BlackBerry JDE version that matches the lowest version of BlackBerry Device Software you want to support.
Note: To verify the version of BlackBerry Device Software installed on the BlackBerry smartphone, select Options > About.
Applications developed using the BlackBerry JDE are forward-compatible but not backward-compatible. In other words, an application developed with JDE 4.1 will run on BlackBerry devices with device software version 4.1 and later; however, they will not run on device software 4.0.
Applications developed using the BlackBerry JDE are forward-compatible but not backward-compatible. In other words, an application developed with JDE 4.1 will run on BlackBerry devices with device software version 4.1 and later; however, they will not run on device software 4.0.
Wednesday, July 28, 2010
MC55
how to create a shortcut in program
Cut and paste the shortcut from that folder into the \Windows\Start Menu\Programs folder on your device. You can also then rename the shortcut if you want.
Cut and paste the shortcut from that folder into the \Windows\Start Menu\Programs folder on your device. You can also then rename the shortcut if you want.
Subscribe to:
Posts (Atom)