0

I looked up how to run java programs within the notepad++ using the Nppexec plugin. I use the following script to change to the current directory, compile and run the program:

cd $(CURRENT_DIRECTORY)
javac $(FILE_NAME)
java $(NAME_PART)

The code compiles fine, however I get a number of errors when it tries to run. These were the errors I got when I tried to run a simple Hello World java program:

java.lang.UnsupportedClassVersionError: Hello : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Exception in thread "main" <<< Process finished. (Exit code 1)

I do have Java JDK installed on my computer and I can run all programs externally. Can anyone help me fix this?

xcoder
  • 1,336
  • 2
  • 17
  • 44
  • You are using an old Java version, see for example http://stackoverflow.com/questions/22489398/unsupported-major-minor-version-52-0 – osundblad Oct 12 '15 at 22:00
  • Use force, Luke: https://www.jetbrains.com/idea/download/ – ursa Oct 12 '15 at 23:11

2 Answers2

1

From the exception (Unsupported major.minor version 52.0 )it seems you compiled your code using a version of java and you are trying to execute the java class with a different version.

Albert Pinto
  • 392
  • 2
  • 6
  • 17
0

That's because you compile and run with a different version of JDK/JRE (different versions of javac and java on the script).

on cmd, you might check it with

> where java
> where javac
> java -version
> javac -version

It is well explained here