0

I want to run a jar file on a ubuntu server without writing the full path. Therefore, I would like to edit the .zshrc. I would appreciate it if you could tell us how to set JAVA_HOME and PATH.

I am currently trying that with reference to this web site, but have been unsuccessful because I don't know how to get the path to the jdk. I am having trouble. https://www.ibm.com/docs/en/b2b-integrator/6.0.1?topic=variables-setting-java-linux

1 Answers1

0
# The next var an example path obvs.
export JAVA_HOME=/usr/lib/jvm/bellsoft-java16-amd64
export PATH=$JAVA_HOME/bin:$PATH
g00se
  • 3,207
  • 2
  • 5
  • 9
  • You might like to look at `update-java-alternatives` though – g00se Mar 17 '22 at 16:03
  • Thank you so much for your answer. How do I know what JAVA_HOME should be set to in my case? I wrote "which java" but could not know it. – mikasa nakamura Mar 17 '22 at 16:11
  • You should see that with `readlink -f $(which java)` Why do you think you need to set JAVA_HOME btw? Iust to be clear the value for JAVA_HOME would be the directory that contains bin normally. You should probably tell use what value you get from `readlink` – g00se Mar 17 '22 at 16:12
  • I have a file called trimmomatic.jar running on my ubuntu server. But to do that I have to write `java -jar ~anaconda3/share/trimmomatic-0.39-2/trimmomatic.jar`. I want to just write `java -jar trimmomatic.jar` to execute the file. – mikasa nakamura Mar 17 '22 at 16:19
  • That's not relevant to our discussion I'm afraid. The variables will have no bearing on the path to the jar – g00se Mar 17 '22 at 16:22
  • It was. So when we run the jar file, do we have to write the full path? – mikasa nakamura Mar 17 '22 at 16:25
  • Effectively yes. Obviously you could have a launcher or a script that would contain the path – g00se Mar 17 '22 at 16:27
  • The question has been answered. Thank you so much for your help. I will now learn more about launchers. – mikasa nakamura Mar 17 '22 at 16:33