How to configure a Tomcat cluster on Ubuntu

Apache Tomcat is the most popular open-source Java web server. If your web site is expecting more traffic as your business grows, a single instance of Tomcat will probably not scale with the growing traffic. In that case, you might be thinking to run Tomcat in a “clustered” environment, where web server workload is distributed […]
Continue reading…

 

How to fix Android SDK Content Loader stuck at 0% in Eclipse

Have you encountered the case where Eclipse hangs upon startup, in particular when you are developing an Android application with Android SDK? When that happens, you would see “Android SDK Content Loader” stuck at 0% at the Eclipse status bar in the right bottom area. There can be a variety of reasons for that, and […]
Continue reading…

 

How to create .deb Debian package for Java web application

Suppose you have built a Java web application as a Java servlet. Now you want to create .deb Debian package for the Java web application, such that when you install the .deb package file, it will automatically install any prerequisite packages (e.g., Java and Tomcat web server), and deploy the Java servlet on Tomcat. I […]
Continue reading…

 

How to find which jar file a Java class belongs to

Suppose you have multiple jar files, and want to know which jar file contains a given Java class definition. This kind of situation can arise when you are dealing with “NoClassDefFoundError” in your Java program. The JAR (Java ARchive) format is built on ZIP file format, so in order to check what Java class definitions […]
Continue reading…

 

How to save console output to a file in Eclipse

When you are running/debugging an application in Eclipse, output or any logging information of your application is sent to the console. While you can check Eclipse console box for diagnosis and debugging, the Eclipse console can only preserves the last bit of program output/logs, not the entire history. So if your program generates a huge […]
Continue reading…

 

How to call Octave from Java

If you need to perform sophisticated numerical mathematics or data analysis in Java, you may consider offloading some of needed computation to Octave program, which is equipped with extensive libraries of numerical, statistical and graphics algorithms. Then the question is how can you interface with an external Octave program from within Java? One straightforward way […]
Continue reading…

 

How to convert List to Array in Java

Suppose you are maintaining a list of objects using List (i.e., List<Object>), and want to convert it into an array of objects (i.e., Object[]). How would you convert List to Array in Java? To do that, you can in general take advantage of List.toArray(), which returns Object[], an array of all the elements in the […]
Continue reading…

 

How to use spaces instead of tabs for indentation in Eclipse

In Eclipse, you can auto-indent your code, so that your code can be formatted effortlessly. By default, Eclipse inserts 4-space wide tabs for indentation. While no one questions the importance of indentation for clean programming, there’s a never-ending debate on whether to use spaces or tabs for indentation. Some folks prefer spaces to tabs or […]
Continue reading…