Java Programing

June 16, 2007

You have many options for Java development environments,

Filed under: Java Programming — webmaster @ 6:29 am

You have many options for Java development environments, from the traditional text-editor-andcommand- line environment to IDEs like WebGain’s Visual Caf , Inprise’s JBuilder, Tek-Tools’ KAWA, or Sun’s Forte for Java. The examples in this book were developed using the Solaris and Windows versions of the Java Software Development Kit (SDK), so we will describe those tools here. When we refer to the compiler or interpreter, we’ll be referring to the command-line versions of these tools, so the book is decidedly biased toward those of you who are working in a Unix or DOS-like environment with a shell and filesystem. However, the basic features we’ll be describing for Sun’s Java interpreter and compiler should be applicable to other Java environments as well. In this chapter, we’ll describe the tools you’ll need to compile and run Java applications. The last part of the chapter discusses how to pack Java class files into Java archives ( JAR files). Chapter 20, describes the ability to “sign” classes within a JAR file, and to give greater privileges to classes with a signature that you trust. 3.1 The Java Interpreter A Java interpreter is software that implements the Java virtual machine and runs Java applications. It can be a standalone application like the SDK’s java program, or part of a larger application like the Netscape Navigator web browser. It’s likely that the interpreter itself is written in a native, compiled language for your particular platform. Other tools, like Java compilers and development environments, can be written in Java (and should be, we’d argue, in order to maximize the portability of the Java development environment). Sun’s Forte for Java is one example of a pure- Java IDE. The Java interpreter performs all of the activities of the Java runtime system. It loads Java class files and interprets the compiled byte-code. It verifies compiled classes that are loaded from untrusted sources. In an implementation that supports dynamic, or just-in-time, compilation, the interpreter also serves as a specialized compiler that turns Java byte-code into native machine instructions. Throughout the rest of this book, we’ll be building both standalone Java programs and applets. Both are kinds of Java applications run by a Java interpreter. The difference is that a standalone Java application has all of its parts; it’s a complete program that runs independently. An applet is more like an embeddable program module. The Java interpreter can’t run an applet directly, because it is used as part of a larger application. To run an applet, you can use a web browser like Sun’s HotJava or Netscape Navigator, or the appletviewer tool that comes with the SDK. Both HotJava and appletviewer are standalone Java applications run directly by the Java interpreter; these programs implement the additional structure needed to run Java applets. Sun’s Java interpreter is called java. In a standalone Java application, one class includes a main( ) method, which contains the statements to be executed upon startup. To run the application, execute the interpreter, specifying that class as an argument. You can also specify options to the interpreter, as well as arguments to be passed to the application: % java [interpreter options ] class_name [program arguments ] The class should be specified as a fully qualified class name, including the package name, if any. Note, however, that you don’t include the .class file extension. Here are a few examples: % java animals.birds.BigBird% java test - 54

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by Java Web Hosting