鄧華

          BlogJava 聯系 聚合 管理
            48 Posts :: 0 Stories :: 149 Comments :: 0 Trackbacks

          hibernate8ide在新版本中已經改名叫console了.  用如下方法運行,可以利用項目中已經建好的配置文件, 不用再配置, 減少了hibernamte8ide出錯的機會. 以前直接RUN的時候, 有各種錯誤出現. 搞得人很頭暈的.

          下載最新版hibernate-extensions, 解壓到相關目錄.

          在jb的工程中引入console目錄下的hibernateconsole.jar, 再引入console\lib目錄下的所有jar文件

          創建一個StartHibern8IDE.java文件, 拷貝下面的代碼,然后run.

          參考了一篇hibernate8ide運行在eclipse中的文章.

          當然,下面的代碼,再eclipse中是一樣的用的.

          用下面的代碼運行,可以解決中文問題.

          import java.awt.Font;

          import javax.swing.UIManager;

          import com.jgoodies.clearlook.ClearLookManager;
          import com.jgoodies.clearlook.ClearLookMode;
          import com.jgoodies.plaf.plastic.PlasticXPLookAndFeel;


          import net.sf.hibernate.cfg.Configuration;
          import net.sf.hibernate.console.*;


          public class StartHibern8IDE {

          public static void main(String[] args) throws Exception {
          Configuration configuration = new Configuration();

          try {
              if (System.getProperty("sun.awt.exception.handler")==null) {
                 System.setProperty("sun.awt.exception.handler", AWTExceptionHandler.class.getName());
              } else {
                 System.err.println("could not install AWT handler ;(");
              }
              ClearLookManager.setMode(ClearLookMode.ON);
              UIManager.setLookAndFeel(new PlasticXPLookAndFeel());

           setUIFont (new javax.swing.plaf.FontUIResource("宋體",Font.PLAIN,12));
                    
           configuration.configure();

          // run

           Start.startWith(configuration);

           } catch (Exception e) { // noop
               e.printStackTrace();
           }

          }

          public static void setUIFont (javax.swing.plaf.FontUIResource f){
              java.util.Enumeration keys = UIManager.getDefaults().keys();
              while (keys.hasMoreElements()) {
                Object key = keys.nextElement();
                Object value = UIManager.get (key);
                if (value instanceof javax.swing.plaf.FontUIResource)
                  UIManager.put (key, f);
                }
              }
          }

           

          posted on 2006-03-16 11:54 鄧華的碎碎念 閱讀(155) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 巴彦县| 池州市| 鄂尔多斯市| 青海省| 黔西| 九龙坡区| 神池县| 海宁市| 兴和县| 武鸣县| 历史| 安平县| 和林格尔县| 涟源市| 西昌市| 攀枝花市| 靖远县| 石景山区| 武川县| 鹤庆县| 兴文县| 湖北省| 荆州市| 新民市| 南木林县| 云阳县| 武夷山市| 平顺县| 绥德县| 米易县| 五寨县| 县级市| 梨树县| 青海省| 东港市| 弋阳县| 翁源县| 扎囊县| 呼图壁县| 翼城县| 武义县|