Forum Stats

  • 3,752,487 Users
  • 2,250,508 Discussions
  • 7,867,852 Comments

Discussions

How to configure JRE?

ptoye
ptoye Member Posts: 72
edited Oct 5, 2011 2:14AM in New To Java
In a previous thread I was told that my Java 7 was wrongly configured. But I can find absolutely nothing in the documentation about configuring it.

What I want to do is to make sure that when I invoke it the java.net.preferIPv4Stack=true parameter is set without having to type (or, more usually, mistype) it each time.

Best Answer

  • tschodt
    tschodt Member Posts: 537
    Accepted Answer
    ptoye wrote:>
    I searched for "_JAVA_OPTIONS".
    Some of the results hint that the format needed would be something like -Djava.net.preferIPv4Stack=true but
    I had hoped there would be a link to some sort of
    Java tutorial which actually tells you how to configure the parameters without having to guess.
    tschodt wrote:
    Are you asking if specifying -Djava.net.preferIPv4Stack=true when launching Java sets the java.net.preferIPv4Stack parameter to true?
    1) No - even I'd have taken that as obvious.
    Can you devise a way to determine if specifying -Djava.net.preferIPv4Stack=true does what you want?
    2) No - I can find out what works by running my simple program.
    Can you devise a way to determine if adding -Djava.net.preferIPv4Stack=true to the JAVAOPTIONS env. var. does what you want?
    3) No - as (2). I've tried it and it doesn't work.
    It works fine for me, both on Windows and on Linux (as well as on Solaris).

    When I add -Djava.net.preferIPv4Stack=true to JAVAOPTIONS and run Java I get
    C:\>java -version
    Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
    java version "1.6.0_26"
    Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
    Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)
    How do you add -Djava.net.preferIPv4Stack=true to the JAVAOPTIONS env. var. ?

     
    I've also tried adding that string to the runtime parameters in the java configuration mechanism from the control panel.
    There are two contexts you configure env.vars for in the control panel; Java Applets and Java Webstart.
    This is only for Java applications launched in one of those contexts.
    But what is the syntax?
    The syntax of what? Where?
    That's why I'm asking if there's any form of tutorial or documentation on configuring Java.
    Once we establish what specific information you are looking for we can probably find plenty of tutorials that cover it.
    At this time I am still trying to determine exactly what information you are looking for.
    Obviously any help here in actually getting it to work is gratefully received. But the inability of Oracle (probably inherited from Sun) to provide what I'd have thought was fairly basic information is a bit discouraging.
    I cannot comment. Yet. I still don't know what information you are looking for.
    After all, they're in competition with MS and their Visual Studio products, and have to do better to compete.
    Are you talking about an IDE? Like eclipse or Netbeans (which are free)?
«13

Answers

  • tschodt
    tschodt Member Posts: 537
    You can use environment variables - the JVM reads these environment variables
    JAVAOPTIONS

    JAVA_TOOL_OPTIONS
    when you launch java.
    tschodt
  • ptoye
    ptoye Member Posts: 72
    Thanks very much. But I've done a search in the Oracle documentation and got:
    We did not find any search results for: "_JAVA_OPTIONS"

    (Who's this guy "We"?)

    Googling wasn't much help either.

    Any hints as to where to find this info? I'd have thought it was something in the Java FAQ at least.
  • gimbal2
    gimbal2 Member Posts: 11,949 Gold Trophy
    it is not really a good idea to configure anything through command line variables; for one your application won't work out of the box when run on another machine until the variables are added there as well.

    During development it is a good idea to use a tool like ANT to build and run your applications; ANT can also manage the command line parameters passed to the java executable and it makes the whole deal of building, testing and packaging an application easier as well - once you learn to use the tool of course, which is not entirely trivial. Next to ANT you also have Maven, which is an even more versatile tool that can also manage all application dependencies for you but it has an even steeper learning curve; be warned.

    When deploying your application it is good to create shell scripts that invoke the application in the way you need it to. Alternatively you could use a jar wrapper tool to create a native executable that does it. Yet another alternative is to use Java webstart. Whatever you do, you do not want people to have to learn specifics of Java or command prompt mechanics just to be able to run your stuff!
  • tschodt
    tschodt Member Posts: 537
    ptoye wrote:
    ... I've done a search in the Oracle documentation and got:
    ... did not find any search results for: "_JAVA_OPTIONS"

    Googling wasn't much help either.

    Any hints as to where to find this info?
    I'd have thought it was something in the Java FAQ at least.
    You say you searched, but you do not say what additional information you are looking for.
    What kind of results did Google return?
    How do these results differ from what you expected?
  • 802889
    802889 Member Posts: 105
    I am not 100% sure, but you might be able to set this in net.properties in the <jre>/lib folder
  • ptoye
    ptoye Member Posts: 72
    edited Sep 29, 2011 7:37AM
    (answering gimbal2)
    Well, my problem appears to be dependent on the computer configuration - if I switch off the firewall(Outpost) it works OK, but I don't do that for long. On the Outpost forum, users of the same firewall have had trouble with Java 7.and the blame seems to point towards Java rather than Outpost.

    But Netbeans can't communicate either, which is really serious. That's why I want a solution for my machine, not anyone else's.

    Edited by: ptoye on 29-Sep-2011 04:37
  • ptoye
    ptoye Member Posts: 72
    edited Sep 29, 2011 7:38AM
    (answering tschodt)
    I searched for "_JAVA_OPTIONS". Some of the results hint that the format needed would be something like -Djava.net.preferIPv4Stack=true but I'd hoped that there'd be a link there to some sort of Java tutorial which actually tells you how to configure the parameters without having to guess.

    Edited by: ptoye on 29-Sep-2011 04:38
  • ptoye
    ptoye Member Posts: 72
    edited Sep 29, 2011 7:38AM
    (Answering TheAvalanche)
    Hmmm. The first few lines say

    # For now, only the various proxy settings can be configured here.

    which isn't encouraging.

    Also, because Java is installed in the "program Files" folder no-one, not even an administrator, can edit it. Well done Microsoft. I don't have time now to deinstall Java, reinstall it in another folder and start all over again.

    Nice idea, though. Thanks.

    Edited by: ptoye on 29-Sep-2011 04:38
  • darke
    darke Member Posts: 138
    ptoye wrote:
    Also, because Java is installed in the "program Files" folder no-one, not even an administrator, can edit it.
    I doubt that .

    BTW , You can reply to specific posts using the Reply button.
  • 802889
    802889 Member Posts: 105
    ptoye wrote:
    (Answering TheAvalanche)
    Hmmm. The first few lines say

    # For now, only the various proxy settings can be configured here.

    which isn't encouraging.
    True
    Also, because Java is installed in the "program Files" folder no-one, not even an administrator, can edit it. Well done Microsoft. I don't have time now to deinstall Java, reinstall it in another folder and start all over again.
    An administrator can edit files in Program Files, but he will first need to start his editor using 'Run as Administrator' in the context menu of the application icon, and then open the file from within the editor.
This discussion has been closed.