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)?
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.
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.
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.
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.
Add a String
array argument to the main
method as expected by the JVM
public static void main(String[] args) {
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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With