Results 1 to 5 of 5
  1. #1
    P@Java is offline Member
    Join Date
    Jan 2014
    Posts
    1
    Rep Power
    0

    Default Help, new to programing

    Im following a simple set of code and can not get the correct output, in chapter 1 (Intro to Java)
    Im stuck on getting a set of code to run completely through command prompt. I installed
    JDK and textpad4, type the code, save it, direct towards it in cmd prompt but javac wont work.
    Is there something simple I am missing or doing wrong?

    Here's the code I put in textpad;

    public class Test {
    public static void main(string[] args)
    Ststem.out.println("3.5 * 4 / 2 - 2.5 is ")
    System.out.println(3.5 * 4 / 2 - 2.5);
    }
    }

    cmd prompt contents;

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    C:\Users\Da Man>cd\

    C:\>cd \Users\Da Man\My Documents\java

    C:\Users\Da Man\My Documents\java>dir
    Volume in drive C has no label.
    Volume Serial Number is 96FC-5C35

    Directory of C:\Users\Da Man\My Documents\java

    01/29/2014 11:41 PM <DIR> .
    01/29/2014 11:41 PM <DIR> ..
    01/31/2014 07:22 AM 169 Test.java
    1 File(s) 169 bytes
    2 Dir(s) 120,305,917,952 bytes free

    C:\Users\Da Man\My Documents\java>javac Test.java
    'javac' is not recognized as an internal or external command,
    operable program or batch file.

    C:\Users\Da Man\My Documents\java>

    Is there something simple im doing wrong?
    Any help would be much appreciated
    Thanks

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: Help, new to programing

    You need to add the bin folder of your JDK to the PATH variable.
    Lesson: Common Problems (and Their Solutions) (The Java™ Tutorials > Getting Started)
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    mbschutlz97 is offline Member
    Join Date
    Jan 2014
    Posts
    30
    Rep Power
    0

    Default Re: Help, new to programing

    how to change you PATH variable:
    open control panel go to system and security then system... click advanced system settings... when the system properties window comes up go to the advanced tab and then click environment variables... under system variables scroll down until you find one that says PATH... keep the window up and open a folder... go to your C: then program files... java... the jdk folder... and then the bin folder... copy the location and paste that in the path

  4. #4
    MW130 is offline Senior Member
    Join Date
    Jan 2013
    Posts
    317
    Rep Power
    2

    Default Re: Help, new to programing

    Your code:
    Java Code:
    public class Test {
    public static void main(string[] args)
    Ststem.out.println("3.5 * 4 / 2 - 2.5 is ")
    System.out.println(3.5 * 4 / 2 - 2.5);
    }
    }
    Correct code:
    Java Code:
    public class Test {
    public static void main(String[] args){
    System.out.println("3.5 * 4 / 2 - 2.5 is ")
    System.out.println(3.5 * 4 / 2 - 2.5);
    }
    }
    When you begin the main method you need brackets, and also need to capitalize the S in String. There was a typo for system, which I also fixed.

  5. #5
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    301
    Rep Power
    4

    Default Re: Help, new to programing

    Quote Originally Posted by mbschutlz97 View Post
    how to change you PATH variable:
    open control panel go to system and security then system... click advanced system settings... when the system properties window comes up go to the advanced tab and then click environment variables... under system variables scroll down until you find one that says PATH... keep the window up and open a folder... go to your C: then program files... java... the jdk folder... and then the bin folder... copy the location and paste that in the path
    Just be sure not incidentally to erase other PATH variables which are already in the PATH. add new one at the end of line with semicolon as delimiter.

Similar Threads

  1. Help with basic programing
    By gem132 in forum New To Java
    Replies: 2
    Last Post: 03-18-2012, 02:17 PM
  2. Regarding OS for Java Programing
    By Sanjeeva in forum Advanced Java
    Replies: 3
    Last Post: 01-19-2011, 07:57 PM
  3. Simple programing help.
    By koppojutsu in forum New To Java
    Replies: 12
    Last Post: 09-11-2010, 02:28 AM
  4. Hi, I am new to programing!
    By Zrob in forum Introductions
    Replies: 1
    Last Post: 09-14-2008, 06:38 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
  •