You can not run java program using notepad. However you can use command prompt if dont intend to use IDE.
e.g.
javac yourFileName.java // It will create .class file
java yourFileName // It will run your program and will show output/errors
Answer from AbhiN on Stack OverflowVideos
Can I use any text editor for “Java Hello World" programs?
Why use a class and the main method in a “Java Hello World" program?
What are the other resources provided by The Knowledge Academy?
You can not run java program using notepad. However you can use command prompt if dont intend to use IDE.
e.g.
javac yourFileName.java // It will create .class file
java yourFileName // It will run your program and will show output/errors
Create a program in notepad and save file as .java extension. e.g as hello.java.
Use compiler to run the program from console. e.g javac hello.java and to run use java e.g. java hello.
import java.io.*;
class hello
{
public static void main(String[] args)
{
System.out.print("hello");
}
}
The 'learning curve' associated with IDEs like Eclipse or Netbeans initially mostly involves what you already have above - knowledge of setting class paths, environment variables and so on. Instead of Notepad++ (which I love, but it's not 'made' for Java), I'd recommend Eclipse especially if you have a grunty PC (it's a bit memory hungry). Aside from getting the paths setup, after that you'll be ready to rock.
And Eclipse being actively and openly developed is one of the most documented IDEs out there. The tutorials are bound to work correctly for it :). But seriously, it's pretty good. And then when you want to expand to Android development in Java, or some other type of Java programming, you just load up the add-ins required, and you're away laughing. It also supports debugging, the likes of which Notepad++ certainly cannot compete.
Probably changing the last line to:
java -cp . $(NAME_PART)
will work for you. The problem is that you aren't setting up the classpath.
Notepad++ will be fine for compiling a single file project. For anything more than this you will need an IDE or at least integrate with ant instead of java compiler.
I would like to start learning javascript but when I follow the tutorials and use NPPexec in notepad++, it gives me an error code. It says the following:
CD: C:\Users\cnemm\Desktop\Programming\Javascript
Current directory: C:\Users\cnemm\Desktop\Programming\Javascript
javac MyJavaProgram.java
; about to start a child process: "javac MyJavaProgram.java"
CreateProcess() failed with error code 2:
Can not find file
java MyJavaProgram
Process started (PID=17264) >>>
Error: Could not find or load main class MyJavaProgram
<<< Process finished (PID=17264). (Exit code 1)
================ READY ================
Please help.