java - Unable to run the javafx project using command line -


i had created javafx project in eclipse, ran in eclipse , works fine. wanted run project using command line interface.

i able compile not able run , keeps on giving "error: not find or load main class main"

compile command (works fine):   javac -cp "c:\program files (x86)\oracle\javafx 2.2 runtime\lib\jfxrt.jar" main.java  main.class created after above command.  run command (doesn't work): java -cp "c:\program files (x86)\oracle\javafx 2.2 runtime\lib\jfxrt.jar;." main 

i know missing here in order run it.

adding main.java

package application;  import java.io.ioexception; import javafx.application.application; import javafx.fxml.fxmlloader; import javafx.stage.stage; import javafx.scene.scene; import javafx.scene.layout.anchorpane; import javafx.scene.layout.borderpane;   public class main extends application {     private stage primarystage;     private borderpane root;     @override     public void start(stage primarystage) {         try {             this.primarystage = primarystage;             primarystage.settitle("mojo");             initrootlayout();             showmaplayout();         } catch(exception e) {             e.printstacktrace();         }     }      private void showmaplayout() {         try {             fxmlloader loader = new fxmlloader();             loader.setlocation(main.class.getresource("/application/viewcontrollers/mapview.fxml"));             anchorpane mappane = (anchorpane)loader.load();             root.setcenter(mappane);         } catch (ioexception e) {             e.printstacktrace();         }      }      private void initrootlayout() {         try{             fxmlloader loader = new fxmlloader();             loader.setlocation(main.class.getresource("/application/viewcontrollers/rootlayout.fxml"));              root = (borderpane)loader.load();             scene scene = new scene(root);             primarystage.setscene(scene);             primarystage.show();         }catch(exception e){             system.out.println(e.getmessage());         }     }      public static void main(string[] args) {         launch(args);     } } 

your class declared in package application. so, compile correct folder structure should compile -d option:

javac -cp "c:\program files (x86)\oracle\javafx 2.2 runtime\lib\jfxrt.jar" -d . main.java 

that should create directory called application, , main.class in there.

then execute (from same folder, not application folder) with

java -cp "c:\program files (x86)\oracle\javafx 2.2 runtime\lib\jfxrt.jar";. application.main 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -