Use Notepad and Command Prompt for Java Programming

154,213

6

16

Introduction: 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.

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

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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.

Coded Creations

Participated in the
Coded Creations

Be the First to Share

    Recommendations

    • Backyard Contest

      Backyard Contest
    • Silly Hats Speed Challenge

      Silly Hats Speed Challenge
    • Arduino Contest 2020

      Arduino Contest 2020

    16 Discussions

    0
    Tannu Choudhary
    Tannu Choudhary

    Question 2 years 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
    RomanM61
    RomanM61

    3 years ago

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

    0
    Dumni
    Dumni

    3 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
    GadepalliY
    GadepalliY

    Reply 3 years ago

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

    0
    Addy55
    Addy55

    Reply 3 years ago

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

    0
    Dumni
    Dumni

    3 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
    Dumni
    Dumni

    3 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
    Gregorid
    Gregorid

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

    4 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..."

    0
    nancyjohns
    nancyjohns

    Reply 4 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
    bhanon815
    bhanon815

    5 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