I have an application that's built in grails 2.1
My environment variables are set to point to JAVA 8 and Grails 3.8 along with the path.
I am aware of the fact that grails 2.1 has support upto Java 6. But I donot want to make changes to my environment variables in order to make it point to Java 6.
So I tried to set home and path for java 6 and grails 2.1 via command line. I was successful in doing so and echoe %JAVA_HOME%
, %GRAILS_HOME%
and %PATH%
did show that values were set correctly.
Trying to run the app with grails run-app
command from under the project's root directory throws below error :
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/grails/cli/GrailsCli : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.grails.cli.GrailsCli. Program will exit.
I tried to write a batch script that would set the %JAVA_HOME%
, %GRAILS_HOME%
and %PATH%
to Java 6 and Grails 2.1 specific locations and then execute "grails run-app" from under the project's root directory, but while executing the script I got the same above error.
Below is how my batch script looks like:
set JAVA_HOME=C:\Softwares\Java\Java-6\jdk1.6.0_41
set PATH=%PATH%;%JAVA_HOME%\bin
set GRAILS_HOME=C:\Softwares\Grails\Grails_2.1.0
set PATH=%PATH%;%GRAILS_HOME%\bin
cd /D C:\MyWorkspace\MyApplication
grails run-app
REM pause
I have never written a batch script before.So, please correct me where possible.
Also, as for some restrictions in place I do not have the freedom of installing SDKMan.
Any guidance in this regard is greatly appreciated.
It seems you have to set environment variable in front of the existing PATH setting:
set PATH=%JAVA_HOME%\bin;%PATH%;
This will lookup at the first match (the wanted version)}
Also, make sure you are using the exact same version of compile