Testing is very important and time consuming in the development of high-quality software systems. This paper proposes an automatic testing tool JUTA for unit testing of Java programs. The approach is based on sharp analysis of the programs. JUTA firstly employs the Java optimization framework Soot to parse a single Java method into byte code and translates it into a control flow graph (CFG). It then performs depth-first or breadth-first search on the CFG to extract paths from it. Some techniques such as path length restriction are used to prevent path number explosion. Finally JUTA analyzes the paths based on the combination of symbolic execution and constraint solving. The goal of path analysis lies in two folds. It can generate a set of test cases satisfying the test criterion such as statement coverage. The test set typically has small number of test cases that are all executable. In addition to test generation for dynamic testing, it can also be used in static testing. JUTA can reveal certain kinds of errors from the source code automatically if the user provides proper assertions to describe the errors. The experimental results show that this tool is efficient for both dynamic and static testing.