import java.util.*; import java.lang.management.ManagementFactory; class main { public static void main(final String[] args) { System.out.println(fullVMArguments()); } static String fullVMArguments() { String name = javaVmName(); return (contains(name, "Server") ? "-server " : contains(name, "Client") ? "-client " : "") + joinWithSpace(vmArguments()); } static List vmArguments() { return ManagementFactory.getRuntimeMXBean().getInputArguments(); } static boolean contains(String s, String b) { return s != null && s.indexOf(b) >= 0; } static String javaVmName() { return System.getProperty("java.vm.name"); } static String joinWithSpace(Collection c) { return join(" ", c); } public static String join(String glue, Iterable strings) { if (strings == null) return ""; StringBuilder buf = new StringBuilder(); Iterator i = strings.iterator(); if (i.hasNext()) { buf.append(i.next()); while (i.hasNext()) buf.append(glue).append(i.next()); } return buf.toString(); } }