Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

43
LINES

< > BotCompany Repo | #1012389 // Test fullVMArguments (slimming for Stack Overflow)

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (43L/1K).

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<String> 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<String> c) {
    return join(" ", c);
  }
  
  public static String join(String glue, Iterable<String> strings) {
    if (strings == null) return "";
    StringBuilder buf = new StringBuilder();
    Iterator<String> i = strings.iterator();
    if (i.hasNext()) {
      buf.append(i.next());
      while (i.hasNext())
        buf.append(glue).append(i.next());
    }
    return buf.toString();
  }
}

Author comment

Began life as a copy of #1012388

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

-
Snippet ID: #1012389
Snippet name: Test fullVMArguments (slimming for Stack Overflow)
Eternal ID of this version: #1012389/1
Text MD5: b07c7983bb2e23e475210b4618ac1701
Transpilation MD5: b07c7983bb2e23e475210b4618ac1701
Author: stefan
Category: javax
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-11-29 14:10:28
Source code size: 1171 bytes / 43 lines
Pitched / IR pitched: No / No
Views / Downloads: 562 / 1204
Referenced in: