I am a beginner developer trying to create my first project using Jhipster. I am trying to set up everything to start coding in the most accurate environment in order to avoid further problems or warning in the future.
I have imported the new project to the Eclipse IDE following the instructions in jHipster web, but as you can see in the picture, some warnings appear:
Is there something important that I have to worry about? If yes, how can I solve it?
I can solve the first one, but I am not sure if I solve it in the right way. I did not find any solution related to the other ones.
Is there something important that I have to worry about? If yes, how can I solve it?
Warnings are not high priority problems, they will not break your application. That said fixing them is never a bad idea, I personally like to keep my projects clean.
Most of the Java problems you have are for unused imports or variables, remove them from your code and the warnings will disappear. You can double click on each warning and eclipse will take you right to the line of code.
For the serialVersionUID problems you can just click on the yellow light bulb left of the line number and then click Add default serial version ID.
The first two problems you say you can fix them, good. They are telling you there is a mismatch between the expected Java version and the one used. One way to fix them is to install the 1.8 JDK (get it from here) and set it as your default JRE (Windows > Preferences > Java > Installed JREs).
Related
Just starting working on an existing project at work and wanted to use Visual Studio Code as my IDE (I have used it for a recent Rails project and loved it, so wanted to try with Java).
However, whenever I try to open one of the projects I receive a ton of different errors including:
When importing java.io, java.util, or anything similar, the error:
"The import of java.io (or java.util) cannot be resolved"
Existing classes have an error:
"The implicit super constructor is undefined for default constructor. Must define explicit constructor"
Other random "cannot resolve to a type" errors.
All of these seem to stem from some sort of setting error I have with VS Code but can seem to find what it is. I have already uninstalled and reinstalled the RedHat plug-in that enables the Java language for VS Code.
I have tried setting the java_home setting in the extension to the direct location of the install but that didn't work. Tried uninstalling and reinstalling java and that also didn't work.
My operating specs are as follows:
OS: macOS Sierra
VS Code version 1.15.1
JDK version 1.8.0.144
Any idea on what may be causing this? Do you think it may be an error in how I have VS Code set up or if it's an error (or rather incompatibility) with how the existing project is set up?
I ran into a similar issue. The solution was to remove everything from VS Code's workspace storage directory, which was located at $HOME/Library/Application Support/Code/User/workspaceStorage/.
I found this solution here: https://github.com/redhat-developer/vscode-java/wiki/Troubleshooting#clean-the-workspace-directory
Update: This can now be done from within VS Code as of Language Support for Java(TM) by Red Hat Version 0.33.0. Open the command palette and type "java clean" (see official description in link).
As already mentioned previously, you require to clean the project, but that is a bit difficult thing because every folder is a Guid, and you do not know which one to clear, thus requiring you to delete everything. Starting with 0.33.0 version of the plugin you can automatically do that from within the IDE as well, use CTRL + Shift + P and type, java clean, and IDE will show you the suggestion tip for, Java: Clean the Java language server workspace. Upon selection, agree and restart the IDE. It will clean the language server workspace for you.
Another approach can be, the Maven tools within the IDE. If you have this plugin installed, you can use the side bar and utilize the Maven project helper options to perform actions like, clean, install, and package etc. For example, here is the project I am having and the options this shows,
That can be used, graphically, to manage your Maven-based projects. Also, this would work with the Java Extension Pack, not sure yet as to how it would behave with other extensions.
For me: CMD + Shift + P
Then type "Java: Clean Java language Server Workspace"
Note: This will reload/restart vscode as well.
Update:
This appears to not fix it anymore for me. In my case I am using a gradle project, and needed to set the rootProject.name in the settings.gradle to be the same as the folder name that the project is in.
I faced this issue after creating a whole Java project in one computer and then trying to run it on another computer.
After doing everything said in the other answers, what really made VS Code compile was to open each single project java file in VS Code and save it (a simple Ctrl + S). Maybe there is a simpler way of doing it, but that is what worked for me and I hope this helps anyone stuck in this issue.
Press ctrl+shift+p
then search 'java clean' and click 'java: clean java language server workspace' then click restart IDE.
I found another simple trick at least to get rid of "cannot be resolved to a type" errors which were coming from older workspaces and wrong project files I guess?. I just ran an empty main(), with the body commented out, while still keeping my local package / import commands at the start - no errors. After commenting in again, the project compiled without errors. Perhaps this refreshing effect might also help in this context?
I had to clean this folder to get it working on Windows
%APPDATA%\code\Local Storage
I suspect that the way this project is developed by my team is counter-intuitive as far as gradle is concerned, however, that's not about to change any time soon.
Also... technically the location in the drop down menu points towards a missing feature/plugin or error at IDE level.
Any ideas on how to fix this, or where I would begin modding netbeans itself to fix this would be appreciated.
The only options for changing the way packages show up in the project tab, i.e. tree/reducedTree/list etc don't change anything at that level.
I feel I don't have to explain this, but those Business Packages [java][src] entries should show up as something like com.sun.moon.stars packages
Thank you.
at time of writing, 2020/01/18, apache netbeans can't deal with jdk8 codebases defined in gradle.
Solution is to use Netbeans 8.
Just starting working on an existing project at work and wanted to use Visual Studio Code as my IDE (I have used it for a recent Rails project and loved it, so wanted to try with Java).
However, whenever I try to open one of the projects I receive a ton of different errors including:
When importing java.io, java.util, or anything similar, the error:
"The import of java.io (or java.util) cannot be resolved"
Existing classes have an error:
"The implicit super constructor is undefined for default constructor. Must define explicit constructor"
Other random "cannot resolve to a type" errors.
All of these seem to stem from some sort of setting error I have with VS Code but can seem to find what it is. I have already uninstalled and reinstalled the RedHat plug-in that enables the Java language for VS Code.
I have tried setting the java_home setting in the extension to the direct location of the install but that didn't work. Tried uninstalling and reinstalling java and that also didn't work.
My operating specs are as follows:
OS: macOS Sierra
VS Code version 1.15.1
JDK version 1.8.0.144
Any idea on what may be causing this? Do you think it may be an error in how I have VS Code set up or if it's an error (or rather incompatibility) with how the existing project is set up?
I ran into a similar issue. The solution was to remove everything from VS Code's workspace storage directory, which was located at $HOME/Library/Application Support/Code/User/workspaceStorage/.
I found this solution here: https://github.com/redhat-developer/vscode-java/wiki/Troubleshooting#clean-the-workspace-directory
Update: This can now be done from within VS Code as of Language Support for Java(TM) by Red Hat Version 0.33.0. Open the command palette and type "java clean" (see official description in link).
As already mentioned previously, you require to clean the project, but that is a bit difficult thing because every folder is a Guid, and you do not know which one to clear, thus requiring you to delete everything. Starting with 0.33.0 version of the plugin you can automatically do that from within the IDE as well, use CTRL + Shift + P and type, java clean, and IDE will show you the suggestion tip for, Java: Clean the Java language server workspace. Upon selection, agree and restart the IDE. It will clean the language server workspace for you.
Another approach can be, the Maven tools within the IDE. If you have this plugin installed, you can use the side bar and utilize the Maven project helper options to perform actions like, clean, install, and package etc. For example, here is the project I am having and the options this shows,
That can be used, graphically, to manage your Maven-based projects. Also, this would work with the Java Extension Pack, not sure yet as to how it would behave with other extensions.
For me: CMD + Shift + P
Then type "Java: Clean Java language Server Workspace"
Note: This will reload/restart vscode as well.
Update:
This appears to not fix it anymore for me. In my case I am using a gradle project, and needed to set the rootProject.name in the settings.gradle to be the same as the folder name that the project is in.
I faced this issue after creating a whole Java project in one computer and then trying to run it on another computer.
After doing everything said in the other answers, what really made VS Code compile was to open each single project java file in VS Code and save it (a simple Ctrl + S). Maybe there is a simpler way of doing it, but that is what worked for me and I hope this helps anyone stuck in this issue.
Press ctrl+shift+p
then search 'java clean' and click 'java: clean java language server workspace' then click restart IDE.
I found another simple trick at least to get rid of "cannot be resolved to a type" errors which were coming from older workspaces and wrong project files I guess?. I just ran an empty main(), with the body commented out, while still keeping my local package / import commands at the start - no errors. After commenting in again, the project compiled without errors. Perhaps this refreshing effect might also help in this context?
I had to clean this folder to get it working on Windows
%APPDATA%\code\Local Storage
So I'm using Eclipse for Java development but I'm getting annoyed that the "Quick-Fix" context menu is incomplete. In the Eclipse documentation, there's a full list of all the quick fixes for different common problems. If I press Ctrl+1 over an error, I get an incomplete list of "Quick-Fixes".
For Example, I know for a fact that "Create setters and getters" is a quick fix for instances where private variables in a class are never called.
However, this is not an option when I use the Quick Fix command for the item.
Also, quick fixes are NOT showing up in the context menu for items marked with errors. I have confirmed in Preferences > Java > Editor > Content Assist: that "Insert common prefixes automatically" is checked to True.
Is there possibly a problem with the JRE? (I DID have an issue earlier where the context menu wouldn't appear at all because eclipse couldn't find the .rt file. I had to decompress it and point eclipse to the folder containing the JRE before it would show anything.)
Any help would be greatly appreciated. Thanks in advance!!
So I feel so stupid but found the issue. Somehow, I installed the 2008, 3.3.2 version of Eclipse. Stumps me how it happened by it did. Lol. So After uninstalling and reinstalling the newest version of Eclipse, everything worked as expected. Thanks.
I am working on a soucre code which was developed using java 1.4 but now we want to migrate it to java 6. I was able to compile it but there are tons of warnings related to use of java generics wherever we have made use of collections framework. It is possible to remove them by manually make changes to them, but I wanna know if is there any tool which can run on the source code and remove all the warnings by making necessary changes ot the code. Any help will be highly appreciated.
Cheers,
Nitin Ware
Eclipse has an option to try to infer the type arguments for generic types. It's not fool-proof, but it's a start. It's available from the "Refactor" option in the context menu when you right-click inside the class's code.
Open your code with Eclipse, select your Package or Project and in the Refactor menu select "Infer Generic Type Arguments". It will infer the types and correctly change almost all the warnings. Correct the last ones by hand.
Unfortunately sometimes the plugin sometimes crash while trying to do it. I'd also try to do it with IntelliJ IDE. Edit: I've tried with InteliJ and it also failed. Nothing happened after 2 days running. The newer eclipse almost worked, just crashed in 2 files. I'm using it in a very old project with non-standard paths. Maybe you'll have better luck.
You could suppress warnings as a compiler option
-nowarn or -Xlint:none
see http://java.sun.com/javase/6/docs/technotes/tools/solaris/javac.html#options
In eclipse you can set the "Target" JVM to 1.4, that should fix your problem in the editor. I think you can also specify a target option to javac, but I'm not sure about that.