Reputation: 385
I have a small gui swing application(Chat) in java, I need to run it multiple times, each time it should give me a GUI chat window,
It works fine for the first time, when I try to run the same application again in IntelliJ it wont generate anymore GUI window
any help is greatly appreciated thank you in advance
public static void main(String[] args) throws IOException, InterruptedException, SQLException {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("sconfig.xml");
CClient client = (CClient) context.getBean("simpleClient");
client.init();
}
Application Context:
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL">
<!-- value>tcp://localhost:61616</value -->
<value>vm://localhost</value>
</property>
</bean>
<!-- <bean id="pooledJmsConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop">
<property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>-->
<bean id="destination" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="jmsExample" />
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>
<bean id="simpleClient" class="com.CClient">
<property name="template" ref="jmsTemplate"/>
<property name="destination" ref="destination" />
</bean>
<bean id="messageListener" class="com.ExampleListener" />
<!-- and this is the message listener container -->
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="jmsConnectionFactory"/>
<property name="destination" ref="destination"/>
<property name="messageListener" ref="messageListener" />
</bean>
Upvotes: 1
Views: 840
Reputation: 691715
There's no reason launching an application once works fine, and launching it a second time doesn't do anything, since they're launched in a different JVM. There could be a problem if the first launch tries to open a TCP socket, or lock a file, and the second launch tries doing the same thing.
But I think the explanation is that you checked the "single instance only" checkbox in the Run Configuration, which is precisely used to make IntelliJ only launch one instance of your application instance at once.
If that's not the case provide more details: what happens when you launch the second app? Do you get an exception? If so, what's the stack trace? If not, what does your application do?
Upvotes: 2