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
Related
I can't find the terminal where the message is supposed to show. How is it called?
I'm guessing it should be in View->Tool Windows but nothing from there seems to work. It's a Maven project and all I can see is GlassFish log.
System.out and System.err output is written to either the Run or the Debug tool window depending on whether you launch the run/debug configuration as Run or Debug. See https://www.jetbrains.com/idea/help/running-and-debugging.html and https://www.jetbrains.com/idea/help/run-tool-window.html for more information (Same information is in the Help guide of the IntelliJ IDEA Ultimate version).
In Java EE applications with Tomcat container, if you want to see the result of prints like System.out.println(), first go to Run > Edit Configurations and select your tomcat server in the left menu, then open Logs tab and check 'Show console when a message is printed to standard output stream'
Click on the below image to figure out.
For running mode:
View -> Tool Windows -> Run
For debugging mode:
View -> Tool Windows -> Debug
You must be on one of the above two states in order to accomplish this action.
As you know when we building applications we get Errors/Exceptions such as NullPointerException etc. on IDE Console (I'm using IntelliJ IDEA).
I want to display those errors simultaneously in my Mac Terminal for larger view so I don't have to horizontally scroll IDE Console every time when I get big errors.
I don't want to run my applications from Terminal with commands (java class...)
I want to run from my IDE and all texts which is going down(errors,exceptions infos.) will reflect to Terminal.
So is there a any log file that i can look into? How can I achieve this?
In the Logs tab of an IntelliJ IDEA run configuration, there is an option "Save console output to a file". You can use that to save the output of your application to a file and to view it in the terminal.
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
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.
I have coded in c++ in visual studio for several years.
I am now working in java with eclipse.
the java programs are launched from a .bat file so I cannot breakpoint them to debug.
Without being able to step through my code i am finding it very hard to find the root cause of the error as the thrown exception is not usually the source of the problem.
How can I debug my code without access to breakpoints ?
You can find the main method, as suggested by Ben J, and run this from Eclipse. To pass arguments to it, edit the run configuration. e.g. Right-click on the main class, click "Run As" and then "Run Configurations...". Select the "Arguments" tab and enter whatever you need.
Or since you need to debug this, click "Debug As" and "Debug Configurations..." instead.
Use Maven or Ant to launch your programs, instead of a batch file. There is much better integration with Eclipse.