What to do if you try to start GlassFish and it becomes java.lang.UnsupportedClassVersionError: org / glassfish / admin / cli / AsadminMain: Unsupported major.minor version 51.0

--Environment - Windows10 64bit - GlassFish : 4.1.2

I was angry when I tried to launch GlassFish.

$ /c/app/glassfish-4.1.2/glassfish4/glassfish/bin/asadmin
java.lang.UnsupportedClassVersionError: org/glassfish/admin/cli/AsadminMain : 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.glassfish.admin.cli.AsadminMain. Program will exit.
Exception in thread "main"

Cause: The Java version did not match.

This is because the “jar” is compiled with JDK 1.7, but you try to run in a JDK 1.6 environment. Java : Unsupported major.minor version 51.0

I didn't run the jar ... I thought, and when I opened asadmin.bat, the jar was running properly.

REM Always use JDK 1.6 or higher
REM Depends on Java from ..\config\asenv.bat
VERIFY OTHER 2>nul
setlocal ENABLEEXTENSIONS
if ERRORLEVEL 0 goto ok
echo "Unable to enable extensions"
exit /B 1
:ok
call "%~dp0..\config\asenv.bat" 
if "%AS_JAVA%x" == "x" goto UsePath
set JAVA="%AS_JAVA%\bin\java"
goto run
:UsePath
set JAVA=java
:run
%JAVA% -jar "%~dp0..\lib\client\appserver-cli.jar" %*

Java at that time was ...

$ java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

Is it because of your mind? I feel like it says Always use JDK 1.6 or higher in asadmin.bat.

Workaround: Make java version 1.7 or higher

I changed JAVA_HOME to 1.8. If you cannot switch Java successfully on Windows 7, please refer to here.

$ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

Try to start GlassFish again.

$ /c/app/glassfish-4.1.2/glassfish4/glassfish/bin/asadmin start-domain domain1
Attempting to start domain1.... Please look at the server log for more details.....

The message I was expecting was ``` Command start-domain executed successfully.` `` It wasn't like, so I couldn't start it: I was impatient with: interrobang :, but when I looked at http: // localhost: 4848, it started. It was. FireShot Capture 1 - GlassFish Console - Common Tasks - http___localhost_4848_common_index.jsf.png

Recommended Posts

What to do if you try to start GlassFish and it becomes java.lang.UnsupportedClassVersionError: org / glassfish / admin / cli / AsadminMain: Unsupported major.minor version 51.0
What to do if you get Application with name appName is already registered. When you try to start GlassFish
What to do if you get a java.io.IOException in GlassFish
What to do if you install Ubuntu
When I tried to start GlassFish, I got an internal error while "Publishing to GlassFish 4.0 on localhost ...". What to do when it becomes
What to do if you get an "A server is already running." Error when you try to start the rails server
What to do if you push incorrect information
What to do if you accidentally create a model
What to do if you enable UFW on Ubuntu VM on GCP and you can't connect to SSH
What to do if you installed Ruby with rbenv but the version does not change
What to do when it becomes Unable to find CDI BeanManager.
# What to do if you accidentally do rails db: migrate: drop
What to do if you can't use the rails command