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?

2

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.