Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML


Java Tutorials



Struts Tutorials

Struts Resources

Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Java Notes

TextPad Editor + JDK

[an error occurred while processing this directive]

1. Download and install the Java JDK if necessary

Install the J2SE JDK. See Java Development Kit (JDK).

2. Download and install TextPad

  • Download a free, trial version of TextPad from www.textpad.com . You will be reminded from time to time that you might pay for it, but don't worry, it won't expire.
  • Install TextPad by double clicking on the downloaded file and following the prompts. Do this only after you have installed the Java JDK.

3. Entering, compiling, and executing your Java program in TextPad

  1. Type or paste your Java program source code into the large text pane.
  2. Create new directory. Putting the programs directly on your desktop is not a good idea. Create a directory (folder) for all of your course work, and a separate directory within that for each assignment. The tiny extra work to create separate directories prevents unwanted interactions between old and new programs. It can save endless hours of frustration. This is not just an academic neatness obsession - it comes from seeing students who couldn't complete their assignments because of old-file pollution.
  3. Save the source in a file with EXACTLY the same name as the "class" with an extension of ".java". Assume the source code defines this class.
        public class InitialTest {
           . . .

    It must be saved in a file called InitialTest.java . Put it in the directory you created previously.

  4. Compile (translate from source code to machine code) by selecting the Tools > Compile Java menu item. If there are errors (and there usually will be at first), go back and forth between the "Command Results" and the source code by clicking on each of them in the top left pane. Continue with this process until it compiles correctly.
  5. Run the program by choosing Tools > Run Java Application menu item. You will be using one of these to styles of interaction (Input-Output) at the beginning.
    • Console Output (System.out.println(...)). This will open a DOS Command Window and you will see your text output, followed by "Press any key to continue . . .". Your program is done!
    • Dialogbox Output (JOptionPane.showMessageDialog). Program output will appear in dialog boxes. The only weird thing is that TextPad creates an unnecessary DOS window -- that isn't something that the Java system does.

Optional, but useful, TextPad preferences

There no critical preferences that need changing, but they can be set by selecting the Configure > Preferences menu item. Some things you might wish to set:

To conform to the Java indentation standards, you should set your tabs as follows. Go to
Configure menu > Preferences... > Document Classes > Java > Tabulation
Set the "Default tab spacing" and "Indent size" fields to 4.
Check both the "Convert new tabs to spaces" and "Convert existing tabs to spaces when saving new files".
Click OK.
Set the Startup directory to where your files are normally located.
Document Classes > Java > Tabulation
Set the default tab spacing to 4, indent size to 4, and check both the Convert new tabs to spaces and Convert existing tabs to spaces when saving files. Tabs should generally not be used in programming because the size of tabs is not universal so someone else looking at your program will often see a mess
To turn runtime assertion checking on in TextPad go to Configure > Preferences... > Tools > Run Java Application. Set the value in the Parameters text field to -ea $BaseName . "-ea" is the abbreviation for Enable Assertions. If you don't know what assertions are yet, don't bother with this.
Line numbers
This isn't in the Preferences area, altho it should be. TextPad will show line numbers if you select View menu then choose Line Numbers. This is useful in coordinating error messages with your source code.

TextPad Problems?

  1. Q: TextPad can't find the Java compiler. What's wrong?

    A: When TextPad can't find the Java compiler, there are two common causes.

    1. You installed TextPad before the Java compiler. You MUST install Java first. Uninstall TextPad (from the System control panel) and reinstall it.
    2. You didn't install the Java JDK, maybe you only have the Java JRE. If you installed Java 5 is should install by default in
      C:\Program Files\Java\jdk1.5.0_04

      There will also be a "JRE" (Java Runtime Environment), which is appropriate, but be sure there is a "jdk" (Java Development Kit).

  2. Q: I get a message about "javac ...". How can I fix it?

    A: Check the Configure > Preferences > Tools > Compile Java > Parameters field. You only need $File in it. Reinstalling TextPad might clear it up. When I reinstall it I get the following.

     -Xlint:unchecked  $File

    You don't need the -Xlint option (which notes situations where you could take advantage of Java 5 generics), but you do need the $File. Put blanks in front and after the $File value.

  3. Q: This message comes out when I try to run my program in TextPad. What's wrong?
      Exception in thread "main" java.lang.NoClassDefFoundError:

    A: The most common cause at this point is that the file name doesn't match the class name. Make sure the names agree exactly first.

    Another, much less likely, problem could be that the parameters are set wrong in TextPad. Look at
    Configure menu > Preferences... > open Tools > Run Java Application.
    The Parameter field should have $BaseName (with blanks around it). You can skip the "-ea", which stands for "enable assertions". The Initial Folder should have $FileDir in it.

  4. Q: Can I run my Java program like a normal application? [an error occurred while processing this directive]

    A: No. TextPad translates the .java files into .class files which can not be run by double-clicking them. Some IDE's (eg, NetBeans) will produce double-clickable .jar files, and there are programs which will package your Java files into a .exe file.

Ask programming questions?



Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

3 comments so far (post your own) View All Comments Latest 10 Comments:

i want to get new data in java

Posted by rasmita nayak on Tuesday, 08.3.10 @ 23:45pm | #98674

can i know the code for "javac.exe" and "java.exe" files?

Posted by romapathy on Wednesday, 11.26.08 @ 02:45am | #82048

can i know the code for "javac.exe" and "java.exe" files?

Posted by romapathy on Wednesday, 11.26.08 @ 02:44am | #82047

  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name


Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright 2007. All rights reserved.

[an error occurred while processing this directive]