Recent Notes

Displaying keyword search results 91 - 101
Created by Bambi on August 07, 2009 03:47:56    Last update: August 07, 2009 03:59:15
Code: package hello.world; // package declaration, must ... Compile/Run: C:\tmp>javac hello\world\HelloWorld.java C:\tmp... Since the class is not public (package access), the name of the Java file could be anything! If a package access class has a public static void main(String[]) method, it may still be run from the command line using the class name. C:\tmp>copy hello\world\HelloWorld.java hello\worl...
Created by Dr. Xi on March 16, 2009 22:10:29    Last update: March 16, 2009 22:12:35
Generate the keys $ ssh-keygen -t rsa Generating public/private r... Copy id_rsa.pub to the remote server. scp .ssh/id_rsa.pub jmann@sleepy:/home/jmann/.ssh/ Logon to the remote host, append id_rsa.pub to authorized_keys . Make sure authorized_keys is writable only by owner. $ cd ~/.ssh $ cat id_rsa.pub >>authorized_keys ... For putty, you need to convert the private key to putty format using puttygen : and tell it to use the private key:
Created by Dr. Xi on February 09, 2009 23:14:15    Last update: February 09, 2009 23:14:15
This example demonstrates the general steps in creating a custom Java class loader. Normally a class loader would consult its parent class loader when asked to load a class. If it's not loaded by the parent class loader, then the class loader would try to load the class on its own. This class loader tries to load the requested class on its own first, and delegates to the parent only when a java.lang.SecurityException is thrown (which happens when it tries to load core Java classes such as java.lang.String ). The classes are loaded from CLASSPATH through the getResourceAsStream call. It's important to note that when a class is loaded with a certain class loader, all classes referenced from that class are also loaded through the...
Created by Dr. Xi on January 29, 2009 17:11:34    Last update: January 29, 2009 17:11:34
import java.awt.Color; import java.awt.Font; ...
Created by Dr. Xi on October 18, 2008 03:16:24    Last update: October 18, 2008 03:17:21
Normally the browser opens a page if it knows how to. For example, text files are usually displayed in the browser window. You can set the Content-Type and Content-Disposition headers in the HTTP response to force the browser to popup the download dialog. Python example: def download_log(req, app = None, file = None): ... Java example: public void service(HttpServletRequest req, Ht...
Created by Dr. Xi on October 16, 2008 23:09:28    Last update: October 17, 2008 03:30:38
import java.io.*; public class TestMSOffice...
Created by Dr. Xi on October 14, 2008 23:02:29    Last update: October 14, 2008 23:03:50
Wrap JWhich in a servlet: Implement the servlet: package com.example; import java.io.*; ... Add this to web.xml : <servlet> <servlet-name>jwhich</servlet... Request the path for a class or properties file: http://mydomain.com/jwhich/com.example.SomeCla...
Created by Dr. Xi on September 25, 2008 02:58:27    Last update: October 14, 2008 22:49:32
This following code came from a JavaWorld tip, with some minor modifications. public class JWhich { /** * Retu...
Created by Dr. Xi on September 05, 2008 22:58:01    Last update: September 07, 2008 03:25:24
Java introduced annotations since JDK1.5. Annotations are used to decorate code and can be applied to declarations of classes, fields, methods, and other program elements. They are not part of the code per se, but frequently used to apply external logic to the code being annotated. An "Annotation Type" must accompany each type of annotation. For example, the following code will fail compilation: public class TestAnnotation { @deprecated ... Changing @deprecated to @Deprecated with an upper case D will fix the problem, since @Deprecated is a built in annotation type. There are three built in annotation types: @Deprecated , @Override , and @SuppressWarnings . This is an example of a user defined annotation (the file must be named Test.java ): import java.lang.annotation.*; /** * In......
Created by Dr. Xi on September 04, 2008 18:56:19    Last update: September 04, 2008 18:56:42
If you keep SQL strings in a file, you probably comment it to make it more readable. But when you feed the SQL to JDBC, you may prefer to clean it up. This is a regex to do that. public class CleanupSql { public static voi...
Created by Dr. Xi on September 04, 2008 18:18:07    Last update: September 04, 2008 18:18:07
If the argument to getResourceAsStream is a directory, the stream content returns a list of files under that directory. The following code returns the list of files under the first directory on CLASSPATH (not the current directory): import java.io.*; public class TestGetResou...
Previous  1 2 3 4 5 6 7 8 9 10 Next