Java环境设置及中文问题祥解

Java环境设置及中文问题祥解
1:Java开发中系统环境变量设置(JDK):
方法如下:
Win2000/winXP中:
右键我的电脑--》属性--》高级--》环境环境变量
classpath=.;jdk安装目/lib
path=jdk安装目录/bin
注意:一定不可忽略“.”。
Win98中:
修改autocexe.bat 就是修改自动批处理文件。
添加:
set classpath=.;jdk安装目/lib
set path=jdk安装目录/bin;%path%
linuX中:
假设JDK安装在/home/jdk1.4.0/下,打开/etc/profile,在其中加入:
PATH="/home/jdk1.4.0/bin:$PATH"
CLASSPATH=.:/home/jdk1.4.0/jre/lib/rt.jar:/home/jdk1.4.0/lib/tools.jar
JAVA_HOME=/home/jdk1.4.0
export PATH CLASSPATH JAVA_HOME
2:(前提设置好了系统环境变量)
不带包的编译,相当简单:
javac 类名.java
java 类名
关于带包的编译问题:
如果你的类是带包的,应该用如下方法编译:
javac -d 包的父目录 类名.java
java 包名.类名

3:Tomcat服务器配置:
1):设置好系统环境变量。
2):JAVA_HOME=G:/JBuilder6/jdk1.3.1
G:/JBuilder6/jdk1.3.1为jdk安装目录
3):TOMCAT_HOME=tomcat安装目录
4:修改serlet而不重新启动tomcat修改
%TOMCAT_HOME%/conf/server.xml
大致如下:
<Context path="" docBase="ROOT" debug="0" reloadable="true"/>
其中reloadable就是配置是否自动reload的,把它设为true,如果没有这一项,加上。
5:修改webshpere中的servlet而不重新启动服务:
修改../WEB-INF下面的web.xml:
加入
<webappext:WebAppExtension xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:webappext="webappext.xmi" xmlns:webapplication="webapplication.xmi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmi:id="WebApp_ID_Ext" reloadInterval="3" reloadingEnabled="true" fileServingEnabled="true" directoryBrowsingEnabled="true" serveServletsByClassnameEnabled="true">其中reloadInterval="3" reloadingEnabled="true" fileServingEnabled="true" directoryBrowsingEnabled="true" serveServletsByClassnameEnabled="true"是主要的,reloadInterval="3" reloadingEnabled="true" 是说修改后3秒自动重新载
入。

6:配置jbuilder6+webshpere4.0AE,其实jb7可以参照:
首先安装j2ee,然后把j2ee加入到jb的libraries里面。方法如下
1:)tools--->configure libraries-->new--->name:里面填写j2ee,Location:里面默认的旧可以了。---->add-->选在j2ee安装路径,选中lib文件夹--ok--oK.
 2:)返回到configure libraries也面后,选中Required Libraries-->add--》选中你刚才创建的j2ee,点ok就可以了。
然后配置webshpere应用服务器和database pilot:
第一步:tools-->enterprise setup-->Application servers设置安装路径以及IBM的JAVA路径,DB2你自己看着办
第二步:project-->Defaults project properties里servers选择Ws4.0,应该可以用了
webshpere4.0不支持ejb2.0,webshpere5.0支持。
配置database pilot
第一步:添加类库tools-->config libraries添加你的数据库驱动程序类
第二步:tools-->enterprise setup-->Database Drivers里面添加你刚添加的那个类库
第三步:重启JBilder后,tools-->database pilot-->option-->drivers,添加驱动程序
第四步:在database pilot点新建就可以了,driver:COM.ibm.db2.jdbc.app.DB2Driver。url:jdbc:db2:db_sdbc.(db_sdbc为服务器上的db2数据库).
7:解决java中文问题:
针对applet和awt:
 1:)
    Font f = new Font(UIResource.getString(      "Default_font"),Font.PLAIN,12);
      UIManager.put("Label.font",f);
      UIManager.put("Label.foreground",Color.black);
      UIManager.put("Button.font",f);
      UIManager.put("Menu.font",f);
      UIManager.put("MenuItem.font",f);
      UIManager.put("List.font",f);
      UIManager.put("CheckBox.font",f);
      UIManager.put("RadioButton.font",f);
      UIManager.put("ComboBox.font",f);
      UIManager.put("TextArea.font",f);


    2:)
      Font f = new Font("隶书",Font.PLAIN,15);
           UIManager.put("Button.font",font);
            UIManager.put("ToggleButton.font",font);
            UIManager.put("RadioButton.font",font);
            UIManager.put("CheckBox.font",font);
            UIManager.put("ColorChooser.font",font);
            UIManager.put("ToggleButton.font",font);
            UIManager.put("ComboBox.font",font);
            UIManager.put("ComboBoxItem.font",font);
            UIManager.put("InternalFrame.titleFont",font);
            UIManager.put("Label.font",font);
            UIManager.put("List.font",font);
            UIManager.put("MenuBar.font",font);
            UIManager.put("Menu.font",font);
            UIManager.put("MenuItem.font",font);
            UIManager.put("RadioButtonMenuItem.font",font);
            UIManager.put("CheckBoxMenuItem.font",font);
            UIManager.put("PopupMenu.font",font);
            UIManager.put("OptionPane.font",font);
            UIManager.put("Panel.font",font);
            UIManager.put("ProgressBar.font",font);
            UIManager.put("ScrollPane.font",font);
            UIManager.put("Viewport",font);
            UIManager.put("TabbedPane.font",font);
            UIManager.put("TableHeader.font",font);
            UIManager.put("TextField.font",font);
            UIManager.put("PasswordFiled.font",font);
            UIManager.put("TextArea.font",font);
            UIManager.put("TextPane.font",font);
            UIManager.put("EditorPane.font",font);
            UIManager.put("TitledBorder.font",font);
            UIManager.put("ToolBar.font",font);
            UIManager.put("ToolTip.font",font);
            UIManager.put("Tree.font",font);

 3:)针对jsp和servlet:
解决办法:
第一:
在jsp页面加入:
<%@ page contentType="text/html; charset=gb2312" %>
或者在servlet里面
  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html; charset=gb2312");//这是重要的
上面的如果在不行就用如下的方法在数据入库前进行调用:
public static String UnicodeToChinese(String s){
  try{
     if(s==null||s.equals("")) return "";
     String newstring=null;
     newstring=new String(s.getBytes("ISO8859_1"),"gb2312");
     return newstring;
    }
  catch(UnsupportedEncodingException e)
  {
  return s;
  }
  }

public static String ChineseToUnicode(String s){
  try{
  if(s==null||s.equals("")) return "";
  String newstring=null;
  newstring=new String(s.getBytes("gb2312"),"ISO8859_1");
   return newstring;
  }
  catch(UnsupportedEncodingException e)
  {
  return s;
}
  }
3:)解决weblogic/webshpere中文问题:
在web.xml文件中需要配置中文环境。r如下:
<context-param>
  <param-name>weblogic.httpd.inputCharset./*</param-name>
  <param-value>GB2312</param-value>
</context-param>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值