Webstorm desktop launcher - java

I'm trying to get a working desktop launcher for Webstorm (applicable to any JetBrains product, however.) I've tried using the built-in menu "Add desktop launcher" in both Xubuntu and Lubuntu with no dice.
Running ./webstorm.sh from a terminal in the application's folder works fine.
If I add the option to the .desktop file to run in terminal I get an error message:
ERROR: cannot start WebStorm.
No JDK found. Please validate either WEBIDE_JDK, JDK_HOME or JAVA_HOME environment variable >points to valid JDK installation.
Press Enter to continue.
If I open a terminal and do javac -version I get a response, indicating my path is set correctly.
What gives? I am baffled as to what I'm doing wrong.

Set JAVA_HOME in your ~/.profile like this:
export JAVA_HOME=/usr/lib/jvm/java-7-oracle/
Then restart your system (or just X-Windows using sudo /etc/init.d/gdm restart).

Related

"No JDK found. Please validate ...JAVA_HOME...."-message with desktop launcher in ubuntu but works in shell

I recently installed android-studio on my machine (ubuntu 16.04). After configurating my .bashrc file (JAVA_HOME is also set there), it starts in in my shell.
I also wanted to create a launcher on my desktop, so i created a androidstudio.desktop file in ~/.local/share/applications/.
Here is my .desktop entry:
[Desktop Entry]
Type=Application
Name=AndroidStudio
Exec=/home/<path to android-studio>/bin/studio.sh
Icon=/home/<path to android-studio>/bin/studio.png
Terminal=false
Categorie=Development
The icon appears on my desktop but when I launch android-studio now, I get the following Error:
No JDK found. Please validate either STUDIO_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation.
You can set environment variables for your .desktop entry, see r.g. https://askubuntu.com/a/144971
TL;NR:
Exec=env JAVA_HOME=/usr/local/java /home/<path to android-studio>/bin/studio.sh

why jdk on centos not work

I install jdk on my centos in my vmware.
I put whole folder in the directory /usr/local/java,and set the environment varable in the file /etc/profile like this:
export JAVA_HOME=/usr/local/java
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:$JAVA_HOME/bin
And then I type into "source /etc/profile".After that I execute java -version,it's ok.But when I open another terminal the command java -version didn't work again.why?
One reason could be that your profile needs to be read/exec. Try to logout and log back in. That should do the trick.
Or use command "source"

javac not reconigzed for Jenkins Windows batch command

Not sure what the issue is here but javac is not recognized when I try to compile a java file. I am assuming I need a special plugin for this or I am required to use apache ANT but not too sure.
cd src
javac HelloWorld.java
'javac' is not recognized as an internal or external command,
operable program or batch file.
java HelloWorld
Error: Could not find or load main class HelloWorld
In Jenkins goto Manage Jenkins -> Configure System , scroll down to JDK installations and click the ADD JDK button.
I recommend trying the Install Automatically option, and let it install a fresh copy and give it a name you can recognize in project setting like jdk8_update51, and agree to the license.
In each project check that the JDK Setting is the correct version.
In windows batch command text box, you may want to add
echo "PATH is:"
echo %PATH%
echo "JAVA_HOME is:"
echo %JAVA_HOME%
javac -version
If this fails as above, try :
eg.
set PATH="C:\Program Files\Java\jdk1.8.0_31\bin"
javac -version
should print the following in Console Output:
javac 1.8.0_31
Note: "C:\Program Files\Java\jdk1.8.0_31\bin" should have the file javac.exe in it.
For Resolving this issue Go to :
Jenkins --> Manage Jenkins --> Global tool configuration.
You can add the full path JAVA_HOME there or click on "install automatically" for automatically downloading the Java.
I just tried this and issue is resolved now.
Thanks to Stackoverflow as well !!
Select "Manage Jenkins" and then "Configure System" on the Dashboard.
On the screen that opens, there is the "Environment variables" section. The tick next to it is marked. Then click the "Add" button. The «name» and «path» fields that appear after this marking are filled by entering the java-jdk path as in the image. Then click "Apply" and "Save" to complete the process.
That's all. I hope this will fix your problem. :)
**This solution can use for all similar command errors for python,maven, etc. **

Cannot locate java installation error for logstash

I downloaded Logstash-1.5.0 on Windows 8.1 and tried to run it in the command prompt.
First I checked the java version.
Then changed the directory to logstash-1.5.0/bin
then entered the command logstash -e 'input { stdin { } } output { elasticsearch { host => localhost } stdout { } }' it gave the following error:
Cannot locate java installation, specified by JAVA_HOME
The Logstash folder is on C: and the version of Java is 1.7.0_25. I've set the JAVA_HOME environmental variables to the jdk /bin directory, but still it doesn't work.
I'm new to Logstash. Can somebody tell me in detail why this happens and help me fix it?
Set the JAVA_HOME and PATH environmental variables like this:
JAVA_HOME = C:\Program Files\Java\jdk1.7.0_25
PATH = C:\Program Files\Java\jdk1.7.0_25\bin
In my case the problem was that I set the JAVA_HOME variable with a space in the end:
"set JAVA_HOME=c:\Programs\Java "
instead of
"set JAVA_HOME=c:\Programs\Java"
And logstash couldn't figure that out :) Removing the space fixed the issue.
On Windows when you change environment over the system settings, you have to close and reopen the command shell, before the changes take effect.
Step by step:
Locate your java JRE installation directory you want to use. For example: "C:\Program Files\Java\jre7"
Open start menu right click computer and select settings. In System settings window on right side click on "Extended Systemsettings".
On Tab extended select environment variables, add your JAVA_HOME variable to your path and hit OK.
Open command shell and check environment by entering "set" and hit enter. Look if JAVA_HOME is set.
If your JAVA_HOME is now correctly set, logstash should work.

How to set JAVA_HOME environment variable on Mac OS X 10.9?

I just purchased a brand new MacBook Pro.
This is my first MAC ever and I'm still trying to get the hang of navigating my way around.
Anyway, I'm also new to Java and I've been practicing on my Windows PC before it permanently died.
Now that I'm on this MAC, I installed my JDK and now I need to set the JAVA_HOME environment variable.
I have no idea what to do.
I tried following some of these guides and didn't get very far.
Mkyong.com : How to set JAVA_HOME variable in Mac OSX
YouTube : How to set environment variables on mac, linux, solaris, rhel
YouTube : How to Set Environment Variables in Mac
I was able to locate the terminal and I think I created some multiple files. I'm getting messages like this:
(1) Another program may be editing the same file.
If this is the case, be careful not to end up with two
different instances of the same file when making changes.
Quit, or continue with caution.
(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r /Users/Erwin/.bash_profile"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file "/Users/Erwin/.bash_profile.sw p"
to avoid this message.
Can somebody tell how to set Java in Mac OSX environment step by step?
If you're using bash, all you have to do is:
echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile
If you're using zsh (which probably means you're running macOS Catalina or newer), then it should instead be:
echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.zshrc
In either case, restart your shell.
If you have multiple JDK versions installed and you want it to be a specific one, you can use the -v flag to java_home like so:
echo export "JAVA_HOME=\$(/usr/libexec/java_home -v 1.7)" >> ~/.bash_profile
I just spent 2 hours setting this variable. The other answers did not work properly for me. I'm using macOS Catalina 10.15.4.
First, find your actual Java SDK Home directory:
/usr/libexec/java_home
Manually navigate there to make sure you don't have any mistakes due to incorrect versions, etc. For me, this was:
/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home
Next, edit your terminal's profile. If you're using zsh, this will be:
vim ~/.zshrc
If you're not using zsh, this will be:
vim ~/.bash_profile
Inside, add the following new line anywhere in the file:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home
Restart your terminal app (or source ~/.bash_profile), and it should work properly.
I did it by putting
export JAVA_HOME=`/usr/libexec/java_home`
(backtics) in my .bashrc. See my comment on Adrian's answer.
Set $JAVA_HOME environment variable on latest or older Mac OSX.
Download & Install install JDK
First, install JDK
Open terminal check java version
$ java -version
Set JAVA_HOME environment variable
Open .zprofile file
$ open -t .zprofile
Or create . zprofile file
$ open -t .zprofile
write in .zprofile
export JAVA_HOME=$(/usr/libexec/java_home)
Save .zprofile and close the bash file & then write in the terminal for work perfectly.
$ source .zprofile
Setup test in terminal
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home
In Mac OSX 10.5 or later, Apple recommends to set the $JAVA_HOME variable to /usr/libexec/java_home, just export $JAVA_HOME in file ~/. bash_profile or ~/.profile.
Open the terminal and run the below command.
$ vim .bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
save and exit from vim editor, then run the source command on .bash_profile
$ source .bash_profile
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home
It is recommended to check default terminal shell before set JAVA_HOME environment variable, via following commands:
$ echo $SHELL
/bin/bash
If your default terminal is /bin/bash (Bash), then you should use #Adrian Petrescu method.
If your default terminal is /bin/zsh (Z Shell), then you should set these environment variable in ~/.zshenv file with following contents:
export JAVA_HOME="$(/usr/libexec/java_home)"
Similarly, any other terminal type not mentioned above, you should set environment variable in its respective terminal env file.
If you are using Zsh, then try to add this line in ~/.zshrc file & restart terminal.
export JAVA_HOME=$(/usr/libexec/java_home)
I got it working by adding to ~/.profile. Somehow after updating to El Capitan beta, it didnt work even though JAVA_HOME was defined in .bash_profile.
If there are any El Capitan beta users, try adding to .profile
Since I'm using openjdk managed with sdkman, I added
sudo ln -sfn /path/to/my/installed/jdk/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
Adding this to your system lets java_home recognize your installed version of Java even when its not installed via standard packages
I checked my /Library/Java/JavaVirtualMachines/
directory and found the version to be jdk1.8.0_321.jdk/Contents/Home
and added this directly to my .bash_profile:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_321.jdk/Contents/Home
but it's still complaining after sourcing the .bash_profile:The operation couldn’t be completed. Unable to locate a Java Runtime that supports apt.
In the latest Mac, you have to add the Set $JAVA_HOME environment variable in .zprofile. Here, we simple way to open it. Press ⌘ + Shift + . from keyboard. Just open it and add the $JAVA_HOME environment variable as explained here:
JAVA 11 via Homebrew - tested on macos Ventura 2022
.zshrc
export JAVA_HOME=/opt/homebrew/opt/openjdk#11/libexec/openjdk.jdk/Contents/Home
For Mac M1
Download & Install install JDK
Open terminal check java version
java -version
Now create a file
touch .zprofile
Open the file
open -t .zprofile
Add the below line
export JAVA_HOME=$(/usr/libexec/java_home)
I resolved it on macOS Monterey by using the option provided by Google
Under Gradle JDK, choose the Embedded JDK option.
https://developer.android.com/studio/intro/studio-config#:~:text=A%20copy%20of%20the%20latest,use%20for%20your%20Android%20projects.
I'm able to solve this issue by setting JAVA_HOME in .bash_profile file
export JAVA_HOME=/usr/local/opt/openjdk#17
Note:
I installed openjdk version 17 using 'brew'. I got this location from brew console. I'm using 'bash' instead of 'zsh' in my mac.
Open Terminal.
Confirm you have JDK by typing “which java”. ...
Check you have the needed version of Java, by typing
“java -version”.
Set JAVA_HOME using this command in Terminal: export
JAVA_HOME=/Library/Java/Home.
echo $JAVA_HOME on Terminal to confirm
the path.
More simply on a mac terminal with a modern OSX
$ vim ~/.zshrc
Type "a" to being editing, and then paste (ctrl + v):
$ JAVA_HOME=/usr/libexec/java_home
then hit "escape" and type exactly ":wq" in order to write to the file and quit vim mode.
Finally, when out of vim mode and back in your terminal, type
$ source ~/.zshrc
This will refresh so that your terminal is aware of the changes.
IMPORTANT * If you don't "source" the file, you won't see the changes in this terminal session.
Check the changes by typing
$ echo $JAVA_HOME
and you should see /usr/libexec/java_home
Quick Guide for M1
Add java sdk into your m1
check version
java --version
Get all java versions installed in ur mac
/usr/libexec/java_home -V
Execute for Java path from library
/usr/libexec/java_home
(specify java version if you have multiple version, In my case -v17.0.5
/usr/libexec/java_home -v17.0.5
Mac>User>'YourUserName/Home'>.zshrc
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-17.0.5.jdk/Contents/Home

Categories

Resources