By default, jp@gc - WebDriver Sampler has javascript as a Script Language.
As soon as I switch to java, I get this error message.  
ReferenceError: "ImportPackage" is not defined in at line number 2.
I use JMeter 3.2 and Java 1.8.
There is a bug in the WebDriver Sampler plugin, you can report it via JMeter Plugins support forum. For the time being there is no fix so currently you have the following options:
ImportPackage function while Nashorn JavaScript Engine which comes with JDK8 doesn't. With nashorn, importPackage is not defined by default. But, you can eval the following line to get few Rhino compatibility features:
load("nashorn:mozilla_compat.js");
See also: https://wiki.openjdk.java.net/display/Nashorn/Rhino+Migration+Guide