Using Notepad++ to compile Java code

Although I'm convinced that you have to work with an IDE (NetBeans, Eclipse, IntelliJ IDEA (which I use), I think it's always good to know and learn what is failing in your small example. With an IDE, the compile and runtime environment are configured, but as a developper, it's important to understand the basic concepts hidden. Anyway,

From the link you've posted, here are the environnement variables you must define

FULL_CURRENT_PATH: C:\Documents and Settings\Administrator\My Documents\JavaP\ExampleProgram.java
CURRENT_DIRECTORY: C:\Documents and Settings\Administrator\My Documents\JavaP\
FILE_NAME: ExampleProgram.java
NAME_PART: ExampleProgram
EXT_PART:java

Make sure that all is named according to these settings, ie:

- your source file is under C:\Documents and Settings\Administrator\My Documents\JavaP\
- your source file is named ExampleProgram.java

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.


Set the classpath in the java command like this:

java -classpath “$(CURRENT_DIRECTORY)” “$(NAME_PART)”

Tags:

Java

Notepad++