Use Notepad and Command Prompt for Java Programming

About: I like food, music, video games, and art. I enjoy learning languages, playing games, making music, drawing, and making things in general. Don't mind my weird instructables.

Intro: Use Notepad and Command Prompt for Java Programming

Hello, in this instructable, I will show you how to create, and execute a program that you created in java using notepad. You will need to open some things:

-Notepad

-Command Prompt

Step 1: Create the Program

For this step, use notepad and make your program. Don't forget to save as ".java" in all files. I typed in the "Hello World!" program to keep it simple. It goes as following:

class Hello{
public static void main(String[] args){
  System.out.println("Hello World!");
   }
}

Step 2: Make Into .class

Now, open Command Prompt. You can open it on Windows 8 by going into the start menu, then type, "Command Prompt" then click the program titled "Command Prompt". For older versions of windows, click the start button, then go to All Programs>Accessories>Command Prompt. Once you have it open, go to the file destination of the .java file. Then, type, "dir", it will bring up everything in the directory. Now, type, "javac ____.java". Replace the blank space with your program's name. Now, type, "java ____". Again, replace the blank with your program's name, and remember not to type, ".java" at the end this time. It should then successfully open your program.

If you get an error when typing "javac" then you have to set some things up before you can build java files.

Open File Explorer. Then go to C Drive. Then, Program Files. Then, Java. Then, jdk1.8.0_40. Then, bin. Then, click once on java. Then, click the top bar where it says "Local Disk C > Program Files > Java > jdk1.8.0_40 > bin > java. It should highlight the text. Now, copy that text. From there, Open Control Panel, then, go to System and Security. Then, go to System. Then, go to Advanced system settings. From there, click, "Environment Variables". Then, click "Path". Now, DO NOT DELETE THE HIGHLIGHTED TEXT. You need to go to the very right-most part of all the text then type ";" then paste the text you copied from

earlier onto the end. Then, click OK, then OK, then OK. You can now build your program.

Share

    Recommendations

    • Audio Contest 2018

      Audio Contest 2018
    • Plastics Contest

      Plastics Contest
    • Electronics Tips & Tricks Challenge

      Electronics Tips & Tricks Challenge

    16 Discussions

    0
    None
    Tannu Choudhary

    Question 8 months ago on Step 2

    Javac is not recognized..... What I have to do?.... Tell me fastly.....my exam is coming soon as on 20 feb

    0
    None
    RomanM61

    1 year ago

    When I compiled the code, I have the error: ____.java:1: error: illegal character '\u00bb'.

    0
    None
    Dumni

    2 years ago

    I am getting an error when I am typing "javac". I did what you wrote. But when I open java after bin, a command prompt opens and closes, almost simultaneously which makes it almost impossible to highlight the text. What's wrong? Please Help!

    2 replies
    0
    None
    GadepalliYDumni

    Reply 1 year ago

    What u need to write is actually is "javac" and the class name which u gave for the path.

    0
    None
    Addy55Dumni

    Reply 2 years ago

    bro u must have not set the PATH learn how to set it from youtube

    0
    None
    Dumni

    2 years ago

    I am getting an error when I am typing "javac". I did what you wrote. But when I open java after bin, a command prompt opens and closes, almost simultaneously which makes it almost impossible to highlight the text. What's wrong? Please Help!

    0
    None
    Dumni

    2 years ago

    I am getting an error when I am typing "javac". I did what you wrote. But when I open java after bin, a command prompt opens and closes, almost simultaneously which makes it almost impossible to highlight the text. What's wrong? Please Help!

    0
    None
    Gregorid

    2 years ago

    People actually not know, but Notepad can be used as a first help for many things and not just a simple text writing... For example I often use Notepad when I need to create list of all folders and files by names since I work with many files everyday. Here is one nice tutorial about that trick : http://pc-problem-solutions.blogspot.com/2014/07/how-to-take-text-from-folders-bat.html

    0
    None
    DIYWizzard

    3 years ago on Introduction

    I got " 'javacHello.java' is not recognized as an internal or external command, operable program or batch file." I tried it again with 'javac Hello.java.' with a space and it still didn't work. Only that time it just said "'javac' is not recognized..."

    1 reply
    0
    None
    nancyjohnsDIYWizzard

    Reply 2 years ago

    Did you make the hello world file? Also, it doesn't have to be a hello world. I'm just showing how to compile things you've made in notepad.

    0
    None
    bhanon815

    3 years ago on Introduction

    sorry i posted b4 i read you got me confused i thought you were doing something else on windows that is technaly impossible