📄 readme20.html
字号:
<P><A HREF="#Top">Back to top</A></P>
</dir>
</dir>
<H2><A NAME="Part2"></A>PART II - USING FREEJAVA</H2>
<dir>
<B>
<P><A NAME="Applets"></A>1. STARTING A NEW PROJECT - APPLETS</P></B>
<P>
To create a new applet project, click "New Project..." on the Project menu.
In the dialog that follows, type in a name for your main applet class, and
choose the "Applet Project" radio button. Then click "OK". FreeJava will
then automatically generate a Java source file for your applet class, and
an HTML file that can be used to launch the applet. You are prompted to save
the project, and when you do you should create a new folder for it, since
the Java and html source files will be saved in the same folder as the project.
</P>
<P>
You can then edit the Java file to create your own applet. You can add existing
Java code files to the project by choosing "Add Java Source Files..." from
the Project menu. Or you can open a Java source file and choose
"Add Window to Project" from the Project menu. You can also do this with
new Java source files created by choosing "New" from the file menu.
</P>
<P>
Choose "Build" from the Build menu to compile the applet, and "Run Applet"
to execute the applet with the JDK's applet viewer.
</P>
<P>
<b>NEW:</b> If you want to see how your applet looks in your default web browser,
open the HTML file and choose "Open in Web Browser" from the Build menu.
</P>
<P><A HREF="#Top">Back to top</A> </P></BODY>
<B><P><A NAME="Apps"></A>2. STARTING A NEW PROJECT - APPLICATIONS</P></B>
<P>
Follow the same steps as in II.1. above, but instead of choosing
"Applet Project" in the New Project dialog, choose "Application Project".
FreeJava will generate skeleton code for a GUI Java application.
You can compile the application by choosing "Build" from the Build menu,
and run it with "Run". (The reason both "Run" and "Run Applet" area
available on the Project menu is so that you can create FreeJava
projects that are both applications and applets.
</P>
<B><P><A NAME="empty"></A>3. CREATING A PROJECT FROM EXISTING SOURCE CODE</P></B>
<P>
Choose "New Project" from the Project menu, but this time choose "Empty Project".
You will then be prompted for a place to save your new project. Add your existing
files to the project by choosing "Add Java Source Files..." from the Project menu.
When you want to compile and run the project, you must first set one of your
source files as "Main". In the case of an application, this is the source file
that contains the code for the "main" function. In the case of an applet it is
the source file containing the code for the Applet-derived class. To do this,
select the file in the Project window, and choose "Set as Main" from the
Project menu. You can also do this by right-clicking on the file name in the Project
window and choosing "Set as Main" from the pop-up menu. A small purple M on the file's
icon signals its status. You can change which file is set as Main at any time.
(When FreeJava runs javac, the Java compiler, it is always set to compile the class
that is set as Main with the -depend flag set. In this way, all of the files needed
to run the application/applet are compiled, and only those files.)
</P>
<p>
If you just want to compile a single file, open it or select it in the Project window, and
choose Compile from the build menu.
</p>
<B><P><A NAME="FunctionLists"></A>4. DROP-DOWN FUNCTION LISTS</P></B>
<P>
At the top of each open source code-editing window is a drop-down list
of all the functions defined in the open file. You can choose any of
these functions to go straight to its definition in the source code.
You can also double click on the file names, class and function names
in the Project Window to open and go straight to the relevant code portion.
If the line references in the Project window get out of sync with the line
number in your code, just save your file, or choose "Refresh Function List"
from the Edit menu (or press F2).
</P>
<P><A HREF="#Top">Back to top</A> </P></BODY>
<B><P><A NAME="ProcessWindow"></A>5. THE PROCESS OUTPUT WINDOW</P></B>
<P>
When you compile or run a Java program in FreeJava, all output that
would normally go to a DOS mode terminal window is diverted to the
process window. If you try to close this window before the process
is complete, you will be asked if you want to terminate the process. You may
need to do this, for example, if your Java program gets stuck in a loop,
or if you have no code to close the main window of an application. Try
to use this feature as little as possible, as it may fragment memory.
If you single-click the icon on the left end of the Process Window's
title bar, you will see menu options to save the content of the window
(as a text file), and to set the font used to display the output.
</P>
<B><P><A NAME="ProjectWindow"></A>6. THE PROJECT WINDOW</P></B>
<P>
The class and function listings in the project window are updated each
time you open or save a source file, or when you click the drop-down function
list. Click the + and - boxes to the left of the files and classes to expand
them and view the function lists for each file. This provides a powerful way
to view and understand your own code, and the code of others.
</P>
<B><P><A NAME="MoreInformation"></A>For more information on FreeJava</P></B>
<P>Visit the FreeJava web site at
<A HREF="http://www.freejava.co.uk/">www.freejava.co.uk</A>.
</P>
<B><P>For more information on Java</P></B>
<P>
For people who have some experience of programming but are new to
Java, I would recommend <B>Java In A Nutshell</B> by David Flanagan,
published by O'Reilly, and its companion volume <B>Java Examples In A Nutshell</B>.
These books have the great advantage of being reasonably priced,
and containing more useful information than much larger and more
terrifyingly costly volumes. For absolute beginners, you could do
worse than "<B>Java For Dummies</B>", widely available and instantly
recognizable by its hideous cover.
</P>
<P><A NAME="QandA"></A>Q & A</P>
<B><P>Q. How do you work with packages in Free Java?</B> </P>
<BLOCKQUOTE>A. There is support for packages in FreeJava. Here's how it works:<BR>
<BR>
Just specify the name of your package
in Project | Properties.<BR>
<BR>
</BLOCKQUOTE>
<B><P><A NAME="keyboard_input"></A>Q. Why can't I write applications that use keyboard inputs?</B> </P>
<BLOCKQUOTE>
A.By capturing the output from Java in a window in the FreeJava IDE,
console input to applications run from within the FreeJava environment will not work.<BR>
<BR>
However, you can write applications that use console input in FreeJava, but when
you run them you should choose "Run with Console" from the Build menu. Output capture to
the Process output window will then not be available.
</BLOCKQUOTE>
<P><A HREF="#Top">Back to top</A> </P></BODY>
<b><P><A NAME="SyntaxColor"></A>Syntax Colouring Issues</P></B>
<p>
FreeJava only syntax colours the line that you are editing, so if you comment
out a large block of code using /* and */, you may then need to choose "Syntax Colour
Update" from the edit menu (or press F3) to update the colouring. Also, if you open a
file that is in Macintosh format, you may need to choose "Convert Linebreaks" from the
edit menu before FreeJava is able to colour it correctly.
</p>
<b><P><A NAME="JarFile"></A>Creating Jar Files</P></B>
<p>
When you choose "Create Jar File" from the Project menu, FreeJava will create
a Jar file containing every class that is in the same folder as your Main Class.
It will also create a file (called "manifest.txt") that specifies the name of the
main class, and include that with the Jar file so that, if your Project is an
application you can run it from the command line with "java -jar MyApp.jar", where MyApp
is the name of your jar file.
</p>
<p>
If you need to include other files or resources with your Jar file, you must
do so manually, using the "jar" tool included with the JDK. More support for this
feature will be coming in future versions.
</p>
<p>
You can see what files FreeJava put into the Jar file, by choosing "Show Archive Contents..."
from the Project menu. The contents will be listed in the Process Output window (which will
pop open).
</p>
<P><A HREF="#Top">Back to top</A> </P></BODY>
</dir>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -