unknown
unknown

Reputation: 853

How to print the console value in my Eclipse?

My Application is in some other folder, I call that function, the output is printed in my console.

How can I get the value from the console?

Upvotes: 14

Views: 85797

Answers (4)

Sebastian Łaskawiec
Sebastian Łaskawiec

Reputation: 2737

I'm not sure if I understand the question. However, you can use this code snippet to get line of text from console (it also works in Eclipse):

String val = new BufferedReader(new InputStreamReader(System.in)).readLine();
System.out.println("val = " + val);

Upvotes: 14

dogbane
dogbane

Reputation: 274612

Your function may be using System.out.println() to print out a variable to the console. To get this value from your function, you need to make your function return it e.g.

public int myFunction(){
   int val=42;
   System.out.println(val);
   return val;
}

//call it like this:
int result = myFunction();

Upvotes: 2

Spoike
Spoike

Reputation: 121772

You select the text in your console, right-click and select copy.

Now you can paste the text you've copied.

Upvotes: 2

Nirmal- thInk beYond
Nirmal- thInk beYond

Reputation: 12054

There is a way to redirect the console text into a log/text file under eclipse. If you are running a web-based application, possibility is that you already have a .log file configured some where. You can simply open this log file and look for messages.

In case of pure java application however, most of the output is showin in the eclipse console unless you configure a redirect.

Pull up the "Debug" or "Run" dialogs where you configured your main class. Select the java application you want to run. If you dont have an entry under "java applications", you might have to create one. On the right hand side of the screen, select the "Common" tab. Check the "File" checkbox and mention a physical path+filename in the input textbox. You are all set! Open the specified file in your fav text editor.

Upvotes: 2

Related Questions