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 3 of 3

Thread: Java throwing error with Simple Program

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    11
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Java throwing error with Simple Program

    Can't figure this out at all. I'm getting this error "Static Error: Undefined class 'Variables3'" in Dr. Java when trying to run a file named "Variables3.java".

    Variables3.java contains this code:
    PHP Code:
    public class Variables3
    {
      public static 
    void main(String[] args)
      {
        
    int myInteger 10;
        
    System.out.Println(myInteger);
      }

    The console window is printing out this:
    "javacTask: target release 1.7 conflicts with default source release 1.8"

    When I compile the program, the compile window throws no errors. It says "Compilation completed."


  2. #2
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Java throwing error with Simple Program

    A printwriter like System.out does not have a method called Println. There is however a method called println, I guess that is what you wanted to write here. Remember, java is case sensitive.
    I dont know if this is the only problem you got but the code looks okay to me.

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Java throwing error with Simple Program

    I don't know how Dr. Java is configured, but I suspect there's a version mismatch with the compiler (javac) and execution (java) executables. Drop to a console and type both:

    javac -version

    and

    java -version

    and ensure the results match. Report the results here if you need to.

    If the results do match, then dig into the Dr. Java configuration and ensure that both the compiler and execution settings point to the same Java installation. If they don't match, then you have multiple Java installations with paths or environment variables pointing to both, one for JRE and one for JDK, that you need to fix so that both point to the same Java installation.

Similar Threads

  1. Getting error on a simple program.
    By prateek46 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: September 13th, 2014, 10:37 AM
  2. Java simple program error?
    By derialvish in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 22nd, 2014, 05:48 AM
  3. Replies: 3
    Last Post: November 30th, 2013, 05:52 PM
  4. [SOLVED] Java Simple Rectangle Program Error
    By XP360 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 22nd, 2013, 11:07 PM
  5. Error of data types and type casting in java program
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: September 2nd, 2009, 10:22 AM