AZ,
This seems to be turning more and more into questions about Java then how to use NetBeans. But I will help you, so if you check the documentation located at:

        https://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html

which states that the "public Map<String,String> environment()" API :

"Returns a string map view of this process builder's environment. Whenever a process builder is created, the environment is initialized to a copy of the current process environment (see System.getenv()). Subprocesses subsequently started by this object's start() method will use this map as their environment.

The returned object may be modified using ordinary Map operations. These modifications will be visible to subprocesses started via the start() method. Two ProcessBuilder instances always contain independent process environments, so changes to the returned map will never be reflected in any other ProcessBuilder instance or the values returned by System.getenv."

So the value for the map (i.e. the context variable from the code below) will have the value of the environment variable "PROMPT". I am not sure why you are checking whether it is a string. By definition of the variable context it will always be a string. If the value of context is null, then it will no be a string but it is not the correct way to check to see if the variable is null. It just needs to check if context is not null (i.e. "if (context != null)") then the environment variable "PROMPT" exists.

Note #1: Further discussion on Java related issues should be moved to another mailing list/sub reddit/IRC channel/etc community. Note #2: This is feeling more and more like you are asking us to help you with your computer programming homework.


Paul Franz
Senior Principal Applications Engineer
Oracle Transportation Management
Phone #: 1-610-729-3347
Skype Id: PaulPFranz

On 19 Sep 2018, at 3:50, A Z wrote:

I am using the following to try and determine some more
execution context:

     ProcessBuilder builder = new ProcessBuilder();

     Map<String,String> map = builder.environment();

     String context = map.get("PROMPT");

     if(context instanceof String)

     //...

The only thing that I have been able to discern is that you have the

PROMPT

key if you are running from the command line, whereas
if you are testing inside Netbeans, that key does not appear.

What I can't work out is what the environment Key value is
if I am double clicking on a successfully self executing .jar file.
Is anyone associated with this mailing list able to tell
me what the key value is then?


Reply via email to