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

Thread: My first java code won't run from cmd Windows

  1. #1
    Junior Member
    Join Date
    Jan 2022
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default My first java code won't run from cmd Windows

    Hi.

    I'm a totally beginner in java and was wondering if someone could help me out

    I have made an easy java file, but can't run it from cmd - windows.

    Can someone tell me why I'm not able to run the file?

    My commands with error message:

    C:\Program Files\Java\jdk-17.0.2\bin>set path=C:\Program Files\Java\jdk-17.0_2\bin

    C:\Program Files\Java\jdk-17.0.2\bin>cd\

    C:\>dir
    Volume in drive C has no label.
    Volume Serial Number is 7048-6868

    Directory of C:\

    02/09/2019 11:11 AM <DIR> DRIVERS
    01/29/2022 10:37 AM 196 FirstJavaProgam.java
    10/06/2020 08:43 AM <DIR> Intel
    12/07/2019 10:14 AM <DIR> PerfLogs
    01/29/2022 10:44 AM <DIR> Program Files
    10/15/2021 10:58 AM <DIR> Program Files (x86)
    10/06/2020 08:44 AM <DIR> Users
    01/28/2022 06:37 PM <DIR> Windows
    1 File(s) 196 bytes
    7 Dir(s) 73,367,609,344 bytes free

    C:\>java FirstJavaProgam
    'java' is not recognized as an internal or external command,
    operable program or batch file.


    My code looks like this:

    public class FirtsJavaProgram {
    public static void main(String[] args){
    system.out.println("This is my first program in java");
    }//End of main
    }//End of first JavaProgram Class


    Thanks!

    --- Update ---

    by the way, this is the website I followed when trying to make my first java code:

    https://beginnersbook.com/2013/05/first-java-program/

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: My first java code won't run from cmd Windows

    'java' is not recognized as an internal or external command,
    The OS can not find a command named java.

    You need to
    either give the OS the full path to the java command; for example:
    C:\Program Files\Java\jdk1.8.0_60\bin\java.exe TestCode27
    or add the path to the bin folder to the OS's PATH environment variable so the OS can find the java command

    Note: You need to run the javac.exe command to compile the source and create a .class file before running the java command.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Jul 2019
    Posts
    36
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default Re: My first java code won't run from cmd Windows

    C:\Program Files\Java\jdk-17.0.2\bin
    C:\Program Files\Java\jdk-17.0_2\bin

    find one difference
    0.2
    0_2

  4. #4
    Junior Member
    Join Date
    Feb 2022
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: My first java code won't run from cmd Windows

    This is so helpful since I am having the same problem. Thank you

  5. #5
    Junior Member
    Join Date
    Feb 2022
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: My first java code won't run from cmd Windows

    This is so helpful since I am having the same problem. Thank you

Similar Threads

  1. Java RTE in Windows 10
    By Vibe in forum Computer Support
    Replies: 3
    Last Post: May 8th, 2023, 10:57 AM
  2. Replies: 0
    Last Post: March 9th, 2018, 04:34 AM
  3. Java 1.6.0_21 x 64 - Windows 7, Add-ins
    By DAVESINGER in forum Java Theory & Questions
    Replies: 3
    Last Post: July 24th, 2014, 07:11 AM
  4. Java and Windows
    By teslaa in forum Java Theory & Questions
    Replies: 0
    Last Post: April 3rd, 2014, 05:32 PM
  5. Replies: 0
    Last Post: July 2nd, 2012, 09:11 PM