Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Strange Compiling Error

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Strange Compiling Error

    I'm having a weird problem and I hope someone can help me. I was trying to compile a program with string earlier and I got errors while compiling. That's fine. But now, all of the programs I try to compile give me the same error that has nothing to do with the code. For example:

    public class New {
    public static void main(String[] args) {
     
    	System.out.println("Hello");
     
    	}
    }

    gives me the following error:


    .\String.java:11: incompatible types
    found : java.lang.String
    required: String
    String username = scanner.nextLine();
    ^
    .\String.java:17: incompatible types
    found : java.lang.String
    required: String
    String password = scanner.nextLine();
    ^
    2 errors


    And this happens with everything I do.
    Sorry, but I'm completely new to this.

    **I use javac
    Last edited by crism85; October 12th, 2009 at 04:30 PM.


  2. #2
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Strange Compiling Error

    are you writing your codes in DOS editor?

    always check the EXACT file that you are compiling when using javac

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Strange Compiling Error

    Yes, I was.
    I was compiling the right files.

    I used the console in Notepad++ and cmd stopped giving me an error.

    But I still have no idea what was going on because I am absolutely sure, and I tried with lots of different files and I kept getting the same error.

    Some kind of bug maybe?
    Or am I just clueless?

  4. #4
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Strange Compiling Error

    I think you're compiling the wrong Java class file... if you want to get rid of many of the mundane things of coding, I'd really recommend getting an IDE. The two best Java IDE's are Eclipse and NetBeans. From what I've heard, they're pretty much on equal footing, it's mostly personal preference. For example, I prefer Eclipse because it's fast and let's you get on with the important coding stuff, but NetBeans has a powerful GUI designer, and is backed by Sun. Both are completely free, and offer a wide variety of helpful tools, many of which you probably won't use unless you're developing large projects.

  5. #5
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Strange Compiling Error

    dont forget this..

    always remember that the java code that you are editing in DOS MUST be SAVED at the 'bin' folder...

    BIN.


    it looks like the error is pointing on a particular program.... does that program still exist in one of your folders?
    Last edited by chronoz13; October 13th, 2009 at 01:03 AM.

  6. #6
    Java kindergarten chronoz13's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    659
    Thanks
    177
    Thanked 30 Times in 28 Posts

    Default Re: Strange Compiling Error

    I agree with what hellowolrd have said... i think you should use a better compiler

    ECLIPSE or NETBEANS... most of the java programmers here are using Eclipse.. but im using netbeans.. coz
    thats where i Started.

    BUT!!!!

    you have so many advantages using NOTEPAD or DOS, why?
    think of this..

    what if you encounter a PRE-HISTORIC personal computer ,(e.g windows 1990 (if theres something like that)) a very low specs? expect that there's no any full blown IDE..so what are you going to do?

    as far as i experienced using DOS.. that is the LAST RESORT of a programmer.. (just a personal idea)
    you just need a java library..

    I encountered this kind of scenario in my school
    theres an IDE 'blue J' but! i dont know how to compile or write on that version of 'blue j' , (the version of blue j that were using was not a user friendly one).
    so my proffesor asked us if its ok for us to use DOS to compile java programms...

    at first it was peculiar.. coz you need to compile the program step-by-step..

    but later on.. i found the benefits of using DOS.... 1 is the reason that,what if I encounter a computer without an IDE?


    you can also learn on how to do the classpaths stuffs. (that I never encountered)..