Na klar:

Die Lösung: PI ist die XML Processing Instruction. Gefunden auf http://thedailywtf.com/.
PDF ist ein Standard-Dokumentenformat geworden, an dem man nicht vorbeikommt.
Java bietet eine Reihe von Bibliotheken an, die PDF-Dokumente verfassen und darstellen. Bekannter sind:
Was sind Bibliotheken zum Anzeigen und Erstellen? Welche Einschränkungen sind bekannt? Was kann man mit http://djproject.sourceforge.net/ns/ machen?
Erstelle mit iText aus den Kurzbeispielen http://itextdocs.lowagie.com/tutorial/ eine PDF mit Absätzen, einfachen Tabellen und Bildern. Zeige die PDF mit dem https://pdf-renderer.dev.java.net/ an.
Microsoft versucht mit dem XPS-Standard (http://en.wikipedia.org/wiki/XML_Paper_Specification) eine Alternative zu etablieren. Gibt es dazu irgendwelche Java-Bibliotheken?
Das AppFramework (RI von JSR 296) ist wohl tot. Von Pushing-Pixels:
Hans Muller confirms what many have already guessed. His e-mail on the users mailing list of AppFramework (reference implementation of JSR 296) confirms that the development of this project has been dead since last November and will continue to be so through this summer. The subsequent discussion on the mailing list indicates that it is quite unlikely that somebody will step up and be able to provide leadership that is much needed for JSR-level projects. The inclusion in JDK 7 looks like it’s in jeopardy as well.
Hans Muller schreibt dazu:
I’m the spec lead for JSR-296 and the only developer as well. I’ve been neglecting the project for the past several months to focus exclusively on Sun’s Java FX initiative. You can see the results of some of that work in the Scenario project (http:www.scenegraph.dev.java.net), and before too long in the revised („Reprise“) version of the graphics/UI library for the FX Script language. I’d originally expected to be heads-down on FX for a couple of weeks and then after that return to devoting part of my time to this project. Unfortunately that hasn’t happened and it’s unlikely to change through this summer.
I’m proud of how far along Application Framework is and it’s inspiring to see how the developer community has responded. It’s particularly gratifying to see questions asked and answered on this list and proposals floated and discussed. I’d like to restore the project’s ability to make some progress, by adding a few developers to the project who’ll be able to update the code and make decisions about how to evolve the design. If you’re interested and if you feel you have the time and the right kind of experience, please send me an email. I’m going to try and resolve this in the next week or so.
Tja. Hoffentlich bleibt dann das Bean-Binding stehen. Obwohl — da schreibt Pushing-Pixels weiter:
John O’Connor has an article on Beans Binding (reference implementation of JSR 295). Unfortunately, these two projects are twin victims of JavaFX for the better part of this year, and one could only hope that JavaFX will live up to its promise and to the investment in engineering resources that have been subverted to it.
So viel zum Thema: „Wir bringen Java zurück zum Desktop. In Java 7.“ Klar.
Java verarbeitet Zeichen (bisher) intern in 2-Byte Unicode. Gespeichert werden Daten aber in der Regel in UTF-8 oder, für uns in Europa, in Latin-1. Thema der Woche ist Unicode und die Umkodierungen. Am Anfang sollen The Ten Commandments of Unicode von Elliotte Rusty Harold stehen:
Da schließen sich nun einige Fragen an, die es zu klären gilt:
Auch neu: tutego’s Clip-Art Seite. Links zu weiteren Clip-Art Sammlungen (ohne die lästigen Popup-Menüs) sind willkommen.
Einige Änderungen aus dem Preview der EJB 3.1 Specification.
Es gibt neu auch Singleton Session Beans, die mit @Singleton annotiert sind:
The EJB specification defines stateful, stateless, and singleton session beans. There are differences in
the API between stateful session beans, stateless session beans, and singleton session beans.
4.7 Singleton Session Beans
A Singleton session bean is a session bean component that is instantiated once per application. In cases
where the container is distributed over many virtual machines, each application will have one bean
instance of the Singleton for each JVM.
Once instantiated, a Singleton session bean instance lives for the duration of the container in which it is
created. It maintains its state between client invocations but that state is not required to survive container
shutdown or crash.
Man kann für lokale Beans auf eine Business-Schnittstelle verzichten:
In EJB 3.x, a local client accesses a session bean through the bean’s local business interface or through
a no-interface client view representing all the public methods of the bean class.
3.4.2 Obtaining a Reference to the No-interface Local View
A client can obtain a reference to a Session Bean’s No-interface Local View through dependency injection
or lookup in the JNDI namespace.
For example, the No-interface Local view of the CartBean session bean with bean class com.acme.Cart-
Bean may be obtained using dependency injection as follows :
@EJB CartBean cart;
The CartBean No-interface view could also be looked up via JNDI as shown in the following code segment
using the lookup method provided by the EJBContext interface. In this example, a reference to
the client bean’s SessionContext is obtained through dependency injection:
@Resource SessionContext ctx;
…
CartBean cart = (CartBean)ctx.lookup(“cart”);
Despite the fact that the client reference for the No-interface Local view has type <bean class> , the client
never directly uses the new operator to acquire the reference.
3.4.4 Session Bean’s No-Interface Local View
A Session Bean’s no-interface view is a variation of the Local view that exposes the public methods of
the bean class without the use of a separate business interface.
A reference to the no-interface view may be passed as a parameter or return value of any Local business
interface or no-interface view method.
The container provides an implementation of a reference to a no-interface view such that when the client
invokes a method on the reference, the business method on the session bean instance and any interceptor
methods are invoked as needed.
Only public methods of the bean class (and any super-classes) may be invoked through the no-interface
view. Attempted invocations of methods with any other access modifiers via the no-interface view reference
result in the javax.ejb.EJBException.
It is invalid to reference a session object that does not exist. If a stateful session bean has been removed,
attempted invocations on the no-interface view reference result in the javax.ejb.NoSuchEJBException.
Neu ist, das eine Session-Bean synchron oder asynchron aufgerufen werden kann:
3.4.8 Asynchronous Invocations
By default, session bean invocations through the Remote, Local, and no-interface views are synchronous,
meaning the client blocks for the duration of the invocation and is returned control only after all
invocation processing has completed. Clients can achieve asynchronous behavior by invoking session
bean methods that have been designed to support asynchrony.When a client invokes an asynchronous method, the container returns control to the client and continues
processing the asynchronous invocation on a separate thread of execution.
3.4.8.1 Return Values
Asynchronous methods have a return type of void or Future<V>, where V represents the result value
of the asynchronous invocation.
In the case of a Future<V> return type, the object returned to the client is a container provided object.
This object allows the client to retrieve the invocation result value, discover any invocation exception,
or attempt to cancel the asynchronous invocation.
Reguläre Ausdrücke vereinfachen die Abfragen an Strings radikal. Lese zunächst zur Einleitung
Anschließend sollte man die die API-Doku lesen:
In einer Code-Suchmaschine kann man nun einige Beispiele für Pattern-Nutzung ablesen:
Mehr Beispiele (allerdings auch mit Perl-RegEx, die Java nicht unterstützt) gibt die Seite
Hier sollte man sich ein paar Beispiele anschauen.
Zum Schluss eine Übung: Schreibe einen RegEx-Ersetzer, der aus einem Satz mit der „Basic text formatting“ Regel der Wiki-Syntax (http://wiki.splitbrain.org/wiki:syntax) HTML erzeugt. Also soll aus
**bold**
folgendes werden:
<b>bold</b>
Java hat seine Monopolstellung eingebüßt – die hochoptimierte JVM und die umfangreichen Java-Bibliotheken lassen sich mittlerweile durch alternative Programmiersprachen nutzen. Auf der einen Seite existieren klassische Interpreter und Compiler für existierende Sprachen, wie Ruby, Prolog, LISP, BASIC, Python, die bestmöglich auf die Java-Umgebung portiert werden. Auf der anderen Seite sind es ganz neue Programmiersprachen (wie Groovy), die sich als echte Alternative zur Programmiersprache Java etablieren. Skriptsprachen werden oft über die JSR 223: Scripting for the Java Platform, einer standardisierten API, angesprochen.
Seit Java 6 ist über Rhino – ein Projekt der Mozilla Foundation – eine JavaScript-Laufzeitumgebung integriert. Die Script-Engine erlaubt die dynamische Übersetzung in Bytecode, was schnelle Ausführungszeiten der prozeduralen, funktionalen, objektorientierten Programmiersprache garantiert.
Groovy bietet eine starke Syntax mit Closures, Listen/Mengen, Reguläre Ausdrücke, eine dynamische und statische Typisierung und vielem mehr. Moderne IDEs wie Eclipse oder NetBeans unterstützen Groovy durch Plugins. Der Groovy-Compiler erzeugt für die Groovy-Klassen den typischen Bytecode, sodass normale Java-Klassen problemlos Groovy-Klassen nutzen können – oder umgekehrt. Zwei Vorträge zum Einlesen:
JRuby ist die Java-Version der dynamisch getypten Programmiersprache Ruby. Sun beschäftigt mit Charles Nutter und Thomas Enebo (die ›JRuby Guys‹) zwei Entwickler, und bringt auch mit der Integration in die NetBeans IDE (J)Ruby weit nach vorne. Ruby wird mit einem Atemzug mit dem Web-Framework Ruby on Rails genannt, ein Framework für Web-Applikationen, welches dank JRuby auch auf jedem Tomcat und Java Application-Server läuft.
Die beliebte Programmiersprache Python bringt Jython auf die Java-Plattform. Auch Jython übersetzt Python-Programme in Java-Bytecode und erlaubt relativ schnelle Ausführungszeiten. Jython 2.2 implementiert Python auf 2.2, doch hat sich (C-)Python mit Version 2.6 und 3 schon weiter entwickelt. Auch sonst gibt es Unterschiede, etwa bei den eingebauten (nativen) Funktionen. Sun hat im März 2008 Ted Leung und Frank Wierzbicki (Hauptentwickler von Jython) eingestellt, um Python auf der JVM weiter zu fördern.
Scala ist eine Funktionale, objektorientierte Programmiersprache, die in der Java-Community große Zustimmung findet, obwohl sie von Martin Odersky erst 2001 entwickelt und 2004 vorgestellt wurde. Ein Eclipse-Plugin steht ebenfalls bereit. Für die .NET-Plattform gibt es ebenfalls eine Implementierung. Besonders zeichnet Scala ein durchdachtes Typsystem aus.
Quercus ist eine Implementierung von PHP, welches insbesondere dazu geeignet ist, bestehende und beliebte PHP-Projekte in einer Java-Umgebung ablaufen zu lassen. In der Java-Welt werden zwar nicht alle PHP-Funktionen unterstützt, aber es gibt in der Java-Welt keine Speicherüberläufe oder Sicherheitsprobleme.
Jatha ist eine ›Common LISP library in Java‹, eine Implementierung von Common LISP. Mit einer API lassen sich LISP-Programme aus Java heraus aufrufen.
LuaJava implementiert die Programmiersprache Lua für die JVM. Die aus Brasilien stammende dynamisch getypte Programmiersprache Lua zählt zu den performantesten, interpretierten Skriptsprachen. Sie ist in erster Linie als eingebettete Programmiersprache zur Applikationssteuerung entworfen worden; prominete Nutzer sind Sim City, World of Worcraft, Adobe Photoshop Lightroom, SciTE.
Pnuts gehört zu den schnellsten Skriptsprachen auf der JVM. Die Sprache hat eine einfache Syntax und übersetzt Programme ebenfalls in Bytecode.
Mit JBasic gibt es für die Java-Plattform einen BASIC-Dialekt, der sich an GW-BASIC anlehnt.
JLog implementiert einen ISO-Standardisierten PROLOG-Interpreter. JLog läuft in einem eigenen Fenster mit Quellcode-Editor, Query-Panel, Hilfe, Debugger, oder es kann in einem eigenen Java-Programm eingebettet werden.
Jacl implementiert einen TCL-Interpreter in Java. Die Entwicklung ist nicht mehr aktiv.
Die Webseite http://www.robert-tolksdorf.de/vmlanguages.html führt weitere Programmiersprachen für die JVM auf. Allerdings sind viele der gelisteten Sprachen für sehr spezielle Anwendungsfälle entworfen, experimentell oder werden nicht mehr gepflegt.
Java 5 ist mittlerweile weit verbreitet, und Entwickler sollten auf der einen Seite die neuen Spracheigenschaften kennenlernen, auf der anderen Seite sich mit dem Update der Bibliotheken beschäftigen. Als Startlinks gelten:
Von jeder neue Klasse und Schnittstelle sollte man zumindest den API-Kopf gelesen haben. Besonderes Augenmerk sollten Entwickler auf Generics legen. Hier gilt hervorzuheben das Tutorial http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf. Die Begriffe
solle man sofort einordnen und beschreiben können.
Jeder Entwickler sollte insbesondere alle Anwendungen von Generics bei der Utility-Klasse Collections verstehen:
static <T> boolean addAll(Collection<? super T> c, T... a)static <T> int binarySearch(List<? extends Comparable<? super T>> list, T key)static <T> int binarySearch(List<? extends T> list, T key, Comparator<? super T> c)static <E> Collection<E> checkedCollection(Collection<E> c, Class<E> type)static <E> List<E> checkedList(List<E> list, Class<E> type)static <K,V> Map<K,V> checkedMap(Map<K,V> m, Class<K> keyType, Class<V> valueType)static <E> Set<E> checkedSet(Set<E> s, Class<E> type)static <K,V> SortedMap<K,V> checkedSortedMap(SortedMap<K,V> m, Class<K> keyType, Class<V> valueType)static <E> SortedSet<E> checkedSortedSet(SortedSet<E> s, Class<E> type)static <T> void copy(List<? super T> dest, List<? extends T> src)static boolean disjoint(Collection<?> c1, Collection<?> c2)static <T> List<T> emptyList()static <K,V> Map<K,V> emptyMap()static <T> Set<T> emptySet()static <T> Enumeration<T> enumeration(Collection<T> c)static <T> void fill(List<? super T> list, T obj)static int frequency(Collection<?> c, Object o)static int indexOfSubList(List<?> source, List<?> target)static int lastIndexOfSubList(List<?> source, List<?> target)static <T> ArrayList<T> list(Enumeration<T> e)static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll)static <T> T max(Collection<? extends T> coll, Comparator<? super T> comp)static <T extends Object & Comparable<? super T>> T min(Collection<? extends T> coll)static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp)static <T> List<T> nCopies(int n, T o)static <T> boolean replaceAll(List<T> list, T oldVal, T newVal)static void reverse(List<?> list)static <T> Comparator<T> reverseOrder()static <T> Comparator<T> reverseOrder(Comparator<T> cmp)static void rotate(List<?> list, int distance)static void shuffle(List<?> list)static void shuffle(List<?> list, Random rnd)static <T> Set<T> singleton(T o)static <T> List<T> singletonList(T o)static <K,V> Map<K,V> singletonMap(K key, V value)static <T extends Comparable<? super T>> void sort(List<T> list)static <T> void sort(List<T> list, Comparator<? super T> c)static void swap(List<?> list, int i, int j)static <T> Collection<T> synchronizedCollection(Collection<T> c)static <T> List<T> synchronizedList(List<T> list)static <K,V> Map<K,V> synchronizedMap(Map<K,V> m)static <T> Set<T> synchronizedSet(Set<T> s) static <K,V> SortedMap<K,V> synchronizedSortedMap(SortedMap<K,V> m)static <T> SortedSet<T> synchronizedSortedSet(SortedSet<T> s)static <T> Collection<T> unmodifiableCollection(Collection<? extends T> c)static <T> List<T> unmodifiableList(List<? extends T> list)static <K,V> Map<K,V> unmodifiableMap(Map<? extends K,? extends V> m)static <T> Set<T> unmodifiableSet(Set<? extends T> s)static <K,V> SortedMap<K,V> unmodifiableSortedMap(SortedMap<K,? extends V> m)static <T> SortedSet<T> unmodifiableSortedSet(SortedSet<T> s)PS: Beginne bei <T>/<E> bzw. <K,V>, dann <?> und dann den restlichen. max/min sind dann die Generics-„Bonbons“.
Wer danach die Nase von Generics immer noch nicht voll hat, beginnt http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html zu lesen. Das ist die umfangreichste Quelle zu dem Thema im Netz.
Nach mehr als 10 Jahren in der Java-Weiterbildung wiederholen sich doch die Fragen. Die Klassiker: „Wie haben Sie Java gelernt?“, „Wie bilden Sie sich weiter?“, „Was für Java-Bibliotheken nutzen Sie?“, „Wie verbreitet ist eigentlich XZY?“ Aus diesen Anfragen heraus möchte ich eine neue Rubrik „Die wöchentliche Dosis Java“ vorstellen. Die Idee ist, die kontinuierliche Weiterbildung von Software-Entwicklern zu fördern. In der (hoffentlich) wöchentlichen Rubrik stelle ich Technologien, Bibliotheken, Tools, Sprachupdates, … vor, in der sich Programmierer in einer Woche beschäftigen können und somit ein neues Gebiet kennenlernen. Der Bereich umfasst dabei die gesamte Java-Landschaft. Mal werden es Sprach-Erweiterungen sein, mal XML-Technologien, dann wieder etwas von Swing und Gui-Frameworks, dann REST, Web-Toolkits oder Open-Source Bibliotheken.
Mit der Google Java API (http://code.google.com/apis/gdata/javadoc/) lässt sich leicht auf die Dokumente oder Kalender zurückgreifen. Ein erstes Beispiel für eine Liste der Google-Calender ist schnell formuliert:
import java.net.URL;
import com.google.gdata.client.calendar.CalendarService;
import com.google.gdata.client.docs.DocsService;
import com.google.gdata.data.calendar.CalendarEntry;
import com.google.gdata.data.calendar.CalendarFeed;
import com.google.gdata.data.docs.DocumentListEntry;
import com.google.gdata.data.docs.DocumentListFeed;
public class GoogleExample
{
public static void main( String[] args ) throws Exception
{
String user = „user@gmail.com“, pass = „pass“;
CalendarService calService = new CalendarService( „Mein Kalender“ );
calService.setUserCredentials( user, pass );
CalendarFeed resultFeed = calService.getFeed(
new URL( „http://www.google.com/calendar/feeds/default/allcalendars/full“ ),
CalendarFeed.class );
for ( CalendarEntry entry : resultFeed.getEntries() )
System.out.println( entry.getTitle().getPlainText() );
DocsService service = new DocsService( „Meine Dokumente“ );
service.setUserCredentials( user, pass );
DocumentListFeed feed = service.getFeed(
new URL( „http://docs.google.com/feeds/documents/private/full“ ),
DocumentListFeed.class );
for ( DocumentListEntry doc : feed.getEntries() )
System.out.println( doc.getId() + „/“ + doc.getTitle().getPlainText() );
}
}
Die notwendigen Java-Archive nimmt man aus dem lib-Verzeichnis des Archivs http://gdata-java-client.googlecode.com/files/gdata.java-1.15.2.zip. Um auf die Dokumente zurückzugreifen (oder auch nur aufzulisten), ist mail.jar ebenfalls nötig.
Die Informationen von Mikroformaten lassen sich mit JAXB relativ leicht in XML konvertieren:
import java.util.*;
import javax.xml.bind.*;
import javax.xml.bind.annotation.*;
public class MicroformatViaJaxb
{
public static void main( String[] args ) throws JAXBException
{
Microformat mf = new Microformat();
mf.elements.add( new Element( "name", "Christian Ullenboom" ) );
mf.elements.add( new Element( "address", "tutego Allee" ) );
mf.elements.add( new Element( "phone", "2873568956928" ) );
JAXBContext context = JAXBContext.newInstance( Microformat.class );
Marshaller m = context.createMarshaller();
m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
m.marshal( mf, System.out );
}
}
@XmlRootElement( name = "div" )
class Microformat
{
@XmlAttribute( name = "class" )
public String key = "person";
@XmlElement( name = "span" )
public List<Element> elements = new ArrayList<Element>();
}
class Element
{
@XmlAttribute( name = "class" )
public String key;
@XmlValue
public String value;
public Element() { }
public Element( String key, String value )
{
this.key = key;
this.value = value;
}
}
XML HK2 WSIT ESB JMS SSO SAO JSR JAX-RS JCP DOJO AJAX WSDP jBMP RIFE RAILS MC4J CAPS SAML WS-* WSRP SAW JXTA HTTP URL IIOP ORB JMX TCP/IP WSDL MEX XWSS MTOM XSD SMTP WSA SOAP JBI JCA CMT LDAP BMT CMPI VJM CDDL GPL BSD API JAX-B StAX JSP JSTL EJB JPA TCK JDBC JDK JRE JAXP XOP REST POJO SQL GUI URI XMLDSig JAAS GSSAPI META-INF NIO ACL JNL CORBA CDC CLDC MIDP ACID SSL DRDA UML SAX DOM XOM XML-RPC MVC XSLT DAO SVG COM FTP PDF JNA ANTLR SLF4J
Alles klar?
Die PDFs sind zwar schon länger online, aber für Interessierte noch der Link: http://de.sun.com/sunnews/events/2007/20071203/agenda_frankfurt.jsp#agenda-2:
Sun Microsystems Country Manager Introduction:Donatus Schmid, Marketing Director Germany
Download PDF
Demo. Showcase: Tomorrow’s Technologies in action Today
Sang Shin, Simon Ritter, Sridhar Reddy, Carol McDonald, Philip Torchinsky, Joey Shen, Inyoung Cho
Sun Spot
Java EE, GlassFish and their Future
Daniel Adelhardt
Download PDF
Java SE 6 Top 10 Features, Java SE 7 and OpenJDK
Inyoung Cho
Download PDF
What Makes Solaris Interesting?
Frank Curran
Download PDF
Oracle Sponsor Session: Discover Oracle
Wolfgang Ehrenthaler
Download PDF
Easy Deployment: Leaner and Meaner Runtime
Simon Ritter
Download PDF
New Security Features in Solaris and OpenSolaris
Scott Rotondo
Download PDF
Sun Keynote – James Gosling
Download PDF
Java DB: The Multi-tier Database
Dag H. Wanvik
Download PDF
A Rich Application Platform: JavaFX
Sridhar Reddy
Download PDF
Building High Performance Applications on Multicore Systems Using Sun Studio Compilers and Tools
Vijay Tatkar
Download PDF
Solaris Virtualization for Systems Administrators
Philip Torchinsky
Download PDF
Rapid Development with Ruby, JRuby and Rails
Joey Shen
Download PDF
Real-time Java
Simon Ritter
Download PDF
Performance Tuning With Sun Studio Analyzer, Race Detection Tools, Dtrace (D-Light)
Boris Ivanovsky
Download PDF
Efficient System Administration Using Sun’s System Management Technologies
Juergen Fleischer
Download PDF
Developing Applications Using Spring and JPA
Eberhard Wolff
Download PDF
Effective Concurrency for the Java Platform
Sang Shin
Download PDF
Let SMF Deal With That
Detlef Drewanz
Download PDF
Java Persistence API: Further Simplifying Persistence
Simon Ritter
Download PDF
Isolating Performance Bottlenecks and Memory Leaks
Jaroslav Bachorik
Download PDF
Enterprise Database Inside: The PostgreSQL In Your Solaris
Paul van den Bogaard
Download PDF
Sun Community Keynote: Developing in a Polyglot World by Craig McClanahan
Download PDF
Ajax and Web 2.0 Related Frameworks and Toolkits
Carol McDonald
Download PDF
Programming for Cool Devices using the Open Source Java ME PhoneME Stack
Terrence Barr
Download PDF
ZFS – Using Its Full Potential
Uli Graef
Download PDF
Building Rich Web Applications using jMaki
Joey Shen
Download PDF
More Concurrency: The Ten Unofficial Laws
Heinz Kabutz and Kirk Pepperdine
Download PDF
NFS and pNFS: High Performance Shared Data Stores for HPC Applications
Guenter Herbert
Download PDF
AMS GmbH Sponsor Session: jBEAM – A Framework for Desktop and Web Based Analysis and Reporting Systems
Dr. Bernhard Sünder
Download PDF
OpenSolaris Testing
Joaquim Rosell &
Sean McGrath
Download PDF
AMD Sponsor Session: Optimizing for Quad-core Solaris Systems based on AMD platforms
Raj Kharran
Download PDF
Metro and REST: Everyday Web Services
Harold Carr and Carol McDonald
Download PDF
Web Services Security, OpenSSO and Access Management for SOA
Abdi Mohammadi
Download PDF
Intel Technical Session: What are we doing to optimize Solaris on Intel Architecture?
Download PDF
Java ME GUI Makeover with Ajax Mashup
Terrence Barr
Download PDF
Performance Tuning Applications: GC Friendly Java Programming
Simon Ritter
Download PDF
How to Develop Solaris Parallel Applications
Leonid Lenyashin
Download PDF
DTrace Web 2.0 Applications, JavaScript, PHP, Java and the SAMP Stack
Peter Karlsson and Philip Torchinsky
Download PDF
SOA Using OpenESB, BPEL and NetBeans
Armin Wallrab
Download PDF
Get Your Parallel Applications Onto The Grid With Sun Grid Engine
Guenter Herbert
Download PDF
|
Bad |
Good |
|
import java.lang.*; |
|
|
import java.util.*; import java.util.Scanner; |
import java.util.*; |
|
class MyClass extends Object { } |
class MyClass { } |
|
class MyClass { int i = 0; boolean b = false; char c = ‚\u0000‘; String s = null; double d = 0.0; } |
class MyClass { int i; boolean b; char c; String s; double d; } |
|
class MyClass { MyClass() { super(); } } |
class MyClass { MyClass() { } } |
|
interface MyInterface { public abstract void foo(); } |
interface MyInterface { void foo(); } |
|
void lollipop() { return; } |
void lollipop() { } |
|
java.lang.String s; |
String s; |
|
Object[] param = new Object[ 1 ]; param[ 0 ] = i; |
Object[] param = { i }; |
Something missing?
Details dazu gibt es hier: http://blogs.sun.com/jonathan/entry/winds_of_change_are_blowing
In den Java-Projekten haben sich unterschiedliche Verzeichnisstrukturen durchgesetzt. Je nach Komplexität ist eine einfache ausreichend oder eine starke Strukturierung gibt eine Vorgabe.
Eine einfache Vorgabe ist, die Order mit dem Quellcode und den übersetzten Klassendateien zu trennen. Die üblichen Ordnernamen für Java SE-Projekte sind src und bin. Entwicklungsumgebungen wie Eclipse übersetzten Java-Typen aus dem src- in den bin-Ordner und kopieren Ressourcen wie Bilder und Übersetzungsdateien bei jedem Build ebenfalls in den bin-Ordner. Eclipse unterstützte diesen Aufbau standardmäßig, wenn beim Dialog für ein neues Java-Projekt unter „Project Layout“ die Option „Create separate folders vor source and class files“ aktiviert ist.
Unter NetBeans ist die Standardstruktur etwas anders und eng mit dem Build-Tool Ant verbunden. Der Ordner src enthält die Standard-Klasen und Ressourcen, ein zweiter Ordner test die Test-Klassen und Ressourcen. Die übersetzten Java-Klassen nimmt der Ordner build/classes auf. Das Ergebnis des Builds, eine Jar-Datei im Fall eines einfachen Java-Projekts, steht im Ordner dist.
Einen deutlichen Schritt weiter geht die Anregung vom Build-Manager Maven. Es schlägt zwei Hauptordner src und target vor. Der src-Ordner enthält alle Quellen und Ressourcen und ein build übersetzt das Projekt in den target-Ordner. Maven empfiehlt, den src-Ordner weiter nach Artefakten zu unterteilen: main (eigentliche Applikation oder Bibliothek), test (Testfälle), demo (Beispiele). Unter diesen Artifakten-Ordnern folgenden weitere Unterordner. Der wichtigste Ordner ist für Java-Projekte java. Es kommen optional hinzu: ressources (für Ressourcen), config (Konfigurationsdaten), webapp (Dateien einer Web-Applikation). Für den Ausgabeordner target wiederum sieht Maven die Unterteilung in classes (übersetze Klassen aus src/main/java und Kopie aus src/main/resources), javadoc (Java-Doc von src/main/java), test-classes (Test-Klassen aus src/test/java und Kopie aus src/test/resources).
|
Library |
Uppercase Variant |
Lowercase Variant |
Special Case |
|
Java SE |
GZIPOutputStream |
ZipOutputStream |
HttpURLConnection |
|
DGC |
MidiSystem |
StAXSource |
|
|
AWTError |
JdbcRowSet |
|
|
|
HTML |
Clob, Blob, NClob |
|
|
|
ImageIO |
|
|
|
|
JAXBContext |
|
|
|
|
JMXConnector |
|
|
|
|
JPEGImageWriteParam |
|
|
|
|
PBEKey |
|
|
|
|
RMIClassLoader |
|
|
|
|
RSAKey |
|
|
|
|
SAXParser |
|
|
|
|
SOAPElement |
|
|
|
|
SQLException |
|
|
|
|
SSLContext |
|
|
|
|
UIDefaults |
|
|
|
|
URI, URL, PrinterURI |
ReferenceUriSchemesSupported |
|
|
|
Java EE |
XMLEvent |
XmlElement |
W3CDomHandler |
|
XMLOutputFactory |
XmlSchema |
|
|
|
XMLType |
XmlType |
|
|
|
EJB |
Xid |
|
|
|
ELResolver |
JspTag |
|
|
|
HTTPBinding |
HtmlMessage |
|
|
|
JAXBElement |
SqlResultSetMapping |
|
|
|
JDBCStats |
HttpServlet |
|
|
|
JMSSessionStats |
|
|
|
|
JVMStats |
|
|
|
|
SAAJResult |
|
|
|
|
SOAPBinding |
|
|
|
|
URIValidator |
|
|
|
|
XAConnection |
|
|
|
|
Spring |
MessageEOFException |
JmsException |
|
|
OC4JJtaTransactionManager |
JmxUtils |
|
|
|
SQLErrorCodes |
SqlCall |
|
|
|
SQLExceptionTranslator |
SqlFunction |
|
|
|
URIEditor |
UrlResource |
|
|
|
|
JndiRmiClientInterceptor |
|
|
|
|
JpaTemplate |
|
|
|
|
JstlView |
|
|
|
|
MimeMailMessage |
|
|
|
|
SimpleJaxWsServiceExporter |
|
|
|
|
XmlBeanFactory |
|
|
|
Apache Commons |
NTPUDPClient |
NtpUtils |
HttpURL |
|
FTPClient, POP3Client |
HttpClient |
|
|
|
SimpleSMTPHeader |
|
|
|
|
NTLMScheme |
|
|
|
|
RFC2965Spec |
|
|
|
|
URI |
|
|
What is your favourite example or inconsistent usage?
Werbung: Wir haben neue Java-Seminare!
Beautiful Code: Leading Programmers Explain How They Think
Andy Oram, Greg Wilson. O’Reilly. 2007. 618 Seiten
Bekannten Autoren und Software-Architekten geben in 33 Kapiteln viele Beispiele ihrer Kunst, und Einblicke in ihr Schaffen. Doch sehr spezielle Beispiele in diversen Programmiersprachen machen es für Java-Programmierer schwer, hier „schönen Code“ zu entdecken. Unter dem Strich bleibt nicht viel für Java-Entwickler über, wenn Programmiersprachen wie C, Ruby, LISP ihren Platz finden und Algorithmen vorgestellt werden, die für die allermeisten kaum relevant sind. Interessant ist es allemal, und wer sich viel Zeit für die Einarbeitung nimmt, wird auch sicherlich viel entdecken, zumal das Design einen größeren Stellenwert einnimmt, als der Quellcode an sich. Bei den wenigen Java-Programmen gibt leider etwas zu bemängeln. Einmal ein einfacher Fehler auf Seite Seite 478, in dem die Klammerung falsch ist:
class Sample {}
public static void main(String[] argv) {
System.out.println("Hello World");
}
Der zweite Hammer haut aber stärker rein und ist definitiv kein Beispiel für „Beautiful Code“. Seite 332 stellt eine EJB Session-Bean FileReaderBean vor, die über eine FileInputStream Daten vom Dateisystem holt – das ist nun wirklich nicht in Ordnung. Toll finde ich, dass die Erlöse an Amnesty International gehen: „All royalties from this book will be donated to Amnesty International.”. Das nette Kapitel Code in Motion ist online verfügbar.
Google Android ist der Versuch von Google, ein quelloffenes und freies SDK für mobile Endgeräte zu etablieren. Nach ein paar Monaten gibt es die ersten Stimmen aus dem Netz, die nicht so positiv sind. Insbesondere werden die mangelhafte Dokumentation (damit meine ich nicht die „FAQ“ http://code.google.com/android/kb/general.html), fehlende Beispiele und ein nicht öffentliches Issue/Bug-Tracking-System bemängelt. Interessant ist ebenfalls der Ansatz von Google, eine eigene JVM auszuliefern, um sich damit eventuell um Lizenzrechte rumzuwinden. Die Idee ist, den Java Quellcode zunächst über den Standard-Compiler in Java Bytecode zu übersetzen, aber dann über einen weiterer Präprozessor dx den JVM-Bytecode in das so genannte DEX-Format zu bringen, was die VM Dalvik dann ausführt. Dalvik ist etwas anders gebaut als die Standars-JVMs, denn es ist zum Beispiel eine Register-Maschine und keine Stack-Maschine. Ein weiteres Detail sind die Bibliotheken. Die Java Standard Library kommt vom Apache Harmony Projekt und ist somit Apache-Lizenz, genauso wie vieles von Android auch. (Das Betriebssystem unter der Haube ist Linux und somit GPL.)