Results 1 to 2 of 2
  1. #1
    beatzz is offline Member
    Join Date
    Mar 2009
    Posts
    1
    Rep Power
    0

    Question My first Java project, encountering bugs

    I have recently wrote a program in C/++. I am trying to port that program to Java. In an attempt to learn something about the language, and get some hands on experience with it. So far this is what I have.
    Java Code:
    // JavarocKs, by blacksheep
    
    import java.io.*;
    
    public class javarocks {
    
    	public static void main (String args[]) {
    
    		int channel;
    		String bssid;
    		String essid;
    
    		System.out.println("BSSID: ");
    		InputStreamReader input = new InputStreamReader(System.in);
    		BufferedReader reader = new BufferedReader(input);
    		try
    		{
    			bssid = reader.readLine(); 
    		}
    		catch(Exception e){}
    		System.out.printnl("ESSID: ");
    		InputStreamReader input = new InputStreamReader(System.in);
    		BufferedReader reader = new BufferedReader(input);
    		try
    		{
    			essid = reader.readLine(); 
    		}
    		catch(Exception e){}
    		System.out.printnl("CHANNEL: ");
    		InputStreamReader input = new InputStreamReader(System.in);
    		BufferedReader reader = new BufferedReader(input);
    		try
    		{
    			channel = reader.readLine(); 
    		}
    		catch(Exception e){}
    		System.out.println("You typed: " + bssid);
    		System.out.println("You typed: " + essid);
    		System.out.println("You typed: " + channel);
    	}
    }
    All I want is to declare an int, and 2 strings, then have the program get the values from the user and assign them to the int, and 2 string. But when I tried to compile it. I got these bugs.
    Java Code:
    beatzz@hax0r:/usr/java/jdk1.5.0_17/bin$ ./javac /home/beatzz/documents/crackrocks/source/javarocks.java
    /home/beatzz/documents/crackrocks/source/javarocks.java:21: cannot find symbol
    symbol  : method printnl(java.lang.String)
    location: class java.io.PrintStream
                    System.out.printnl("ESSID: ");
                              ^
    /home/beatzz/documents/crackrocks/source/javarocks.java:22: input is already defined in main(java.lang.String[])
                    InputStreamReader input = new InputStreamReader(System.in);
                                      ^
    /home/beatzz/documents/crackrocks/source/javarocks.java:23: reader is already defined in main(java.lang.String[])
                    BufferedReader reader = new BufferedReader(input);
                                   ^
    /home/beatzz/documents/crackrocks/source/javarocks.java:29: cannot find symbol
    symbol  : method printnl(java.lang.String)
    location: class java.io.PrintStream
                    System.out.printnl("CHANNEL: ");
                              ^
    /home/beatzz/documents/crackrocks/source/javarocks.java:30: input is already defined in main(java.lang.String[])
                    InputStreamReader input = new InputStreamReader(System.in);
                                      ^
    /home/beatzz/documents/crackrocks/source/javarocks.java:31: reader is already defined in main(java.lang.String[])
                    BufferedReader reader = new BufferedReader(input);
                                   ^
    /home/beatzz/documents/crackrocks/source/javarocks.java:34: incompatible types
    found   : java.lang.String
    required: int
                            channel = reader.readLine();
                                                     ^
    7 errors
    beatzz@hax0r:/usr/java/jdk1.5.0_17/bin$
    Please if anyone could offer advice, or help it would be greatly appreciated. I am very excited about learning Java and hope that with some of this communities help I will be able to do so.

  2. #2
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default Errors...

    Java Code:
    System.out.print[B][COLOR="Red"]nl[/COLOR][/B]("ESSID: ");
    The error is telling you that it can't find the above method. It's misspelled:
    Java Code:
    System.out.print[B][COLOR="Blue"][B]ln[/B][/COLOR][/B]("ESSID: ");
    Java Code:
    [B][COLOR="Red"]InputStreamReader input[/COLOR][/B] = new InputStreamReader(System.in);
    Don't reuse variables... call them differently so you don't get confused later:
    Java Code:
    InputStreamReader [B][COLOR="Blue"]Binput[/COLOR][/B] = new InputStreamReader(System.in);
    The same goes for variable reader.
    Java Code:
    [B][COLOR="Red"]channel[/COLOR][/B] = reader.readLine();
    the readLine() method returns a String, not an int. You have to convert the String to an int if you want to use it as an int. Look at the methods that the Integer class has to do this.

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Similar Threads

  1. Use Java 2 Project in different IDE
    By ramzansadiq in forum Eclipse
    Replies: 8
    Last Post: 02-15-2009, 05:33 PM
  2. Replies: 6
    Last Post: 01-11-2009, 04:37 AM
  3. Java Project
    By Smirre in forum New To Java
    Replies: 7
    Last Post: 11-06-2008, 07:13 PM
  4. how to get the project in java.....
    By thirumurugan.sethu in forum New To Java
    Replies: 2
    Last Post: 10-07-2008, 08:37 AM
  5. Help Java project.
    By mandrake446 in forum New To Java
    Replies: 1
    Last Post: 11-27-2007, 12:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •