Keywords C programming language, C++, Sun Microsystems, conection pool, object-oriented programming
Copyright Information All rights reserved by the author of this article.
Contact
webmasters for more information
on copyright issues.
1 Introduction
Java is an object-oriented programming (OOP) language. Similar to C++ , Java was originated from the C programming language and it has C-style
grammar. Different from C++, Java is a strict object-oriented programming language (not 100% though), while C++ is compatible with C and doesnot
force OOP. When Java was invented in Sun Microsystems in 1990, the Green Project Team first called it oak.
java.lang.NoClassDefineError, ClassNotFound
Use
varargs?
Starting from Java 1.5, java starts supporting something called varargs.
public String format(String pattern, Object... arguments)
You can pass in either an array, or a series of Objects. A vararg can only be used at the end of the argument list.
foreach loop
Iterator suites something;
for (Suit suit : suits)
for (Rank rank : ranks)
sortedDeck.add(new Card(suit, rank));
int sum(int[] a) {
int result 0;
for (int i : a)
result + i;
return result;
}
Why is my nohup not working with Java 1.4?
Use "nohup java -Xrs your.java.program &", instead of "nohup java your.java.program&".
java.lang.Ill...[more ]
Introduction
Apache Ant is a Java-based build tool. In theory, it is kind of like Make, but without Make's wrinkles.
Troubleshooting
Use "ant -v" to show all the commands being executed.
Run ant with proxy?
set ANT_OPTS to -Dhttp.proxyHost proxy -Dhttp.proxyPort 8080
How do I check if a directory exists, and create it if it's not?
You don't need to will not fail if a directory already exists.
...[more ]
BeanShell is a Java scripting language.
...[more ]
Groovy is an alternative to Java programming language on Java platform. Different from Java which is statically typed, groovy is dynamically typed, meaning you do not have to declare a type for a variable.
...[more ]
The Java Authentication and Authorization Service (JAAS) is a set of APIs that enable services to authenticate and enforce access controls upon users.
It implements a Java technology version of the standard Pluggable Authentication Module (PAM) framework, and supports user-based authorization.
...[more ]
Introduction
JavaBeans technology is the component architecture for the Java 2 Platform, Standard Edition (J2SE). Components (JavaBeans) are reusable software programs that you can develop and assemble easily to create sophisticated applications. JavaBeans was originally designed for
visual components, but the basic JavaBean architecture is useful in constructing Java components.
Here is the old-fashioned definition of a Java bean: a JavaBean is "a reusable software component that can be visually manipulated in builder tools.". In this simple definition, a bean must has the following
three properties: software component, builder tool, and visual manipulation.
...[more ]
A famous Java application server
A Hello World example with Jboss and Eclipse
Install and
Install
In eclipse create a new project by selecting new->Project->Web project->dynamic web project, say the project name is demo. The project should have a demo\src directory for source files, a demo\WebContent directory for jsp and html files.
Right click project name demo, select properties->packaging configurations. Select Standar-War.war. You need to manually add the items you want in the package. You need to fill out Prefix field: if it's .jsp page, then leave it blank; if it's .class file, use WEB-INF\classes. There is also an include and an exclude field: use \ \ \ .class if you want to include all .class files.
Add a few jsp file ...[more ]
JMX is short for Java Management Extension.
...[more ]
Introduction
Java Server Pages, a server side technology which embeds java into html pages.
Custom Tags
A custom tag is a user-defined JSP tag.
Custom tags have a rich set of features. They can
Be customized via attributes passed from the calling page.
Access all the objects available to JSP pages.
Modify the response generated by the calling page.
Communicate with each other. You can create and initialize a JavaBeans component, create a variable that refers to that bean in one tag, and then use the bean in another tag.
Be nested within one another, allowing for complex interactions within a JSP page.
To use a custom tag, you
check and make sure there is a tag library description (.tld) file. You could either create a cus...[more ]
Logging and Programming
Many programmers use logging or print statement to debug programs. First, it works. Second, it's handy. And third,
debuggers may not be available. The flip side is: it may pollute the code if not properly handled,
and also there will be a performance drawback.
What is log4j?
Log4J is a Java package. With log4j, "it is possible to enable logging at runtime without modifying the application binary."
The log4j package "is designed so that these statements can remain in shipped code without incurring a heavy performance cost".
Logging behavior "can be controlled by editing a configuration file, without touching the application binary".
What are the possible log4j targets?
a local file
an OutputStream...[more ]
Introduction
Persistent is the opposite of transient. In a Java application,
there are classes that come and go: you create them, use them, and discard them.
Some other classes such as database related classes, will not go away after you quit the application,
they (or their data) are stored in a pesistent external storage. These are called persistent classes.
Bean Managed Persistence (BMP)
In BMP, developers take care of persistence.
Container Managed Persistence (CMP)
Container Managed Persistence (CMP) is more strategic
Vendor takes care of everything by using O-R or OODB mappings using metadata.
A developer cannot optimize performance as the vendor takes care of it .
Hibernate
OJB
...[more ]
Introduction
Struts is an open source framework for building Java-based web applications. It is maintained by the Apache Software Foundation.
The Structs framework features the MVC architecture where "Model" (data) and "View" (data presentation) are completely separated by a "Controller".
Struts has a controller which supports various model techniques and view techniques.
Supported model techniques include but not limited to JDBC, EJB, Hibernate, Object Relational Bridge, etc.
Supported view techniques include JSP, JSTL, JSF, Velocity, XSLT, etc.
A brief history of Java-based web application develoepment
At first it was plain HTML, where information flow is almost uni-directional. The only feedback from the browser is the link to
the n...[more ]
Introduction
Tomcat is a Java servlet container from Apache
How do I bind my tomcat server to a specific IP address?
In conf/server.xml, add address "1.2.3.4" to all connector tags. For example
Use
instead of
I changed my index.jsp, however, my changes didn't seem to take effect
Look for the following lines in webapps/ROOT/WEB-INF/web.xml, look for the following, and comment it out
org.apache.jsp.index_jsp
org.apache.jsp.index_jsp
org.apache.jsp.index_jsp...[more ]
c3p0 is a simple-to-use Java-based database pooling package.
C3P0 manual
How to set up c3p0 with jboss
download c3p0 package from
extract the downloaded binary package and put the c3p0-version.jar into your jboss
lib directory ($JBOSS_HOME/server/default/lib)
put the following xml file into your deployment directory ($JBOSS_HOME/server/default/deploy)
Note that you need to change JdbcUrl, User, Password into your own configuration
java:PooledDS
jdbc:postgresql://localhost/c3p0-test
org.postgresql.Driver
swaldman
test
...[more ]
Here is a summary of conection pool s
This is a summary of Java reporting tools.
A reporting tool presents data as reports, optionally in HTML, PDF, CSV, and other formats.
Open-source Java reporting tools
DataVision
is, quote from :
"DataVision is an Open Source reporting tool similar to Crystal Reports. Reports can be designed using a drag-and-drop GUI. They may be run, viewed, and printed from the application or exported as HTML, XML, PDF, LaTeX2e, DocBook, or tab- or comma-delimited text files. The output files produced by LaTeX2e and DocBook can in turn be used to produce PDF, text, HTML, PostScript, and more.
"DataVision is written in Java and runs almost anywhere. It can generate reports from databases or text data files. Any database with an available JDBC driver should work...[more ]
18 Misc
Java town, Wyoming County, New York:
Check out what google has to say about
Java town, Wyoming County, New York
Total households 807, total housing units: 1035
Population:2222, male 1133 female 1089
Races in Java town, Wyoming County, New York:
White/Non-Hispanic (98.74%) Hispanic (0.41%) Black (0.14%) Asian (0.09%): Korean(0.09%)
Java town, South Dakota:
Check out what google has to say about Java town, South Dakota
Total households 94, total housing units: 133
Land area: 0.479417 square miles, water area 0.000000 miles
Latitude: NORTH 45.502870, longitude: EAST -99.88604
MAP
Population:197, male 100 female 97
Races in Java town, South Dakota:
White/Non-Hispanic (95.94%):
(search time: 215.533 msec)
Ja"va (?), n. 1.
One of the islands of the Malay Archipelago belonging to the
Netherlands.
2. Java coffee, a kind of coffee brought
from Java.
Java cat (Zoöl.) , the
musang. -- Java sparrow (Zoöl.) ,
a species of finch (Padda oryzivora ), native of Java, but
very commonly kept as a cage bird; -- called also ricebird ,
and paddy bird . In the male the upper parts are glaucous gray,
the head and tail black, the under parts delicate rose, and the
cheeks white. The bill is large and red. A white variety is also kept
as a cage bird.
(search time: 46.472 msec)
Java ['d70v2] 爪哇,爪哇产的咖啡,咖啡;一种网络编程语言,编译后可在不同的平台上运行,支持多媒体
(search time: 74.407 msec)