Analyzing Java Problems – Tools, Snippets and Workflows

When we need to investigate the cause for a dysfunctional Java application we have a plethora of tools available that on the one hand help us in gathering information, artifacts and statistics and on the other hand help us in processing this information and identifying possible problems. The following list of tools, snippets, workflows and information about specific artifacts could provide a starting point for analyzing such problems and covers topics like heap-dumps, thread-dumps, heap-histograms, heap-regions, garbage-collection-logs, hotspot-compiler/codecache-logs, debugging native-memory, tools for heap-dump-analysis, JVM unified logging and more.. ...

April 30, 2018 · 26 min · 5513 words · Micha Kops

Java EE: Logging User Interaction the Aspect-Oriented Way using Interceptors

Using dependency injection and aspect-oriented mechanisms like interceptors allow us to separate cross-cutting-concerns in our Java enterprise application, to control global aspects of our application and to avoid boilerplate code. In the following short tutorial we’re going to create an aspect-oriented logger to protocol the initiating user, class and method called and the parameters passed to the method and finally we’re adding this interceptor to a sample RESTful web-service by adding a simple annotation. ...

May 26, 2014 · 6 min · 1275 words · Micha Kops

First steps on Android: Creating a simple Todo App

In this tutorial we are going to build a simple todo app that is able to store simple todos in a database. The user is able to add new todos or delete old ones by clicking on a todo. For this tutorial we won’t use maven to keep it simple – if maven integration is desired – take a look at this tutorial. Steps Create a new android project using the Android SDK and your IDE Create some packages com.hascode.android.activity and com.hascode.android.persistence Create the layout in res/layout/main.xml – the main elements: a listview for the todos-list, a textbox and a button to enter new data. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:id="@+id/widget31" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" > <TableRow android:id="@+id/row" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_below="@+id/tasklist" android:layout_alignParentLeft="true" > <EditText android:id="@+id/etNewTask" android:layout_width="200px" android:layout_height="wrap_content" android:text="" android:textSize="18sp" > </EditText> <Button android:id="@+id/btNewTask" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@+string/add_button_name" > </Button> </TableRow> <ListView android:id="@+id/tasklist" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" > </ListView> </RelativeLayout> ...

April 26, 2010 · 5 min · 1056 words · Micha Kops

Java Snippets

Remote Debug a Pod’s Java Process Simple steps for remote debugging a Java process running on a k8 pod: Edit deployment and add the following parameters to the Java start line: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=127.0.0.1:5005 Also add the following port mapping at the section container → ports in the deployment: - containerPort: 5005 protocol: TCP Safe, wait for the new pods and then add a port forward for port 5005 for this pod: kubectl port-forward podname 5005 ...

March 1, 2010 · 13 min · 2583 words · Micha Kops