background preloader

Java

Facebook Twitter

Java theory and practice: Dealing with InterruptedException - www.ibm.com (HTTP) This story is probably familiar: You're writing a test program and you need to pause for some amount of time, so you call Thread.sleep().

Java theory and practice: Dealing with InterruptedException - www.ibm.com (HTTP)

But then the compiler or IDE balks that you haven't dealt with the checked InterruptedException. What is InterruptedException, and why do you have to deal with it? The most common response to InterruptedException is to swallow it -- catch it and do nothing (or perhaps log it, which isn't any better) -- as we'll see later in Listing 4. Unfortunately, this approach throws away important information about the fact that an interrupt occurred, which could compromise the application's ability to cancel activities or shut down in a timely manner.

Blocking methods When a method throws InterruptedException, it is telling you several things in addition to the fact that it can throw a particular checked exception. A blocking method is different from an ordinary method that just takes a long time to run. Igor Minar's Blog: How a Java Application Can Discover its Process ID (PID) - blog.igorminar.com (HTTP) Occasionally it is important for an application to know its PID, specially if this application cooperates with other non-java applications.

Igor Minar's Blog: How a Java Application Can Discover its Process ID (PID) - blog.igorminar.com (HTTP)

Currently there is no direct support for retrieving an application's process id by using standard Java api (this might change in the future if RFEs like 4250622, 4244896 or 4890847 are resolved). I found five ways how to get the PID from my Java code: Using the java management and monitoring API (java.lang.management): ManagementFactory.getRuntimeMXBean().getName();returns something like: 28906@localhost where 28906 is the PID of JVM's process, which is in fact the PID of my app.This hack is JVM dependent and I tested it only with Sun's JVM.From Javadocs for getName() method of RuntimeMXBean: Returns the name representing the running Java virtual machine.

The returned name string can be any arbitrary string and a Java virtual machine implementation can choose to embed platform-specific useful information in the returned name string. Howto:column_spanning [SwingWiki] In an equaly distributed table, a single cell is an intersection of a single row and a single column.

howto:column_spanning [SwingWiki]

However, for design purposes, it is often convenient to use group table column headers (above a sequence of cells), and sometimes several vertical cells are containing the same data, so they can be merged into one single large cell. Word processing and spreadsheet software usually uses terms like “merged cells” for joined cells, and in HTML terminology, merged cells are often denoted by column-spanning and row-spanning. We will use HTML terminology here, since it is more precise and takes into account a difference betweek horizontal (column) and vertical (row) merging. Column spanning is a HTML cell property that defines how much “logical” columns a table cell contains.

Source Code Analysis Using Java 6 APIs. Have you ever thought of how tools like " or " perform a static code analysis, or how Integrated Development Environments (IDEs) like NetBeans or " execute quick code fixes or find the exact references of a field declared in your code?

Source Code Analysis Using Java 6 APIs

In many cases, IDEs have their own APIs to parse the source code and generate a standard tree structure, called an Abstract Syntax Tree (AST) or "parse tree," which can be used for deeper analysis of the source elements. The good news is that it is now possible to accomplish the said tasks plus a lot more with the help of three new APIs introduced in Java as part of the Java Standard Edition 6 release. The APIs that might be of interest to developers of Java applications that need to perform source code analysis are the " Compiler API (JSR 199), the " Annotation Processing API (JSR 269), and the " Tree API. [/prettify] Let us go on and analyze this class as part of the build process with the help of these three APIs.

Plugging In the Annotation Processor. Reflecting generics. Code by Any Other NameReflecting genericsby Ian RobertsonJune 23, 2007 Summary Type arguments to generic classes are not available for reflection at runtime - or are they?

Reflecting generics

The type arguments for statically declared types can be discovered at runtime. A look at how to do this, and why you might want to. Probably the most common complaint about generics in Java is that they are not reified - there is not a way to know at runtime that a List<String> is any different from a List<Long>. I've gotten so used to this that I was quite surprised to run across Neil Gafter's work on Super Type Tokens. Super type tokens are a nice trick to distinguish between types which have the same raw type, but different type arguments. Java Generics FAQs - Frequently Asked Questions. All text and content found at URLs starting with (collectively, "the Java Generics FAQ") are the sole property of Angelika Langer.

Java Generics FAQs - Frequently Asked Questions

Copyright @ 2004-2019 by Angelika Langer . All rights reserved. Except as specifically granted below, you may not modify, copy, publish, sell, display, transmit (in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise), adapt, distribute, store in a retrieval system, create derivative works, or in any other way use or exploit the contents of the Java Generics FAQ, without the prior consent of the author. All rights, titles and interest, including copyrights and other applicable intellectual property rights, in any of the material belongs to the provider of the material. You do not acquire proprietary interest in such materials by accessing them on my web site. In particular, I do NOT grant permission to copy the Java Generics FAQ or any part of it to a public Web server.

UnboundID LDAP SDK for Java. LDAP SDK for Java Getting Started with the UnboundID LDAP SDK for Java The UnboundID LDAP SDK for Java is a powerful, user-friendly, pure Java library for interacting with LDAP directory servers.

UnboundID LDAP SDK for Java

It contains a full-featured API that may be used to communicate with any LDAPv3 directory server, as well as additional enhanced functionality for performing additional operations when interacting with the UnboundID Directory Server. UnboundID SDK. My experiments with technology. My earlier post covered in-built annotations supported by Java 5.

My experiments with technology

Today we will look at developing custom java annotations on our own. Let’s begin by defining our own custom java annotation called Documentation. The definition of the annotation class is as below: The only difference between an interface definition and that of an annotation is the presence of @ before the interface keyword. Now the annotation can have its own members. Below are the general guidelines to be followed while defining annotations: Annotation declaration should start with an ‘at’ sign like @, following with an interface keyword, following with the annotation name.Method declarations should not have any parameters.Method declarations should not have any throws clauses.Return types of the method should be one of the following:primitivesStringClassenumarray of the above types Let’s look at how the custom annotation Documentation can be used.

The annotation member elements can be set to have default values. Glazed Lists. Java Parallel Processing Framework. Learning ANTLR part I - Blogs at Near Infinity. Design Patterns. Debugging Swing, the final summary. Posted by alexfromsun on February 16, 2006 at 11:49 AM PST It's taken some time to study all possible ways of detecting Event Dispatch Thread rule violations, and now I feel I this topic is about to be closed.

Debugging Swing, the final summary

But let me tell from the beginning: ThreadCheckingRepaintManager I was really surprised when I got to know about the smart solution invented by Scott Delapwho created a RepaintManager which finds EDT mistakes, I started to play with it and noticed that Note: Please take the latest version of the ThreadCheckingRepaintManager from the SwingHelper project. Generics Tutorial. Oracle Technology Network > Java Software Downloads View All Downloads Top Downloads.

Generics Tutorial

10 things you need to know about Java 6. Need a digest, summary, compressed form, precis of what's up with Java SE 6 'Mustang', currently in beta ? Here it is, the top 10 things you need to know. 1. Web Services All developers get first class support for writing XML web service client applications. No messing with the plumbing, you can expose your APIs as .NET interoperable web services with a simple annotation. 2. Java 7 features. You are here: Home / Java 7 This page lists the proposed features in Java 7 and information about them. Writing Javadoc comments. Javadoc Home Page This document describes the style guide, tag and image conventions we use in documentation comments for Java programs written at Java Software, Oracle. It does not rehash related material covered elsewhere: For reference material on Javadoc tags, see the Javadoc reference pages. For the required semantic content of documentation comments, see Requirements for Writing Java API Specifications.

Java memory tuning tips. Speaking the Java language without an accent. Learning a new programming language is easier than learning a new spoken language. But, in both endeavors, it takes extra effort to learn to speak the new language without an accent. It isn't that hard to learn the Java language when you already know C or C++; it's similar to learning Danish when you already speak Swedish. The languages are different, but mutually comprehensible. However if you aren't careful, your accent will reveal you as a nonnative speaker every time. Java Platform SE 6. H2 SQL Grammar. Derby Reference Manual.

API docs

Libraries.