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

Thread: CMD WONT COMPILE MY .JAVA FILES

  1. #1
    Junior Member
    Join Date
    Oct 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry CMD WONT COMPILE MY .JAVA FILES

    I'v tried everything, i'v tried to create new path in enviornment variables i tried adding this path -->(C:\Program Files\Java\jdk1.8.0_20\bin) to the end of the default path doesnt work i uninstalled and reinstalled and did the same thing over and it didnt work am i editing the files wrong ? what i do is write the hello world program in eclipse to make sure there arent any errors then copy and paste in note pad++ save it as a .java file and it doesnt work i tried save it in regular notepad as .java laso and it doesnt work iv done every thing i could possibly find on youtube is this stuff outdated ? is there a new way? this one one of the errors ill get


    C:\javat>javac helloworld.java
    helloworld.java:1: error: '{' exp
    public class helloworld.java {
    ^
    and this is the code for that file im trying to compile

    public class helloworld.java {
    public static void main (String args[]){
    System.out.println("hello world");
    }
    }

    can any one help me please im new to java and i only have beginner experience in visual basic


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

    Default Re: CMD WONT COMPILE MY .JAVA FILES

    Class names start with capital letters and the dot '.' is not a valid character for a class name.
    Your class might look like this:
    public class HelloWorld {
        public static void main (String args[]){
            System.out.println("hello world");
        }
    }

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

    Default Re: CMD WONT COMPILE MY .JAVA FILES

    Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.

    Please post your code correctly per the above link.

    The class name SHOULD be capitalized and SHOULD NOT have .java as an extension. Eclipse should not have allowed that as a class name, so I think you must have changed something from the Eclipse version. Don't confuse the class name with the file name, because the file name SHOULD have the .java extension.

    Oh, and you apparently didn't try everything.

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

    Default Re: CMD WONT COMPILE MY .JAVA FILES

    thanks guys worked great

Similar Threads

  1. how to compile your .java files
    By wilcomega in forum Java Theory & Questions
    Replies: 6
    Last Post: November 16th, 2011, 02:38 AM
  2. WHY WONT THIS COMPILE!
    By usmc0311 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: October 12th, 2011, 02:42 PM
  3. anagram program wont compile please help
    By Rusak in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 26th, 2011, 06:23 PM
  4. Anagram program wont compile
    By Rusak in forum Member Introductions
    Replies: 0
    Last Post: March 25th, 2011, 02:38 PM
  5. class wont compile
    By waspandor in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 15th, 2011, 03:40 PM