Solving a compiler error in Netbeans IDE

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 3591 Views - Last Post: 27 February 2012 - 10:57 PM Rate Topic: -----

#1 Eddie_Nygma  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 10
  • Joined: 09-January 12

Solving a compiler error in Netbeans IDE

Posted 23 February 2012 - 03:27 AM

Greeting everyone, I'm posting as a complete noob to Java, but I've had experience writing programs in shell scripting, PHP, Python, Ruby, Perl and Lua, Java being my current main focus. Now this one source file has been quite troubling when loading it into the compiler for the Netbeans IDE on Fedora 16, and the syntax is exactly as shown in the book. What makes coming up with a solution problematic for me is that, I don't often find myself dealing with compiler errors very much when writing scripting language application with Python or Lua for example, so I have practiced it. So I'll show everyone the source code and what I need is a basic small-step walkthrough regarding how I can correct
all these errors.
                                                                                                                              class Jabberwock {
    String color;
    String sex;
    boolean hungry;

    void feedJabberwock(){
        if (hungry == true) {
            System.out.printIn("Yum -- a peasant!");
            hungry = false;
        } else
            System.out.printIn("No, thanks -- already ate.");
    }
        
    void showAttributes() {
        System.out.printIn("This is a " + sex + " " + color + " jabberwock.");
        if (hungry == true)
            System.out.printIn("The jabberwock is hungry.");
        else
            System.out.printIn("The jabberwock is full.");
    }

    public static void main (String arguments[]) {
        Jabberwock j = new Jabberwock();
        j.color = "orange";
        j.sex = "male";
        j.hungry = true;
        System.out.printIn("Calling showAttributes ...");
        j.showAttributes();
        System.out.printIn("-----");
        System.out.printIn("Feeding the jabberwock ...");
        j.feedJabberwock();
        System.out.printIn("-----");
        System.out.printIn("Calling showAttributes ...");
        j.showAttributes();
        System,out.printIn("-----");
        System.out.printIn("Feeding the jabberwock ...");
        j.feedJabberwock();
    }
}
                                                   

And here's the output I get when I try to compile it:
init:
Deleting: /home/eddie_nygma/NetBeansProjects/Jabberwock.java/build/built-jar.properties
deps-jar:
Updating property file: /home/eddie_nygma/NetBeansProjects/Jabberwock.java/build/built-jar.properties
Compiling 1 source file to /home/eddie_nygma/NetBeansProjects/Jabberwock.java/build/classes
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:35: error: not a statement
        System,out.printIn("-----");
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:35: error: ';' expected
        System,out.printIn("-----");
2 errors
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/nbproject/build-impl.xml:551: The following error occurred while executing this line:
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/nbproject/build-impl.xml:261: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)


Ok thank you everybody and I hope you guys can contribute to making me better at learning the jit compilation process, thus improving my skill on a fixability factor. Any questions to start off with?

Is This A Good Question/Topic? 1
  • +

Replies To: Solving a compiler error in Netbeans IDE

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2724
  • View blog
  • Posts: 11,456
  • Joined: 20-September 08

Re: Solving a compiler error in Netbeans IDE

Posted 23 February 2012 - 04:11 AM

You have a typo

Quote

 System,out.printIn("-----");


should be

 System.out.printIn("-----");


(full stop, not comma)
Was This Post Helpful? 2
  • +
  • -

#3 Eddie_Nygma  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 10
  • Joined: 09-January 12

Re: Solving a compiler error in Netbeans IDE

Posted 24 February 2012 - 07:26 AM

View Postg00se, on 23 February 2012 - 04:11 AM, said:

You have a typo

Quote

 System,out.printIn("-----");


should be

 System.out.printIn("-----");


(full stop, not comma)

Thanks, that error was obviously inexcusable, but it's been corrected, and yet it still can't finish compiling. Take a look:
init:
Deleting: /home/eddie_nygma/NetBeansProjects/Jabberwock.java/build/built-jar.properties
deps-jar:
Updating property file: /home/eddie_nygma/NetBeansProjects/Jabberwock.java/build/built-jar.properties
Compiling 1 source file to /home/eddie_nygma/NetBeansProjects/Jabberwock.java/build/classes
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:8: error: cannot find symbol
            System.out.printIn("Yum -- a peasant!");
  symbol:   method printIn(String)
  location: variable out of type PrintStream
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:11: error: cannot find symbol
            System.out.printIn("No, thanks -- already ate.");
  symbol:   method printIn(String)
  location: variable out of type PrintStream
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:15: error: cannot find symbol
        System.out.printIn("This is a " + sex + " " + color + " jabberwock.");
  symbol:   method printIn(String)
  location: variable out of type PrintStream
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:17: error: cannot find symbol
            System.out.printIn("The jabberwock is hungry.");
  symbol:   method printIn(String)
  location: variable out of type PrintStream
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:19: error: cannot find symbol
            System.out.printIn("The jabberwock is full.");
  symbol:   method printIn(String)
  location: variable out of type PrintStream
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:27: error: cannot find symbol
        System.out.printIn("Calling showAttributes ...");
  symbol:   method printIn(String)
  location: variable out of type PrintStream
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:29: error: cannot find symbol
        System.out.printIn("-----");
  symbol:   method printIn(String)
  location: variable out of type PrintStream
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:30: error: cannot find symbol
        System.out.printIn("Feeding the jabberwock ...");
  symbol:   method printIn(String)
  location: variable out of type PrintStream
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:32: error: cannot find symbol
        System.out.printIn("-----");
  symbol:   method printIn(String)
  location: variable out of type PrintStream
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:33: error: cannot find symbol
        System.out.printIn("Calling showAttributes ...");
  symbol:   method printIn(String)
  location: variable out of type PrintStream
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:35: error: cannot find symbol
        System.out.printIn("-----");
  symbol:   method printIn(String)
  location: variable out of type PrintStream
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:36: error: cannot find symbol
        System.out.printIn("Feeding the jabberwock ...");
  symbol:   method printIn(String)
  location: variable out of type PrintStream
12 errors
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/nbproject/build-impl.xml:551: The following error occurred while executing this line:
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/nbproject/build-impl.xml:261: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)

How do I go about parsing these ones now? I didn't encounter any instance variable errors during my interactive mode sessions, mainly typos?
Was This Post Helpful? 0
  • +
  • -

#4 mi14chal  Icon User is offline

  • D.I.C Head

Reputation: 81
  • View blog
  • Posts: 202
  • Joined: 11-December 10

Re: Solving a compiler error in Netbeans IDE

Posted 24 February 2012 - 07:47 AM

Change all lines System.out.printIn to System.out.println
Was This Post Helpful? 0
  • +
  • -

#5 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2198
  • View blog
  • Posts: 5,226
  • Joined: 10-September 10

Re: Solving a compiler error in Netbeans IDE

Posted 24 February 2012 - 08:04 AM

I'm not an experienced Netbeans user, but I expect that it would highlight the simple syntactic errors that you're making. Beginners are often advised to not use such crutches, but if you're going to - and I'm personally fine with it - please learn HOW to use them. You should be seeing red squigglies or something under your "printIn" statements. If you hover your mouse over them, right click, or something simple, the editor should give you a hint about what's wrong.

Keep coding!
Was This Post Helpful? 1
  • +
  • -

#6 Eddie_Nygma  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 10
  • Joined: 09-January 12

Re: Solving a compiler error in Netbeans IDE

Posted 24 February 2012 - 09:59 PM

View PostGregBrannon, on 24 February 2012 - 08:04 AM, said:

I'm not an experienced Netbeans user, but I expect that it would highlight the simple syntactic errors that you're making. Beginners are often advised to not use such crutches, but if you're going to - and I'm personally fine with it - please learn HOW to use them. You should be seeing red squigglies or something under your "printIn" statements. If you hover your mouse over them, right click, or something simple, the editor should give you a hint about what's wrong.

Keep coding!

In my window, the syntax highlighting is colored orange for both printIn and afterwards println, isn't that strange though. In Python for example I would only get red for specifically typos, so I'm somewhat used to quantifiably single-class highlights , and I also didn't get an overview of the syntax highlighting in my book. Anywho, here's the error I'm getting now?:
init:
Deleting: /home/eddie_nygma/NetBeansProjects/Jabberwock.java/build/built-jar.properties
deps-jar:
Updating property file: /home/eddie_nygma/NetBeansProjects/Jabberwock.java/build/built-jar.properties
Compiling 1 source file to /home/eddie_nygma/NetBeansProjects/Jabberwock.java/build/classes
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:35: error: cannot find symbol
        System.out.prinln("-----");
  symbol:   method prinln(String)
  location: variable out of type PrintStream
1 error
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/nbproject/build-impl.xml:551: The following error occurred while executing this line:
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/nbproject/build-impl.xml:261: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds) 

Was This Post Helpful? 0
  • +
  • -

#7 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Solving a compiler error in Netbeans IDE

Posted 24 February 2012 - 11:24 PM

May be you post your updated code, because I dont see the reason println(String) to be rejected while the above one are accepted.
Was This Post Helpful? 0
  • +
  • -

#8 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2198
  • View blog
  • Posts: 5,226
  • Joined: 10-September 10

Re: Solving a compiler error in Netbeans IDE

Posted 24 February 2012 - 11:38 PM

In line 7, I see "prinln" without the 't'. Another typo that should be highlighted in your source code.
Was This Post Helpful? 1
  • +
  • -

#9 lbfb  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 31
  • Joined: 23-February 12

Re: Solving a compiler error in Netbeans IDE

Posted 24 February 2012 - 11:49 PM

Eddie,
I am new to programming myself, but I think that part of the problem is in the way you have built the program. In the code that I can see, you have not declared Jabberwock as a class anywhere, and there is no constructor method for the class. For example, I tried the following code with netbeans and it compiled ok.


public class Jabberwock {

    private String colour;
    private String gender;
    private boolean hungry;
    
    
    // default constructor
    public Jabberwock() {
        colour = null;
        gender = null;
    }  // end constructor
    
    
    // method to initialise attributes
    private Jabberwock (String c, String g, boolean h) {
        colour = c;
        gender = g;
        hungry = h;
    }  // end method to initialise attributes
    
    
    
    public static void main (String arguments[]) {
       Jabberwock j = new Jabberwock("orange", "male", true);
       
    }
    
}  // end class declaration



If you were to add a few of your methods to this, it would probably do what you want it to do.

I hope this helps and that it is close to the answer you were looking for.

regards

lbfb
Was This Post Helpful? 0
  • +
  • -

#10 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2724
  • View blog
  • Posts: 11,456
  • Joined: 20-September 08

Re: Solving a compiler error in Netbeans IDE

Posted 25 February 2012 - 06:25 AM

Quote

For example, I tried the following code with netbeans and it compiled ok.


That's because yours isn't full of typos ;)
Was This Post Helpful? 0
  • +
  • -

#11 Eddie_Nygma  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 10
  • Joined: 09-January 12

Re: Solving a compiler error in Netbeans IDE

Posted 25 February 2012 - 11:54 AM

View Postlbfb, on 24 February 2012 - 11:49 PM, said:

Eddie,
I am new to programming myself, but I think that part of the problem is in the way you have built the program. In the code that I can see, you have not declared Jabberwock as a class anywhere, and there is no constructor method for the class. For example, I tried the following code with netbeans and it compiled ok.


public class Jabberwock {

    private String colour;
    private String gender;
    private boolean hungry;
    
    
    // default constructor
    public Jabberwock() {
        colour = null;
        gender = null;
    }  // end constructor
    
    
    // method to initialise attributes
    private Jabberwock (String c, String g, boolean h) {
        colour = c;
        gender = g;
        hungry = h;
    }  // end method to initialise attributes
    
    
    
    public static void main (String arguments[]) {
       Jabberwock j = new Jabberwock("orange", "male", true);
       
    }
    
}  // end class declaration



If you were to add a few of your methods to this, it would probably do what you want it to do.

I hope this helps and that it is close to the answer you were looking for.

regards

lbfb

I'll try taking my twenty lines from the book and replacing it with your methods in a seperate source file. In the meantime take a look at my code altered due the typos shown at first glance, corresponding with the compiler errors I posted:
class Jabberwock {
    String color;
    String sex;
    boolean hungry;

    void feedJabberwock(){
        if (hungry == true) {
            System.out.println("Yum -- a peasant!");
            hungry = false;
        } else
            System.out.println("No, thanks -- already ate.");
    }
        
    void showAttributes() {
        System.out.println("This is a " + sex + " " + color + " jabberwock.");
        if (hungry == true)
            System.out.println("The jabberwock is hungry.");
        else
            System.out.println("The jabberwock is full.");
    }

    public static void main (String arguments[]) {
        Jabberwock j = new Jabberwock();
        j.color = "orange";
        j.sex = "male";
        j.hungry = true;
        System.out.println("Calling showAttributes ...");
        j.showAttributes();
        System.out.println("-----");
        System.out.println("Feeding the jabberwock ...");
        j.feedJabberwock();
        System.out.println("-----");
        System.out.println("Calling showAttributes ...");
        j.showAttributes();
        System.out.prinln("-----");
        System.out.println("Feeding the jabberwock ...");
        j.feedJabberwock();
    }
}



Was This Post Helpful? 0
  • +
  • -

#12 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Solving a compiler error in Netbeans IDE

Posted 25 February 2012 - 12:58 PM

What is the question now?
You didnt change line 35 yet?
 System.out.prinln("-----");

it is println()
Was This Post Helpful? 0
  • +
  • -

#13 lbfb  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 31
  • Joined: 23-February 12

Re: Solving a compiler error in Netbeans IDE

Posted 25 February 2012 - 03:48 PM

Also, you still have no constructor method for Jabberwock. Without this, the new Jabberwock() means nothing to the compiler and so you are bound to get a build error. Even if you just add an empty constructor method with
public Jabberwock() {

}



at least then the new Jabberwock line means something.
Was This Post Helpful? 0
  • +
  • -

#14 Eddie_Nygma  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 10
  • Joined: 09-January 12

Re: Solving a compiler error in Netbeans IDE

Posted 27 February 2012 - 02:13 AM

View Postlbfb, on 25 February 2012 - 03:48 PM, said:

Also, you still have no constructor method for Jabberwock. Without this, the new Jabberwock() means nothing to the compiler and so you are bound to get a build error. Even if you just add an empty constructor method with
public Jabberwock() {

}



at least then the new Jabberwock line means something.

Thanks man, but I tried the empty constructor method and alternately your other blocks of code and I got some new errors:
public class Jabberwock {

   private String colour;
   private String gender;
   private boolean hungry;


   // default constructor
   public Jabberwock() {
       colour = null;
       gender = null;
   }  // end constructor

   // method to initialise attributes
   private Jabberwock (String c, String g, boolean h) {
       colour = c;
       gender = g;
       hungry = h;
  } // end method to initialise atrributes

   }
    void feedJabberwock(){
        if (hungry == true) {
            System.out.printIn("Yum -- a peasant!");
            hungry = false;
        } else
            System.out.printIn("No, thanks -- already ate.");
    }
        
    void showAttributes() {
        System.out.printIn("This is a " + gender + " " + colour + " jabberwock.");
        if (hungry == true)
            System.out.printIn("The jabberwock is hungry.");
        else
            System.out.printIn("The jabberwock is full.");
    }

    public static void main (String arguments[]) {
        Jabberwock j = new Jabberwock();
        j.colour = "orange";
        j.gender = "male";
        j.hungry = true;
        System.out.printIn("Calling showAttributes ...");
        j.showAttributes();
        System.out.printIn("-----");
        System.out.printIn("Feeding the jabberwock ...");
        j.feedJabberwock();
        System.out.printIn("-----");
        System.out.printIn("Calling showAttributes ...");
        j.showAttributes();
        System.out.printIn("-----");
        System.out.printIn("Feeding the jabberwock ...");
        j.feedJabberwock();
    }
}                                                        

Now what am I supposed to do?


Forgot to post the compiler errors heheh.
init:
Deleting: /home/eddie_nygma/NetBeansProjects/Jabberwock.java/build/built-jar.properties
deps-jar:
Updating property file: /home/eddie_nygma/NetBeansProjects/Jabberwock.java/build/built-jar.properties
Compiling 1 source file to /home/eddie_nygma/NetBeansProjects/Jabberwock.java/build/classes
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:22: error: class, interface, or enum expected
    void feedJabberwock(){
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:25: error: class, interface, or enum expected
            hungry = false;
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:26: error: class, interface, or enum expected
        } else
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:28: error: class, interface, or enum expected
    }
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:32: error: class, interface, or enum expected
        if (hungry == true)
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:34: error: class, interface, or enum expected
        else
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:36: error: class, interface, or enum expected
    }
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:38: error: class, interface, or enum expected
    public static void main (String arguments[]) {
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:40: error: class, interface, or enum expected
        j.colour = "orange";
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:41: error: class, interface, or enum expected
        j.gender = "male";
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:42: error: class, interface, or enum expected
        j.hungry = true;
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:43: error: class, interface, or enum expected
        System.out.printIn("Calling showAttributes ...");
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:44: error: class, interface, or enum expected
        j.showAttributes();
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:45: error: class, interface, or enum expected
        System.out.printIn("-----");
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:46: error: class, interface, or enum expected
        System.out.printIn("Feeding the jabberwock ...");
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:47: error: class, interface, or enum expected
        j.feedJabberwock();
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:48: error: class, interface, or enum expected
        System.out.printIn("-----");
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:49: error: class, interface, or enum expected
        System.out.printIn("Calling showAttributes ...");
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:50: error: class, interface, or enum expected
        j.showAttributes();
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:51: error: class, interface, or enum expected
        System.out.printIn("-----");
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:52: error: class, interface, or enum expected
        System.out.printIn("Feeding the jabberwock ...");
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:53: error: class, interface, or enum expected
        j.feedJabberwock();
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/src/jabberwockjava/Main.java:54: error: class, interface, or enum expected
    }
23 errors
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/nbproject/build-impl.xml:551: The following error occurred while executing this line:
/home/eddie_nygma/NetBeansProjects/Jabberwock.java/nbproject/build-impl.xml:261: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)  

This post has been edited by smohd: 27 February 2012 - 02:24 AM
Reason for edit:: Removed long self quote

Was This Post Helpful? 0
  • +
  • -

#15 eker676  Icon User is offline

  • Software Engineer
  • member icon

Reputation: 378
  • View blog
  • Posts: 1,833
  • Joined: 18-April 09

Re: Solving a compiler error in Netbeans IDE

Posted 27 February 2012 - 02:17 AM

Extra right brace on line 21 that is closing your class prematurely.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2