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

Comments

author
RomanM61 (author)2017-03-25

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

author
Dumni (author)2016-09-11

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!

author
GadepalliY (author)Dumni2017-03-11

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

author
Addy55 (author)Dumni2016-09-16

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

author
AndrewS523 (author)2017-03-11

"1. open command prompt and issue instruction:
setx PATH "%PATH%";"C:\Program Files\Java\jdk1.8.0_121\bin"
2. restart command prompt
3. give a try"

Worked for me.

Found it here: https://coderanch.com/t/676964/java/javac-path

author
Dumni (author)2016-09-11

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!

author
Dumni (author)2016-09-11

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!

author
aarushdarpally (author)2016-09-05

Wow, makes people smart

author
Gregorid (author)2016-04-14

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

author
DIYWizzard (author)2015-09-27

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

author
nancyjohns (author)DIYWizzard2015-11-01

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.

author
bhanon815 (author)2015-04-15

sorry typo

author
bhanon815 (author)2015-04-15

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

author
bhanon815 (author)2015-03-27

the terminal?

author
nancyjohns (author)bhanon8152015-03-29

?

About This Instructable

91,735views

6favorites

License:

Bio: I like food and art. Don't mind my weird instructables.
More by nancyjohns:Cardboard And Duct Tape ShelfCardboard Book Page HolderPoor Man's Portable RetroPie Gaming Console
Add instructable to: