For Linux when you download the JDK using http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html.
Goto Run > Debug > Debug (Edit configuration) > Default > TestNG > JRE (set up the location where you have downloaded the file)