I wrote some java code in Eclipse. When I run it, I see the output of another project (that I wrote before) in the console. How can I see the output of my new code?
Trying to guess your problem: When you press the Run as button (White arrow in green circle), Eclipse doesn't run the program you're editing. Instead, it runs again the last program you executed. That's the reason why you see the output of another project: You're telling Eclipse to repeat its execution.
So, to run your new app, right click over the code and select Run as/Java application.
Right click your project in the project explorer. And then this menu will pop up:
Click Run As > Java Application
Related
I was working on a project in Intellij then suddenly there was a pop up and now the run button is greyed out. It is a Java FX project and it runs with coverage and debug, but the normal run button is greyed out. What could be the problem?
PS: I know I don't give you much to work with but unfortunately it was working and now it isn't, that's all.
I had the same issue and fixed it with the old "Invalidate Caches and Restart"
Open the source code, right-click and hit run using the option run "filename.java".
IntelliJ will make the configuration for you and then you can click the run button after the configuration is made by the IDE.
Same thing for debug configuration.
This has happened to me countless times. One possible problem is that the program is still running in the background and hasn't exited completely. Check your running processes for java applications and see if it exists.
Try to start the program again via Run in the menu bar.
Alt+Shift+F10 solved my problem.
I guess for me disabling windows instant replay fixed the issue.
Restarting IntelliJ and re-opening the project resolved the issue for me.
I think it the maven/gradle plugin that failed to load.
For me I closed the project, open another previous project and the run button appeared.Then I closed it and open my new project,I got a prompt bottom right that says "load maven script" I clicked it and it was resolved.
Change the jdk version to 11 or any lts ..
Steps :
file> Project Structure
Edit SDK [enter image description here][1]
Click on the below link to see the image for editing SDK :
[1]: https://i.stack.imgur.com/3IyXA.jpg
I had the exact same thing using IDEA 2021.3.3 ultimate edition. My "Run Hello (Shift+F10)" button was greyed out, so I right clicked the source code (any whitespace in the editor worked fine), and there was an option in the menu called "Run Hello.main() (Ctrl+Shift+F10)", which WAS clickable. I clicked it, then it ran, after which the first button was no longer greyed out.
Intellij Idea 14.1.2, Gradle 2.3
I have a project with few java subprojects. Gradle builds works as expected but Intellij Idea does not capture the output of it and does not show the Messages Tool Window where you can click on the error and go to the source file.
Steps to reproduce:
Create new gradle project
Create new class with one method
Introduce intentionally one error
Build using Gradle tool window
Expected result: Message Tool window will show up showing the error.
Actual result: Output is shown in the Run tool window, but the Message window is not shown (it's menu item is not even active in View -> Tool windows)
I've tryed to reimport the project, to create it from scratch, searched Idea's settings, manipulated manually values in *.iml but with no success and I am running out of ideas.
Any idea where I can find a setting that tells the IDE to direct output to the Messages window?
In Intelij 16.2 I had this problem as well. In the top left corner of the "Run" window there is an odd looking button that when you mouse over is labeled "Toggle tasks executions/text mode." Click it and it will show you the output from the Gradle build instead of the steps in the task execution.
I had this problem on IntelliJ 2017.1, as well. The answer posted by BrianC on Aug 4 '16 helped me--however I found the button on the opposite side--on the left side of the Run window, therefore I am posting an image with the exact button.
When you hover over this button, it says 'Toggle tasks executions / text mode'. The image shows the button when selected.
Finally found the solution:
For some reason when creating gradle project or module Idea does not add automatically the java-gradle facet.
In order to get the errors in the Message Tool window you will have to add it to your module(s) like this:
File -> Project structure -> Facets
Click on the plus sign, select Java-gradle, select module, OK.
Please note that if you start the build from the Gradle tool window (the right side pane) errors will not be shown in the Message window. You will have to use the "normal" build in the IDE, e.g. Build -> Compile module.
I had a very similar issue in 2019.2.* where if I had previous results in the run tool window and then did a gradle build and had errors, it would switch me to the run tool window instead of the build window. This looks to be fixed in 2019.3.*.
I have updated my Java recently and since then i can not press "run" (the green arrow) anymore.
I tried to reinstall Intellij but it did not work.
Try right-clicking within the file that contains a main method, and click "Run CLASSNAME.main()". That should generate a run configuration for the file that will let you use the green play button.
I seem to be able to run Java programs and get output in Eclipse when I use StdOut.println(...). I have a program that reads from StdIn and should print to StdOut. I know the program works because I have submitted it to a class autograder and got a perfect score on it, but I must be doing it wrong in Eclipse. Please explain how to set this up. I thought I understood how to use the "Run Configuration", but obviously I don't.
Follow these steps.
Right click on the project that you want to run. (In Eclipse)
From the appeared menu, Select Run As
Then finally select Java Application
And make sure, Your console is visible in your Eclipse IDE,
To Enable it,
Goto Windows tab in Eclipse IDE
Then Select Show View
Finally select Console
I have to build a Decision Support System, but dont have much experience in Java. So after I connected to MySql with Eclipse (with Connector/J) eclipse started to mess up my other projects. Now, when i try to run other projects in eclipse (that are not related to MySql, ex. Guessing Game) the following error message apperars:
Launch configuration DocsConnectionPropsHelper references non-existing project MySql connection test.
Can anyone help me to resolve this problem please?
UPDATE. it seems that when i press "RUN" elcipse is not running the project that im working with, but other
Your update indicates the issue is actually running the wrong project. To avoid that you may want to close projects you're not working on (right click them in package explorer and select close).
If you do need multiple projects open then when clicking the run icon (which defaults to re-run whatever was ran last among your open projects) make sure you have open in the editor window something that can be ran (and is from the project you want to run).
Then click the drop down arrow to the right of the icon. This will open up a small menu with options to change your build configurations or how it should run your program (i.e. as an application or on a server).
To solve the problem:
-click right botton on the project package you want to work on (run)
-choose Run As
-choose Run Configurations...
-choose DocsConnectionPropsHelper - if in the Project box you see not correct title just remove it. Also remove anything what is in the Main Class box.
-click Apply
-the best option is to close Eclipse and reopen it to make sure that all the settings were configured
It worked for me. Hopefully it will work for you too.