I have created a JavaFX program in Intellij idea. The program has only two classes named Main.java and Cart.java. When I run Main in Intellij, it works fine and opens the program but when I open it in terminal I get an error at compiling. I first tried javac TopCart.java which gave errors it was not finding my cart class.
I first tried javac TopCart.java which gave errors it was not finding my cart class. Then I tried javac Main.java Cart.java ( I have never had to specify additional class files in intelliJ before) and it compiled but when I attempted to run it I get Error: Could not find or load main class Main
the start of my code is this:
package sample;
import javafx.application.*;
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.scene.control.*;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
I am not sure if it has to do with how I have my override statement but it looks like this
@Override public void start(Stage primaryStage){
stage = primaryStage;
I am trying to make it run out of command prompt as well as eventually build a jar file that will run it. I would be very grateful of how to fix this and why it is not working. The sample package is the default set by intellij
I found another question similar and was able to run it in command line by changing how I was running it. I was using java Main and needed java sample.Main
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.