34. Write and execute Java Programs using TextPad tool

Pre-requisites -
  1. Install Java JDK as explained in the Post#30 Install Java JDK
  2. Configure Java as explained in the Post#31 Configure Java
  3. Understand the Simple Java Program explained in the Post#32 A Simple Java Program
  4. Install TextPad editor tool as explained in the Post#33 TextPad editor Installation
Please follow the below steps to write and execute Java programs using TextPad editor tool:

1. Launch TextPad editor tool as shown below:

2. Write any sample Java program in the editor tool as shown below:

3. Select 'Compile Java' option  from the Tools Menu -> External Tools Sub Menu (or you can also try Ctrl+1 shortcut key instead):

4. Ensure that the 'Sava As' dialog is displayed. In 'Save As' dialog, ensure that 'Save As Type' is selected as All Files , type '' into the 'File Name' field (Ensure that the class name you have mentioned in the above java program and the name you are giving here to save the Java file should match else the java program will throw an error i.e. class Simple in the java code and while saving) and click on 'Save' button as shown below:

5. Repeat Step 3 to compile the saved Java file 
6. Select 'Run Java Application' option from the Tools Menu -> External Tools Sub Menu (or you can also try Ctrl+2 shortcut key instead)

7. Observe that the output of the above written Java program is displayed in the command window as shown below:

Please comment below to feedback or ask questions.

Before going to learn complex Java programs, lets understand few concepts that makes our understanding on the java programming code better. 

So 'Object Oriented Programming' is the concept that I'm going to explain in the next post.


Unknown said...

Hello Could you please explain why the below error is executed

" Could not find or load main class simple"

Arun Motoori said...

@ Shamai Panchakshar - Double check the file name you have given while saving the java program. You would have give '' instead of ''. The file name should match with the class name as explained in the Step#4. Java is case sensitive hence '' name is different from ''

ShivvBlog said...

@shamai Pachakshar: I got similar error, double check your print statement followed by ; or not. that's where i did the mistake..

Unknown said...

I like the fact with textpad you can use to compile and run java program - thank you!

saranraj said...


In the Textpad editor->External Tools-> Compile java/Run Java application is not available.

Kindly tell me how to proceed further.


Arun Motoori said...

@saranraj - Refer

Shru said...

I have tried many times but still getting same error.

Error: Could not find or load main class Simple
Press any key to continue . . .

I have saved the file correctly with (

JAVA details:

java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

Please please do the needful


hi said...

Hi Arun,
You done a good job, This blog is very useful to learn java alone with selenium. Thank U.

Unknown said...

Shru....Have u compiled the pgm before running Java application...

Chandana said...

Hi Arun,

Java is installed through java -version i errors too in the program.(Fine name,semi colon etc)but getting same error

Error: Could not find or load main class Simple
Press any key to continue . . .

anything else might be the reason.please let me know