Running a GUI application twice in java

I have a small gui (Chat) drag and drop application in java, I need to run it several times, every time it should give me a GUI chat window,

It works fine the first time when I try to run the same application again in IntelliJ it won't generate any more GUI window

any help greatly thanks 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>

      

+3


source to share


1 answer


There is no reason why launching an application once works fine and launching it a second time does nothing as they are being launched in a different JVM. It could be a problem if the first launch tries to open a TCP socket or lock a file, and the second launch tries to do the same.

But I think the explanation is that you checked the "only one instance" checkbox in the Run Configuration, which is exactly what is used to make IntelliJ only run one instance of your application instance at a time.



If not, please provide more details: What happens when the second application starts? Are you getting an exception? If so, what is the stack trace? If not, what does your application do?

+2


source







All Articles