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).

1  
import java.util.*;
2  
import java.lang.management.ManagementFactory;
3  
4  
class main {
5  
  public static void main(final String[] args) {
6  
    System.out.println(fullVMArguments());
7  
  }
8  
  
9  
  static String fullVMArguments() {
10  
    String name = javaVmName();
11  
    return (contains(name, "Server") ? "-server "
12  
      : contains(name, "Client") ? "-client " : "")
13  
      + joinWithSpace(vmArguments());
14  
  }
15  
16  
  static List<String> vmArguments() {
17  
    return ManagementFactory.getRuntimeMXBean().getInputArguments();
18  
  }
19  
  
20  
  static boolean contains(String s, String b) {
21  
    return s != null && s.indexOf(b) >= 0;
22  
  }
23  
  
24  
  static String javaVmName() {
25  
    return System.getProperty("java.vm.name");
26  
  }
27  
  
28  
  static String joinWithSpace(Collection<String> c) {
29  
    return join(" ", c);
30  
  }
31  
  
32  
  public static String join(String glue, Iterable<String> strings) {
33  
    if (strings == null) return "";
34  
    StringBuilder buf = new StringBuilder();
35  
    Iterator<String> i = strings.iterator();
36  
    if (i.hasNext()) {
37  
      buf.append(i.next());
38  
      while (i.hasNext())
39  
        buf.append(glue).append(i.next());
40  
    }
41  
    return buf.toString();
42  
  }
43  
}

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: 563 / 1205
Referenced in: [show references]