How do I install [Bash on Ubuntu on Windows] [environment variables] from [path window]?

Try using samza.apache.org/startup/hello-samza/0.7.0/ with Bash On Windows

it will work

bin/grid bootstrap

      

where is the current code

if [ -z "$JAVA_HOME" ]; then
  if [ -x /usr/libexec/java_home ]; then
    export JAVA_HOME="$(/usr/libexec/java_home)"
  else
    echo "JAVA_HOME not set. Exiting."
    exit 1
  fi
fi

      

give an error

JAVA_HOME not set. Exiting.

      

on CMD when I run

echo %JAVA_HOME%

      

I got

C:\Program Files (x86)\Java\jdk1.8.0_102\

      

I want to import path data into Bash

enter image description here

+5


source to share


2 answers


I would try export JAVA_HOME="/mnt/c/Program Files (x86)/Java/jdk1.8.0_102"

setting the JAVA_HOME variable in the bash shell.

Update (response to edit):



I would not recommend to automatically import Windows paths to bash in Ubuntu on Windows because the paths must be converted to be understood by bash shells ( \

to /

, C:\

before mnt/c/

, etc.), and because not all tools you are likely to going to link will work on both Windows and Linux. Instead, install what you need in the bash shell using apt-get

(you don't need to use sudo

because BUW loads in the root shell). Java is probably fine for links like above, but most of the things you want to install are separate on Ubuntu.

+4


source


As a quick solution, I created a powershell script which

  1. Take all windows environment variables
  2. Change the path separator to /

  3. Change C:

    to/mnt/c

  4. Outputting commands to export

    one line per environment variable

    Get-ChildItem Env: | % {"export $($_.Name)='"$($_.Value.Replace('\', '/').Replace('C:', '/mnt/c'))'""}
    
          



Now all you have to do is run this script in Powershell, copy the output and paste it into WSL / Ubuntu for Windows to populate the environment variables. You can also put all these commands in a file .sh

and execute it with bash.

This is a rough solution, but it worked for me. I'm open to suggestions for improving this.

0


source







All Articles