This is a loaded question. Is it going to be a Swing/SWT app or Main program of some type?
Here is some pointers that might help
No you don't need J2EE container to run Spring.
You would obviously need a Java program with main() method in it ( I assume you know that ) and there are various ways to instantiate Spring Bean Factory and/or Application Context (see a quick example below).
Code:
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
ITest test = (ITest) context.getBean("testTarget");
test.foo("Foo");
System.out.println("Done");
}
If you are running it in Swing/SWT app then you would include this code in the appropriate place within your GUI container.
If you are planing to implement your own container you can look at implementation of Main class of Tomcat, Servicemix, JBoss and other containers (Servicemix would be preferable since it is Spring based)
small example would be:
Code:
public static void main(String args[]) {
try {
ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
. . . . .
Object lock = new Object();
synchronized (lock) {
lock.wait();
}
} catch (Exception e) {
e.printStackTrace();
}
}
Hope it helps
Oleg Zhurakousky