Java programming tips LIBRARY
Java programming tips LIBRARY
A ride the Orient Express Lok dust 2002-9-10 beijing
1. Javadoc API documentation procedures for Javadoc Java class read a document and automatically create a group of HTML files, HTML document describes the Java class files class, variable, function members, all of the Java class libraries APIHTML this document can be create procedures. Javadoc of the package or the source file list as a variable. Javadoc @ beginning to rely on the note marker to create HTML documents, the following is a list of tagging, they are in the Javadoc HTML document for the creation of links.
Options @ see classname function marked in this category to the list provided by the addition of a category of "See Also" entries.
@ # Methodname see classname this marked the creation of a function to a specific member of the "See Also" entries.
@ Version text of this document in HTML tagging to add a version of @ author text message entries in this notice is to add a HTML document author information entries @ param name description by members of this notice is to describe the function of a member of Remarks arising variable @ Function Marking this return description used to describe members of function return value Remarks @ exception classname with members of the tagging function Note to connect the abnormal function of exports
- Classpath path designated the command line to the directory search for Java
- D directory earmarked for this command-line Add to the final HTML document very useful.
2 debugger - jdb. Exe
Java Scheduler for Java program provides a command-line debugging environment. It can in the local, long-distance and can be explained in a dialogue with the Executive. Jdb available on the local machine in the following order activated.
Options function
Catch calssID abnormal for specific exports interrupted
Known classes of the current list
Clear classID: removal of a line break
Cont breakpoint from the continued implementation
Down [n frames] a lower thread stack
Dump ID [ID …] show all information objects
Exit (or quit) withdrew debugger
Help (or?) List all orders
Ignore classID ignored specific export anomaly
List [line number] shows that the source code
Load classbame included in the Java class to debug
Locals in the current stack frame to display all local variables
RAM memory usage report
Methods classID a list of the members of Function Set
Print ID [ID …] listed object or domain
Resume [threadID …] resume threads (default restore all threads)
Run class [args] started downloaded Java class
Step implementation of the current trip
Stop in classID: method in a member function to set up a breakpoint
Stop at classID: in his line to set up a break point
Suspend [threadID …] stop a thread (default cessation of all threads)
Hreads threadgroup list thread
Thread threadID set the current thread
Threadgroups list thread Group
Threadgroup name group set up the current thread
Up [n frames] shift a thread stack
Use [path] display or change the source path
Where [threadID] or all of the threads to a heap of empty home
! Repeat the last command
- Host hostname of the order told Jdb Where the establishment of long-distance running Java interpreter dialogue process
This option-password password Jdb told which password to use with the remote operation of the process of dialogue to link Java.
Password with a password by running - Java debug options provided by the interpreter.
3 Applet quoted in the jar in the resource file
If you want to add servlets procedures designed some picture, sound, animation, etc., can simply use the sun provides a useful tool: jar. This tool can bring these documents are in a document, to avoid frequent http request, can be downloaded cache!
Use of resources in the jar examples are as follows: add a picture button ImageButton
(Friendly reminder ieg: The voices, cartoons, pictures of a relative path. / Img / my.gif)
Import java.awt .*;
Import java.awt.event .*; / / download it
Import javax.swing .*; / / download it
Public class ImageButtonApplet extends JApplet (
Private String path = "/ img / my.gif";
Private ImageIcon myButtonIcon = new ImageIcon (getClass (). GetResource (path));
/ * Debugging and many times in my own view of the demo since jdk generation API text block, a JDK1.1, also related ClassLoader, demo resources in the application of the methods used when getClass (). GetResource (String sourceName)
As follows:
Public URL getResource (String name)
Finds a resource with a given name. This method returns null if no resource with this name is found. The rules for searching resources associated with a given class are implemented by the * defining class loader of the class.
This method delegates the call to its class loader, after making these changes to the resource name: if the resource name starts with "/", it is unchanged; otherwise, the package name is prepended to the resource name after converting "." To "/." If this object was loaded by the bootstrap loader, the call is delegated to ClassLoader.getSystemResource.
Parameters:
Name - name of the desired resource
Returns:
A java.net.URL object.
* /
/ * Initialize the applet * /
Public void init () (
Try (
If (myButtonIcon == null)
Throw new Exception ( "cannot get the image!");
JButton iButton = new JButton (myButtonIcon);
Container cp = this.getContentPane ();
Cp.add (iButton);
)
Catch (Exception e) (
E.printStackTrace ();
)
)
)
- Compiler, and the ImageButtonApplet.class my.gif maintain relative path into jar inside, the corresponding code for HTML pages <APPLET CODE = "ImageButtonApplet.class" CODEBASE = "." ARCHIVE = "my.jar" WIDTH = "200" HEIGHT = "200"> </ APPLET>. The key to success lies in using getClass (). GetResource (path).
I limited the level of that criticism about!
2002-9-10
Tags: programming, tips








0 Comments to “Java programming tips LIBRARY”
No Comments. Send your comment.
Leave a Reply
You must be logged in to post a comment.