Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse doesn't compile java files into classes

Tags:

I have no idea why, but from today Eclipse doesn't compile .java files into .class. I press the "Run" button and Eclipse only tries to run the program rather then compiles it first, so i get this error all the time:

Exception in thread "main" java.lang.NoClassDefFoundError 
like image 305
Marco Micheli Avatar asked Aug 02 '13 07:08

Marco Micheli


People also ask

How do I compile a .Java file into a .class file in Eclipse?

Step 1: Open Eclipse and click File > New > Java Project. Step 2: Provide the Project Name and click on the Finish button. Step 3: In the Package Explorer (left-hand side of the window) select the project which you have created. Step 4: Right-click on the src folder, select New > Class from the submenu.

Why can't I compile my Java program?

It means that javac.exe executable file, which exists in bin directory of JDK installation folder is not added to PATH environment variable. You need to add JAVA_HOME/bin folder in your machine's PATH to solve this error. You cannot compile and run Java program until your add Java into your system's PATH variable.

Why is Eclipse not running my code?

If you've installed Eclipse but are having trouble getting it to run, the most likely cause is that you have not correctly specified the JVM for it to run under. Eclipse startup is controlled by the options in $ECLIPSE_HOME/eclipse. ini. If $ECLIPSE_HOME is not defined, the default eclipse.

How do I create a .class file in Java?

To create a new Java class or type, follow these steps: In the Project window, right-click a Java file or folder, and select New > Java Class. Alternatively, select a Java file or folder in the Project window, or click in a Java file in the Code Editor. Then select File > New > Java Class.


2 Answers

open problems view from window -> show view -> problems, if there's any error, fix it

eclipse will reject to compile if there is any problems in your project

like image 98
Septem Avatar answered Oct 09 '22 08:10

Septem


Close Project -> Open Project -> Clean -> Refresh

Hope it helps for someone else

like image 30
Johnny2012 Avatar answered Oct 09 '22 08:10

Johnny2012