NetBeans 5.5 / Java question regarding user input

Java code runs fine from system prompt but not in NetBeans

Page 1 of 1

1 Replies - 11269 Views - Last Post: 07 December 2006 - 07:10 PM Rate Topic: -----

#1 sirrom  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 07-December 06

NetBeans 5.5 / Java question regarding user input

Posted 07 December 2006 - 04:11 PM

Hi -
I'm new to the NetBeans IDE (5.5) and am trying to get some Java code I've written to run in it. The program has three classes (one with a main method), and it all compiles and runs fine using javac and java from a DOS system prompt. In the IDE it doesn't run properly. I've spent a frustrating amount of time looking at the IDE documention, searching the web, etc. without success.

I've used MS Visual Studio for several years and seek the ability to step through the code and watch how variables change, etc. I'm trying to move from VB to Java. I think I have the packages and classes in the IDE correctly, and I get messages saying that the project builds successfully. I don't understand why a program would run in a DOS window but not in a simple IDE output window.

The problem comes about when the program asks for user input. I see that there is a small Input window below the Output window in the IDE. The program pauses for input before displaying the prompt which is BEFORE the input statements in the code, e.g.:

	 System.out.print("Enter a number");
	 try {
	   BufferedReader is = new BufferedReader(new InputStreamReader;
	   inputLine = is.readLine();
	   if (inputLine.length() == 0 )  return null; 
	 } catch (IOException e) {
	   System.out.println("IOException: " + e);
	 return inputLine;

I can step right over the System.out.print line without anything displaying in the Output window. Then if I enter a number in the Input window and press Enter, "Enter a number" appears in the Output window and the program continues to run.

What could be different about running this from the NetBeans IDE? I know many people suggest not using IDEs especially in the learning phase of a language, but want to be able to use at least the most basic NetBeans features so I can step through my programs to debug them...

This is my first post here. Any guidance would be much appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: NetBeans 5.5 / Java question regarding user input

#2 salindor  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 46
  • View blog
  • Posts: 302
  • Joined: 10-November 06

Re: NetBeans 5.5 / Java question regarding user input

Posted 07 December 2006 - 07:10 PM

In past versions, you needed to set the main class by right clicking on the class that has the main method and clicking the set main menu option (it is possible for every java class to have a main function)

However, I stopped using netbeans when I ran into some glitches with the application that cost me my work; and compared to eclipse it is slow.

Eclipse is also free, written by ibm instead of sun. It also has a debugger built into. Personally it feels more stable to me than netbeans ever has.

Anyways, sorry I couldn't be more helpful.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1