Dan O'Sullivan
Dan O'Sullivan

Reputation: 1

Running Java programs in Notepad++

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?

Upvotes: 0

Views: 1450

Answers (2)

ichsanSandi
ichsanSandi

Reputation: 1

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

Upvotes: 0

Albert Pinto
Albert Pinto

Reputation: 402

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.

Upvotes: 1

Related Questions