Autograding Java code for computer science assignments
Guides
April 26, 2021

Webinar: How to automatically grade Java code and code quality

In 30 seconds...

After the success of our previous webinar on Python Autograding, we answered the many requests to cover all ins and outs of Java Autograding in a webinar too. This Java Autograding webinar was part of our monthly focus groups (on April 23rd of 2021) and can be watched on demand now!

Creating a basic autograded Java assignment in CodeGrade

In the first part of this webinar, CodeGrade's founder and product expert Devin Hillenius discusses ways to design your basic autograded Java assignments in CodeGrade. He goes over three aspects: hand in requirements for Java, compiling Java code and I/O tests for Java.

  • Hand In Requirements are an important aspect of all CodeGrade assignments, but especially for the large projects with specific directory structure you have for Java assignments. Three tactics are discussed: denying all files and specifying the files you want in the root of the submission, allowing all files and denying any class files and denying all files and requiring specific folder structures (e.g. `src/com/codegrade/Class1.java`). A useful tip mentioned in the webinar is to turn off the "Delete leading directories" option for Java submissions in which folder structures are important.
  • Compiling Java code can be done in AutoTest in two ways, either in the per-student setup script or in a separate test. Doing it in the per-student setup script has the benefit that the compiled files are available in all categories, whereas in a separate test you can actually grade the compilation step too. An attentive viewer mentioned that these do not have to exclude each other, and that you can simply grade a compilation step by checking if the compiled files are present or not.
  • Finally, some easy Input and Output tests (I/O tests) are set up for our Sudoku Solver assignment.
Save time by autograding your Java assignments now!

Autograding Java Code Quality

Code Quality autograding is discussed in the second part of the webinar. The Code Quality steps in CodeGrade allow you to very easily use powerful tools to assess student code. In this webinar, Devin explains not only how you can use these powerful tools, but also how you can design your own style guide with custom messages, so that you can use these powerful tools in a very meaningful way that suits your class, your learning goals and the level of your students.

Two linters are discussed:

  • Checkstyle is a static code analysis tool to assess Java code. This tool can be used to check the presentation or "style" of code, and whether that conforms to the style guide you have set up or enforce. It does not check for actual correctness or completeness of code.
  • PMD, or Programming Mistake Detector, is a cross-language source code analyzer that works not only for Java, but also for JavaScript, XML and many other languages and frameworks. It does not detect bad presentation or style, but looks at code structures: inefficient code, bad programming habits and overcomplicated expressions.

Devin discusses many rules and checks that are very suitable for education, or specific courses, and shows how you can use them in your own custom style guide. The examples in this webinar are not meant as an exhaustive list, but rather as inspiration for your own style guide considerations for education. A separate blog on Code Quality in Java, with these lists, will be published on our website soon.

Advanced Java Autograding in CodeGrade

Finally, some more advanced ways of grading Java code are briefly shown. These topics have also been discussed in previous blogs or documentation:

This webinar and article point you in the right direction to set up your own automatic tests for your Java programming assignments. Of course, the possibilities with CodeGrade's AutoTest are endless. Would you like to learn more about setting up Java automatic grading for your code exercise? Feel free to email me at support@codegrade.com and I’d be more than happy to help out!

Devin Hillenius

Devin Hillenius

Co-founder, Product Expert
Devin is co-founder and Product Expert at CodeGrade. During his studies Computer Science and work as a TA at the University of Amsterdam, he developed CodeGrade together with his co-founders to make their life easier. Devin supports instructors with their programming courses, focusing on both their pedagogical needs and innovative technical possibilities. He also hosts CodeGrade's monthly webinar.

Continue reading

Teaching Intro to Python with CodeGrade

The CodeGrade Introduction to Python course is an 8-week basic Python course. Students are not required to have any prior knowledge on programming or Python. This course will cover the basic concepts of programming up to Python specific modules and OOP design. It is available for all instructors now.

New release CodeGrade QuietStorm.1!

Find out about all the features and updates coming with our latest release, QuietStorm.1!

New release CodeGrade QuietStorm.1!

Automatically grading Haskell code assignments

Learn about autograding Haskell coding assignments for Computer Science education courses. CodeGrade can help you use tools like input and output checking, Quickcheck, Tasty and HUnit unit test autograding, HLint code quality checking and code structure autograding using semgrep.

Top tips for teaching programming

The most efficient ways to teach students how to code, by defining your target audience, designing your assignments in a meaningful way and eliminating distractions in the classroom.

Top tips for teaching programming

Learn more about CodeGrade!

Grow your coding classroom
without compromise.