Massive Open Online Courses (MOOCs) is a new online possibility of education with the help of reading materials, video lectures and tests. Online coding exercises are essential in computer programming courses. For students, it is important to receive rapid feedback on their coding submissions and there is an automatic grader that is responsible for evaluating source-code submissions. This paper presents a technique based on the Java unit testing framework that allows automatic grading of code chunks and the concepts and further techniques for grading Java code submissions. The paper also presents the system architecture, components, and security considerations of our grading system. Further possibilities of the grading system, are also discussed, like coding style recognition and encourage using coding standards.