This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 116077 - Print feature doesn't work when trying to run a file.
Summary: Print feature doesn't work when trying to run a file.
Status: RESOLVED INVALID
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 6.x
Hardware: PC Windows Vista
: P3 blocker (vote)
Assignee: issues@java
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-20 00:22 UTC by linxus
Modified: 2007-09-26 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description linxus 2007-09-20 00:22:59 UTC
Hi,
We are required to use netbeans for Intro to Programming with Java.  However, once I have compiled a working program,
and I click Run -> Run File -> Run "***.java", nothing happens if I use the System.out.print feature.  The program will
work if I use System.out.println() feature, but does not go to the next line of code if I just use System.out.print.


When I do try to run it, it just sais :
"init:
deps-jar:
compile-single:
run-single:"

However, when changing it to println(), everything works fine.

Any help is appreciated! 
-Alex


Here's the code:

package stateexam;

import java.util.*;
import java.io.*;

public class StateExam 
{     

    public static void main(String[] args) throws IOException
    {
        String stateName1;
        String stateName2;
        double population1;
        double population2;
        double averagePop;
        
       Scanner input = new Scanner(System.in);
        
       System.out.print("What is the name of the first state?: ");
            stateName1 = input.nextLine();

        
        System.out.print("What is the name of the second state?: ");
            stateName2 = input.nextLine();
            
        
        System.out.print("First state's population?: ");
            population1 = input.nextDouble();
          
        
        System.out.print("Second state's population?: ");
            population2 = input.nextDouble();
            
        
        averagePop = (double) (population1 + population2) / 2;
                
        System.out.print("The average population of " + stateName1 + " and " + stateName2 + " is " + averagePop);   
        
            
            

    }
    
}
Comment 1 Vladimir Yaroslavskiy 2007-09-20 07:26:56 UTC
Print category is for Print and Print Preview actions only.
Reassigning to the right category.
Comment 2 Jan Lahoda 2007-09-20 08:58:34 UTC
AFAIK, the PrintStream caches data written by "print" method (so it is not required to actually send the data out until
flushed). Try to use System.out.flush(). See java.io.PrintStream for more information.