Menu

#959 Run button chooses first defined class or interface in file

2: Annoying
open
nobody
None
5
2016-03-10
2016-03-10
Alex Jacoby
No

The "Run" button tries to run the first defined class (or interface!) in a file, even if it's non-public and hence can't be run.

For example, consider file Foo.java:

interface Bar {}

public class Foo {
  public static void main(String[] args) { }
}

This compiles, but if you try to run with the run button, it tries to run "Bar" in the Interactions window and gives the following error:
Static Error: This class does not have a static void main method accepting String[].

If you type "run Foo" in Interactions it's happy. Alternatively, if you move the Bar declaration to after the Foo declaration, that works too, but sometimes Bar makes more sense before Foo (for in-class examples anyway).

Suggested fix: either search the file for a public class to run, or just use the filename to determine the name of the class to run.

Thanks!

Discussion


Log in to post a comment.