Sample Java Code To Enable Graceful Shutdowns from the Windows Control Panel Is Failing To Compile (Doc ID 1304405.1)

Last updated on FEBRUARY 11, 2017

Applies to:

Oracle Weblogic Server - Version: 10.3.3 and later   [Release: and later ]
Information in this document applies to any platform.

Symptoms

The Weblogic Server documentation on Enabling Graceful Shutdowns suggests writing some Java code that will help to shut down the WLS Admin Server gracefully. However, when trying to compile the provided Java class it fails as follows:

D:\oracle\Middleware>javac ServerStopper.java
ServerStopper.java:7: package weblogic.jndi does not exist
import weblogic.jndi.Environment;
^
ServerStopper.java:8: package weblogic.management does not exist
import weblogic.management.MBeanHome;
^
ServerStopper.java:9: package weblogic.management does not exist
import weblogic.management.WebLogicMBean;
^
ServerStopper.java:10: package weblogic.management.configuration does not exist
import weblogic.management.configuration.ServerMBean;
^
ServerStopper.java:11: package weblogic.management.runtime does not exist
import weblogic.management.runtime.ServerRuntimeMBean;
^
ServerStopper.java:12: package weblogic.management.runtime does not exist
import weblogic.management.runtime.ServerStates;
^
ServerStopper.java:13: package weblogic.management does not exist
import weblogic.management.WebLogicObjectName;
^
ServerStopper.java:17: cannot find symbol
symbol : class MBeanHome
location: class ServerStopper
MBeanHome home = null;
^
ServerStopper.java:23: cannot find symbol
symbol : class ServerRuntimeMBean
location: class ServerStopper
ServerRuntimeMBean serverRuntime = null;
^
ServerStopper.java:29: cannot find symbol
symbol : class URL
location: class ServerStopper
URL[] urls = { new File("/").toURL() };
^
ServerStopper.java:29: cannot find symbol
symbol : class File
location: class ServerStopper
URL[] urls = { new File("/").toURL() };
^
ServerStopper.java:31: cannot find symbol
symbol : class URLClassLoader
location: class ServerStopper
URLClassLoader(urls));
^
ServerStopper.java:33: cannot find symbol
symbol : class Environment
location: class ServerStopper
Environment env = new Environment();
^
ServerStopper.java:33: cannot find symbol
symbol : class Environment
location: class ServerStopper
Environment env = new Environment();
^
ServerStopper.java:38: cannot find symbol
symbol : class MBeanHome
location: class ServerStopper
home = (MBeanHome)
^
ServerStopper.java:44: cannot find symbol
symbol : class ServerRuntimeMBean
location: class ServerStopper
serverRuntime = (ServerRuntimeMBean)mbeanIterator.next();
^
ServerStopper.java:45: cannot find symbol
symbol : variable ServerStates
location: class ServerStopper
if(serverRuntime.getState().equals(ServerStates.RUNNING)){
^
17 errors

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms