I am able to get localhost:16010 running. But, somehow the Hbase shell is not launching when I use :
01HW993798:bin tcssig$ cd /Users/tcssig/Downloads/hbase-1.0.3/bin
01HW993798:bin tcssig$ hbase shell
-bash: hbase: command not found
When I directly launch Hbase Unix executable, it generates the below error log.
Error: JAVA_HOME is not set
Although I have set it. After this only, the localhost:16010 is running.
NOTE : I know there is one similar question, but no relevant answers are present there.
Using this I am able to invoke the command, but now it gives the error :
./hbase: line 403: /Users/tcssig/Downloads/hbase-
1.0.3/bin/JAVA_HOME:/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Cont``ents/Home/bin/java: No such file or directory
Although I have java file there.
Your hbase invocation should be like this:
cd /Users/tcssig/Downloads/hbase-1.0.3/bin
./hbase shell [Note the ./]
When you just type hbase shell linux searches for hbase executable in all directories included in PATH environment variable. Since above bin directory is not included it errors out.
Alternatively you can also update your path variable, based on linux distribution, the command to do that may vary. It should be something like:
export PATH=/Users/tcssig/Downloads/hbase-1.0.3/bin:$PATH
Put this command in your .bashrc or .bash_profile and then source this file. That way the bin directory is now included in PATH and hbase command is available.
Go into $HBASE_HOME/bin path, and try:
./hbase shell
Related
I've made an executable jar file for a terminal game that can be opened by typing java -jar name.jar in the Terminal.
Then I made a .sh file inside the same folder as the jar file to open it by double-clicking the .sh. I asked how to do this here, where people told me to use the following code in the .sh.
#! /bin/bash
DIR=$(dirname "$0")
java -jar "$DIR/game.jar"
This worked for a while, but when I renamed the folder, I realised if I move the folder to a pen drive the whole thing stops working and I get this in the Terminal.
Error: Unable to access jarfile /Volumes/Hard
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
[Process completed]
So how to find the file path to the folder the .sh and the jar are in, regardless of where it is, what its name is and what drive it is on?
Also, I'm using MacOS Mojave 10.14.4 if that's of any importance.
The error looks like the path does contain spaces, like probably /Volumes/Hard Drive/Users/something. The solution is to quote the command substitution.
Tangentially, don't use upper case for your private variable names.
But of course, the variable isn't really necessary here, either.
#!/bin/sh
java -jar "$(dirname "$0")/game.jar"
Nothing in this script uses Bash syntax, so it's more portable (as well as often slightly faster) to use sh in the shebang. Perhaps see also Difference between sh and bash
You can store the full path of the working directory using the environement variable $PWD, like in this example (done in 5min, it is just to show you how it is works) :
#!/bin/bash
DIR=$PWD
gamePath='java -jar '$DIR'/game.jar'
echo $gamePath
Wherever I will execute this script, it will shows up the working directory even if I change the name of the parent. Let me show you :
You can see that $PWD environnment variable works great.
Now, I will change the directory name from TestFolder to TestFolderRenamed and execute the script again :
So, in your case, change your code as following :
#! /bin/bash
DIR=$PWD
java -jar "$DIR/game.jar"
It should works.
I'm trying to execute a Java file I was given on Windows 10, inside of the Bash shell.
I open my command prompt. I enter bash.
I set
JAVA_CALL="C:/Program Files/Java/jdk1.8.0_192/jre/bin/java"
I try to execute the call, but to no luck. I read several threads on here and tried several things. I made sure my path includes both the Program Files x86 and the regular Program Files version of my JAVA.
I executed
sudo ln -s -f /mnt/c/Program\ Files/Java/jre1.8.0_192/jre/bin/java.exe /bin/java
To try and make a link to it. I cannot get it to wrong. It always tells me
-bash: C:/Program Files/Java/jdk1.8.0_192/jre/bin/java: No such file or directory
I am sure that file exists. Any ideas?
I have azure-cli installed in my mac and I can successfully execute all azure commands from cli. I want to do the same from a java application. I have seen examples of using REST endpoints and azure-sdk-for-java. But what I want is to execute the azure-cli commands directly from java.
I tried running 'azure login' from a java program, but I got the following error.
Cannot run program "azure": error=2, No such file or directory
The problem is in a lack of your PATH variable. If you want to enjoy the same "find the command" capabilities that you have on the command line, you need to set it somehow within your Java program: import the PATH variable from the environment, set it within the code you're writing, or whatever mixture covers your needs.
Giving the absolute (full) path is the surest way, but you may not want to read such long command names in your source codes.
#harshithabt Per my experience, the issue was caused by the command azure could not be searched in the directories listed in PATH. There are two ways to solve the issue for running commands in Java, please see below.
Setting up the environment variable PATH for the current shell session or the configuration files ~/.profile(or ~/.bashrc).
If you command export PATH=<your-node-path>/bin:$PATH in a shell session, you only run the Java program with azure command in the current shell session, even run via the Java IDE which must be opened in the current shell session (it means you should open Eclipse via command <your-ide-path>/eclipse).
If you configure the files ~/.profile or ~/bashrc to add the node runtime as below, please make sure the configuration files have been reloaded via command source ~/.profile in a current session or restart sessions via logout & login or reboot.
A simple way is that adding the command links into the dirs listed in PATH, such as /bin. You just need to run the commands below.
sudo ln -s /bin/node /bin/node
sudo ln -s /bin/azure /bin/azure
Then you can run azure-cli command from Java successfully.
Environment: mac
Precondition: I already configured 'adb' full path to my bash_profile. and when I tried type 'adb' in my terminal, it is working.
But, I tried to exec 'adb' command from java, 'adb' is not working, instead I need to pass the full adb path to make it work.
I guess this is probably something to do with the bash_profile setting, anyone know the exact reason for this issue?
Runtime.getRuntime().exec() runs /bin/sh -c <command>. If this is or points to a bash shell on your system: A non-interactive bash does not read .bash_profile unless explicitly (--login) told to do so.
From the documentation:
When Bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.
It's a little convoluted, but non-interactive, non-login bash instances don't read the profile files.
Your path settings does not get picked up by the subshell (which is actually /bin/sh which might not even be bash at all).
If you want, you can add the path to adb system wide by adding an appropriate entry to to /etc/paths.d.
My site is being hosted on a shared server so I don't have su access. I needed to run a piece of code with java but it's not available on the server. So I got a self-extracting version of java and put it on the server in my home directory. Then I gave executable permissions to java and I try running the code. I have to use relative paths when running the file because of the restrictions of the server.
Trying to run the java file ../java/bin/java -jar 'javafile.jar' gives me the following:
error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
I looked and libjli.so is located at ../java/lib/i386/jli/libjli.so. So I'm thinking that because I'm running java using a relative path it doesn't exactly know how to look for the other files. I'm hoping that if I can add absolute/path/to/java/bin to $PATH then this issue will be resolved.
So once I'm running my PHP, I can use dirname(__FILE__) to get the full path of my java bin directory. I've tried the following code:
exec('export PATH='.$bin_path.':$PATH', $output, $return);
print_r(array(getenv('PATH'), $output, $return));
Prints:
Array(
[0] => /usr/local/admin/bin:/usr/local/admin/bin/servers:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/bin:/usr/bin,
[1] => Array(),
[2] => 0
)
So nothing was added to $PATH, no output was given, and the command returned a successful exit value. Is it just the restriction of the server that is preventing me from getting this working?
Firstly, this is not going to work.
exec('export PATH='.$bin_path.':$PATH', $output, $return);
It will launch a child process with a shell, run the export command in the shell, and then the shell will exit. But the export command only changes $PATH for that shell.
I'm not sure, but I suspect that you need to use putenv.
I'm hoping that if I can add absolute/path/to/java/bin to $PATH then this issue will be resolved.
Well, it could only help if you used a simple command name for invoking the java command.
And it would be simpler to just run java using the full absolute pathname; e.g. "/absolute/path/to/java/bin/java"