Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Launching a JavaFX Application

963155Sep 19 2012 — edited Sep 19 2012
Hi,

when i was learning JavaFX, i always had everything in 1 class with the main method that called launch() method. However, now im trying to follow MVC pattern and my main method looks like this:
public static void main(String[] args){
        System.out.println("Inside the launcher code");
        
        Model model = new Model();
        MainView view = new MainView();
        
        Controller controller = new Controller(model, view);
        controller.getView().launch();
        
        System.out.println("End of launcher code");        
        
    }
Basically, MainView is a class that extends Application and has start() method. Inside Controller i have a getView() method that returns instance of the MainView. Now, when i run the above code i get the error:

Inside the launcher code
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.javafx.main.Main.launchApp(Main.java:658)
at com.javafx.main.Main.main(Main.java:805)
Caused by: java.lang.RuntimeException: Error: class com.beans.Launcher is not a subclass of javafx.application.Application
at javafx.application.Application.launch(Application.java:211)
at com.beans.Launcher.main(Launcher.java:16)
... 6 more
Java Result: 1
jfxsa-run:
BUILD SUCCESSFUL (total time: 9 seconds)



Can Anyone shed any light on it? I can provide more code if necessary. Thank you !!

Edited by: 960152 on 2012-09-19 11:35
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 17 2012
Added on Sep 19 2012
2 comments
2,831 views