0N/A/*
2362N/A * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A */
0N/A
0N/Aimport javax.management.remote.rmi.RMIJRMPServerImpl;
0N/Aimport javax.management.remote.rmi.RMIServer;
0N/A
0N/Apublic class ImplVersionCommand {
0N/A
0N/A public static void main(String[] args) throws Exception {
0N/A
0N/A // Create RMIJRMPServerImpl
0N/A //
0N/A System.out.println("Create RMIJRMPServerImpl");
0N/A RMIServer server = new RMIJRMPServerImpl(0, null, null, null);
0N/A
0N/A // Get the JMX Remote impl version from RMIServer
0N/A //
0N/A System.out.println("Get JMX Remote implementation version from RMIServer");
0N/A String full_version = server.getVersion();
0N/A System.out.println("RMIServer.getVersion() = "+ full_version);
0N/A String impl_version = full_version.substring(
0N/A full_version.indexOf("java_runtime_")+"java_runtime_".length());
0N/A
0N/A // Display JMX Remote impl version and Java Runtime version
0N/A //
0N/A System.out.println("JMX Remote implementation version = " +
0N/A impl_version);
0N/A System.out.println("Java Runtime implementation version = " +
0N/A args[0]);
0N/A
0N/A // Check JMX Remote impl version vs. Java Runtime version
0N/A //
0N/A if (!impl_version.equals(args[0])) {
0N/A // Test FAILED
0N/A throw new IllegalArgumentException(
0N/A "***FAILED: JMX Remote and Java Runtime versions do NOT match***");
0N/A }
0N/A // Test OK!
0N/A System.out.println("JMX Remote and Java Runtime versions match.");
0N/A System.out.println("Bye! Bye!");
0N/A }
0N/A}