Compiling and running Java programs

The JBuilder compiler has full support for the Java language, including inner classes and Java Archive (JAR) files. You can compile (or "make") from within the IDE. With JBuilder Professional and Enterprise, you can also compile from the command line using bmj (Borland Maker for Java) or bcj (Borland Compiler for Java).

For more information on the command-line tools, see "Using the command-line tools" in Building Applications with JBuilder.

The Run command compiles and runs projects, individual .java files (such as JSPs), or HTML applets.

JBuilder's integrated debugger allows you to run a project or file with or without debugging it. In JBuilder Professional and Enterprise, you can set runtime configurations appropriate for the kind of file or program that you want to run, whether it's an application, an applet, a JSP, a servlet, or an EJB.


Compiling Java programs

A Java compiler reads Java source files, determines which additional files need to be compiled, and produces the Java program in the form of .class files containing bytecodes that are the machine code for the Java Virtual Machine (VM).

Compiling produces a separate .class file for each class declaration and interface declaration in a source file. When you run the resulting Java program on a particular platform, the Java interpreter for that platform runs the bytecodes contained in the .class files.

To compile the source files for an application or applet, follow these steps:

  1. Open a project.

  2. Do one of the following in the project pane:

  3. Then, do one of the following:

    Make Project

Compiler error messages are displayed in the message pane below the AppBrowser content pane. Select an error message to display the relevant source code. To get help on an error message, select the error message in the message pane and press F1. To learn about error messages in JBuilder, see "Error and warning messages" in Building Applications with JBuilder.

For more information, see "Compiling Java programs" in Building Applications with JBuilder.


Running Java programs

Running a project runs the main class of that project file. If a main class has not yet been selected, then when you try to run it, a dialog box appears so you can make the selection. If you created your file usin the Application wizard or the Applet wizard, the main class is automatically selected. You can select or change the main class by selecting Project|Project Properties and choosing the Run tab.

If you want to run a .java file such as a JSP, it must contain a main method.

To run an applet, select the HTML file that contains the <APPLET> tag. The HTML file calls the class found in the CODE attribute of the <APPLET> tag. This applet class must contain an init() method.

To run in JBuilder:

  1. Save the program or file that you want to run.
  2. Select it in the project pane.
  3. Compile it (Project|Make Project) if it's a program.
  4. Run it by choosing Project|Run Project, or right-click it in the project pane and choose Run from the drop-down menu.
Once your program has been compiled, you can run it without compiling.

Runtime error messages are displayed in the message pane below the AppBrowser content pane. Select an error message to display the relevant source code. To get help on an error message, select the error message in the message pane and press F1. To learn about error messages in JBuilder, see "Error and warning messages" in Building Applications with JBuilder.

For more information on running programs, see "Running Java programs" in Building Applications with JBuilder.

For more information on running applets, see "Working with applets" in Building Applications with JBuilder.

For more information on running JSPs and servlets, see "Developing JavaServer Pages (JSP)" and "Developing servlets" in the Distributed Applications Developer's Guide.