.java
extension.
Java is an object-oriented language developed by Sun. Java is similar
to C++, but Java has a few new features, such as garbage collection. Java
is also missing a few features C++ has, like multiple inheritance.
The EditJava Itcl class is derived from the
EditCpp Itcl class, and
therefore inherits all of its features, such as invoking make
.
The EditJava class colors certain Java constructs, such as comments.
For more Java resources, see the Tycho Java page.
Compile and Load
menu choice under the File
menu
will compile and optionally run the Java file currently being edited.
The
CompileJava
class documentation discusses the programming details, we discuss the
user level details below.
The EditJava editor supports two primary methods of compiling Java files:
CLASSPATH
environment variable controls where the
Java tools such as javac
, java
, and
appletviewer
. javac
and java
take a -classpath
option, appletviewer
does
not.
If
useEnvClassPath
preference is true, then
the CLASSPATH
is read from the user's senvironment with
$env(CLASSPATH)
and passed to java
or
javac
. (The useEnvClassPath
preferences and the other Java editor preferences are set in the Java
preference).
If the useEnvClassPath
preference is false, then Tycho
reads the classPath
preference and sets the
CLASSPATH
environment variable before calling the Java
tools.
The javaHome
preference
refers to the directory that contains the Java Development Kit (JDK).
The initial default of the javaHome
preference is taken
from the value of the JAVA_HOME
environment variable.
The javaHome
preference is used to find the JDK HTML
documentation for the built in Java classes. The JDK HTML
documentation should be in the api
subdirectory of the
JDK. The location of the JDK HTML documentation is used to fix
javadoc
hyperlinks.
$TYCHO/editors/textedit/test/DrawTest.java
is a Java application that includes a main()
. If you edit
this file and then invoke Compile and Load
with either
then an
Exec
widget will come up and compile and run the Java file with
java -cs -v
Note that compiling a Java file will create a .class
file in the directory where the .java
file resides. If
you do not have write permission to $TYCHO/editors/textedit/test
then you could copy the .java
files to a directory
where you have write permission.
$TYCHO/editors/textedit/test/Blink.java
is a Java applet that does not include a main()
. If
you edit this file and then invoke Compile and Load
as above, first
javac
is run to compile the file, and then
appletviewer
is run.
Note that the Exec windows that come up when you compile a Java file are persistent between compilations. This allows you to modify the command line once and reuse your command line during the next compilation
Special
Menu choicesBody Template
command in the Special
menu places a body template at the current point in the buffer.
The File Template
command in the Special
menu copies the file $TYCHO/editors/textedit/templates/JavaTemplate.java
into the editor and does some substitutions described
below.
The Generate doc
command
in the Special
menu asks the user if they would like to save the buffer
and then runs the javadoc
program to produce HTML documentation
for the current file.
The appletview
choice in the Special
menu
brings up the appletviewer
program and loads the file being
edited into appletviewer
The string ClassName
in the template file is substituted
with a class name based on the name of the file.
For example, if the file is named Elvis.java
, then
the class name Elvis
will be substituted everywhere
ClassName
appears.
The Java package
is updated accordingly if the file is located
in a directory below $TYCHO/java
. For example, if the pathname
to the file was $TYCHO/java/devel/mystuff/Elvis.java
, then
the package
line would look like:
package devel.mystuff;If the file is not below
$TYCHO/java
, then the
package
line is commented out.
The @author
Java doctag is updated to use the
userName
preference which contains the full name of the user.
This preference can be updated by mousing on the Help button on the
upper right of most Tycho windows and then clicking on
Preferences
. The userName
preference is under the
Miscellaneous
preferences.
javadoc
tags below:
@see classname
javadoc
will not create links in the html
output for the @see
tags unless javadoc
is passed both the file that contains the @see
and the
file that is referred to.
Foo.java
uses
@see Bar.java
, then you must run javadoc
Foo.java Bar.java
.
@see full.classname
@see full.classname#method-name
@see full.classname#method-name(first.arg.type, second.arg.type)
@see <a href="myfile.html">My File</a>
@version text
@version
tag may only be used before a class
definition. Call javadoc
with the -version
flag to generate an version listing in the HTML file.
@author text
@author
tag may only be used before a class
definition. Call javadoc
with the -author
flag to generate an author listing in the HTML file.
@param parameter-name description
@return description
@exception full-classname description
@deprecated description
@deprecated
tag is noticed by the Java compiler. If it is present, then the
compiler will not warn about a method that overrides a deprecated
parent method.
description
should be of the form
As of version xxx, replaced by newmethod()
@since text
text
need not have
any particular structure.