0

Error: Main method not found in class StdDraw, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application

I'm getting the above error when I run the program:

public class Lineage {

    public static void main(String args[]) {

//Task1 Wk2
        StdDraw.setScale(0, 512);
        StdDraw.line(0, 500, 0, 10);
        StdDraw.line(0, 500, 0.5, 10);
        StdDraw.line(0, 500, 1, 10);
        StdDraw.line(0, 500, 2, 10);
        StdDraw.line(0, 500, 5, 10);
        StdDraw.line(0, 500, 10, 10);
}

/*public static void drawlines(double M, double C) {
    //algorithm for line increment
    double Y;//declares value for Y-axis
    StdDraw.setScale(1, 512);//sets scale
    for(double xi=1; xi<512; xi++) {
        Y = (M*xi) + C;
        StdDraw.point(xi, Math.round(Y));
    }
}*/
}

I know it's a compiler error of some sort but don't understand why because my previous tasks have all been using the same reference folder StdDraw.jar which has a "final" class and compiles perfectly fine in all other projects. Not only that but the way I was taught is that the main method is the point of entry on runtime, so, if I have one here in my program (above) why am I being asked to provide one in a reference folder? I'm confused.

I'm unsure how to get my program to compile properly, I've tried extending the StDDraw class in the main class but is causing more errors. I've tried researching but can't seem to find a solution to this likely, very simple issue. I'm operating in Eclipse Juno and if requested I can post the StdDraw class but it's massive.

Edit: I tried to edit the reference class and include a main method of some kind but I literally am unable to make changes to the file.

Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
  • Are you trying to run the Lineage class or the StdDraw class? If the latter, please show that class instead. – OneCricketeer Feb 28 '16 at 20:02
  • I'm trying to run the Lineage class but the references for all the method stuff is in the StdDraw class so it's in the referenced library section in Eclipse. Managed to get it to compile now. Thanks for your time. Also, tried top up vote everyone, I don't have enough rep yet. xD – Mike Kain Markov Feb 28 '16 at 20:35

2 Answers2

0

The point of issue in you question is which main method is getting called, the StdDraw class has a main method too,

enter image description here

so my 1st recommendation is to verify, whether your app is trying to run over the main method in the StdDrar class or the Lineage class.

is you are developing in eclipse, then right click on the Lineage class--> run as.. and select java application...

will run

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
  • According to the error, though, the main method got removed from StdDraw somehow – OneCricketeer Feb 28 '16 at 20:12
  • the stdDraw method has a main method too... that is what i am setting focus in my answer, but tnxs – ΦXocę 웃 Пepeúpa ツ Feb 28 '16 at 20:15
  • It should have a main method, that's what I understand you're saying, but we don't know where the source of the StdDraw that the OP is using – OneCricketeer Feb 28 '16 at 20:17
  • Hey, thanks for the help and assistance. I did not vote this question the official "answer" though it practically was. I unfortunately can't pick more than one and I chose the earliest response. Even though both are technically right. =] Thanks again folks. =DDD – Mike Kain Markov Feb 28 '16 at 20:40
0

Error: Main method not found in class StdDraw

Means 1) it's missing a main method and 2) you currently have the project in eclipse setup to run the StdDraw class.

Try right-clicking on your Lineage class in the left pane (or where the files view is open) and choose "Run as > Java application" (can't remember exactly what it says)

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245