SOLVED

How to introduce Java commands into PowerShell on Linux platform.

Copper Contributor

As shown in the following figure, I can't use Java commands in PowerShell on Linux platform. How to set PowerShell to use Java commands on Linux platform.

QQ截图20220404235337.png

3 Replies
best response confirmed by fsq2018 (Copper Contributor)
Solution

@fsq2018 The Java program is perhaps not in your path? If you do a write-host $env:PATH, what does it show you? If the path in which Java is located is missing, then you can add it to your Powershell profile by running nano $profile and adding and restart PowerShell to load the adjusted profile:

 

$env:Path += "/path/to/java"

 

I think the path should be in your ~/.bash_profile as JAVA_HOME? 

@Harm_Veenstra 

Thank you for your reply. I tried $env: path and found that there was no Java path,
while in my ~/.bash_profile file, there is a Java path
fsq2018_0-1649134229986.png

 

Then I modified the powershell profile file

 

 

$env:path+="/home/fang/.jdk/bin" ​

 

 

fsq2018_1-1649134229988.png

 

then I finally found that it work out.
 
fsq2018_2-1649134229989.png

 

 
In Windows it automatically takes the path settings into the powershell session, in Linux it's different so it seems. Good to hear that this works
1 best response

Accepted Solutions
best response confirmed by fsq2018 (Copper Contributor)
Solution

@fsq2018 The Java program is perhaps not in your path? If you do a write-host $env:PATH, what does it show you? If the path in which Java is located is missing, then you can add it to your Powershell profile by running nano $profile and adding and restart PowerShell to load the adjusted profile:

 

$env:Path += "/path/to/java"

 

I think the path should be in your ~/.bash_profile as JAVA_HOME? 

View solution in original post