Not able to run two Java FX Instance from Java main application? [duplicate]










1
















This question already has an answer here:



  • JavaFX launch another application

    3 answers



I am begineer in Java FX application. I have created a simple project where i want to run two Java FX instance using Java main application.



public class InfoMain {
public static void main(String args) throws Exception
Application.launch(CxiC.class, args);
Application.launch(BiC.class, args);


BiC class is sample application while I change the text of CxiC class as follow:



public class CxiC extends Application
@Override
public void start(Stage primaryStage)
Button btn = new Button();
btn.setText("Say 'Hello budapest'");
btn.setOnAction(new EventHandler<ActionEvent>()

@Override
public void handle(ActionEvent event)
System.out.println("Hello budapest!");

);

StackPane root = new StackPane();
root.getChildren().add(btn);

Scene scene = new Scene(root, 300, 250);

primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();



When i execute the application, following screen appear from the message in BiC class. But i am expecting both screen to be appeared on same time. Any suggestion?.



Based on the comments, i modify my code, but stills it shows Hello World message. Even i have deleted both instance from my Java main method class, the message is same. It seems JavaFX argument is not accpeted from the Java Application.
Thanks in advance.
enter image description here










share|improve this question















marked as duplicate by fabian java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 13 '18 at 22:36


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • How about creating each instance in a thread ? (one thread for each)

    – Chargnn
    Nov 13 '18 at 22:18











  • Application.launch() blocks until the javafx toolkit shuts down. This is why you don't see the results of the second launch call immediately. Note that the results of the second launch call would be an exception, see the duplicate link.

    – fabian
    Nov 13 '18 at 22:38











  • All the linked answers are valid, if this still isn't working for you Yatish, create a new question which contains your new code which does not work, otherwise, you can't be helped as it is impossible to help debug code which you cannot see.

    – jewelsea
    Nov 14 '18 at 0:28















1
















This question already has an answer here:



  • JavaFX launch another application

    3 answers



I am begineer in Java FX application. I have created a simple project where i want to run two Java FX instance using Java main application.



public class InfoMain {
public static void main(String args) throws Exception
Application.launch(CxiC.class, args);
Application.launch(BiC.class, args);


BiC class is sample application while I change the text of CxiC class as follow:



public class CxiC extends Application
@Override
public void start(Stage primaryStage)
Button btn = new Button();
btn.setText("Say 'Hello budapest'");
btn.setOnAction(new EventHandler<ActionEvent>()

@Override
public void handle(ActionEvent event)
System.out.println("Hello budapest!");

);

StackPane root = new StackPane();
root.getChildren().add(btn);

Scene scene = new Scene(root, 300, 250);

primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();



When i execute the application, following screen appear from the message in BiC class. But i am expecting both screen to be appeared on same time. Any suggestion?.



Based on the comments, i modify my code, but stills it shows Hello World message. Even i have deleted both instance from my Java main method class, the message is same. It seems JavaFX argument is not accpeted from the Java Application.
Thanks in advance.
enter image description here










share|improve this question















marked as duplicate by fabian java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 13 '18 at 22:36


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • How about creating each instance in a thread ? (one thread for each)

    – Chargnn
    Nov 13 '18 at 22:18











  • Application.launch() blocks until the javafx toolkit shuts down. This is why you don't see the results of the second launch call immediately. Note that the results of the second launch call would be an exception, see the duplicate link.

    – fabian
    Nov 13 '18 at 22:38











  • All the linked answers are valid, if this still isn't working for you Yatish, create a new question which contains your new code which does not work, otherwise, you can't be helped as it is impossible to help debug code which you cannot see.

    – jewelsea
    Nov 14 '18 at 0:28













1












1








1


1







This question already has an answer here:



  • JavaFX launch another application

    3 answers



I am begineer in Java FX application. I have created a simple project where i want to run two Java FX instance using Java main application.



public class InfoMain {
public static void main(String args) throws Exception
Application.launch(CxiC.class, args);
Application.launch(BiC.class, args);


BiC class is sample application while I change the text of CxiC class as follow:



public class CxiC extends Application
@Override
public void start(Stage primaryStage)
Button btn = new Button();
btn.setText("Say 'Hello budapest'");
btn.setOnAction(new EventHandler<ActionEvent>()

@Override
public void handle(ActionEvent event)
System.out.println("Hello budapest!");

);

StackPane root = new StackPane();
root.getChildren().add(btn);

Scene scene = new Scene(root, 300, 250);

primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();



When i execute the application, following screen appear from the message in BiC class. But i am expecting both screen to be appeared on same time. Any suggestion?.



Based on the comments, i modify my code, but stills it shows Hello World message. Even i have deleted both instance from my Java main method class, the message is same. It seems JavaFX argument is not accpeted from the Java Application.
Thanks in advance.
enter image description here










share|improve this question

















This question already has an answer here:



  • JavaFX launch another application

    3 answers



I am begineer in Java FX application. I have created a simple project where i want to run two Java FX instance using Java main application.



public class InfoMain {
public static void main(String args) throws Exception
Application.launch(CxiC.class, args);
Application.launch(BiC.class, args);


BiC class is sample application while I change the text of CxiC class as follow:



public class CxiC extends Application
@Override
public void start(Stage primaryStage)
Button btn = new Button();
btn.setText("Say 'Hello budapest'");
btn.setOnAction(new EventHandler<ActionEvent>()

@Override
public void handle(ActionEvent event)
System.out.println("Hello budapest!");

);

StackPane root = new StackPane();
root.getChildren().add(btn);

Scene scene = new Scene(root, 300, 250);

primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();



When i execute the application, following screen appear from the message in BiC class. But i am expecting both screen to be appeared on same time. Any suggestion?.



Based on the comments, i modify my code, but stills it shows Hello World message. Even i have deleted both instance from my Java main method class, the message is same. It seems JavaFX argument is not accpeted from the Java Application.
Thanks in advance.
enter image description here





This question already has an answer here:



  • JavaFX launch another application

    3 answers







java javafx






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 22:56







Yatish Bathla

















asked Nov 13 '18 at 22:01









Yatish BathlaYatish Bathla

326520




326520




marked as duplicate by fabian java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 13 '18 at 22:36


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by fabian java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 13 '18 at 22:36


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • How about creating each instance in a thread ? (one thread for each)

    – Chargnn
    Nov 13 '18 at 22:18











  • Application.launch() blocks until the javafx toolkit shuts down. This is why you don't see the results of the second launch call immediately. Note that the results of the second launch call would be an exception, see the duplicate link.

    – fabian
    Nov 13 '18 at 22:38











  • All the linked answers are valid, if this still isn't working for you Yatish, create a new question which contains your new code which does not work, otherwise, you can't be helped as it is impossible to help debug code which you cannot see.

    – jewelsea
    Nov 14 '18 at 0:28

















  • How about creating each instance in a thread ? (one thread for each)

    – Chargnn
    Nov 13 '18 at 22:18











  • Application.launch() blocks until the javafx toolkit shuts down. This is why you don't see the results of the second launch call immediately. Note that the results of the second launch call would be an exception, see the duplicate link.

    – fabian
    Nov 13 '18 at 22:38











  • All the linked answers are valid, if this still isn't working for you Yatish, create a new question which contains your new code which does not work, otherwise, you can't be helped as it is impossible to help debug code which you cannot see.

    – jewelsea
    Nov 14 '18 at 0:28
















How about creating each instance in a thread ? (one thread for each)

– Chargnn
Nov 13 '18 at 22:18





How about creating each instance in a thread ? (one thread for each)

– Chargnn
Nov 13 '18 at 22:18













Application.launch() blocks until the javafx toolkit shuts down. This is why you don't see the results of the second launch call immediately. Note that the results of the second launch call would be an exception, see the duplicate link.

– fabian
Nov 13 '18 at 22:38





Application.launch() blocks until the javafx toolkit shuts down. This is why you don't see the results of the second launch call immediately. Note that the results of the second launch call would be an exception, see the duplicate link.

– fabian
Nov 13 '18 at 22:38













All the linked answers are valid, if this still isn't working for you Yatish, create a new question which contains your new code which does not work, otherwise, you can't be helped as it is impossible to help debug code which you cannot see.

– jewelsea
Nov 14 '18 at 0:28





All the linked answers are valid, if this still isn't working for you Yatish, create a new question which contains your new code which does not work, otherwise, you can't be helped as it is impossible to help debug code which you cannot see.

– jewelsea
Nov 14 '18 at 0:28












1 Answer
1






active

oldest

votes


















3














Calling Application.launch() twice should result in an exception.



From Application.launch() API docs:




Launch a standalone application. This method is typically called from the main method(). It must not be called more than once or an exception will be thrown.
The launch method does not return until the application has exited, either via a call to Platform.exit or all of the application windows have been closed.




You need to create an additional Stage and show it.
Here is an example of showing another stage:
How to open two Javafx windows?






share|improve this answer























  • or even here : stackoverflow.com/a/26369173/4565693

    – Chargnn
    Nov 13 '18 at 22:21











  • Both approaches doesn't work for me. @B.Thomas. It shows me always Hello Message screen even if i commented both Application call methods.

    – Yatish Bathla
    Nov 13 '18 at 22:51

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














Calling Application.launch() twice should result in an exception.



From Application.launch() API docs:




Launch a standalone application. This method is typically called from the main method(). It must not be called more than once or an exception will be thrown.
The launch method does not return until the application has exited, either via a call to Platform.exit or all of the application windows have been closed.




You need to create an additional Stage and show it.
Here is an example of showing another stage:
How to open two Javafx windows?






share|improve this answer























  • or even here : stackoverflow.com/a/26369173/4565693

    – Chargnn
    Nov 13 '18 at 22:21











  • Both approaches doesn't work for me. @B.Thomas. It shows me always Hello Message screen even if i commented both Application call methods.

    – Yatish Bathla
    Nov 13 '18 at 22:51















3














Calling Application.launch() twice should result in an exception.



From Application.launch() API docs:




Launch a standalone application. This method is typically called from the main method(). It must not be called more than once or an exception will be thrown.
The launch method does not return until the application has exited, either via a call to Platform.exit or all of the application windows have been closed.




You need to create an additional Stage and show it.
Here is an example of showing another stage:
How to open two Javafx windows?






share|improve this answer























  • or even here : stackoverflow.com/a/26369173/4565693

    – Chargnn
    Nov 13 '18 at 22:21











  • Both approaches doesn't work for me. @B.Thomas. It shows me always Hello Message screen even if i commented both Application call methods.

    – Yatish Bathla
    Nov 13 '18 at 22:51













3












3








3







Calling Application.launch() twice should result in an exception.



From Application.launch() API docs:




Launch a standalone application. This method is typically called from the main method(). It must not be called more than once or an exception will be thrown.
The launch method does not return until the application has exited, either via a call to Platform.exit or all of the application windows have been closed.




You need to create an additional Stage and show it.
Here is an example of showing another stage:
How to open two Javafx windows?






share|improve this answer













Calling Application.launch() twice should result in an exception.



From Application.launch() API docs:




Launch a standalone application. This method is typically called from the main method(). It must not be called more than once or an exception will be thrown.
The launch method does not return until the application has exited, either via a call to Platform.exit or all of the application windows have been closed.




You need to create an additional Stage and show it.
Here is an example of showing another stage:
How to open two Javafx windows?







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 22:19









B. ThomasB. Thomas

22116




22116












  • or even here : stackoverflow.com/a/26369173/4565693

    – Chargnn
    Nov 13 '18 at 22:21











  • Both approaches doesn't work for me. @B.Thomas. It shows me always Hello Message screen even if i commented both Application call methods.

    – Yatish Bathla
    Nov 13 '18 at 22:51

















  • or even here : stackoverflow.com/a/26369173/4565693

    – Chargnn
    Nov 13 '18 at 22:21











  • Both approaches doesn't work for me. @B.Thomas. It shows me always Hello Message screen even if i commented both Application call methods.

    – Yatish Bathla
    Nov 13 '18 at 22:51
















or even here : stackoverflow.com/a/26369173/4565693

– Chargnn
Nov 13 '18 at 22:21





or even here : stackoverflow.com/a/26369173/4565693

– Chargnn
Nov 13 '18 at 22:21













Both approaches doesn't work for me. @B.Thomas. It shows me always Hello Message screen even if i commented both Application call methods.

– Yatish Bathla
Nov 13 '18 at 22:51





Both approaches doesn't work for me. @B.Thomas. It shows me always Hello Message screen even if i commented both Application call methods.

– Yatish Bathla
Nov 13 '18 at 22:51



這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3