Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse "Run as" has no "Java Application" option (What exactly is needed to be able to run a class/.java?)

Tags:

java

eclipse

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)?

like image 707
A.M. Avatar asked Jun 14 '13 18:06

A.M.


People also ask

How do I change my java program to run in Eclipse?

right click on you project in project explorer,then choose run configuratin,in the "type filter text" text box type "java application" ,select it and choose prespective link on the right side. select Java Application in "Application Type/Launchers:" list box. Then select "Java" in "Run" drop down box. apply>ok.

How do I run an Eclipse application?

Click Run > Run... Select Eclipse Application in the left hand list of launch configuration types, and press New. In Main tab, enter for example MyApplication in the Name field. Choose in field Location your target workspace.

Why I am not getting run on server option in eclipse?

For me worked: Right click on project > Properties > Project Faces > change Configuration from "custom" to "Default configuration for Apache Tomcat v7. 0" > OK and then Run on Server option has appeared.

How do I run current class in Eclipse?

Eclipse allows you to launch classes using a keystroke, including JUnit tests, Java applications, etc using Alt+Shift+X. Alternatively, right-click on the class and select Run As. The submenu will show available options for launching the class.


2 Answers

Add a String array argument to the main method as expected by the JVM

public static void main(String[] args) {
like image 157
Reimeus Avatar answered Oct 24 '22 23:10

Reimeus


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".

like image 35
Great Question Avatar answered Oct 25 '22 01:10

Great Question