I deleted my ./bin folder in an Eclipse Indigo (super similar to Helios), and now I am wondering how to rebuild my Java project. I just cannot find a button like we can see in Netbeans.
For Eclipse you can find the rebuild option under Project > Clean and then select the project you want to clean up... that's all.
This will build your project and create a new bin folder.
In Eclipse there is an "Auto Build" option, which is checked by default. When it is checked, you don't need to build your project, this happens automatically. If this behaviour is unwanted, uncheck this option and click build project whenever you want.
To clean a project, select Clean Project. This will delete the bin folder, however if Auto build is checked, it will be immediatelly regenerated.
In case you are unable to find a file in Eclipse code after pulling code from git or creating a file in intelliJ seperately (my case) you ca do the following
Right click on 'src' folder and in the menu that appear click on the 'refresh' button
Related
I'm using Apache Maven in my Java project. in NetBeans there are build and clean build icons but there aren't in IntellIJ IDEA. How can I clean or clean build my project in it?
Maven > Lifecycle > clean
Open the Maven Projects panel. Click lower-left corner for pop-up menu if that panel is not already visible.
In that panel, open the Lifecycle item. There you will find clean and install items for you to run.
As commented, you can also invoke this by command-line/console. But if already using IntelliJ, I do not see the point. Just show/hide this pane as you work. I use it countless times a day to hit install to build complete app, and hit clean whenever I suspect not all of the project is up-to-date in the build-results.
Build > Rebuild Project
If you are having weird problems in running the app in development also try the menu item Build > Rebuild Project.
I have asked what is the difference between a Build > Rebuild Project versus doing a Maven clean. But I still do not understand the precise details. So when things seem wonky, I do both to right the ship.
Tips:
Restarting IntelliJ may help when behavior seems odd.
Keep Intellij updated.
The answer here with the most votes suggests running the clean and install Lifecycle items separately in IntelliJ, which is easy enough and works. But it’s worth mentioning that you can combine these steps (and/or others) by instead creating a new Run/Debug Configuration of type maven and adding the command clean install (or whichever combination of maven lifecycle methods you run on a recurring basis).
Thereafter, running a mvn clean install is as simple as clicking the green button to run that Run/Debug Configuration.
Here is a faster way to do that:
in IntelliJ IDEA window hit Ctrl key twice, then a pop-up window appears like this:
there you can enter your command and use recommendation tools, too.
including template commands and the list of your previous ones:
In IntelliJ, go to your Toobar, View>Tools Windows>Maven Projects
From there, you can click Clean to clean the project
click on maven panel --> select project--> lifecycle --> double click clean.
source: vaadin.com
I have the same problem. I found some suggestions but nothing get me to an acceptable solution. Here are some things I found maybe it will help you:
File -> Invalidate caches / restart
or just rebuild the project: Build -> Rebuild project (Shift+F11)
But it's nothing like Clean or Clean and Build from netbeans.
By the way I use intellij-15.
Edit: Finally, Build->Build Artifacts->Build or Rebuild works for me.
So far, the best I can come up with (for a non-Maven project) would be to manually delete the target folder and then do your build. But I'm still looking for a better answer, myself.
I'm building a Maven project, and I discovered if I run the Maven Clean phase from the IntelliJ "Maven Projects" pane, it deletes the target folder. The target folder itself (without subfolders) corresponds to NetBeans' dist folder, and the subfolders in target have corresponding subfolders of the build folder in NetBeans. When you clean and build in NetBeans, the first thing that happens is the build folder and dist folder are deleted, and this corresponds to deleting the target folder in IntelliJ, so that's why I suggest it.
Note that just as you get an error if you try to clean and build in NetBeans while holding open a file that happens to be in the build or dist directory, you will similarly get an error in IntelliJ if you try to execute the Maven Clean phase while a file is open in the target folder - the difference is, if you are doing this in Windows, IntelliJ will half-way delete the folder and there isn't a simple straightforward way to clean up the mess even after you close the program that is holding the file open. Probably if you reboot it will clean up, but who wants to do that? I ended up identifying the culprit process (processes, actually - two copies of explorer.exe) with Sysinternals Process Explorer, killing all instances of explorer (killing only the two culprits didn't seem to work), then starting explorer back up via Task Manager, and everything was fine.
You can use the terminal to switch to the current project directory and use mvn clean install
If it's a Maven project:
Go to your project's root folder (where your pom.xml is located)
In address bar of windows explorer type cmd
You should be prompted with cmd window where you should type mvn clean
That will clean your target folder which is getting created after build
Make sure you have your system variables set so mvn commands can work (otherwise you will get "mvn is not recognized as an internal or external command")
This is how it should look:
Hope this helps.
As explained in Jetbrains help there are three ways to execute maven goals in IntelliJ.
One simple way to execute clean and install and also save the configuration is to select with CRTL button the goals "clean" and "install" from the maven tab -> Right click in one of the selected -> Modify Run Configuration -> check all the fields -> click OK. Then you can execute this configuration in order to clean and install.
This way works for the InteliJ IDEA 14 upwards not exceeding InteliJ IDEA 20:
Click Run -> Edit Configurations -> Press + -> Search for "Maven" -> Locate "Command Line" field and enter in following maven commands "clean install" -> Press OK.
Now click the green button to run that Run/Debug Configuration, this will maven clean install the module/project.
The output of the module if you are to deploy somewhere can be seen in the target directory in the project.
Maven Clean Install refers to clear any compiled files you have, making sure that you're really compiling each module from scratch
From my eclipse project I've removed .class file for a particular class thinking eclipse will regenerate it for me if I build it again or run the project again.
But when I tried to run the program, It's showing class not found exception.
I'm wondering what's happening there? doesn't eclipse build .class files each time we run the project? when compilation will happen in eclipse?
Compilation will happen either the next time the source file is modified, if you have it set to Build Automatically, or the next time you run. Both of these expect compiled source files to still have their .class files around. Clean the project from the Project menu to force it to recompile regardless.
Make sure that in the Project up-menu, the option "Build Automatically" is checked then just clean your project.
It should regenerate the .class file(s).
Check Your java file is in a source folder (right click project, properties, build path)
and you have automatic build turned on (Project menu -> Build automatically)
Also make sure your project compilation/build succeeds, otherwise Eclipse may not compile all the classes.
Check in the Problem windows if there is any error on the project compilation then fix it first.
Project menu
Click "Clean"
Select "clean all projects" or "Clean selected projects below" and
choose your project
Check "Start a build immediately"
Click "ok"
Now run your program.
Also as suggested by other answers, enable "Build Automatically" in Projects Menu.
Hope it helps
While running my java project on Eclipse Luna, I have some errors due to which I suppose related to this problem.I right click on the project, choose properties --> java build path --> source, I see a warning at the top:
And it seems that I have forgotten to add this package at the beginning of my project.I want to add it now, but I cannot do it via "Add Folder" button.When I press "Add Folder" button, a window appears like this one:
However, I believe I should add it under "Java Resources" on the tree:
How can I modify this?
Thanks for any help..
src/test/java is just maven's default entry for any test classes. If you have (or plan to have) test classes, you can create a new folder structure test/java below your src folder and afterwards select it in the dialog you've shown. If you don't plan to have any test classes, you can safely remove the entry from the build path.
This worked for me:
mvn clean install
How to add missing src/test/java folder to the maven project in Eclipse
1) Create a folder test/java under src folder
2) Right click on the project and choose Maven --> Update Project --> choose for Force update of Snapshot/Releases and click ok. Now test folder should appear as src/test/java in Eclipse project explorer
I get a mvn project , and to debug this project in eclipse,I imported the project into eclipse.But it's a pitty that some imported packages cannot be resolved by eclipse.Othes tell me that I should install m2eclipse plugin for eclipse, and run ""mvn eclipse:eclipse" to convert the project as a eclipse-like" project ,thus all packages will imported to eclipse build path automatically. Yes , I do so. And the eclipse build path is just like this
:
But it is extremely strange that eclipse still cannot resolve some import .
Any body can tell me what happened? From the build path ,I can see that eclipse have already imported the needed jar file for me.But it seems that the build path didn't take effect.
First of all, you're not using the m2e plugin; while it may be installed, it's not activated for this project:
There is no little "M" on the project's icon
The classpath doesn't include an entry org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER
From what I can see, Eclipse can't resolve the dependencies since the variable M2_REPO isn't defined (if it could, you would see the absolute path to the JARs in the upper image after the symbolic path).
To fix this, go to Preferences and search for "Classpath Variables". Add M2_REPO there with the correct path (default is $HOME/.m2/repository).
If it already exists, make sure the path is correct.
Alternatively, right click on project and select "Convert to Maven Project" under "Configuration".
How did u create a project. Try creating a web project. This template will provide the correct creation web application structure. It will also automatically add the required jars in the build path.
It is an eclipse problem (are you using the latest version?), try to run:
mvn eclipse:clean
mvn eclipse:eclipse
then open eclipse, refresh the project (right click on the project icon and select refresh),
clean it (Project > clean ...). It could be necessary to reconvert the project to maven
(right click on the project and convert it to maven project).
Sometimes closing the project (right click on the project icon > close project) and reopening it (double click on the icon) solves this issue.
I am trying to import maven project into eclipse 4.2 version.Its not importing the project properly. Its giving me error "Source folder is not a Java project" while I am trying to create a new call in it. Even ctrl+mouse click is also not working. I don't understand the problem. Even when I right click on project and select build path it shows me no action available. Anyone face the same issue
In the maven project directory try
mvn eclipse:eclipse
that may do the trick.
I ran into the same issue and fixed it by converting my project to faceted form.
Right click your project > Properties > Project Facets > Convert to Faceted Form, and select Java.
I had the same problem... But you just need to update "source Folder" to correct source "src/main/java" from whatever mentioned in the pop up:
[]
Either turn your project into Eclipse project, using mvn eclipse:eclipse, or install Maven Integration for Eclipse plugins, like m2eclipse, and import project as a Maven project.
I got the same error in a slightly different context (Indigo with m2eclipse):
I imported a multi-module (1 jar module and 1 war module) maven project into Eclipse. Everything worked fine (clean, install OK) until I tried to add a new class to one of the modules and got the "Source Folder is not a Java project" error.
I solved this by opening the properties on the parent project and selecting the following Project Facets:
Java
Dynamic Web Module
This solved the problem. My guess is that, because the parent project for a multi-module project has pom packaging (<packaging>pom</packaging>), Eclipse doesn't know what kind of projects the parent project encloses (i.e. if the packaging were jar, it would know that it's a java project; if the packaging were war, it would know that it's a static or dynamic web module, etc.)
This is just my guess, but the fix worked for me, and it makes sense.
for those who already see java selected, uncheck and check it again.
select apply to override the existing setttings. finally it works !
Right click your project > Properties > Project Facets > Convert to Faceted Form, and select Java
Right click your project > Maven > Update Project
This step will add your project so the issue resolves easily.
mvn eclipse:eclipse
will resolve this problem. convert to maven project.
I had this error because I tried to create a new Project by doing "Ctrl+N", typing "Project" on the Wizard's input label and then just pushing "Enter" until it was created.
I solved this by typing "Java Project" instead of just "Project".
You can also create a JAVA PROJECT by going to File > New > Java Project.
open cmd and run the following command in the folder of your project-
mvn eclipse:eclipse
This did the trick for me
If you are having maven project and you are getting this error. You can follow below steps.
Right click on the project and select properties.
Then click on Project Natures
In the dialogue box, click on Add and in the warning click on OK.
Filter java in the popup box and click on OK.
Click on apply and close.
It will add java nature to your maven project and you will not get this error anymore.
Right click your project > Properties > Project Facets > Convert to Faceted Form, select Java, and apply&close