Use Notepad and Command Prompt for Java Programming

Published

Introduction: Use Notepad and Command Prompt for Java Programming

About: I like food and art. 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

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

    • Woodworking Contest

      Woodworking Contest
    • Planter Challenge

      Planter Challenge
    • Make it Move Contest

      Make it Move Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

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

    15 Comments

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

    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

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

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

    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!

    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!

    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

    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

    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.

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