This discussion is archived
1 2 Previous Next 15 Replies Latest reply: Jul 27, 2012 3:32 PM by rp0428 RSS

JVM properties from command line

800839 Newbie
Currently Being Moderated
Hi,

Is there anyway we can find the JVM properties from command line?

Thanks.
  • 1. Re: JVM properties from command line
    aksarben Journeyer
    Currently Being Moderated
    If you mean "find JVM properties that were set on the command line," System.getProperties() will tell you the current system properties. Of course, this is NOT the same as a program's command line arguments, which will be found in String array passed to main().
  • 2. Re: JVM properties from command line
    800839 Newbie
    Currently Being Moderated
    Thanks. Is there any possibility of getting the JVM properties from the command prompt using JVM command like jstat or etc?
  • 3. Re: JVM properties from command line
    EJP Guru
    Currently Being Moderated
    What JVM properties are you talking about? Java System properties?
  • 4. Re: JVM properties from command line
    800839 Newbie
    Currently Being Moderated
    Yes, I am talking about the system properties. How we can get that through command line.
  • 5. Re: JVM properties from command line
    sabre150 Expert
    Currently Being Moderated
    797836 wrote:
    Yes, I am talking about the system properties. How we can get that through command line.
    I don't understand this. The Java system parameters only exist within a running Java program and can be set on the command line that executes the program.
  • 6. Re: JVM properties from command line
    gimbal2 Guru
    Currently Being Moderated
    sabre150 wrote:
    797836 wrote:
    Yes, I am talking about the system properties. How we can get that through command line.
    I don't understand this. The Java system parameters only exist within a running Java program and can be set on the command line that executes the program.
    So creating a small java application that simply System.outs the system properties that exist at that point in time would be an answer to this dubious question I guess :/
  • 7. Re: JVM properties from command line
    DrClap Expert
    Currently Being Moderated
    gimbal2 wrote:
    So creating a small java application that simply System.outs the system properties that exist at that point in time would be an answer to this dubious question I guess :/
    I suppose so. That might be a reasonable guess at what it means to "get (something) through the command line" but of course the OP is free to provide an English translation at any time. Anyway here's the code I use to do that:
    Properties sys = System.getProperties();
    sys.list(System.out);
    Apologies for the verbosity, I know it could be reduced to 1 line of code, but I just cut it and pasted it from a larger piece of code.
  • 8. Re: JVM properties from command line
    BIJ001 Explorer
    Currently Being Moderated
    However the System properties include besides the ones set in the command line also the preset, predefined ones like file.separator, user.dir, user.home, user.name etc.

    http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html
  • 9. Re: JVM properties from command line
    gimbal2 Guru
    Currently Being Moderated
    DrClap wrote:
    Properties sys = System.getProperties();
    sys.list(System.out);
    Apologies for the verbosity, I know it could be reduced to 1 line of code, but I just cut it and pasted it from a larger piece of code.
    Mother of god, you doubled the amount of code! Boo! Hiss!
  • 10. Re:  doubled the amount of code!
    BIJ001 Explorer
    Currently Being Moderated
    doubled the amount of code!
    If the code size is measured in the number of lines. More subtle size measurements are also conceivable.

    Once in the past we got a new boss who introduced an exact measurement for the programmers' efficiency based on the statistics taken from the cvs (Concurrent Versioning System) repository.

    Soon the colleagues began to comment out whole code blocks and reintroduce them instead of simply modifying them. Thus the number of the code lines changed by them skyrocketed.

    There was a nice guy there. During his studies, he used to be the system & network administrator at a hostel for students of the electrical engineering faculty at the technical university. We feel it must have been a nice job. We plain programmers used Linux as desktop OS, but he used Solaris: even good old Linux was not good enough for him. (Windows? Naturally out of question!) I put up a big fight with our chief until I persuaded him to allow the Exchange server's supporting the standard (non-proprietary) mailing protocols, so that we were able to use the mailing infrastructure from our Linux and his Solaris boxes albeit without the calendar functions.

    Well, this guy was an expert for difficult technical questions, he engineered the site-wide single-sign-on system etc. When he perused a piece of code, he shrank it by eliminating obsolete methods, by refactoring parallel ones etc. His measured output was negative...
  • 11. Re:  doubled the amount of code!
    gimbal2 Guru
    Currently Being Moderated
    BIJ001 wrote:
    doubled the amount of code!
    If the code size is measured in the number of lines.
    Yeah I knew that one was coming the moment I hit submit ;)
    His measured output was negative...
    So he was canned? The manager saw the light? Hell froze over? Don't end on a cliffhanger, if you tell a story then provide the juicy bits too! :)
  • 12. Re: JVM properties from command line
    DrClap Expert
    Currently Being Moderated
    BIJ001 wrote:
    However the System properties include besides the ones set in the command line also the preset, predefined ones like file.separator, user.dir, user.home, user.name etc.

    http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html
    Yes, I know that. I was answering one possible English translation of the OP's question. It would be possible to ask a clear question which specified whether all of the system properties were required, or only the ones specified on the command line, but miraculously the OP still hasn't done that.
  • 13. Re: Yes, I know that.
    BIJ001 Explorer
    Currently Being Moderated
    Yes, I know that.
    My remark was meant for the OP.
    Whereas there is ground to assume you do, there is not forcibly one to assume the OP does.
  • 14. Re:  Don't end on a cliffhanger
    BIJ001 Explorer
    Currently Being Moderated
    So he was canned? The manager saw the light?
    It would be interesting to know it indeed.
    The sorrowful truth is that I left that shop (not independently from these things) and did not become witness how things evolved further...
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points