Call hibern8ide in eclipse and solve Chinese problems

Source: Internet
Author: User
Call hibern8ide in eclipse and solve Chinese problems at the same time --


System Environment:

Hibernate 2.1

Hibernate-extensions-2.1.2

Eclipse 3.0

Oracle 8.1.7

Step 1

Configure your hibernate. cfg. xml and all your *. HBM. XML files.

Import JDBC driver to libraries.

Import the *. jar package under hibern8ide \ Lib to libraries

Import hibernate2.jar and related packages to libraries

Step 2

Create a starthibern8ide. Java file in your project to start hibern8ide

See the following JavaCode

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. hibern8ide. awtexceptionhandler;

Import net. SF. hibern8ide. hibern8ide;

Import net. SF. hibernate. cfg. configuration;

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 ("cocould not install AWT handler ;(");

}

Clearlookmanager. setmode (clearlookmode. On );

Uimanager. setlookandfeel (New plasticxplookandfeel ());



Setuifont (New javax. Swing. plaf. fontuiresource ("", Font. Bold, 12 ));

// The above settings are used to solve Chinese problems



// Start hibern8ide

Configuration. Configure ();

Hibern8ide. 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 );

}

}

}

 


Previously, we used ant run to directly call hibern8ide. When initializing and applying, we couldn't find *. HBM. xml or other files and packages.

There are also Chinese characters.

In this way, you can directly transfer the net. SF. hibernate. cfg. Configuration instance and start hibern8ide. Therefore, you do not need to configure Mapping Files, classpath

And other files.

======================================

Refer:

What is the solution http://forum.javaeye.com/viewtopic.php for hibern8ide Chinese problems? T = 5830 & Highlight = hibern8ide

========================================================== ==============

If you want to reference myArticleKeep the following information.

I am a beginner, and I have a lot of bugs in my article. You are welcome to correct me. I will make timely adjustments. Thank you !!!!

Author: Xiaomi Eugene

Blog http://deve.blogdriver.com

Email: javapattern (AT) 126.com

Stupid remarks:

The latest version of this tool is called hibernateconsole, and the code can be written in this way. However, the hibernateconsole with such settings loses the interface's adaptability to resolution:

Package amao. helper;

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. Console. awtexceptionhandler;

Import net. SF. hibernate. Console. Start;

Import net. SF. hibernate. cfg. configuration;

/**

* @ Author Wyn

*

* Todo to change the template for this generated type comment go to window-

* Preferences-Java-code style-code templates

*/

Public class starthibernateconsole {

Public static void main (string [] ARGs) throws exception {

// 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 ("cocould not install AWT handler ;(");

}

Clearlookmanager. setmode (clearlookmode. On );

Uimanager. setlookandfeel (New plasticxplookandfeel ());

Setuifont (New javax. Swing. plaf. fontuiresource ("", Font. Bold, 12 ));

// The above settings are used to solve Chinese problems

// Start hibern8ide

// Configuration. Configure ();

// Start. startwith (configuration );

Start. Main (null );



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

}

}

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.