Skip to main content Skip to local navigation

VPL & Java 17

In our first year programming class for engineering students, EECS 1021, we're using modern features like jShell and var. Unfortunately, the OS that our VPL instance sits on came with an older version of Java, so we've had to modify our scripts to point to the Java 17 JDK. If you get an error like this

---------
Utils.java:5: error: cannot find symbol
        var outputString = new String();
        ^
  symbol:   class var
  location: class Utils
1 error
Not compiled
The "var" keyword causes an error because we're using an old version of Java in VPL.

You should consider modifying your scripts to point to Java 17 (JDK17). You'll need the following files:

  1. the VPL Run file (the rocket icon): vpl_run.sh (update for JDK17 on EECS VPL server)
  2. The VPL Evaluate file (the check box icon): vpl_evaluate.sh (update for JDK17 on EECS VPL server)
  3. The sample student submission: Utils.java (contains the "var" keyword)
  4. The JUnit test suite: MyTest.java (no update needed)
  5. The Java file that glues VPL to the JUnit: Main.java (no update needed)
  6. The secret teacher solution: solution_its_secret.txt (no update needed -- identical to Utils.java).

In the end you should see that the student submission compiles and checks for a successful grade.

successful compilation and submission for grades for a Java 17 assignment with the "var" keyword.

As always, I'm grateful to Jason Keltz for supporting me through my awkward journey through VPL and Java!


Java lends itself well to the creation of student exercises in systems like VPL due to JUnit. I use this material from Jim Burton to create my JUnit material. And it's all based on work by an emeritus prof at Smith College (original pages are now gone). However, you may find this example to be a better fit.


a pen

James Andrew Smith is a Professional Engineer and Associate Professor in the Electrical Engineering and Computer Science Department of York University's Lassonde School, with degrees in Electrical and Mechanical Engineering from the University of Alberta and McGill University.  Previously a program director in biomedical engineering, his research background spans robotics, locomotion, human birth and engineering education. While on sabbatical in 2018-19 with his wife and kids he lived in Strasbourg, France and he taught at the INSA Strasbourg and Hochschule Karlsruhe and wrote about his personal and professional perspectives.  James is a proponent of using social media to advocate for justice, equity, diversity and inclusion as well as evidence-based applications of research in the public sphere. You can find him on Twitter. Originally from Québec City, he now lives in Toronto, Canada.