Java - How to Compile a single file with Java Eclipse
Solution 1
Your class has to define a public static void main(String[] args)
method. Then find the Java file in the project explorer, right-click on it, and choose "run as Java application".
Solution 2
In addition to the info in the answer already selected, others having this or a similar problem should chech the "Run Configurations" panel to make sure the setting are correct for the app you are launching. Check
madhu131313
I code in whichever language is needed for the idea to be executed rightly!
Updated on June 18, 2022Comments
-
madhu131313 about 2 years
I am trying to compile one file in a java project, but I am seeing other result (result of another file ) in console. I even tried Ctrl + F11 but the same thing happened
In the dropdown of Run button of Java I am not finding the current file name but if I start a new project and run the file it is compiling. Note:I am a beginner in Java.
-
madhu131313 over 11 yearscan I save this file with either names.PassOb.java or Block.java pastebin.com/t7Jq9sdm
-
Axel over 11 yearsThe file name has to be the same (+ extension ".java") as the public class (or interface) defined inside the file.