In an Eclipse SVN project I have a problem; when I tried to open a declaration of one class, I got this error:
Problems opening an editor Reason : projectname does not exist.
Also refactoring does not work.
I have searched the web and tried all found solutions but nothing helped.
I have downloaded different Eclipse and Java versions and switched to a clean workspace but I still have the problem.
How can I solve my problem or which solution can I try?
Right Click on the project -> Properties -> Project Facets -> Click on the Configuration Link -> Click on Apply Button -> Click on OK button.
The above steps should set your project as a Java project.
If the project is a multi-module Maven project, then you need to import the child/module projects in addition to the parent/pom project. Then ensure that you only open source files via the child project. Java files opened this way will have the Refactor right-click menu item, and F3 Open Declaration etc. work properly. However if the Java file is opened from the parent project, these Eclipse functions will be missing.
It's quite frustrating when opening a file via a Search result, as the file will be found and listed in both the parent and child project. You need to ensure you only work with the file accessed via the child project.
I can't explain precisely what's going on with Eclipse, but it appears that Eclipse does not recognize the parent project as being Java projects, although it will correctly syntax-highlight the Java files whether they are accessed via the parent or child project.
You needed to to check it out as a Java Project, or preferably, its creator should have committed the .project and .classpath files for it.
I had this problem, too.
It looks like after a search-in-workspace Eclipse opened a wrong file.
I pressed Ctrl + Shift + H (Open Type in Hierarchy), typed in the class name, and opened it. The file opened in a new tab, and everything was navigable again.
The difference in icons is:
you can solve the problem by create a new java project.
when you check out the project,you should select the default option,
[Check out as a project configured using the new project wizard].
It might lack a builder. Check your PROJ_HOME/.project that should be like:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>the-one-user</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Ref:
FAQ How do I add a builder to a given project?
Are you importing a maven project? If you importing a maven project, a file will be viewed in few perspective, especially if you open the file via "Open Resource (Ctrl + Shift + R)".
Let's look at the example above, "servlet-filter" (mark as 1) imported as maven project, and maven perspective project created in 2. If you open a file in 1, your "Open Declaration F3" will no work, because it is not a valid maven project. It will work if you open the same file in 2.
Hope this helps.
You need to import it as a Java/Maven project. Once you are done importing the project do the following steps
Go to Project -> Select Properties -> Select Project References -> Select/Check all the
dependent/Child projects which you reference in the code base -> Apply
and Close
Once you are done, try to clean the whole project. This should solve the issue.
There is a bug in Eclipse (in Luna at least) for a very specific workflow, which might not be the answer to this specific question, but might be helpful for others.
If you perform an import into the src (meaning src folder has focus before performing import) folder from an extracted jar (as source code), and you place breakpoints in the nested *.java files in the nested packages, it won't hit those breakpoints. In order to get things to work, you must keep hitting F3 instead of using "Open Declaration" to get to the *.java file you want to set a breakpoint in, then add the breakpoint by double clicking in the far left margin. Then Run > Debug As > Java Application.
If the format of the project you checked out is of type Maven, you need to convert it to a Maven project first. It may be because the required classes haven't been generated yet. To do this, right-click on the project, click Configure, and then click Convert to Maven Project.
I had the same in Eclipse Luna on Debian 8.
I was missing the .classpath file when checking out from SVN.
I manually copied it and changed some path names, refreshed the project and it was working again.
It happens, when libraries are not available on class path of the project where F3 does not work.
Select any other project and try to use f3 for navigation. It will work.
The solution is to add JAR files in your libraries or add libraries in your project.
Try to use MAVEN project so that the problem can never occur.
I am using Eclipse Oxygen.2 (4.7.2). I don't see Project Facets after clicking project -> Properties. My solution is right click the project and click Configure, then select configure and detect nested projects, Eclipse will automatically generate the nested projects for you. May get some build errors in the new created projects, that should be easy to fix.
Go to Project properties,Select Project Facets then convert to project facets then click Ok then you will able to open editor.
Related
How can I open a JavaFX Maven project from scratch in IntelliJ IDEA? As there is no difference between a Java project and a JavaFx project, I want to open a dedicated JavaFX project (Selection JavaFX from create project Wizard) with Maven module included.
Although dated I'm answering this because I had the same question recently and too many people told me to write my own pom file etc. While that is technically true, it can create more headaches if you aren't careful.
I recommend you:
Create a JavaFX project as you normally would.
Make sure that project view (dropdown in project structure side tool window) is set to 'Project' or 'Packages' (otherwise option in 4th step will not be visible)
Then once it is opened and ready right click on the project folder
Go to "Add Framework Support...".
Check the box for Maven and click "OK".
Let IntelliJ do the work for you at this point.
As for editing FXML files link the IDEA to SceneBuilder. Here is the official documentation. But basically:
Install Scene Builder.
File -> Settings -> Languages & Frameworks -> JavaFX
Point to the exe file.
To Use: Right click on the FXML file and select "Open In SceneBuilder" (way down at the bottom)
And after all, a program doesn't compiled. So this video helped me: Configuring Maven For Java FX
in words:
we need to move sample.fxml to /resources folder. And in Main.java write:
FXMLLoader loader=new FXMLLoader(getClass().getResource("/sample.fxml"));
This steps worked for me (Is a different process):
1. Create a maven project.
2. In the generated pom.xml add the following:
`<build>
<plugins>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.7.0</version>
<configuration>
<mainClass>your.package.with.mainclass</mainClass>
</configuration>
</plugin>
</plugins>
</build>`
This adds a maven plugin for javafx (more info: https://github.com/javafx-maven-plugin/javafx-maven-plugin)
Create in your resources folder your sample.fxml
Create your controller class for sample.fxml and link
Enjoy!
It takes me a couple of hours to find the right solution.
Many thanks to this video and the author:
https://www.youtube.com/watch?v=qn2tbftFjno
So, following the above video, I would like to recommend:
Download JavaFX SDK from https://gluonhq.com/products/javafx/
Extract the zip file
From the starting page of Intellij IDEA, select Configure/Structure for New Projects
Select Platform Settings/Global Libraries
Select the plus ("+") button/Java
Find the "lib" folder inside your extracted zip file and select all of ".jar" files (except "src.zip"), and then OK
Set a new name for the library, let's say "javafx-whatever-version", then
Apply/OK
Create a JavaFX project as normally.
Select File/Project Structure...
From Project Settings/Project, remember to select the suitable Project SDK and Project language level
From Platform Settings/Global Libraries, right click on the library "javafx-whatever-version" (which you have already added),
choose Add to modules.../OK
Switch to Project Settings/Modules, choose Apply/OK
Back to your project manager, right click on "src"/New/module-info.java
Add new lines to the body of module-info.java:
requires javafx.fxml;
requires javafx.controls;
opens sample;
Run the project and enjoy!
For anyone coming here. I think the best answer lies on the openjfx docs. It contains a separate section for JavaFX & InteliJ, select the Non modular with Maven section.
Ill describe the steps in breif.
Create new Maven project.
Select create from archtype.
Add new archtype ( groupid : org.openjfx , artifactId : javafx-maven-archetypes , version 0.0.1 )
Select the created archtype and Next.
Provide group id org.openjfx ArtifactId hellojavafx and Next.
Change the property archtypeArtifactId value to javafx-archetype-fxml.
Add new property for javafx version : property javafx-version and value : 14.
Finally give a name to project like HelloJavaFX.
Now click finish and wait for inteliJ to build the project.
Once InteliJ finish its work the pom should look like this sample.
PS :
Two more additional tips you need to follow if you follow this approach to get things going smoothly.
JavaFX 14 needs java 11 or newer.
Change the javax maven plugin version to 0.0.1 to 0.0.4 to avoid errors like invalid flag --module-path.
Also to work better Download and install the
If you have already installed Maven, here is the exact user guide below to create a javafx project:
Open intellij
Create javafx project in folder with other maven projects.
Click on folder (project at the top) in intellij and choose run maven and package.
Then if you need plugins for javafx click again on project folder, run maven, plugins and you choose. I needed: javafx: jlink.
IntelliJ IDEA 13 has started exhibiting a very weird behavior in my local setup.
Namely, in any new Java class added to an existing project, Code Completion does not work. So, after declaring an object variable of any type in the new class and then typing the name of that variable, followed by the dot (.), no suggestions come up for any of the methods of the corresponding object.
For example, after declaring
File f = new File("/home");
typing f. does not bring up a list of all the methods in the File class, to select one from. As a matter of fact, when typing the dot (.), no suggestions appear and at the bottom left (in the status bar) of the IDE window, the message "Identifier expected. Identifier expected." is displayed. Sometimes, a long list of totally irrelevant methods from irrelevant components or libraries are proposed.
Strangely, Code Completion works as expected if the above declaration happens in any of the existing classes.
This behavior persists after many combinations of machine restart, IDE restart, project re-importing, closing/reopening, or rebuilding.
Any ideas?
Make sure you mark all your Source directories as such in File -> Project Structure -> Modules.
Ensure that you are not in Power Save Mode while running IntelliJ (File [menu] -> Power Save Mode checked or not). If Power Save Mode is enabled, IntelliJ will not run background tasks, including code completion.
For followers, one thing that helped me (auto complete only showed cast
field
instanceof
etc.) was that I had opened a maven module that didn't link correctly to its children (it had a commented out submodules section), so IntelliJ just showed the maven java files as basically "text" files with a tiny "j" in their icon in the project pane. Fixing up the root maven pom.xml file to include the children dirs as modules and voila, they are treated as real java files again, woot!
I am using IntelliJ Ultimate 2017.1, and I encountered similar issue.
Maven project, was trying to using selenium APIs, but the intellisense didn't pop up relative methods for me.
Here is the way I solved my issue:
Right click on your project src folder
Choose Mark Directory As
Then select Sources Root
I had this same problem and it was caused by me not having a folder marked as sources root.
Right click on your src directory and Mark Directory As > Sources Root.
It helped me to mark the src directory as the "Source Root".
Cut the folder .idea and the files *.iml in the root folder and paste somewhere else out of project. when you re-open the project , auto import will work again magically.
There could be 2 reasons for your problem
Either the the source folder is not properly configured in the your build java build path. If the source folder is not properly configured the autocomplete wont get the required class definitions and autocomplete would fail for your project.
Restoring the default options in 'Windows > Preferences > Java > Editor > Content Assist > Advanced'
Right click on project -> Add framework support -> Select Maven -> Click OK
The only thing that worked for me was killing IntelliJ (on Ubuntu) and starting it again.
This is not IntelliJ 13 but a more recent 2017.1.1 Community version. Adding this answer here so that others benefit from a cause that has its roots in the Gradle Configurations.
Now, in my case too the auto complete, Generate Override methods and other features were not working. What I figured out is that in my project settings, I had multiple configurations for the gradle modules. The moment I cleaned up the rest of the modules and retained the only one (apart from test) I needed for that project, all behaviors were back to normal.
Also in such cases of Gradle projects, remember to mark all your sourceSet root folders ad the Source folders.
Edit: If you do not want to create multiple configurations per sourceSet and you are importing a gradle module, on the import screen, you should also disable the Create a module for per sourceSet flag. Without this, I was having to remove the multiple modules after importing the module.
It was happening for me in a module that was not added in the parent project pom (they did it on purpose), that was the reason, I right clicked the pom.xml of the module that has the issue and clicked the
now the autocomplete came and in addition to that I can see the module as a separate project in the maven tab on the top right.
I was facing this issue while coding for eclipse-che client extension. Eclipse che modules are all of maven type. My client extension project was an independent module which can be compiled independent of the parent project. When I imported the same structure to Intellij my client-side extension project was not giving suggestions. After I include the client-extension project to the parent module (adding it to pom.xml) the suggestions started showing up.
Remove your package from the Settings>Editor>General>Auto Import>Java>Exclude from Import and Completion
I had run into this problem. None of the solutions from this post worked, but I was able to fix it because I accidentally put my project's package in the "Exclude from Import and Completion" settings.
I had a groovy project where somehow the jdk was not set as a dependency, so jdk classes would not autocomplete.
Fix:
project structure
modules
(your module)
tab Dependencies.
In the field Module SDK, add a jdk.
I had similar problem, nothing in this topic helped.
So finally I made it work, I clear cache of IntelliJ and restart.
File > Invalidate Caches / Restart.. > Invalidate Cache and Restart (button)
I am a computer science student learning Java, so I do some work at home and at college on a mixture of Linux and Windows. I have a problem after copying a new project into the Eclipse workspace. The project shows up, but with a red exclamation mark and an error saying:
The project cannot be built until build path errors are resolved
How can I fix this? I tried the solution described here, but it didn't work.
Identify "project navigator" or "package explorer" view.
Right click on your project, select Build Path --> Configure build Path.
In the emerging window, you will find four tabs, select "Libraries".There, under "Web app libraries" (expand it), you will see the libraries added to the project's classpath. Check if all of them are available. If one or more are not (they'll have "missing" beside their name and a red mark on their icon), check if you need them (perhaps you don't); if you don't need them, remove it, if you need them, exit this window, look out for the missing jar and IMPORT it into your project.
Open the Problems view. You can open this view by clicking on the small + sign at the left hand bottom corner of eclipse. It's a very tiny plus with a rectangle around it. Click on it and select problems.
The problem view will show you the problems that need to be resolved.
If the message says "the project is missing the required libraries...", you need to configure your build path by right clicking on your project, selecting properties, then build path. Add the required jar files using the libraries tab.
-If there are other problems other than missing libraries, you need to post the exact problems here to get a precise solution.
If you can't find the build path error, sometimes menu Project → Clean... works like a charm.
In my case, all libraries in the build path were OK.
To solve it, I deleted all project metadata (.project, .classpath, .settings) and re-imported the project as a Maven project.
Right click your Project > Properties > Java Build Path > Libraries
Remove the file with red "X" (something like JRE...)
Add Library
That's how I solved my problem.
I also had this problem in my system, but after looking inside the project I saw the XML structure of the .classpath file in the project path was incorrect. After amending that file the problem was solved.
If not working in any case...then delete your project from the Eclipse workspace and again import as a Maven project if that is a Maven project. Else import as an existing project.
I tried all the previous given solutions, but they didn't work, but it works for me.
In Eclipse, go to Build Path, click "Add Library", select JRE System Library, click "Next", select option "Workspace default JRE(i)", and click "Finish".
This worked for me.
Go to Project > Properties > Java Compiler > Building
Look under Build Path Problems
Un-check "Abort build when build path error occurs"
It won't solve all your errors but at least it will let you run your program :)
I have a Java Project in Eclipse, and a Java Dynamic Web Project in Eclipse. In the former, all the jar files are shown individually under the top-level project folder. In the latter, the jar files are under a Libraries folder and the navigation is more convenient.
Is it possible to organize them in the same way in the Java Project also? If so, how?
Update: It is the Project Explorer View. For the Java Project, I see: "my_project_name" with the arrow expanded to point downwards, then I see: "package_icon src/main/java" and below that "package_icon src/main/resources" and then 20 jar files one below the other: "jar_icon activation-1.1.jar", ...
For the Java Dynamic Web Project I see: "my_project_name" as above, then I see: "JAX-WS Web Services" (unexpanded), then "Deployment Descriptor" (unexpanded), then "Java Resources" which I have expandeded, so I see the components of it below, of which the first is: "package_icon src/main/java", then below it, "package_icon src/main/resources", then below it "libraries_icon Libraries" instead of 20 jars! I have the option of expanding Libraries if I really need to see the 20 jars.
The only option I found to make things prettier in Eclipse Kepler is to:
In the Project Explorer window there is a down arrow in the upper right corner. Select that and then Customize View.
Select 'Libraries from external' and then OK.
Kind of cheesy...
EDIT: Of course I had to go and do some more digging...and it looks like I'll have to try this and see how it works.
Similar to M Miller's answer (but for Juno), click Show 'Referenced Libraries' Node in the dropdown of the Package Explorer window:
I'm using:
Eclipse IDE for Java Developers
Version: Juno Release
Build id: 20120614-1722
I noticed this "feature" on Eclipse Juno (latest version), when you have a jar file added to the build path it is not shown as a single file on the project.
Try removing one of the jars from the build path to see if it shows up again.
I couldn't find how to turn it off though.
BTW... the project layout for your "Java Project" is more akin to a "Maven Project", which is a bit more powerful.
You should change into the Package Explorer by Window > show View. It will display all the referenced libraries in a Referenced Libraries folder.
I checked out a project from SVN and did not specify the project type, so it checked out as a "default" project. What is the easiest way to quickly convert this into a "Java" project?
I'm using Eclipse version 3.3.2.
Open the .project file and add java nature and builders.
<projectDescription>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
And in .classpath, reference the Java libs:
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
</classpath>
Manually changing XML and/or settings is very dangerous in eclipse unless you know exactly what you're doing. In the other case you might end up finding your complete project is screwed. Taking a backup is very recommended!
How to do it just using Eclipse?
Select project.
Open the project properties through Project -> Properties.
Go to "Targetted Runtimes" and add the proper runtime. Click APPLY.
Go to "Project Facets" and select the JAVA facet which has appeared due to step 4. Click APPLY
Set your build path.
If it's a Maven project, you might want to select the project, click Maven -> Update Project configuration...
That did it for me. And Eclipse is configured correctly. Hope it'll work for you too.
In recent versions of eclipse the fix is slightly different...
Right click and select Project Properties
Select Project Facets
If necessary, click "Convert to faceted form"
Select "Java" facet
Click OK
I deleted the project without removing content. I then created a new Java project from an existing resource. Pointing at my SVN checkout root folder. This worked for me. Although, Chris' way would have been much quicker. That's good to note for future. Thanks!
Using project Project facets we can configure characteristics and requirements for projects.
To find Project facets on eclipse:
Step 1: Right click on the project and choose properties from the menu.
Step 2:Select project facets option. Click on Convert to faceted form...
Step 3: We can find all available facets you can select and change their settings.
In newer versions of eclipse (I'm using 4.9.0) there is another, possibly easier, methods. As well as Project Facets, there are now Project Natures. Here the process is simple get the Project Natures property page up, and then click the Add... button. This will come up with possible natures included Java Nature and Eclipse Faceted Project Properties. Just add the Java Nature and ignore the various warning messages and your done.
This method might be better as you don't have to convert to Faceted form first. Furthermore Java was not offered in the add Facet menu.
Joe's approach is actually the most effective means that I have found for doing this conversation. To elaborate a little bit more on it, you should right click on the project in the package explorer in eclipse and then select to delete it without removing directory or its contents. Next, you select to create a Java project (File -> New -> Java Project) and in the Contents part of the New Java Project dialog box, select 'Create project from existing source'.
The advantage this approach is that source folders will be properly identified. I found that mucking around with the .project file can lead to the entire directory being considered a source folder which is not what you want.
You can do it directly from eclipse using the Navigator view (Window -> Show View -> Navigator). In the Navigator view select the project and open it so that you can see the file .project. Right click -> Open. You will get a XML editor view. Edit the content of the node natures and insert a new child nature with org.eclipse.jdt.core.javanature as content. Save.
Now create a file .classpath, it will open in the XML editor. Add a node named classpath, add a child named classpathentry with the attributes kind with content con and another one named path and content org.eclipse.jdt.launching.JRE_CONTAINER. Save-
Much easier: copy the files .project and .classpath from an existing Java project and edit the node result name to the name of this project. Maybe you have to refresh the project (F5).
You'll get the same result as with the solution of Chris Marasti-Georg.
Edit
Another possible way is to delete the project from Eclipse (but don't delete the project contents from disk!) and then use the New Java Project wizard to create a project in-place. That wizard will detect the Java code and set up build paths automatically.
Right click on project
Configure -> 'Convert to Faceted Form'
You will get a popup, Select 'Java' in 'Project Facet' column.
Press Apply and Ok.
Depending on the Eclipse in question the required WTP packages may be found with different names. For example in Eclipse Luna I found it easiest to search with "Tools" and choose one that mentioned Tools for Java EE development. That added the project facet functionality. Searching with "WTP" wasn't of much help.