Adding Java home not working on windows ZSH - java

I have java installed and set up properly and works fine with the normal Windows Powershell. However, I'm trying to make java work with the ZSH terminal and I cannot get it to work.
My JAVA_HOME (in powershell) is set to this path:
C:\Program Files\Java\jdk-15.0.2
Im trying to add this line to my .zshrc file:
export JAVA_HOME=`/mnt/c/"Program Files"/Java/jdk-15.0.2`
but when i do source .zshrc it says permission denied to that file. Running sudo chmod doesnt seem to help either. Am i doing something wrong or missing some other line to add? Most tutorials for ZSH is on a Mac OS so i dont know if it differs being that im in windows...

The backticks are trying to "execute" that folder as a shell command.
Double quotes will store that variables as a string
export JAVA_HOME="/mnt/c/Program Files/Java/jdk-15.0.2"
But this doesn't guarantee that java command itself will work.

Related

How do I find where Java is installed on Windows 10?

I recently installed Java (Java Runtime 1.8.121) to my machine. I need to set up JAVA_HOME and set the variable from the Java folder where it installed.
Everywhere I have looked online says the Java folder should be located in Program files (x86), however, it is nowhere to be found. Its not in program files (x86), not in program files.
I wasn't able to choose a destination when it was installed as Software center was used. It simply completed the installation.
Can someone please help me find where the Java folder is so I can set up JAVA_HOME???!
cmd:
where java
git bash (same as cmd or):
which java
powershell:
(get-command java.exe).Path
Superuser: Equivalent of cmd's "where" in powershell
Open a command prompt
type: wmic product where "Name like '%%Java%%'" get installlocation,Name
This command can take a minute to complete. But should return something like this.
Edit: The benefit of this command, is that it doesn't rely on any system environment variables. It searches for installed programs that have the word 'Java' in the name. It won't return extra files or locations.

Eclipse unable to locate Java in Ubuntu

While I am trying to install the Payara server on my Ubuntu machine after putting the path of the Payara/glassfish server when I try to put the java location whatever i give as path is considered as error. I use Oracle java 10 and as I put the value "/usr/lib/java/jdk-10.0.1/" it says its not a jdk. Path for Java 10 has been properly set in ~/.bashrc as
export JAVA_HOME=/usr/lib/java/jdk-10.0.1/
export PATH="$PATH:JAVA_HOME/bin"
Why is this behaving in this way? Can anybody suggest me a way out.
try export PATH=$PATH:${JAVA_HOME}/bin
Your shell is interpreting JAVA_HOME as string, you forgot a $ before JAVA_HOME in the export PATH line to make it interpret as a variable.

Purpose of setting PATH variable for Java

I'm a complete noob and have been trying to set my mac to learn Java. I have installed JDK 10.0.1 and eclipse oxygen. I also successfully edited the JAVA_HOME variable to point to my jdk location using this:
Setting JAVA_HOME environment variable on MAC OSX 10.9
So far so good, I was able to run simple programs both on eclipse and on terminal ( was having trouble for a while because I couldn't run "HelloWorld" from terminal as it was under a separate package) after using the top answer from Running java in package from command line
However my friend later told me that if I wanted to run java programs from terminal, I'd need to edit PATH variable as it was where the os looks for executables. A lot of websites mentioned editing PATH as well. I ran echo $PATH and terminal outputted /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin.
So I'm really confused that if I haven't edit PATH, then why am i able to run commands like java or javac from terminal? The /usr/bin folder has java javac javadoc etc aliases inside it, could that be the reason?

JAVA_HOME not defined correctly

I am attempting to update Jasper Reports Server, and having an issue with Java. It uses Tomcat to run java. I did not install java on this server, and I am not very familiar with java. Java was installed in a folder called /opt/jasperreports-server-cp-5.0.0/apache-tomcat/java/bin/. I do not believe Java was installed correctly, and it is telling me that the JAVA_HOME is not defined correctly.
We cannot execute /opt/jasperreports-server-cp-5.0.0/apache-tomcat/java/bin/java
Java is located in that directory.
I ran the following in a bash shell:
export JAVA_HOME=”/opt/jasperreports-server-cp-5.0.0/apache-tomcat/java”
export PATH=$JAVA_HOME/bin:$PATH
Can you please help me on what I am doing wrong when setting the JAVA_HOME, or does it have something to do with the java folder? should I reinstall Java altogether?
You say the file /opt/jasperreports-server-cp-5.0.0/apache-tomcat/java/bin/java exists, right ?
Can you execute it ? Can it execute standard jar file ?
Maybe you do not have execute permission for anything inside the $JAVA_HOME path.
You should try using chmod to give execute permission (atleast to bin/java ) , though I would just give to all files. Example -
chmod -R +x /path/to/<folder>/
or for a single file
chmod +x /path/to/file
also, can you please try the export JAVA_HOME without the double quotes and check -
export JAVA_HOME=/opt/jasperreports-server-cp-5.0.0/apache-tomcat/java

command 'notepad' on cmd win7 only works in system32?

I just installed my jdk 8 . I wanna create a java in notepad, but the 'notepad' command doesn't work. it says 'notepad' isnt an operable program.
so, i tried to create the notepad by changing my directory first to system32 and i got the command works.
So, what happened here? and how to fix this? Bcs, in my old laptop I used to use the command in my User too, not only in system32.
sorry for bad eng
You probably messed up with the environment variable path. Go to Env Variables, path and then add C:\Windows\System32; to the beginning of the file
Check out this how-to to see how to set env variables on your OS

Categories

Resources