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);
}
}
}