Run/Debug are not working in IntelliJ IDEA - java

I've installed an IntelliJ IDEA Community Edition 2018.2.4 x64.
I've cloned a Project from Git (I learn a course on the "coursera").
The first task was:
"Click the green arrow at the left side from the code.."
I haven't any arrows. I can't run it from main menu, the programm ask me about configuration. What exactly I need to do?
"Run" is not available.
Asking about configurations.
Configuration's window.

The problem solved.
It was fun.. The firewall blocked all functions of mavel,jdk and part of IDEA. Adding to exceptions didn't help. Switching off the Firewall - helped.
Strange were: Empty repositories of maven, the same settings as at the another computers where it have worked.
Now everything is working.

You have to create a new configuration for Kotlin and specify the main class which would be lesson1.task1.SimpleKt. Then the disabled arrow will turn green and be clickable.
If you want to run the other examples you have to create a new configuration for each one since they all have their own .kt file with a main function.

Right Click on Project Folder->Module Settings -> Add src folder in sources in the following way

Related

Can't start: error in configuration file(s) Can't find setting 'Scenario.nrofHostGroups' Java Result: -1

I am working on one simulator with netbeans IDE. I downloaded one simulator from their official website and it's install an running correctly in cmd.
I import existing project of one simulator into netbeans IDE and included all three libraries, so it have no error. But when i click on run icon, it gives me the following error.
So, as you see on the console tab(text with red marker), that's the error in which i need help. Thanks in advance...
Reason is you working directory in not correctly set in Eclipse for this project.
I was having same problem so I changed it.
Here is screenshot of my working directory. This Might help someone.
During the configuration of One with eclipse make sure that your run configuration path must be in synchronization with the arguments otherwise it will throws an error like you posted.
Steps:
Go to Run -> Run Configurations
After setting the proper configuration of one eclipse, Click on DTNSim present in core
Open Run Configuration Window
Click on Java Application-> Open Drag bar-> Click on DTNSim
Go To Arguments
Check Default and Others path:
It must be like the picture attached here!
One Simulator Working Window

Auto errors detection in IntelliJ IDEA

I am new to Java programming language and the IntelliJ IDEA 2017.1 IDE.
I just installed the IDE and I activated all the various inspections but the IDE is unable to detect the errors any time I make a mistake such as omitting a bracket or a semicolon.
This image displays the activated inspections:
This is a screenshot of my code with multiple errors but no detected by the IDE:
Kindly help me solve this problem.
Java file is not analyzed since it's located outside of the source root. You need to either relocate the file or reconfigure your content roots so that it resides under the folder configured as the Sources root.
Sources root is marked in blue in the project view. Here is the example of the properly configured project (notice the class icon is different than on your screenshot):
One more reason could be IntelliJ is running on power saver mode, this could be disabled following way:
File Menu -> Power Saver Mode
This is finally what worked for me! Phew!
My Problem: Whenever I exit Intellij and try to open up an old/existing project, I have trouble getting the builds and execute to work on my localhost. I'm just using localhost.
Here are the steps that finally worked on my localhost environment:
1. Go to Project Structure and Select Project
a. Set the SDK to 10 (“Java Version 10.0.2”) or whatever you are using.
b. (I think this was the main step I was missing) Set the project compiler output to point to where I want the compiled output to sit: C:\Users\kbala\OneDrive - MatrixCare\SoftWLearnings\Javamyfun\NewHelloWorld\out
c. Project Language Level: I chose “SDK Default”
2. Go to Project Structure and Select Modules
a. Click on src (this is where my source code sits).
b. Then, Click on the “Sources” folder icon on the top. This adds src to the “Source folders” on the right. You will see the color change to Blue
c. Click ok.
3. Then, click on “Add Configuration” (top right corner of Intellij)
a. Select + at the top left hand corner.
b. Select “Application”
c. Change the name to “Main”
d. Now click on the Ellipsis (three dots) in “Main Class”. You should now see your Main Class. Select it.
e. You should now see the execute arrow at that top right of Intellij. And you should see the build icon (Hammer).
This should work!
If you use a build system (Maven, Gradle, etc.):
Open its panel in IntelliJ, then click the reimport button. For Gradle, this button looks like a sync icon and its hovertext says "Reload All Gradle Projects".
Why it works:
Since the build system is in charge of compiling your code, it knows which files are source code. It would be a waste of computing power to look for missing semicolons in a compiled binary file, so IntelliJ won't try to find errors until it knows the file is source code.
Most build systems, Maven and Gradle included, are also dependency managers. When you write code that uses libraries or depends on a different module, IntelliJ needs to be able to understand the dependency to tell you whether your code makes sense, or whether you made a mistake like forgetting an import statement or passing the wrong type of argument into a library function. When IntelliJ doesn't understand your dependencies, it displays all your uses of imported code in red text.
I was getting the same issue, I just clicked on the re-import button on the maven panel and it solved the problem .
I had the same issue and here it is how I solved it:
Some files where ignored and I Unignored them. To do this go to Maven tab on the right panel -> right click on each project that is in grey color and click Unignore projects.
I'll add an another reason for it. For me it was Reader mode enabled. I was not even been aware of its existence. Can be disabled in Settings -> Editor -> Reader mode.
In my case was a maven option!
When you open the proyect in intellij, it create a notification.

Can't Export Android Application in Eclipse

I'm experiencing some strange behavior in Eclipse. I'm trying to export my Android application, which is a game that is written using AndEngine, the open source game engine. Not sure if that is relevant.
Anyway, there are no errors in my project or the library dependencies of Android. I have been running the application on my phone with the debug build for ages. Now I want to export a signed application, and it won't work! (It did used to).
I right click my project, click Android Tools > Export Signed Application and right when I do that, two errors show up that say,
No .class files were found in project "AndEngine" so none of the classfile basechecks could be run . Does the project need to be built first?
No .class files were found in project "AndEnginePhysicsBox2DExtension" so none of the classfile basechecks could be run . Does the project need to be built first?
How the heck do I fix this? I have done a Project > Clean, open and closed Eclipse, open and closed the individual projects. And again - this error is NOT there until I go to export the app! What the heck!
Ok I think I figured this out. Not sure of the "real" issue, but my workaround for the time being is to right click my project in the file tree on the left, then click Properties. I selected the "Android Lint Preferences" in the dialog that comes up, and just hit "Ignore All". Now I can build without the error.
While this is a work around, I'm not thrilled about leaving that disabled completely. I'd like to know which Lint preference i can specifically disable. (I, quite frankly, don't even know what lint is)
I solve this problem turning off Build Automatically in Eclipse before export.
Are those projects set as libraries?
Open Project -> Properties.
Click Android on the left.
Scroll down and make sure under Libraries that "Is Library" is checked.
probably just add:
<issue id="LintError" severity="ignore" />
to your lint.xml config file.
In eclipse probably just set this one (LintError) error to ignore.

I get "Source not found" when debugging my Java code in Eclipse

I'm trying to debug my Java application in Eclipse however when I hit a breakpoint I simply see the following instead of my source:
If I change the stack frame in the Debug window then I can see the function name change in the tab - this is definitely my code, the line number is correct and I'm using the latest build but I still can't get Eclipse to show the source (despite it being open in another tab!)
I'm new to Eclipse and so I'm struggling to find my way around, but everything that I've stumbled across so far seems fine to me.
What might cause this to happen and how can I fix it?
Sounds like the 'source lookup path' section if you edit the debug configuration isn't setup correctly?
Click on "Edit Source Lookup Path" button and then click on Add button then Java Project and include your imported project .. Hope this will solve your problem
I also had this issue in MyEclipse Blue. I resolved it by following these steps:
Debug the project.
Right click on the Thread (Which you will see in Debug tab) and click on the "Edit Source lookup"
New window will open and hit the "Add" button and Select the "Java Project".
Get all the project that is listed over there.
Restart your server.
I had similar problem with my eclipse maven project. I fought with this issue quite a long time then I tried to rebuild projet with
mvn clean eclipse:eclipse
and it helped.
When I faced this problem for the very first time, I've already done all the steps mentioned here. Curiously, my problem happened when I've copied a project into another place. Anyway, the debug starts to work without warnings, after simply remove all breakpoints that was originated from the original project.
Sorry about my English , I'm not fluent.
We had the same problem and none of the suggestions above worked. What did work, was deleting the local workspace and from Eclipse checking out from the repository again. The problem occured for everybody previously working with Netbeans and making the switch to Eclipse.
Try this:
Select Project
Right click
debug
Debug configuration
Select Source Tab
Click on add button
Select Java Project
Add your project there with check box
For local projects I've solved it by selecting the "Resolve Workspace artifacts" checkbox in the Debug Configurations.
This is a common error while debug in eclipse. You can fix it through edit source look up. But make sure once you attach the Project You need to stop the server and again start in Debug mode. It will work.
Here is the detail steps :
Click on "Edit Source Lookup Path" button .
Then click on Add button.
Select Java Project and include your imported project
Then stop the server and start it in Debug mode and hit your service. It will work.
After trying most of the solutions here, try this too once -
Close all the .java files from the editor, in fact, close all unrelated projects in eclipse.
And try running the Debugger.
I solved this problem by adding the class file into the src folder within the project. Hope this method may help.
I got this error when I was running my server using a maven tomcat plugin. When I deployed using my configured server in Eclipse (generating a war file and copying it into my tomcat directory), I didn't have this issue anymore.
In your debug configuration add goals as "clean install"in the maven build con
This is an expansion on JAB's answer:
Click "Edit Source Lookup..." > Add... > Workspace Folder > Project > select your folder > check Search subfolders box > OK.
In Eclipse:Window-->Go to preferences-->Java-->Click on JRE-->Edit--->Restore Default and click on Finish.
Update your Project before Debugging the code!
Alas! It worked for me.
This occurred to me when my working git branch is updated from code in master branch. I have already run mvn clean install after the pull, but seems I had to update projects after the maven build so that project source code and JAR build code gets synchronized.
Right click on your project -> Maven -> Update Project, then select all the
maven modules available and press OK. This resolved the issue for me.
I was facing same issue. After banging my head for several hours, I finally noticed that although Maven was building the project successfully, the source file I was trying to step into had an incorrect package statement and that is why the 'Source Not Found' eclipse problem was happening. When I corrected the package statement and rebuilt the project, the debugger found source file and stopped on my breakpoint.

In Eclipse, what can cause Package Explorer "red-x" error-icon when all Java sources compile without errors?

I'm using Eclipse for Java development. All my sources compile fine and the resulting application compiles fine. However, I keep getting an "red-x" error notification in the Package Explorer.
All my sources in this source directory (too long for the snapshot) compile fine, none of the show the "red-x" error icon.
Any suggestions on how to fix the problem would be highly appreciated.
yeah, this happens sometimes for no apparent reason. You can go to the "Problems"-Tab (right next to console output) and see the error message, so maybe you can narrow it down that way.
This happens often when I use Maven, and I had always ignored it until I found this question. You need to update the project in this case (figured this out by looking in the Problems pane)
From the project context menu: Maven -> Update Project and select the available maven codebases
Alternatively you can use (Alt + F5) to bring up the same window
Try to clean the project and rebuild it.
After build. Refresh project and if still persist just right click Problems tab in eclipse and choose delete all.
It often happens if you do maven install and eclipse properties files do not get updated properly. Even though your project does not have any errors. Hopefully!
I want to start by thanking everyone that answered. But cleaning and rebuilding was not enough in my case because the problem was still there and needed fixing.
Turned out that one of my package directories had accidentally been copied so that an extra directory now existed called "Copy of dagskra" containing Java files with wrong package declarations. In addition the errors in this "new" directory don't show up with a "red-x" in the package that it exists in:
Snapshot from Package Explorer showing errorous "Copy of dagskra" directoryr http://www.freeimagehosting.net/uploads/a824304b18.png
It was the hint of reading the "Problems" tab :-) that turned me into the right direction, so I'm selecting that answer as the accepted answer because this is what I needed:
Snapshot from Problems tab http://www.freeimagehosting.net/uploads/dea26d5dd0.png
Hoping this will help others...
So upon finding that there could be a missing package in the buildpath, thus the red x against the main project, to remove this:
1) go into "Configure Buildpath" of project
2) Java Build Path -> Source Tab - you should see the red x against the missing package/file. if it no longer exists, just "remove" it.
red X begone! :)
Sometimes there are build path errors in .project, and you need to switch to Resource view to actually see the file that is causing the error.
As others have said, bad file references in the build path is often the culprit.
Usually a .jar file that has been moved/deleted. Eclipse expects to find everything referenced on the build path at the location specified, and will complain if not.
I had the same issue and below steps resolved the issue:
Delete the JRE from PROJECT> properties>java build path> libraries.
Restart the eclipse
Add the JRE again
Rebuild the project using Project>Clean and chose option to build automatically.
Please try.
Subversion is occasionally the culprit for this as well. It might not have anything to do with your environment. But, there might be a discrepancy between the current and local state of the project. In my case, doing an update, and then a commit to the subversion server provided me with the expected clean result without any flags in the project such as the X.
In my case what solved this problem was simply to Close Eclipse and opening it again...However I am still not sure why this happened or why it worked. I was having problems Cleaning my project (it said it could not Delete certain file) and this solved it :):
Try doing a rebuild. I've found that the red x's don't always disappear until a rebuild is done.
I've run into a similar problem many a time, what happens usually for me is that a java file will say it won't compile in the text editor but in the package explorer it will say it's compiling fine.
Sometimes doing a 'rebuild' or 'clean-build' doesn't work, the files don't actually get built (one has to presume that eclipse thinks the files it has are up to date) and when this happens I usually open up the java build path and just move one of my dependencies down/up the pecking order. This forces eclipse to do a rebuild of everything and it always seems to work.
If you're still having problems try copying the project and seeing if you get the same behaviour and at a last ditch attempt post a bug for eclipse, it may take a while for them to fix but at least you know that you're being heard.
To add to the previous answer, an extreme way of "cleaning" your project is to delete it (that is deleting its reference from the workspace, not deleting the actual files), and then re-import it.
Sometimes, it helps...
FindBugs also puts a red-x against files/packages to indicate static code analysis errors.
I have run through this. My case was more involved. The project was packaged fine from maven command line.
Couple of things I made.
1. One class has many imports that confused eclipse. Cleaning them fixed part of the problem
2. One case was about a Setter, pressing F3 navigating to that Setter although eclipse complained it is not there. So I simply retyped it and it worked fine (even for all other Setters)
I am still struggling with
Implicit super constructor Item() is undefined for default constructor. Must define an explicit constructor"
I also experience those misterious error-symbols on packages from time to time. A way to get rid of them that works for me is to effectively remove the JRE System Library from Java Build Path and add it back again.
My solution that finally worked was to clean all projects, close eclipse, clean all projects, close eclipse, and so on at least 5-6 times. Eventually it all settled down and everything was as expected. Weirdest thing ever!!
And no there were no errors in the Problem or console view.
Also this happened after a computer crash. The last time it happened my whole workspace was completely lost. It was still there on the computer, but when I tried to access it, it would be all blank.
For whatever reason computer crashes are really really really badly handled by eclipse.
Also, you may update the project by clicking,
Right Click on project name -> Select Maven -> Right click -> Update Project.
This helped out for me.
Thanks.
This can occur for a number of reasons. If you have changed the jdk, the Project facet will have a red X next to it while no other folders shows an error. If this is the case, modify the jdk that is shown. This happens on occasion in our JAX-WS class (HSG
I solved mine by
Close all other projects (i.e. unrelated project option)
Clean and build
My project was android, and that did it.
This happened when i downloaded fabric.io on Eclipse Mars but Restarting computer solved this problem for me.
i had same problem. I checked "Problems"-Tab and found no server for the project. I defined the server. the red-x disappered
You can go to project-> Buildpath-> Library
If there is any library that is X marked ie [cross marked] removed it and again try to build. It worked for me as well/
I encountered this problem today and found this link. I followed as mentioned by Patrick Schaefer above and opened the Update Maven project Dialog. Click on my working project and selected the checkbox "Force Update of Snapshots/Releases" and 'Ok'. All the red cross vanished.
I hope this helps anybody in a similar situation.
The question is old but I had this issue and I tried the following to no avail.
mvn update (with snapshots)
remove project and re-importing
clean build
restarting Eclipse
changing order of items in build path
In my case I've got multi module mvn projects and one of the nested projects was showing a red X icon only in the Project Explorer (package explorer and problems were totally fine) and the whole project was fine as I could run classes without any issues. So seemed like a display issue.
The only thing that worked for me was to edit the pom.xml if the offending project module and make a breaking change (add 'xxx' to a tag name) which caused 1000s of errors and then undo.
You may clean the project by clicking,
In Eclipse, Right Click on Project -> clean
This helped out for me and saved a lot of time.
Thanks.
Right click on the project with errors, then in the sub-menus select:
Maven > UpdateProject >
and then:
Select the checkbox for all the dependent projects
select force update of snapshots
click OK.
This worked for me..

Categories

Resources