TextPad is a simple and lightweight text editor for Windows. You can use TextPad for editing simple Java programs, and even compile and run Java programs with TextPad!

If you haven’t used TextPad before, download and install it from https://www.textpad.com/download/index.html. It’s a shareware - meaning that you can use before purchasing it.

For Java programmers, the coolest feature of TextPad is that it supports for compiling and running Java applications (and Java applets in the old days). This feature can’t be found on other flashy text editors.

TextPad can detect Java compiler program (javac) and Java application launcher program (java) as long as they can be found in the PATH environment variable. So make sure that you did set up the path for Java correctly (See: How to set environment variables for Java using command line).

To compile a Java program in TextPad is simple: Just click Tools > External Tools > Compile Java or press the shortcut key Ctrl + 1:

External Tools TextxPad

 

This will compile the current active Java source file, and in case of error, the compiler’s output is captured by TextPad - displayed in the Tool Output window like this:

TextPad Tool Output Compile Error



You can double-click on the error line (having line number) and the editor will move the cursor to the corresponding line the source code - very helpful!

If the compilation is successful (no error), the Tool Output displays the following message:

Tool Output Compile Success

You can see the generate .class file is in the same folder as the source file. It’s very convenient, isn’t it?

 

And to run the current Java source file, click menu Tools > External Tools > Run Java Application (or press Ctrl + 2).

By default, TextPad invokes the Java launcher program in a new command prompt window, so you will see the output of the program printed in this new window.

If you want TextPad to capture the program’s output, go to menu Configure > Preferences…, then select Tools > Run Java Application, and check the option Capture Output:

Preferences for Run Java

 

Here you can also configure various options for compiling and running Java applications with TextPad. For example, if you want to pass arguments to the program, check the option Prompt for parameters. Then when running a Java program, specify the arguments in the prompt dialog like this:

TextPad Run Java Parameters

 

Keep the parameter $BaseName which is the base file name of the current Java source file, and send the arguments after this parameter. For example, in the above screenshot, we send 3 arguments “Arg1”, “Arg2” and “Arg3” to the program.

That’s how to compile and run a Java program with TextPad editor.

You can also watch this video to learn how to compile and run Java program in TextPad:

 

Related Java Editors / IDEs Tutorials:

 

Other Java Coding Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.



Add comment

   


Comments 

#2Venkatanathan2024-04-09 07:16
Hi I'm venkatanathan
Quote
#1Fikri2020-01-27 12:31
I Love TextPad very much!

In TextPad Notes:

Do not attempt to capture the output of a Java application which reads
from standard input. The Command Results window is output only, so you
will not be able to type responses into it.
Quote