7-10 Learning Java with JBuilder
7-10 Learning Java with JBuilder
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Tomcat Web Hosting services
7-10 Learning Java with JBuilder
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Tomcat Web Hosting services
Using command line tools For more information on using command line tools in JBuilder, see Using the command line tools in Building Applications with JBuilder. For more information on command line arguments, see JBuilder command line arguments in Building Applications with JBuilder. For more general information on command line tools, see http://java.sun.com/j2se/1.3/docs/tooldocs/tools.html#basic. Compiling and running Java programs 7-9
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services
Using command line tools Using command line tools Command line tools allow you to execute global commands from your command line window. Using standard command line tools, you can compile and launch applications, manage your JAR files, view applets outside of a web browser, and extract comments embedded in the code. JBuilder provides additional command line tools that provide extended or improved functionality. The JDK includes the following command line tools: javac - the compiler for the Java programming language. java - the launcher for the Java applications. jar - manages the Java Archive (.jar) files. javadoc - an API documentation comments extraction utility. appletviewer - allows you to run applets outside of the context of a web browser. native2ascii - converts a file of native encoded characters to one with Unicode escape sequences. JBuilder includes the following command line tools: JBuilder command line arguments And, in JBuilder Professional and Enterprise: The bmj command line make The bcj command line compiler JBuilder s command line interface includes such options as: Building projects Displaying configuration information Displaying the license manager Disabling the splash screen Enabling verbose debugging mode for OpenTools authors Note These options vary by edition. To access the list of options available in your edition of JBuilder, open a command-line window, navigate to the JBuilder bin directory and type jbuilder -help. JBuilder runs on its own launcher, which is a shell script, a batch file, or an executable, depending on the platform you run it on. Each of these launchers can pass arguments to JBuilder. 7-8 Learning Java with JBuilder
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services
Deploying Java programs For more information, see Deploying Applications with VisiBroker in the VisiBroker for Java Programmer s Guide if you are using VisiBroker, or see your Application Server s User s Guide. Deploying web-based applications Web-based, multi-tier applications are deployed onto web servers. Consult the documentation for your web server for information on deploying web applications. Running deployed programs You can run a deployed program from the command line with the JDK command line tools. To run a program at the command line, use the -jar option with the java command. For more information, see Running a program from a JAR file, Using the command line tools, and Deploying Java programs in Building Applications with JBuilder. For a tutorial on running programs from JAR files, visit http://java.sun.com/docs/books/tutorial/jar/basics/index.html. Compiling and running Java programs 7-7
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services
Deploying Java programs To deploy a program, 1 Create and compile your code in JBuilder. 2 Run the Archive Builder to create the archive file. 3 Create an install procedure. 4 Deliver your JAR file, all necessary redistributable JAR files, and the installation files. For more information, see Deploying Java programs in Building Applications with JBuilder. For a tutorial on deploying to and running programs from JAR files, visit http://java.sun.com/docs/books/tutorial/jar/basics/index.html. Deploying CORBA applications This is a feature of When deploying CORBA applications with JBuilder Enterprise, the JBuilder Enterprise. Archive Builder collects your stubs and skeletons into a JAR file. You must install your ORB on each machine that runs a client, middle-tier, or server CORBA program. 7-6 Learning Java with JBuilder
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services
Deploying Java programs For more information on the debugger, see Debugging Java programs in Building Applications with JBuilder. Deploying Java programs Deploying a Java program consists of bundling the various Java class files, image files, and other files needed by the project and copying them to a location on a server or client computer where users can access them. You can deliver them in compressed or uncompressed archive files. Using the Archive Builder This is a feature of JBuilder Professional and Enterprise. The JBuilder Archive Builder automatically gathers together the classes and files your program needs. It then bundles files into a compressed or uncompressed archive file, usually a JAR file. It can also create the archive s manifest file, which you can modify in JBuilder. The Archive Builder also creates an archive node in your project, allowing easy access to the archive file. At any time during development, you can make the archive file, rebuild it, or reset its properties. You can also view the contents of the archive, as well as the contents of the manifest file. Compiling and running Java programs 7-5
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services
Debugging Java programs in the Distributed Application Developer s Guide. For more information on CodeInsight and syntax highlighting, see The JBuilder environment in Building Applications with JBuilder. Debugging You may debug a file or a whole project. You may compile before debugging or not. To choose whether to compile before debugging, choose Project|Project Properties and select the Run tab. Use the Compile Before Debugging check box at the bottom of the dialog. In JBuilder Professional, you can choose whether and how to use Smart Step. In JBuilder Enterprise, you can choose to enable remote debugging and to make appropriate settings. To do either of these, choose Project|Project Properties and select the Debug tab. To debug a file, right-click on it in the project pane and choose Debug from the context menu. To set a breakpoint in the source code, either choose Run|Add Breakpoint, click in the gray margin to the left of an executable line of code in the source file, or use the keystroke sequence for your chosen editor emulation. To debug a project, follow these steps: 1 Open your project. 2 Select Project|Project Properties. Choose the Run tab and decide whether JBuilder should compile before debugging. 3 To set a breakpoint in the source code, either choose Run|Add Breakpoint, click in the gray margin to the left of an executable line of code in the source file, or use the keystroke sequence for your chosen editor emulation. 4 Choose Run|Debug Project or click the Debug icon in the toolbar. The compiler and debugger work the same way on both files and projects: If you have set JBuilder to compile before debugging, then any compiler errors will show on the compiler page in the message pane at the bottom of the AppBrowser. You may click the error message to go to the relevant line of code. If you have disabled the compiler, or if there are no errors, the debugger will show in the message pane. Use your tool tip on the left-hand tabs to see the kinds of information the debugger provides: 7-4 Learning Java with JBuilder
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services
Running Java programs 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: To compile an application, select the project node (.jpr or .jpx extension). To compile an applet, select the HTML file that calls the applet. 3 Then, do one of the following: Choose Project|Make Project. Right-click a node and choose Make. Note If you haven t already set the runnable class, the Run page of the Project Properties dialog box appears. Browse to the runnable class and select it to continue compiling. 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 using the Application wizard or the Applet wizard, the main class is automatically 7-2 Learning Java with JBuilder
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services
Chapter 7 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 that are 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 bytecode contained in the .class files. Compiling and running Java programs 7-1
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services
Designing layouts with layout managers Layout managers give you the following advantages: Correctly positioned components that are independent of fonts, screen resolutions, and platform differences. Intelligent component placement for containers that are dynamically resized at runtime. Ease of translation with different sized strings. If a string increases in size, the components stay properly aligned. JBuilder provides the following layout managers from Java AWT and Swing: BorderLayout FlowLayout GridLayout CardLayout GridBagLayout Null JBuilder Professional and Enterprise also provide these custom layouts: XYLayout, which keeps components you put in a container at their original size and location (x,y coordinates) PaneLayout, used to divide a container into multiple panes VerticalFlowLayout, which is very similar to FlowLayout except that it arranges the components vertically instead of horizontally BoxLayout2, a bean wrapper class for Swing s BoxLayout, which allows it to be selected as a layout in the Inpsector OverlayLayout2, a bean wrapper class for Swing s OverlayLayout, which allows it to be selected as a layout in the Inspector You can create custom layouts of your own, or experiment with other layouts such as those in the java.awt classes, new or third-party layout managers. Many of these are public domain on the Web or accessible to members of the Open Source community. If you want to use a custom layout in the UI designer, you may have to provide a Java helper class file to help the UI designer use the layout. Most UI designs use a combination of layouts, nesting different layout panels within each other. For more information, see Using layout managers in Building Applications with JBuilder. 6-6 Learning Java with JBuilder
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services
Powered by Java Web Hosting