Compile and run Eclipse Java projects from Linux terminal

If you are developing a Java project in Eclipse under a linux system, you may want to remote access the project from another location. You can remote desktop the linux box by using teamviewer, but sometimes that can be very slow. You can also edit, compile and execute your Java project from a regular ssh terminal. Using terminal to edit, compile and run your remote eclipse project is often faster. This post shows you how to compile and run eclipse project in terminal.

Read more

6 Interesting Ideas from Research Papers about Java

There are a lot of research papers related with Java. If we type “Java programming”, there are more than a million result in Google scholar. Some papers are very theoretical, some seem to be practical. I recently found some ideas are pretty interesting, so I collect them and create a list. These papers are from world top software engineering conferences.

Read more

LeetCode – Power of Four (Java)

Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Java Solution 1 – Naive Iteration public boolean isPowerOfFour(int num) { while(num>0){ if(num==1){ return true; }   if(num%4!=0){ return false; }else{ num=num/4; } }   return false; }public boolean isPowerOfFour(int num) { while(num>0){ if(num==1){ return true; } … Read more

LeetCode – Coin Change (Java)

Given a set of coins and a total money amount. Write a method to compute the smallest number of coins to make up the given amount. If the amount cannot be made up by any combination of the given coins, return -1.

For example:
Given [2, 5, 10] and amount=6, the method should return -1.
Given [1, 2, 5] and amount=7, the method should return 2.

Read more

LeetCode – Self Crossing (Java)

Analysis This problem can be easily solved if the three self crossing cases are summarized well. Here are the three self crossing cases. There are no other self crossing situations based on the restrictions of counter-clockwise. Java Solution Writing the solution is straightforward once the 3 self crossing cases are identified. public boolean isSelfCrossing(int[] x) … Read more

LeetCode – House Robber III (Java)

The houses form a binary tree. If the root is robbed, its left and right can not be robbed. Analysis Traverse down the tree recursively. We can use an array to keep 2 values: the maximum money when a root is selected and the maximum value when a root if NOT selected. Java Solution public … Read more

LeetCode – Counting Bits (Java)

Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array. Example: For num = 5 you should return [0,1,1,2,1,2]. 1. Naive Solution We can simply count bits for each number like … Read more