Eclipse doesn't build - java

A previously working Ecplise now gives me the error
Java Virtual Machine Launcher
Could not find main class: testing2. Program will exist.
testing2 is my class and a source file exists but Ecplise doesn't seem to build the .class file.
Maybe I hit the wrong hotkey and changed accidently some setting?

As Bozho said Build Automatically should be checked which builds your project on every save of your source file.
If it is unchecked then you have to manually build the project by right clicking on it and select Build Project.

The following menu item should be checked : Project > Build Automatically

Related

IntelliJ IDEA is not recognizing my java files as runnable and instead wants to run the class files. Any ideas of how to fix?

Anytime I try to run a java file by clicking run, it instead tries to run the class file and thus gives a no main method error.
When I try to right click on a java file and run that, it doesn't recogize it as a file that is runable.
I am still able to run programs from the command prompt but I would prefer to be able to run them in IntelliJ.
This occurred after trying to create a Class path when using JSon Libraries.
Edit:
Normally it shows java files with this icon:
But instead it's showing this icon for java files:
I think the change in icon might have something to do with it.
Edit 2:
the exact error I get is "C:\Program Files (x86)\Java\jdk1.8.0_181\bin\java.exe"...bunch of other program file locations
Error: Could not find or load main class sample.Main
Process finished with exit code 1
I had the same problem and found out that my src wasn't marked as Sources Root. To change this:
right-mouse click on your src
navigate to "Mark Directory As"
choose "Sources Root"
It will now recognize your files correctly and your main classes will be able to run again
IntelliJ not recognizing my .java-files
Problem solved
I had a similar problem.It wouldn't pick up ModlServer in any project. (Not just limited to the one I had open).
I had to file -> Manage IDE Settings -> Restore Default Settings
Note: I lost all my live templates, fonts, etc so just a heads up.
I restarted my computer and that somehow fixed it.
My issue was that I have multiple modules for my project and the module I was working on (where java files were not recognized) was not included in the main pom. I just added that module in the main (project) pom and it worked.
Right click on the project and click 'Add framework support' all directories and classes should now be the right type.
I've fixed this at Intelij2023 by using JDK17 as the JDK the IDE uses to import java source files.
Mind this JDK version does not need to be the same you use to build your project.
Go to: Settings > Build, Executio, Deployment> Build Tools > Maven > Importer
Set the JDK For Importer to zulu-17
I'm using zulu-17 as JDK for imports and coretto-8 to build the project (having JDK version 8 seems to be preventing intelij to properly recognize the project structure)
If you are using Maven or Gradle, try to re-import the project and see if that helps. Could be that your IDEA project has some incorrect settings in it set by mistake, so this way those would be removed.

How do I re-enable class verifiction on eclipse start-up

I installed a plugin named, "Optimizer for Eclipse".
I clicked the Disable verification button.
This now doesn't allow me to run files without building the project.
Everytime I run a java project, If it is a new file. It says cannot find or load main class.
If I build the project and then run it runs.
If I change the file and again run it. It runs the previously compiled file.
How do I re-enable class verification in Eclipse?
Suffered the same problem.
Go into your Eclipse folder, open eclipse.ini with your text editor.
Delete the following line:
-Xverify:none
Then, restart your IDE, the verification will come back.
Changing the workspace works!
All the settings are gone in the new workspace and it's totally new.

Using Git with Eclipse causing lots of errors

I made a HelloWorld app in Eclipse that had no errors and runs fine. It was located in
Android/workspace/HelloWorld
Then I created a Git repo elsewhere in, say
Git/MyApp
I want to have MyApp contain the HelloWorld project from eclipse, and when I make edits to HelloWorld, it will show up in git status and I can commit and push those changes.
I tried copying the HelloWorld directory from the workspace into MyApp, then pushing my changes to my repo, which was fine.
Then I deleted the original HelloWorld in the workspace, went to Eclipse, hit import existing project, and selected the HelloWorld from the MyApp repo. But this resulted in a ton of compilation errors. How can I do what I'm trying to do without all these errors?
I've attached a link to a screenshot of the errors I get upon compilation.
I have Understood your problem,your project have a relationship with appcompact.Whenever you import your project you have to check below scenario,
Right click your project ---->select properties--->In side bar select "Android" Tab--->now you can see Project build target and Library Box--->in Library box click add and choose appcompact project and then click apply.
After done above one clean and build your project.Then it will work fine.
try Clean operation on your project and then build your project. replay whether it solves the issue or not.
As a matter of fact it looks to me like your eclipse doesnt recognize your app-compat anymore.
This happend to me once too, after I closed and reopend the appcompat-project.
Try to close all your projects -> open the appcompat first -> restart eclipse and maybe do a clean on your project
Hope this helps.

Eclipse is not showing compilation errors in project explorer

I am using Eclipse Juno with Java 1.7 and i have created a test project. Now the problem is with project explorer. Project explorer is not showing compilation errors if class have any error.
I cleaned, closed , and rebuild the project but nothing is changed. It is still not showing errors in project explorer.It was working fine with Helios.
As I can see in your project explorer there is a RED exclamation mark over your project name which means there is a problem with the build path in your project. See here for more details.
Check the Build Path of the project by right-clicking the project and selecting Build Path -> Configure Build Path.
One problem I often encountered is different people using different Java SDK and so when the exact SDK is not available on your machine, you need to change to your Java SDK (via JRE System Library -> Alternate JRE). A better way to avoid this problem is to always select the JRE System Library from Workspace default JRE or Execution Environment.
Have you checked Project/Build Automatically?
I had the same problem. I checked the .classpath file of the Eclipse project. It had incorrect value of src so it was pointing to the wrong source of Java files.
My file's incorrect entry:
<classpathentry kind="src" path="src"/>
I changed it to the correct entry:
<classpathentry kind="src" path="source/java"/>
Now, its working :)
You can restore the errors to the package explorer by right clicking on an error in the problems pane and selecting show in and then select package explorer.
Set your build path and java compiler:
Steps:
Right click on the project and go to the properties.
Go to the java build path and set the jre version to the jdk5 or more. (which ever you have to your system).
Go to the java compiler and set java version to the compatible with jre (which ever you set in java build path).
After refreshing the project you may get the compilation error.
Set your Errors/Warnings:
Steps:
1) Right click on the project and go to the properties.
2) Select Java Compiler -> Errors/Warnings.
3) Check the "Enable project specific settings"
In eclipse you can right-click on a project and go Maven-->Update Maven
Project and this will tell eclipse to update all of its local project
settings (e.g. source and build paths) based upon the current pom.xml.
You must check the build Path configuration to point for the appropriate /src sources java folders, perform a clean up of the eclipse project as well as a maven clean.
I had the same issue.
I have faced similar kind of problem in Eclipse Photon.
I have cleaned, updated and build the project but nothing was working. Then I figured out that I have disabled problem reporting in preferences.
Here is what I did to resolve the issue :
Preferences-->>Editor--> Checked report problems as you type checkbox
Go to the eclipse project -> check the Build Automatically. It will solve the problem. I had the same issue and resolved like this.
Check your class package, it should be under src/main/java, if package differs from that, the compiler will not be able to read class and will not show compilation errors.
I had created a nested project and imported it by doing a refresh, but to get it to be acknowledged as a project that needed to be compiled, I had to also import it as a project:
Then, I also had to double click on one of the compilation errors in the "Problems" window to get the errors to also be highlighted in the source code file itself:
I had AspectJ enabled on my project, and that was the source of the issue.
So:
Right click on my project, AspectJ Tools, Remove AspectJ Compatibility. Then add it again with Right click and then Configuration and AspectJ

Google Eclipse plugin recompile problem

I have installed Eclipse Helios(3.6) and Google plugin to develope app in GAE/J.Then created project and runned it sucessufull. Later made some changes in source code but it doesnt recompiled. Previous compiled version is in use. It doesnt compile until I make changes in appengine-web.xml. Could you suggest how to solve the problem please?
PS : I had the same problem in Eclipse 3.5. Also I added javac to SYSTEMPATH.
You could try the following:
the folder where your java files are in is a "source folder" (check it via project properties, "build path")
turn on "build automatically"? Can be found in Menu "Project"
Maybe refreshing your workspace automatically will help (Window->Preferences, and search for workspace)
The Project is automatically not builded or recompiled, when there are problems marked by eclipse. Take a look into the marker panel of eclipse and solve the problems.

Categories

Resources