Skip to main content


Showing posts from June, 2011

Resources in NetBeans project and Maven project

For Maven project:

While the Java source files sit under src/main/java, all resources must be under src/main/resources

For NetBeans project:

resources sit under  src/main/java

If you plan to migrate an existing NetBeans project to Maven,

The resources folder may be created outside the IDE, or inside it from the Files tab (under src/main). Then move your resource files to the new folder.

Java EE

You can start without Java EE or other similar framework like .NET, Spring, Guice, or even systems such as CICS, but you will have to implement the concurrency, transactions, locking, sessions on your own. It’s likely that the end result will be more complex, than a full-blown Java EE solution. If you understand the concepts of distributed computing and know the challenges, Java EE becomes suddenly a breeze. Instead of coding, you can mostly rely on the provided defaults or confgure the desired behavior declaratively. In addition you will gain with Java EE vendor independence. Your business logic will be clearly separated from infrastructure, which can be provided by (as of summer 2009) thirteen certifed application servers and even the Spring framework itself.
-- from <<Real World Java EE Patterns Rethinking Best Practices>> by Adam Bien

Add new disk to Centos

fdisk -l

list the disk

fdisk /dev/sdb

suppose /dev/sdb is what you want to add.
Command (m for help): p
Command (m for help): n
Command (m for help): w

mkfs -t ext3 /dev/sdb1

Format the new partition, suppose you want to format
sdb1 to ext3

mkdir /disk2
Add the following line into fstab.

/dev/sdb1 /disk2 ext3 defaults 0 1
for adding to LVM, refers to this link

Sample code to call python script from java

public static void main(String[] args) throws IOException {

try {
Runtime r = Runtime.getRuntime();
Process p = r.exec("python3.2");
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));

while (br.ready()) {

} catch (Exception e) {
String cause = e.getMessage();
if (cause.equals("python: not found")) {
System.out.println("No python interpreter found.");