Use of FreeJava (3) Use of FreeJava

Source: Internet
Author: User

 

 

4. Use of FreeJava

Well, it's time to get started and talk about how to use it. We will not introduce it completely, but first introduce the editing process of a Hello program. This is the most basic program. with step-by-step guidance, I believe you can easily master how to use it.

1. Create a project

Start FreeJava and enter the main interface of FreeJava. If your program runs for the first time, it will pop up a dialog box that accumulates over a period of time. Needless to say, if you are not using it for the first time, it will automatically open the last project you edited and display it.

Select the "New" option in the "File" menu. the pop-up window is as follows:



Three options: Java Source File is used to create a Java File, which is equivalent to writing a Java-type program in Notepad. FreeJava Project, Project File, and Project must be a Project, this concept is a basic concept in visual editing tools. To do things, you must first create a project instead of a file. It is no exception here. The third option is HTML Page, which is used to create a webpage file. Of course, it is used to put a Java Applet. If you want to write a webpage file, we suggest you use another tool, because the webpage editing tool here is very common, just like Notepad, you won't use it to compile webpage files.

Here, of course we chose the "FreeJava Project" option. When a new project is created, it closes the previous project. The pop-up dialog box is as follows:



Here there are three more options: Empty Project, which is to create an Empty Project. After the Project is created, all things need to be customized by yourself, which is not recommended. Item 2: Application Proj. Of course, this is to create an Application program, and the third is the Applet Proj, which is a Java Applet project. You don't need to talk about this. I believe you already know it.

CreateFor the Hello Application project, select the second item. Set "Application Proj" to "Hello", as shown below:



Click OK to go to the main interface, as shown below:



The left side of the window is its project file tree, and the right side is an overview of the project. I personally think it is useless unless you perform advanced debugging, you can use the Java Switch Parameter option. We recommend that you be familiar with javac parameter compilation. Double-click the tree directory on the left to open the file and display the start part of the content you double-click in Reversed colors. After opening it, you can see that it has written some basic code for you, as shown below:


Import java. awt .*;
Import java. awt. event .*;

Public class Hello extends Frame
{
Public Hello ()
{
This. addWindowListener (new WindowAdapter (){
Public void windowClosing (WindowEvent e ){
Dispose ();
System. exit (0 );
}
});

}

Public static void main (String args [])
{
System. out. println ("Starting App ");
Hello f = new Hello ();
F. setSize (100,100 );
F. show ();
}
}

2. program running process

Let's not talk about adding code first. Compile this program and run it. Let's take a look at the results and talk about all the compilation and running processes:
Let's take a look at the buttons above the toolbar:

These are the three most used buttons. The first one is the compile button and the second is the compile button. However, unlike the first one, it is used to compile all the project files, we recommend that you use this. The third button is run. After compilation, the program runs by clicking this button.

Now, click the second button to compile the file. during compilation, a window will be added and the interface will become as shown in:



The newly added window at the bottom is a very useful window and should be used properly. For the essence of the software compilation process, what is displayed here is exactly what you should display during compilation in the DOS environment. However, a "stop" is added here ", program compilation and running can be terminated at any time.

After compilation, if "No Error" is displayed in the window, it indicates that the program has No errors and can be run. Click the third button on the toolbar described above. The program runs. The following figure is displayed:



This is just a Frame interface with nothing in it. The title does not even exist. You can add a statement to set the title in "Hello ()" of the Code: this. setTitle ("this is a test"); after re-Compiling and running, you can see that there is a title. I will not tell you how to program it here. The specific process is like this.

The running prompt is displayed in the displayed window at any time during the running process. Okay, this is basically the process. You can add the code in the code window when you want to add the code.

3. Run the Applet.
Let's first create a Java Applet project to see what is different from the Application. The creation process is basically no different from the previous process. I will not talk about it here. In the created Applet project, apart from a Java source file, there is also a simple HTML file that you can create. Double-click to open the changes. For example:



The compilation process of the Applet is the same. But the operation is a little different. Now you can see the toolbar as follows:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.