Skip to main content



      Home
Home » Newcomers » Newcomers » Run/Test Java in Eclipse
Run/Test Java in Eclipse [message #651117] Thu, 27 January 2011 15:43 Go to next message
Eclipse UserFriend
Pardon me, I am new to all of this.

In my code I have a scanner so that the user can enter two numbers and those numbers will be added together and returned to the user. I want to test that it is working but when I press Run it shows all of my println's in the little Console tab. That's great and all...But I actually want some kind of console window where it asks me to enter the numbers, so that I can test that it is working,

How do I make it so that I can enter the data? At the moment I am just getting a little tab showing me the prints. I want some sort of Command Prompt.

I am running the latest Eclipse Classic.
Re: Run/Test Java in Eclipse [message #651137 is a reply to message #651117] Thu, 27 January 2011 17:33 Go to previous messageGo to next message
Eclipse UserFriend
On 27-Jan-11 13:43, iball8888@gmail.com wrote:
> Pardon me, I am new to all of this.
>
> In my code I have a scanner so that the user can enter two numbers and
> those numbers will be added together and returned to the user. I want to
> test that it is working but when I press Run it shows all of my
> println's in the little Console tab. That's great and all...But I
> actually want some kind of console window where it asks me to enter the
> numbers, so that I can test that it is working,
>
> How do I make it so that I can enter the data? At the moment I am just
> getting a little tab showing me the prints. I want some sort of Command
> Prompt.
>
> I am running the latest Eclipse Classic.

Sorry, the Console view is not interactive. Java applications do not
typically perform console I/O as do ancient C, Pascal, etc.
applications. This is probably why it's never been important enough to
implement an interactive console in Eclipse.

Possibilities include:

a) Run from the command line.

b) Inject data via the command line. Right-click on Run/Debug As ->
Run/Debug Configurations and click the Arguments tab.

c) Inject using an internal array or some other means by which you feed
statically defined data.

d) Rewrite as a full GUI or web application with an interface to supply
the data.
Re: Run/Test Java in Eclipse [message #651160 is a reply to message #651137] Fri, 28 January 2011 00:26 Go to previous messageGo to next message
Eclipse UserFriend
On Thu, 2011-01-27 at 15:33 -0700, Russell Bateman wrote:
> On 27-Jan-11 13:43, iball8888@gmail.com wrote:
> > Pardon me, I am new to all of this.
> >
> > In my code I have a scanner so that the user can enter two numbers and
> > those numbers will be added together and returned to the user. I want to
> > test that it is working but when I press Run it shows all of my
> > println's in the little Console tab. That's great and all...But I
> > actually want some kind of console window where it asks me to enter the
> > numbers, so that I can test that it is working,
> >
> > How do I make it so that I can enter the data? At the moment I am just
> > getting a little tab showing me the prints. I want some sort of Command
> > Prompt.
> >
> > I am running the latest Eclipse Classic.
>
> Sorry, the Console view is not interactive. Java applications do not
> typically perform console I/O as do ancient C, Pascal, etc.
> applications. This is probably why it's never been important enough to
> implement an interactive console in Eclipse.
>
Please ignore the above statement. It is not true. The Eclipse console
is interactive. Reading from System.in will take its input from the
Eclipse console. You enter data by typing in the console view.

Your question isn't really specific to Eclipse. It is a more general
Java question. You will need to write a class that reads from
System.in, parses the input into two numbers and passes the numbers to
your adder. You will then be able to interactively test your code.

A better approach is probably to look at Junit. This is a package
specifically written to help you develop unit tests of your code that
are reproducible and verifiable.

> Possibilities include:
>
> a) Run from the command line.
>
> b) Inject data via the command line. Right-click on Run/Debug As ->
> Run/Debug Configurations and click the Arguments tab.
>
> c) Inject using an internal array or some other means by which you feed
> statically defined data.
>
> d) Rewrite as a full GUI or web application with an interface to supply
> the data.
Re: Run/Test Java in Eclipse [message #651226 is a reply to message #651160] Fri, 28 January 2011 08:07 Go to previous message
Eclipse UserFriend
On 2011.01.27 22:26, David Wegener wrote:
> [snip]
> Please ignore the above statement. It is not true. The Eclipse console
> is interactive. Reading from System.in will take its input from the
> Eclipse console. You enter data by typing in the console view.
>
>[snip]
>

I apologized if I misinformed. I have never been able to enter anything
into the Eclipse Console view from the keyboard. And it's not from not
having tried early on (Europa), asking friends about it, and I am
certain I've read the same answer I just gave in this forum in years past.

I will have to try this out.

Yes, JUnit is an option I left out.

Thanks.
Previous Topic:New To PDE
Next Topic:How To Run PHP Page With "PHP Browser"?
Goto Forum:
  


Current Time: Sat Nov 08 20:53:21 EST 2025

Powered by FUDForum. Page generated in 0.09719 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top