Code Monkey home page Code Monkey logo

Comments (3)

JuicyDragon avatar JuicyDragon commented on June 28, 2024

Hello @chrishaupt, I believe the way Nuix Workstation (the GUI) gets around not having to have the OS Path environment variable include every installed version of Nuix is by setting the Path environment variable for the JVM process started up by nuix_app.exe.

For example, if you start Nuix Workstation and then run the following Ruby script in the script console:

# Get environment variable "Path"
puts java.lang.System.getenv("Path").gsub(";","\n")

You should see output similar to the following:

C:\Program Files\Nuix\Nuix 9.2\bin
C:\Program Files\Nuix\Nuix 9.2\bin\amd64
C:\Program Files\Nuix\Nuix 9.2\bin\x86
C:\Program Files\Nuix\Nuix 9.2\jre\bin
C:\Program Files\Nuix\Nuix 9.2\jre\bin\server
C:\Python39\Scripts\
C:\Python39\
C:\WINDOWS\system32
C:\WINDOWS
etc...

If I then open a command prompt and echo the same variable using:

ECHO %path%

I instead get a listing without the Nuix path entries:

C:\Python39\Scripts\
C:\Python39\
C:\WINDOWS\system32
C:\WINDOWS
etc...

You see that while from the perspective of the running Nuix Java process those path values are present, the OS doesn't have them. So I believe nuix_app.exe is doing the following:

  1. Start JVM process which runs the Nuix main method
  2. Inject into the Path environment variable of that JVM process the relevant additional path entries

The way I might approach this is by writing a similar executable that starts up my JVM/Nuix engine process. I rather like C#/.NET so below here is a snippet that demonstrates the general concept in C#/.NET using the Process class:

// The paths you have decided to add through whatever means, such as
// a little GUI that user selects version they want to run against
string[] additionalPaths = new string[] {
    "D:\engine-releases\9.0.1.325\bin",
    "D:\engine-releases\9.0.1.325\bin\x86",
};

Process engineProcess = new Process();

// The executable to execute
engineProcess.StartInfo.FileName = "C:\Path\To\java.exe";

// The arguments provided to executable above, things like class path, fully qualified name of class
// with static main method, maybe even Nuix specific arguments, etc
engineProcess.StartInfo.Arguments = "-classpath \"D:\\engine-releases\\9.0.1.325\\lib\\*;.\\*\" com.nuix.javaenginesimple.examples.BasicInitializationExample"

// Any additional process configuration you may want to set
engineProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
engineProcess.StartInfo.CreateNoWindow = true;

// Perhaps additional configuration such as standard out and standard error redirection, etc...

// Modify the "Path" environment variable of only the JVM process we are about to start
for (string additionalPath in  additionalPaths) {
    engineProcess.EnvironmentVariables["Path"] += ";"+additionalPath;
}

// Start the process
engineProcess.Start();

from nuix-java-engine-baseline.

chrishaupt avatar chrishaupt commented on June 28, 2024

Thank you for this in depth answer! I thought about starting my applikation via batch script (SET Path/to/Bin). But your idea is much more convenient.

from nuix-java-engine-baseline.

JuicyDragon avatar JuicyDragon commented on June 28, 2024

Hello @chrishaupt, I wanted to add that the batch file approach can work in a similar manner by using SETLOCAL and ENDLOCAL commands, which allows you to localize the modifications to environment variables to just between those 2 commands. I've used both approaches (C#/.NET and batch file) to temporarily set environment variables NUIX_USERNAME and NUIX_PASSWORD to temporarily provide NMS credentials when running a script headless via nuix_console.exe.

from nuix-java-engine-baseline.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.