0

I am creating an application where I need java jdk to be installed.

So I want to create a detection function for jdk in system and if not found then install it by the setup which i will provide and also store it Environment Variables -> System variables as JAVA_HOME C:\Program Files\Java\jdk1.x.y.z by default.

I searched through lot but not getting exact idea how will I achieve this.

14
  • This question is a bit confusing. Are you wanting to use JavaScript and Angular to do this? Commented Oct 4, 2018 at 10:23
  • Is there any reason about tagging javascript and angularjs here? This seems to be java-related, rather than javascript-related. Commented Oct 4, 2018 at 10:26
  • @PeterMellett yes, that's correct . I need Angular javascript/javascript function to achieve this. Commented Oct 4, 2018 at 10:27
  • @briosheje This is angular app. I want to do the task using javascript function. Commented Oct 4, 2018 at 10:28
  • Do you mind expanding your question a little? How are you running your angular app? Commented Oct 4, 2018 at 10:28

1 Answer 1

0

I need to know more about your app, which Angular or Nodejs as the backend of your app and if angular then you need to use ironic or some similar hybrid technology for accessing system level permission like installing software and updating Environment Variables. If you are using NODEJS as backend then you can use exec to execute system command and also you can install your JDK with silent installation refer the link

Sign up to request clarification or add additional context in comments.

3 Comments

Ok . I am using Node.JS as backend. I have an idea of child_process . silent installation will only install silently. I need to set the path also in Environment variables automatically. First search jdk ,if found then skip, not found install silently and put it in Environment Variable.
The MSDN documentation for environment variables tells you what to do: To programmatically add or modify system environment variables, add them to the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment registry key, then broadcast a WM_SETTINGCHANGE message with lParam set to the string "Environment". This allows applications, such as the shell, to pick up your updates. You will of course need admin rights to do this. I know of no way to broadcast a windows message from Windows batch so you'll need to write a small program to do this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.