I'm not sure where I went wrong, but I used nano to edit my bash_profile to install JavaSDK on my Mac a few days ago. I have been doing everything in Eclipse, so I haven't had occasion to visit the command line for a few days...until today.
Nothing works. No ls, no nano, no vim...nothing. I tried to type:
-bash: nano: command not found
-bash: ls: command not found
defaults write com.apple.finder.AppleShowAllFiles YES to unhide system files so I can figure out where my .bash_profile is and I get this:
-bash: defaults: command not found
I'm able to find command line solutions that look promising, but I can't get any commands to be recognized. Any helpful hints would be greatly appreciated.
UPDATE:
I've attempted to implement solutions I've found on StackOverflow and elsewhere, yet I'm still finding commands that were previously working are no longer doing so. When I make changes, I log out and back in. Rebooting doesn't seem to do the trick, either.
echo $PATH returns the following:
/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/root/bin:/usr/local/bin
Here's my .bash_profile:
#Setting PATH for Python 2.7
export RBENV_ROOT=/usr/local/var/rbenv
#Java setup
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home
export PATH=/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
# RUBY FIX?
# PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}:/usr/local/sbin:/usr/sbin:/usr/bin:/root/bin:/usr/local/bin"
export PATH
Are there any other places I should be looking? What turned out to be a minor issue a few days ago is turning into a major one, as I can't get any work done.
Use /usr/bin/nano (not just nano because your PATH variable is messed up) to edit your .bash_profile again.
Remove the line:
export PATH=/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin
As well as the line:
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}:/usr/local/sbin:/usr/sbin:/usr/bin:/root/bin:/usr/local/bin"
First, save this, log out, log in, and make sure that you have all your commands back as you know them.
Then check if you have python and java available. You should not need to change the PATH at all when you have installed Java, and I believe not when you have installed python either. The installation of the Oracle JDK automatically adds java to your existing path. At most, you should set the JAVA_HOME.
Related
i'm very new to this world.. so forgive me for silly explanations.
I've installed maven and all the setting is done. Also i created a maven.sh
Content:
# Apache Maven Environment Variables
# MAVEN_HOME for Maven 1 - M2_HOME for Maven 2
export JAVA_HOME=/usr/lib/jvm/java-11
export M2_HOME=/opt/apache-maven
export MAVEN_HOME=/opt/apache-maven
export PATH=${M2_HOME}/bin:${PATH}
At this point everything is working as expected, but every time i close the terminal it seems to forget some settings..
I have to open the terminal and execute the following commands to make it work again:
~$ cd /etc/profile.d
~$ source maven.sh
I don't know if it is just the way to use maven or i'm missing something, but it's kind of annoying writting the same commands every single time i want to execute maven.. so i would appreciate if you can explain me a way to automate it.
Some extra information:
OS : Ubuntu 20.0.4
JDK : 11
Not first time creating JAVA_HOME variable
After executing those commands above, it shows the correct JAVA_HOME, but it's forgotten after closing the terminal and shows the wrong JAVA_HOME again
Let me tell you guys, this is my first question on stackoverflow, so i will understand if you want to correct me about my manners and my bad english (it's not my mother tongue, i have to get used to it)
Thank you in advance!
I can think of a couple of ways you could resolve this problem given your situation, which is not maven-specific but rather terminal-specific --
Add a reference to your maven.sh script to your profile so that it runs when you start a terminal session. This can typically be accomplished by creating (or adding to) the .bash_profile file in your home directory. You could either add the contents of your maven.sh script to that file, or add source /etc/profile.d/maven.sh to it. From that point forward when you start a terminal session, the script gets run automatically and your variables are set correctly. See https://joshstaiger.org/archives/2005/07/bash_profile_vs.html or the bash man page for some more details about the login shell
If you've already done the first step and it didn't work, consider checking to see if those environment variables are being set in another place (check ~/.bashrc, ~/.bash_profile, and anywhere your particular shell distribution / OS checks for startup scripts
Lastly, I recommend using SDKMan! to manage maven installs without these headaches -- but your mileage may vary. It handles keeping track of the environment variables, java version, &c and allows multiple Java/Maven versions to be installed and managed. https://sdkman.io
Sources:
https://joshstaiger.org/archives/2005/07/bash_profile_vs.html
https://linux.die.net/man/1/bash
https://sdkman.io
You can add these properties to individual user settings file. This file will be available in home directory
vi $HOME/.bash_profile
So everytime, you login to terminal, all these settings will be executed.
I solved the problem by doing a logout and login in Ubuntu
Please bear with me. I'm a biology student trying to perform Species Distribution Modeling of certain plant species in Australia using R Studio (specifically using a Maximum Entropy model) and I have a limited understanding of the command line.
In order to do this, I need to use the rJava package in R Studio. While the installation seems to work, when I run the command:
library(rJava)
I get this warning message:
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
So I found this tutorial online:
https://github.com/s-u/rJava/issues/86#issuecomment-261039681.
Towards the bottom of the page, the user gwarnes-mdsol gives a step-by-step guide to fixing this problem using my mac's command-line. I am supposed to install Java, uninstall any existing rJava packages, and then run a few lines of code that he wrote out. However, I can't seem to get past this step. What does he mean when he says to add the export command to the the filepath he supplied? Am I supposed to fill in portions of this code with filepaths that are specific to my computer?
# Add the following lines to /Users/<userid>/.bashrc:
# Set JAVA_HOME so rJava package can find it
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)/jre
I'm not sure where to begin with this. I've tried downloading a JDK (jdk-11.0.6_osx-x64_bin.tar.gz) and renaming it JAVA_HOME but then I don't know where to put it in my computer. I don't know where to find a .bashrc file. How can I run this code properly?
Any help is greatly appreciated!
After installing hadoop 2.7.7 in standalone mode on a Raspberry Pi on a clean Raspbian Stretch Lite (plus java version 1.8.0_65), I get the following error:
Error: JAVA_HOME is not set and could not be found.
This is despite me having this line in /etc/bash.bashrc:
export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
printenv outputs the following:
...
JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/
....
I see lots of similar questions, but the answers seem to be that either the export is commented out by mistake, or to put this in hadoop-env.sh - however I don't seem to have this file.
I am trying to follow the instructions here, and all is well, until:
Start, stop and list running services
1. $cd $HADOOP_HOME/sbin
2. $./start-dfs.sh
How can I fix this please ?
Let's edit /etc/hadoop/hadoop-env.sh file and set JAVA_HOME for Hadoop. It is the path on which you didn't find hadoop-env.sh.
Open the file and find the line as bellow
export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/
If the line exists and is commented out, do uncomment. Otherwise, add the line into the file. Beware not
export JAVA_HOME=${JAVA_HOME}
If the file is still not found, maybe path is different. Try to search it using,
find / -iname 'hadoop-env.sh'
I will try and keep this as concise as possible since I need to get this figured out quickly. Back when I setup Titanium Studio 2.1.1.201207271312 on Linux Mint 13 64-bit system, I had all kinds of problems installing a version of Java Titanium liked. In the end I Think I used the instructions here to get it working.
Now all these months later when I try to compile an app for Google Play I get this dreaded error:
[ERROR] Program launch failed. Unable to locate Java VM. Please set JAVA_HOMenvironment variable.
[ERROR] Unabled to prepare JavaScript for packaging. Error code 4.
Checking the java alteranatives on my system I get this:
'update-alternatives --query java
Link: java
Status: auto
Best: /usr/lib/jvm/java-6-sun/jre/bin/java
Value: /usr/lib/jvm/java-6-sun/jre/bin/java
Alternative: /usr/lib/jvm/java-6-sun/jre/bin/java
Priority: 63
Slaves:
java.1.gz /usr/lib/jvm/java-6-sun/jre/man/man1/java.1.gz
Alternative: /usr/lib/jvm/java-7-oracle/bin/java
Priority: 1
Slaves:
java.1.gz /usr/lib/jvm/java-7-oracle/man/man1/java.1.gz
I have the following set in my .profile
export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre/bin/java
export PATH=$PATH:/usr/lib/jvm/java-6-sun/jre/bin/java
But still I get the error in Titanium. I have tried numerous different variations of my .profile file, but with no luck.
I really need to work this out quickly. Does anyone have any ideas?
EDIT: Solved
I seem to have worked the proper paths, here is how my .profile now reads:
JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
export JAVA_HOME
PATH=$PATH:/usr/lib/jvm/java-6-sun
export PATH
.profile is usually processed by sh, while .bash_profile is processed by bash (and instead of .profile when present). Try following sh compatible format (which has bitten me before when mucking with .profile files):
JAVA_HOME=/usr/lib/jvm/java-6-sun
export JAVA_HOME
PATH=$PATH:/usr/lib/jvm/java-6-sun/bin:/usr/lib/jvm/java-6-sun/jre/bin
export PATH
I Corrected to what I usually use, I was just echoing your values, but I should have been more careful. I usually have JDK and JAVA_HOME is supposed to be the base for it and then I add bin for both JDK and JRE. If you compiling then you may need the JDK and not just the JRE.
I seem to have worked out the proper paths, here is how my .profile now reads:
JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
export JAVA_HOME
PATH=$PATH:/usr/lib/jvm/java-6-sun
export PATH
Ok, so this is actually quite a long story, but i'll try and keep it pretty short. So I'm trying to get the WebOS SDK working on Windows using Cygwin. Well, it wasn't working. It kept complaining that i was using a 32 bit version of java instead of 64 bit. the explenation for that problem is pretty easy to figure out. my PATH variable was set wrong and was pointing to my 32 bit installation of Java. Simple solution YOU'D THINK. apparantly not. for some reason, despite my best efforts, i cannot get the 64 bit version of java written into the PATH variable. The problem:
Cygwin doesn't like spaces in the Path variable, even though the path variable is littered with spaces, it won't accept it when i add my own space. After a lot of googling, i've found multiple accurances of this problem, and multiple solutions. but none of them seem to work. i always get exactly the same error:
bash: /usr/local/bin:/usr/bin:/cygdrive/c/Program: No such file or directory
The error is pretty self explanetary, basically its not reading anything past the first space, and i have no such directory as C:/Program so it spits out an error, my question is how do i get it to except a space, because changing the name of the directory is not an option, too many things depend on it. heres what i've tried so far:
$PATH=$PATH:C:\PROGRA~1\Java\jre6
$PATH=$PATH:"'pwd'" (while in java directory)
$PATH=$PATH:/cygdrive/c/Program Files/Java/jre6/bin (hay, i had to try)
$PATH=$PATH:/cygdrive/c/"Program Files"/Java/jre6/bin
$PATH=$PATH:/cygdrive/c/Program\ Files/Java/jre6/bin (escape character was rumored to work
$PATH=$PATH:'/cygdrive/c/Program Files/Java/jre6/bin'
$PATH=$PATH:"`/cygdrive/c/Program Files/Java/jre6/bin`"
and i think that was it, if anyone knows how to actually do it properly (or improperly but working for all i care) it would be greatly appreciated
Thanks
--
Chris
You also have the option of using the cygpath tool to help. Cygpath can be used to convert from a Window's path to a Unix path, but that doesn't directly handle spaces, so you need to do a two step process, first eliminate the spaces by converting to a DOS (short) path name, then convert to a Unix style path:
PATH=$(cygpath -u $(cygpath -m -s "C:\Program Files\Java\jre6\bin")):${PATH}
PATH=$(cygpath -u $(cygpath -m -s "C:\Program Files (x86)\HP webOS\PDK\bin")):${PATH}
PATH=$(cygpath -u $(cygpath -m -s "C:\Program Files (x86)\HP webOS\SDK\bin")):${PATH}
PATH=$(cygpath -u $(cygpath -m -s "C:\Program Files (x86)\HP webOS\SDK\bin\novacom")):${PATH}
The end result will be something like (short names may differ slightly):
/cygdrive/c/PROGRA~3/HPWEBO~1/SDK/bin/novacom:/cygdrive/c/PROGRA~3/HPWEBO~1/SDK/bin:/cygdrive/c/PROGRA~3/HPWEBO~1/PDK/bin:/cygdrive/c/PROGRA~1/Java/jre6/bin:....other path elements....
One thing to keep in mind when using this, cygpath generates an error if the provided path actually does not exist because it can not create the short path for a non-existent path.
What is nice about this approach is that if you set Windows environment variables (like for example JAVA_HOME) then you can use that environment variable in the convert operation inside the .bash_profile, since all Windows environment variables are visible when the profile is being loaded. So if you had in the Windows environment
JAVA_HOME=C:\Program Files\Java\jre
then the cygpath command can be
$(cygpath -u $(cygpath -m -s "${JAVA_HOME}\bin"))
which means you only ever need to update via the Windows settings if the java install changes.
In .bash_profile:
PATH=/cygdrive/c/Program\ Files/Java/jre6/bin/:${PATH}
PATH=${PATH}:/cygdrive/c/Program\ Files\ \(x86\)/HP\ webOS/PDK/bin
PATH=${PATH}:/cygdrive/c/Program\ Files\ \(x86\)/HP\ webOS/SDK/bin
PATH=${PATH}:/cygdrive/c/Program\ Files\ \(x86\)/HP\ webOS/SDK/bin/novacom
Adds the paths to your .bash_profile and both java and the webOS SDK tools should be available.