Java tutorial
package iqq.app; import iqq.app.core.context.IMContext; import iqq.app.ui.manager.FrameManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import javax.swing.*; import java.io.File; /** * ? * <p> * Project : iqq * Author : < 6208317@qq.com > * Created : 14-4-17 * License : Apache License 2.0 */ @Configuration @ComponentScan("iqq.app") public class IMLauncher { private static final Logger LOG = LoggerFactory.getLogger(IMLauncher.class); /** * ?? * * @param args */ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { init(); startup(); } }); } /** * ??? */ private static void init() { // APP String path = System.getProperty("user.dir"); if (new File(path + File.separator + "resources").exists()) { System.setProperty("app.dir", new File(path).getAbsolutePath()); } else { // ?main path = path.substring(0, path.lastIndexOf(File.separator)); System.setProperty("app.dir", new File(path).getAbsolutePath()); } LOG.info("app.dir = " + System.getProperty("app.dir")); // ? Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { shutdown(); } })); LOG.info("init..."); } /** * ?? */ private static void startup() { IMContext.init(new AnnotationConfigApplicationContext("iqq.app")); FrameManager frameManager = IMContext.getBean(FrameManager.class); frameManager.showLogin(); } /** * ? */ private static void shutdown() { LOG.info("shutdown..."); } }