How to Run Java Programs With Command Prompt (cmd) and Notepad in Windows

Поделиться
HTML-код
  • Опубликовано: 26 авг 2024
  • How do you compile and execute your Java programs from the command prompt (cmd) in Windows? Also, how you can you write your programs just using Notepad?
    We'll go over how to write a Java program in Notepad, then how you can compile and run that program directly from the command prompt (cmd) in Windows.
    The video shows Windows 11, but the same process works for Windows 10 or other version of Windows.
    This is a great beginner's Java video if you're learning how to execute your programs, or if you're used to using an IDE like Eclipse, and want to learn how to use the command prompt (cmd) instead.
    Learn or improve your Java by watching it being coded live!
    Hi, I'm John! I'm a Lead Java Software Engineer and I've been in the programming industry for more than a decade. I love sharing what I've learned over the years in a way that's understandable for all levels of Java learners.
    Let me know what else you'd like to see!
    JDK download: www.oracle.com...
    Links to any stuff in this description are affiliate links, so if you buy a product through those links I may earn a small commission.
    📕 THE best book to learn Java, Effective Java by Joshua Bloch
    amzn.to/36AfdUu
    📕 One of my favorite programming books, Clean Code by Robert Martin
    amzn.to/3GTPVhf
    🎧 Or get the audio version of Clean Code for FREE here with an Audible free trial
    www.audibletria...
    🖥️Standing desk brand I use for recording (get a code for $30 off through this link!)
    bit.ly/3QPNGko
    📹Phone I use for recording:
    amzn.to/3HepYJu
    🎙️Microphone I use (classy, I know):
    amzn.to/3AYGdbz
    Donate with PayPal (Thank you so much!)
    www.paypal.com...
    ☕Complete Java course:
    codingwithjohn...
    codingwithjohn...

Комментарии • 224

  • @Ecstasy_Android_Gamer
    @Ecstasy_Android_Gamer 2 года назад +29

    John, you're simply the best. All the tutorials from my university never seemed to work for me until I watched your video following all your detailed steps. Thanks for making me run my first java program and making it feel so simple.

  • @nird4897
    @nird4897 2 года назад +43

    Great video! It worked! My programming professor told me to try using cmd to run our java project, and I kept on getting errors until I watched your video. Thanks a lot!

    • @nird4897
      @nird4897 2 года назад +1

      And in addition, I searched for the same question few weeks ago here on RUclips and no one was able to help me like you did. Definitely worth subscribing! 😁

    • @ironman......
      @ironman...... Год назад

      Yes absolutely this vedio helped me a lot...
      Thank you👍

  • @dikshyakafle5530
    @dikshyakafle5530 Год назад +4

    Thank you John, you're the best. I had an assignment to run a program in command prompt and I continuously got errors. Finally, I understood it.

  • @spudbencer7179
    @spudbencer7179 6 месяцев назад +12

    Now try with packages. 1 hour of googling and the java command still doesn't find my class declaration, in the same exact folder

  • @SagarSharma-pb6xh
    @SagarSharma-pb6xh 4 месяца назад

    I attend my college lectures of java but didn't understand anything but by watching your single video I got know the basics of java thank you sir ❤

  • @aramesmaeili4099
    @aramesmaeili4099 Год назад +1

    I am so thankful for this. This saved my life. As a beginner, I was losing my mind

  • @youinagacha8340
    @youinagacha8340 11 месяцев назад +1

    Thank you so much my school couldn't teach me that in a month you just did it in a minute

  • @franz2027
    @franz2027 2 года назад +7

    Hi John, thank you very much for your videos.
    You have the best Java learning channel that I have come across. I've been using your channel to review my Java knowledge after not coding in java for 3+ years and preparing for a Fang interview. I'm also planning to do a talk on it and referencing anybody who wants to learn Java to you.
    My request is: "Will you please do a video on Lambdas?"

  • @soul_conscious
    @soul_conscious Год назад +3

    So simple and to the point without any unnecessary hassles! Thank you!

  • @jesusdiaz5008
    @jesusdiaz5008 Год назад +4

    Thanks big dog, I appreciate content creators such as yourself. You dove straight into the point with great information. Much love ❤

  • @sforsuraj7255
    @sforsuraj7255 Год назад +1

    I learnt a lot from your videos in past 24 hrs.
    Thank you sir for sharing such videos.

  • @battleforge6177
    @battleforge6177 11 месяцев назад

    Thank you very much sir, amazing video ,helped me a biology student who once had no knowledge on computer science,c, java and now I am praised by my java teacher during lab sessions. Once again
    Thank you a lot

  • @Swathi12383
    @Swathi12383 3 месяца назад

    Thank u so much 🙏🙏 I watched so many videos but didn't get it to run Java in CMD...ur video helped me a lot...❤

  • @Swagboij
    @Swagboij 2 месяца назад

    Amazing clear and concise tutorial man thank you

  • @clairejing1958
    @clairejing1958 Год назад

    Thank you so much John, I've been searching how to do for so long.

  • @murewaajala445
    @murewaajala445 Год назад +2

    Could not find or load main class helloworld
    Caused by: java.lang.ClassNotFoundException: helloworld
    mine is showing this error please what can i do

  • @Hakim_fadhli
    @Hakim_fadhli Год назад

    i try many other videos without result this video is very helpfull for beginners like me, thank you

  • @Julia-nk2gj
    @Julia-nk2gj Год назад

    Thank you for such a simple and straightforward explanation.

  • @Beeetle_Juice
    @Beeetle_Juice 10 месяцев назад

    The best explanation I've ever watched !

  • @srisaikunderu1429
    @srisaikunderu1429 Год назад

    Thank you so much. I felt so frustrated for doing this Java file process. You really helped me sir.

  • @lisatorres2234
    @lisatorres2234 Год назад

    You just taught me something I needed for class. Thank you so much.

  • @arnavchauhan9637
    @arnavchauhan9637 8 месяцев назад

    Thanks sir for providing the wonderful commands previously i had to run task build java then click on run button it was too time consuming but its so simple.....

  • @JJJJ-gl2uf
    @JJJJ-gl2uf 2 года назад

    Great video. I just started a Java course on Moodle and your explanation here helped a lot. Will be following you in future. Many thanks.

  • @shirousensei5356
    @shirousensei5356 5 месяцев назад +1

    I'm here because my OOP exam requires us to do our hands-on exam on notepad. Lezz goooo

  • @Kakashi-rx5yc
    @Kakashi-rx5yc 7 месяцев назад +1

    I am getting this error: Could not find or load main class Demo
    Caused by: java.lang.ClassNotFoundException: Demo

  • @Wise-Child-2005
    @Wise-Child-2005 Месяц назад +1

    In Linux we use gedit to open the file from terminal, what is it's windows equivalent?

  • @Fits124
    @Fits124 2 месяца назад

    What an amazing video, thank you so much John

  • @sphurtikulkarni9781
    @sphurtikulkarni9781 2 месяца назад

    Thank you so much for such a detailed video and great explanation!

  • @prokopii18
    @prokopii18 2 года назад +2

    You are a star, amazing explanation and you make amazing videos!

  • @rayannphilip5749
    @rayannphilip5749 4 месяца назад

    Thank you Sir. I am already practicing it after a short while 😊

  • @suknayateluguworld1012
    @suknayateluguworld1012 7 месяцев назад

    I am new to learn coding recently start learn to do coding in java there vast syllabus there is no time to cover all the topics right now to me i want to do coding in java please share some tricks and tips and shortcut to able to do java coding and do tasks u r ans and support is very much need I am impressed by u r knowledge I hope u solve my problem dear❤

  • @CindyAudyaPriecillia
    @CindyAudyaPriecillia 3 месяца назад

    thank youuu so muchhhh this help me to do my assignment, at first i'm very confuse but i found this video and finally it work yayyy✨

  • @afifkhaja
    @afifkhaja Год назад +2

    Nice tutorial although I have an src folder with multiple packages and I need the classes from each package to be compiled into the target folder and need to run the driver class from the target folder. Is there a video on this? Thanks

  • @leeamraa
    @leeamraa 2 года назад

    I would've added command line arguments to the tutorial as this is the best way to demo them!

  • @matildasgalaxy3204
    @matildasgalaxy3204 3 месяца назад

    Thank you so much!!!! Headache gone 😅

  • @niksatan
    @niksatan Год назад

    So simple, but very needed, thx

  • @lucianoprokilla
    @lucianoprokilla 4 месяца назад

    John, I couldn't help but notice your barebones dash DOES include The Binding of Isaac. Great game choice!

  • @swapnilbawiskar3617
    @swapnilbawiskar3617 Год назад

    Thank you so muchh brother, It worked after watching a lot of videos...

  • @nehalkalambe9896
    @nehalkalambe9896 Год назад

    thank you ! I was struggling for this it really helped me

  • @komalsingh-b2l
    @komalsingh-b2l 8 месяцев назад

    Thanku so much sir . Your video is really helpful for me you can simply teach us how I can use cmd. Once again thanku so much ❤❤❤❤❤

  • @davidsalamanca9581
    @davidsalamanca9581 Год назад

    Best Java tutorial, i was stoped cause i always use javac and dont get any output :( im trying to study java alone haha im from python code, same way, at cmd, and there is a special way to do it, here at the same but diferent way you need to compile and then run it, thanks you for this tutorial, now let the java training start !!

  • @user-lk2cy7cc5v
    @user-lk2cy7cc5v Год назад

    John, you are the best and thank you so much it really worked

  • @simple.simple210
    @simple.simple210 Месяц назад

    THANKS TO YOU SIR MY CODE FINAALY RUN THANK YOU SO MUCH!

  • @mulexawikjo8207
    @mulexawikjo8207 11 месяцев назад

    thanks for explaining in detail

  • @electronoob7341
    @electronoob7341 2 года назад

    lol! First thing our old-school Java Profs at Uni taught us, they insisted we only use notepad++ and compile & run our code just like this in cmd, no IDE's allowed. Looking back now I must say this is a great way to learn by forcing you to remember and know how to do thing IDE's usually do fòr us these days.

  • @user-dn1ku8hl1d
    @user-dn1ku8hl1d Месяц назад

    Awesome classes has always. Also, Binding of Isaac! YES

  • @user-xr7gz7cm9u
    @user-xr7gz7cm9u 8 месяцев назад

    hey i have done the things u said but in cmd i have a issue that i have given cd desktop and enter then it us giving that C:\Users\endg3>cd Desktop
    The system cannot find the path specified. how to solve this.

  • @shady2702
    @shady2702 2 года назад +1

    Hey I got an error on javac ..that is javac is not recognised then what I want to do

    • @swemadeeasy1484
      @swemadeeasy1484 Год назад

      do you have JDK installed on your system? if so, do you have the right ENV variables? like JAVA_HOME?

  • @TrinityJackk
    @TrinityJackk 8 месяцев назад +3

    John i ran mind but it keeps shoein Java is not recognize as an internal or external command what do i do?

  • @ulongo123
    @ulongo123 4 месяца назад

    Thank you, big fan out here!!

  • @a99g
    @a99g 6 месяцев назад +1

    When I interd "cd Desktop" it says
    "The system cannot find the path specified"
    Any clue why?
    Edit: Problem solved, I just did a right click one the .java file and choose open in terminal.

  • @pedroaboffa
    @pedroaboffa 2 года назад

    Amazing video John.. thank you !!!

  • @Garrison86
    @Garrison86 2 года назад

    Amazing!! Thank you for your material, it helps big time.

  • @adrian_tr
    @adrian_tr 9 месяцев назад

    Thanks. Extremly good explained

  • @Atojushorts
    @Atojushorts Год назад

    Thanks.This really helped me out

  • @Jan_Jan_
    @Jan_Jan_ 2 года назад

    Thank you! This was very helpful👍

  • @jasminecarol3729
    @jasminecarol3729 2 года назад

    You just saved my life thank you

  • @voizek
    @voizek 3 месяца назад

    Mine always just opens up into VS code, where I wrote the actual program.

  • @1shita
    @1shita 10 месяцев назад

    How to set code file open with notepad like that ?....in my pc showing only ...(open with VS code)

  • @user-nc9ow8td1f
    @user-nc9ow8td1f 7 месяцев назад

    when I put javac it's not detecting the program. What should I do?

  • @wiljohndavebaydo
    @wiljohndavebaydo 3 месяца назад

    After the { how do you click enter that starts on the 2nd line and not in the first line below?

  • @priavteprospaces3943
    @priavteprospaces3943 7 месяцев назад

    Thanks help out heaps I sort forgot how change folder in cmd

  • @vishakhasoni_07
    @vishakhasoni_07 Год назад

    Thankyou thankyou thankyou thankyou thankyou thankyou so very much🙂 This has really been very helpful:)

  • @kennedychidera9580
    @kennedychidera9580 3 месяца назад

    I downloaded eclipse and the jdk both installed yet I can't run a single program
    Pls I need help

  • @LavatejaD-tj6wi
    @LavatejaD-tj6wi 2 месяца назад +1

    Sir in my command prompt it is showing that the system cannot find the path specified while i entered cd Desktop

    • @THEREALBILL03
      @THEREALBILL03 2 месяца назад

      Then you have to cd to something else first if you go to your laptop file you can see what is before your desktop . For me I had to cd OneDrive before desktop

    • @LavatejaD-tj6wi
      @LavatejaD-tj6wi 2 месяца назад

      ​@@THEREALBILL03I did what you said. My program ran successfully. Thank you bro. First i didn't entered onedrive Location. Now I understand

  • @user-wi2pg5sz6p
    @user-wi2pg5sz6p Год назад

    am actually intrested in creating an app using java language

  • @ChandanChandan-ft1ic
    @ChandanChandan-ft1ic 3 месяца назад

    Jhon I'm getting error it says file not found what shall I do

  • @sriyassuperblife1960
    @sriyassuperblife1960 5 дней назад

    Thank you sir!

  • @aljei9146
    @aljei9146 Год назад +1

    Hi, John. Thank you for this tutorial, really helped me a lot. Question though, what if I have multiple classes?? How do I compile and run it in the cmd? Or is it even possible?

  • @sixihili1956
    @sixihili1956 8 месяцев назад

    i am using windows 7 and when i type "javac myProgram" the command line says: javac is not recognized as an internal or external command. knowing that i have java installed when i typed "java version". What could be the problem?

    • @davidmacecek4226
      @davidmacecek4226 2 месяца назад

      i use win11 and this is happening to me too

  • @Sujalchaudhary004
    @Sujalchaudhary004 11 месяцев назад

    Why in my commant prompt it is showing the system cannot find the path specified ❓❓❓❓❓❓

  • @gabfuwak
    @gabfuwak Год назад

    Hello, i have an issue, i have multiple classes in a project, they also use imports. This method does not support that and i can't seem to find any documentation on compiling a full java project in the command line. Do you have any clue on this?

  • @o0.jc.0o26
    @o0.jc.0o26 2 года назад +1

    Thanks for this video.. What if I have multiple classes for one program in separated files and one of them has the main method? How would I just do that for running the program? Thx
    Edit: i just came up with the solution. The question is that the .java files are included in a package, so in order to run the program in cmd, you must be located in the father folder of the package, and then run it typing java packageName.Main where Main is the .java file containing the main method.

  • @reekdas9219
    @reekdas9219 Год назад

    thanks! that was really helpful!

  • @surajwankhade2082
    @surajwankhade2082 10 месяцев назад

    Simply explanation

  • @leodachad260
    @leodachad260 8 месяцев назад

    Hey John, on my side I can't find my file when I enter cd documents and dir.
    What should I do?

  • @Livebio1786
    @Livebio1786 4 месяца назад

    Thank you sooo much for helping out

  • @megalatest
    @megalatest 3 месяца назад

    Very Nice teach 👍🏻

  • @happygrace8065
    @happygrace8065 Год назад

    Maaan!!.. you are the best

  • @shahaansalman3286
    @shahaansalman3286 6 месяцев назад +2

    Not using Hello World for your initial test file is heresy!

  • @Mythri333
    @Mythri333 Месяц назад

    Thank you so much 😊

  • @matiascuervo9941
    @matiascuervo9941 2 года назад

    Awesome channel, could you do a video about stack and heap memory?

  • @ArmyPurpleYou_
    @ArmyPurpleYou_ Год назад

    Ohhh myy godd. It finally worked. Thankyou!!

  • @user-hs3oy1jb4x
    @user-hs3oy1jb4x 5 месяцев назад

    how do i make this code in my notepad automatically create a space, thanks!

  • @AHMED-ry2gy
    @AHMED-ry2gy 2 года назад

    John can you please do some search algorithms and more sorting videos, thank you

  • @poovarasanb9210
    @poovarasanb9210 Год назад

    Amazing tutorial

  • @OmEN1443-j4h
    @OmEN1443-j4h Год назад

    thank you sir , It helped alot

  • @hiteshkalelkar
    @hiteshkalelkar 8 месяцев назад

    Thankyou sir this was very helpfull

  • @arnavchaudhary4785
    @arnavchaudhary4785 Год назад

    Thanks my friend

  • @AmitBiswas0142
    @AmitBiswas0142 6 месяцев назад

    Thanks it's working!!

  • @Rosa-wg3gv
    @Rosa-wg3gv Год назад

    Why cant I find anything when I search for it in my command prompt. I write "cd Desktop" and it just says they cant find it

  • @anubisthealmightycat6322
    @anubisthealmightycat6322 11 месяцев назад

    what does error: Class names, 'AmongUsJava.Java', are only accepted if annotation processing is explicitly requested
    1 error mean

  • @user-lg9im2xy5e
    @user-lg9im2xy5e 8 месяцев назад

    from the background bro looks like musician

  • @suuuuuuppp
    @suuuuuuppp Год назад

    Why var, const, let , console.log() are giving giving error name/command not found.

    • @CodingWithJohn
      @CodingWithJohn  Год назад

      Are you writing JavaScript code instead of Java code? They have similar names but are very different things.

  • @user-js8nb2wb4x
    @user-js8nb2wb4x Год назад

    Thank you john

  • @kobey3044
    @kobey3044 Год назад +1

    hi I am an idiot. I installed JDK-20 (C:\Program Files\Java)
    I tried many times and I cannot see the version when I type (java ~version) on dos cmd.
    please help me.
    I need to learn programming.. i am trying to pass my degree.
    1:07
    I am stuck here.

    • @CodingWithJohn
      @CodingWithJohn  Год назад +1

      Just to make sure, it's "java -version", not "Java ~version"

  • @ilyarepin7750
    @ilyarepin7750 Год назад

    I did this and javac compiled the program and makes a .class file but I cant run it. Java command keeps saying it cant find it

  • @upholdjustice372
    @upholdjustice372 Год назад

    Can you show us if there's a way to view the bytecode and machine code of our Java Program as well? Thanks!

  • @Jorgerodriguez-cf5vy
    @Jorgerodriguez-cf5vy 8 месяцев назад

    Bro, you are awesome.

  • @bipashabanerjee2432
    @bipashabanerjee2432 2 месяца назад

    Thank you sir❤