Reputation: 647
I want to run a specific .java file (a class), but Eclipse is not co-operating.
I have tried to follow the instructions here --> eclipse how to run a different class
... but my "Run As" menu item never contains "Java Project".
I have tried accessing the menu after right-clicking in the .java pane and tab itself, and from the .java name and class name in the Package Explorer, but of course that doesn't make a difference. The only option I ever get is "Run Configurations".
(and yes, my .java has a "main" method.)
import com.jsyn.JSyn;
public class SuperSimpleSounds {
public static void main() {
[...]
What, exactly, is needed to be able to run an individual class (an individual .java file)?
Upvotes: 8
Views: 18949
Reputation: 1
As a minor variation on the perfect answer of Reimus:
Add a
String
array argument to themain
method as expected by theJVM
public static void main(String[] args) {
I had been struggling with my a script, when I ran it showed Run Configuration and Fail.
By changing the following:
public static void LaunchBrowser () throws InterruptedException {
to
public static void main(String[] args) throws InterruptedException {
it solved the problem.
Upvotes: 0
Reputation: 2209
Also one trick when you want to open some java classes that you downloaded elsewhere is to create a new Java project. Then, move all your java classes into the src folder of the project. Now you can run with the option of "run as Java Application".
Upvotes: 1
Reputation: 159784
Add a String
array argument to the main
method as expected by the JVM
public static void main(String[] args) {
Upvotes: 21