background preloader


Facebook Twitter

How to Install Oracle Java JDK on Ubuntu Linux. OSGi Modularity. OSGi is a specification.

OSGi Modularity

The core of the OSGi specification defines a component and service model for Java. The components and services can be dynamically installed, activated, de-activated, updated and de-installed. Tuning and benchmarking Java 7's Garbage Collectors: Default, CMS and G1. Due to trouble in a project with long GC pauses, I just had myself a deeper look into GC details.

Tuning and benchmarking Java 7's Garbage Collectors: Default, CMS and G1

There is not that much acessible information/benchmarks on the Web, so I thought I might share my tests and enlightments ^^. Last time I tested GC some years ago I just came to the conclusion, that allocation of any form is evil in Java and avoided it as far as possible in my code. I will not describe the exact algorithms here as there is plenty of material regarding this. Understanding the algorithms in detail does not necessary help on predicting actual behaviour in real systems, so I will do some tests and benchmarks. The concepts of Garbage Collection in Hotspot are explained e.g. here.

The basic idea of multi generational Garbage Collection is, to collect newer ("younger") Objects more frequent using a "minor" (short duration/pause) Collection algorithm. Java. The java command starts a Java application.


It does this by starting a Java runtime environment, loading a specified class, and calling that class's main method. The method must be declared public and static, it must not return any value, and it must accept a String array as a parameter. The method declaration has the following form: public static void main(String[] args) By default, the first argument without an option is the name of the class to be called. How Can I monitoring java heap with jstat? Java - High Perm Generation and Low Old Generation. Where Has the Java PermGen Gone? The Java Virtual Machine (JVM) uses an internal representation of its classes containing per-class metadata such as class hierarchy information, method data and information (such as bytecodes, stack and variable sizes), the runtime constant pool and resolved symbolic reference and Vtables.

Where Has the Java PermGen Gone?

In the past (when custom class loaders weren’t that common), the classes were mostly “static” and were infrequently unloaded or collected, and hence were labeled “permanent”. Also, since the classes are a part of the JVM implementation and not created by the application they are considered “non-heap” memory. For HotSpot JVM prior to JDK8, these “permanent” representations would live in an area called the “permanent generation”. This permanent generation was contiguous with the Java heap and was limited to -XX:MaxPermSize that had to be set on the command line before starting the JVM or would default to 64M (85M for 64bit scaled pointers).

Bye, Bye PermGen, Hello Metaspace! Anonymous Classes (The Java™ Tutorials > Learning the Java Language > Classes and Objects) Anonymous classes enable you to make your code more concise.

Anonymous Classes (The Java™ Tutorials > Learning the Java Language > Classes and Objects)

They enable you to declare and instantiate a class at the same time. They are like local classes except that they do not have a name. Use them if you need to use a local class only once. Files (Java Platform SE 7 ) Walks a file tree.

Files (Java Platform SE 7 )

This method walks a file tree rooted at a given starting file. The file tree traversal is depth-first with the given FileVisitor invoked for each file encountered. File tree traversal completes when all accessible files in the tree have been visited, or a visit method returns a result of TERMINATE. Where a visit method terminates due an IOException, an uncaught error, or runtime exception, then the traversal is terminated and the error or exception is propagated to the caller of this method. For each file encountered this method attempts to read its BasicFileAttributes. Where the file is a directory, and the directory could not be opened, then the visitFileFailed method is invoked with the I/O exception, after which, the file tree walk continues, by default, at the next sibling of the directory.

Where the directory is opened successfully, then the entries in the directory, and their descendants are visited. How do I save a String to a text file using Java? Java Programmer Certification: Java SE 7 Certified Programmers. Bytearray - byte[] to file in Java. Java – How to get current date time – date() and calender() In Java, you can get the current date time via following two classes – Date and Calendar.

Java – How to get current date time – date() and calender()

And, later use SimpleDateFormat class to convert the date into a user friendly format. 1. Date() + SimpleDateFormat() DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");Date date = new Date();System.out.println(dateFormat.format(date)); //2014/08/06 15:59:48 2. DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");Calendar cal = Calendar.getInstance();System.out.println(dateFormat.format(cal.getTime())); //2014/08/06 16:00:22 Review a full example to show you how to use Date() and Calender() classes to get and display the current date time.

Java: How to get input from System.console() Demo connect to the database using jTDS. ReferenceJarFiles. Java - How to import a jar in Eclipse. Java - How can I generate an MD5 hash? MessageDigest (Java Platform SE 6) Java.lang.Object public abstract class MessageDigestextends MessageDigestSpi This MessageDigest class provides applications the functionality of a message digest algorithm, such as MD5 or SHA.

MessageDigest (Java Platform SE 6)

Bytearray - Convert InputStream to byte array in Java. Technology / Benefits of Using OSGi. OSGi reduces complexity by providing a modular architecture for today's large-scale distributed systems as well as small, embedded applications.

Technology / Benefits of Using OSGi

Building systems from in-house and off-the-shelf modules significantly reduces complexity and thus development and maintenance expenses. The OSGi programming model realizes the promise of component-based systems. The OSGi modular and dynamic model reduces operational costs and integrates multiple devices in a networked environment, tackling costly application development, maintenance and remote service management. The key reason OSGi technology is so successful is that it provides a very mature component system that actually works in a surprising number of environments.

OSGi quick start. OSGi has been looking promising for a long time, but I have felt that getting started have been really complicated and deploying dependencies have been messy, in particular for transitive dependencies.

OSGi quick start

While I was looking into deployment options for Apache Camel I realized that a lot has happened with OSGi since last I looked. Hello, OSGi, Part 1: Bundles for beginners. The Open Services Gateway Initiative (OSGi) defines an architecture for developing and deploying modular applications and libraries. In this first article in a three-part introduction to OSGi, Sunil Patil gets you started with OSGi development concepts and shows you how to build a simple Hello World application using the Eclipse OSGi container implementation, Equinox. He also touches briefly on building service-oriented applications using OSGi and introduces OSGi's ServiceFactory and ServiceTracker classes.

The Open Services Gateway Initiative (OSGi), also known as the Dynamic Module System for Java, defines an architecture for modular application development. OSGi container implementations such as Knopflerfish, Equinox, and Apache Felix allow you to break your application into multiple modules and thus more easily manage cross-dependencies between them. Building CXF REST Service in OSGi for Karaf. I’ll leave it to the experts to tell how awesome OSGi is. Among the many benefits, I could tell you why we picked up OSGi for a pet project - Modularity, avoiding JAR hell and dynamic updates (hey, why not?)

We chose Apache Felix (an OSGi framework specification implementation) and Apache Karaf (ummm, how do I put this - something like an app server for OSGi applications). Besides serving as an OSGi container, Karaf has a lot of awesome features (pun intended). And we like the idea of managing multiple Karaf instances managed through Zookeeper. Enough talk, let’s see some code. So, if the request is the response would be Hello, arun.

Apache FTP

Java. Formatting Numeric Print Output (The Java™ Tutorials > Learning the Java Language > Numbers and Strings) Earlier you saw the use of the print and println methods for printing strings to standard output (System.out). Since all numbers can be converted to strings (as you will see later in this lesson), you can use these methods to print out an arbitrary mixture of strings and numbers.

The Java programming language has other methods, however, that allow you to exercise much more control over your print output when numbers are included. The printf and format Methods The package includes a PrintStream class that has two formatting methods that you can use to replace print and println. These methods, format and printf, are equivalent to one another. System.out.format( The syntax for these two methods is the same: public PrintStream format(String format, Object... args) where format is a string that specifies the formatting to be used and args is a list of the variables to be printed using that formatting.

SimpleDateFormat (Java Platform SE 6) Combine paths in Java. Oracle Launches Project Valhalla for Java. Oracle have announced Project Valhalla for Java. This is an experimental OpenJDK project to develop major new features for Java that require both changes to the language syntax and VM-level support. Valhalla project lead Brian Goetz stressed that this is an early-stage experimentation project, and that the community should not necessarily expect any Valhalla technology to be available as part of JDK 9 (scheduled for 2016). The project is similar in intent to some existing OpenJDK projects such as Project Lambda and the DaVinci Machine project (which led to the invokedynamic functionality released in Java 7). One of the initial features being discussed for Valhalla is a major overhaul of Java's generics. Current versions of Java only allow generic types to contain reference types, and the Java compiler removes the detail of the contained type during compilation.

The other big feature currently proposed for Valhalla is value types.