编译android出现 /bin/bash: jar: command not found; /bin/bash: javah: command not found解决办法

本文提供了解决Linux环境下使用Java和Jar命令时出现'command not found'错误的方法,通过调整路径和使用sudo命令进行权限修改,确保Java和相关工具正确安装并可用。

问题:

/bin/bash: jar: command not found
/bin/bash: javah: command not found

解决办法:
cd /usr/bin

必须先进入/usr/bin,我的jdk是安装在/usr/lib/jvm/jdk1.6.0_42/目录下的

sudo ln -s -f /usr/lib/jvm/jdk1.6.0_42/bin/jar

如果提示javah:commond not found,一样道理

cd /usr/bin
sudo ln -s -f /usr/lib/jvm/jdk1.6.0_42/bin/javah

转载自
http://cofface.blog.163.com/blog/static/209806086201331764347226/

c@abc-virtual-machine:~/catkin_ws$ catkin_make_isolated --cmake-args -DCMAKE_MODULE_PATH=/usr/share/cmake/Modules Base path: /home/abc/catkin_ws Source space: /home/abc/catkin_ws/src Build space: /home/abc/catkin_ws/build_isolated Devel space: /home/abc/catkin_ws/devel_isolated Install space: /home/abc/catkin_ws/install_isolated Additional CMake Arguments: -DCMAKE_MODULE_PATH=/usr/share/cmake/Modules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ traversing 3 packages in topological order: ~~ - drone_control ~~ - mavros_px4_launch ~~ - px4 (plain cmake) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The packages or cmake arguments have changed, forcing cmake invocation ==> Processing catkin package: 'drone_control' ==> cmake /home/abc/catkin_ws/src/drone_control -DCATKIN_DEVEL_PREFIX=/home/abc/catkin_ws/devel_isolated/drone_control -DCMAKE_INSTALL_PREFIX=/home/abc/catkin_ws/install_isolated -DCMAKE_MODULE_PATH=/usr/share/cmake/Modules -G Unix Makefiles in '/home/abc/catkin_ws/build_isolated/drone_control' -- Using CATKIN_DEVEL_PREFIX: /home/abc/catkin_ws/devel_isolated/drone_control -- Using CMAKE_PREFIX_PATH: /opt/ros/noetic -- This workspace overlays: /opt/ros/noetic -- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3") -- Using PYTHON_EXECUTABLE: /usr/bin/python3 -- Using Debian Python package layout -- Using empy: /usr/lib/python3/dist-packages/em.py -- Using CATKIN_ENABLE_TESTING: ON -- Call enable_testing() -- Using CATKIN_TEST_RESULTS_DIR: /home/abc/catkin_ws/build_isolated/drone_control/test_results -- Forcing gtest/gmock from source, though one was otherwise available. -- Found gtest sources under '/usr/src/googletest': gtests will be built -- Found gmock sources under '/usr/src/googletest': gmock will be built -- Found PythonInterp: /usr/bin/python3 (found version "3.8.10") -- Using Python nosetests: /usr/bin/nosetests3 -- catkin 0.8.12 -- BUILD_SHARED_LIBS is on -- Configuring done -- Generating done -- Build files have been written to: /home/abc/catkin_ws/build_isolated/drone_control ==> make -j2 -l2 in '/home/abc/catkin_ws/build_isolated/drone_control' <== Finished processing package [1 of 3]: 'drone_control' ==> Processing catkin package: 'mavros_px4_launch' ==> Building with env: '/home/abc/catkin_ws/devel_isolated/drone_control/env.sh' ==> cmake /home/abc/catkin_ws/src/mavros_px4_launch -DCATKIN_DEVEL_PREFIX=/home/abc/catkin_ws/devel_isolated/mavros_px4_launch -DCMAKE_INSTALL_PREFIX=/home/abc/catkin_ws/install_isolated -DCMAKE_MODULE_PATH=/usr/share/cmake/Modules -G Unix Makefiles in '/home/abc/catkin_ws/build_isolated/mavros_px4_launch' -- Using CATKIN_DEVEL_PREFIX: /home/abc/catkin_ws/devel_isolated/mavros_px4_launch -- Using CMAKE_PREFIX_PATH: /home/abc/catkin_ws/devel_isolated/drone_control;/opt/ros/noetic -- This workspace overlays: /home/abc/catkin_ws/devel_isolated/drone_control;/opt/ros/noetic -- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3") -- Using PYTHON_EXECUTABLE: /usr/bin/python3 -- Using Debian Python package layout -- Using empy: /usr/lib/python3/dist-packages/em.py -- Using CATKIN_ENABLE_TESTING: ON -- Call enable_testing() -- Using CATKIN_TEST_RESULTS_DIR: /home/abc/catkin_ws/build_isolated/mavros_px4_launch/test_results -- Forcing gtest/gmock from source, though one was otherwise available. -- Found gtest sources under '/usr/src/googletest': gtests will be built -- Found gmock sources under '/usr/src/googletest': gmock will be built -- Found PythonInterp: /usr/bin/python3 (found version "3.8.10") -- Using Python nosetests: /usr/bin/nosetests3 -- catkin 0.8.12 -- BUILD_SHARED_LIBS is on -- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy CMake Warning at /opt/ros/noetic/share/catkin/cmake/catkin_package.cmake:166 (message): catkin_package() DEPENDS on 'system_lib' but neither 'system_lib_INCLUDE_DIRS' nor 'system_lib_LIBRARIES' is defined. Call Stack (most recent call first): /opt/ros/noetic/share/catkin/cmake/catkin_package.cmake:102 (_catkin_package) CMakeLists.txt:105 (catkin_package) -- Configuring done -- Generating done -- Build files have been written to: /home/abc/catkin_ws/build_isolated/mavros_px4_launch ==> make -j2 -l2 in '/home/abc/catkin_ws/build_isolated/mavros_px4_launch' <== Finished processing package [2 of 3]: 'mavros_px4_launch' ==> Processing plain cmake package: 'px4' ==> Building with env: '/home/abc/catkin_ws/devel_isolated/mavros_px4_launch/env.sh' ==> cmake /home/abc/catkin_ws/src/PX4-Autopilot -DCMAKE_INSTALL_PREFIX=/home/abc/catkin_ws/devel_isolated/px4 -DCMAKE_MODULE_PATH=/usr/share/cmake/Modules -G Unix Makefiles in '/home/abc/catkin_ws/build_isolated/px4/devel' -- PX4 version: v1.16.0-rc1-452-g78a2a3d0dd (1.16.0) -- PX4 config file: /home/abc/catkin_ws/src/PX4-Autopilot/boards/px4/sitl/default.px4board -- PLATFORM posix -- ROMFSROOT px4fmu_common -- TESTING y -- ETHERNET y -- ROOT_PATH . -- PARAM_FILE /fs/mtd_params -- PX4 config: px4_sitl_default -- PX4 platform: posix -- PX4 lockstep: enabled -- cmake build type: RelWithDebInfo -- ccache enabled (export CCACHE_DISABLE=1 to disable) -- Could NOT find gz-transport (missing: gz-transport_DIR) -- Gazebo simulation bridge module disabled: missing dependencies -- Could NOT find gz-transport (missing: gz-transport_DIR) -- Could NOT find gz-sim (missing: gz-sim_DIR) -- Could NOT find gz-sensors (missing: gz-sensors_DIR) -- Could NOT find gz-plugin (missing: gz-plugin_DIR) -- Found DART: /usr/include (Required is at least version "6.6") found components: dart -- Looking for ignition-math6 -- found version 6.15.1 -- Searching for dependencies of ignition-math6 -- Looking for OGRE... -- Found Ogre Ghadamon (1.9.0) -- Found OGRE: optimized;/usr/lib/x86_64-linux-gnu/libOgreMain.so;debug;/usr/lib/x86_64-linux-gnu/libOgreMain.so -- Looking for OGRE_Paging... -- Found OGRE_Paging: optimized;/usr/lib/x86_64-linux-gnu/libOgrePaging.so;debug;/usr/lib/x86_64-linux-gnu/libOgrePaging.so -- Looking for OGRE_Terrain... -- Found OGRE_Terrain: optimized;/usr/lib/x86_64-linux-gnu/libOgreTerrain.so;debug;/usr/lib/x86_64-linux-gnu/libOgreTerrain.so -- Looking for OGRE_Property... -- Found OGRE_Property: optimized;/usr/lib/x86_64-linux-gnu/libOgreProperty.so;debug;/usr/lib/x86_64-linux-gnu/libOgreProperty.so -- Looking for OGRE_RTShaderSystem... -- Found OGRE_RTShaderSystem: optimized;/usr/lib/x86_64-linux-gnu/libOgreRTShaderSystem.so;debug;/usr/lib/x86_64-linux-gnu/libOgreRTShaderSystem.so -- Looking for OGRE_Volume... -- Found OGRE_Volume: optimized;/usr/lib/x86_64-linux-gnu/libOgreVolume.so;debug;/usr/lib/x86_64-linux-gnu/libOgreVolume.so -- Looking for OGRE_Overlay... -- Found OGRE_Overlay: optimized;/usr/lib/x86_64-linux-gnu/libOgreOverlay.so;debug;/usr/lib/x86_64-linux-gnu/libOgreOverlay.so -- Looking for ignition-math6 -- found version 6.15.1 -- Looking for ignition-transport8 -- found version 8.5.1 -- Searching for dependencies of ignition-transport8 -- Config-file not installed for ZeroMQ -- checking for pkg-config -- Checking for module 'libzmq >= 4' -- Found libzmq , version 4.3.2 -- Checking for module 'uuid' -- Found uuid, version 2.34.0 -- Looking for ignition-msgs5 -- found version 5.11.1 -- Searching for dependencies of ignition-msgs5 -- Looking for ignition-math6 -- found version 6.15.1 -- Checking for module 'tinyxml2' -- Found tinyxml2, version 6.2.0 -- Looking for ignition-msgs5 -- found version 5.11.1 -- Looking for ignition-common3 -- found version 3.17.1 -- Searching for dependencies of ignition-common3 -- Looking for dlfcn.h - found -- Looking for libdl - found -- Searching for <ignition-common3> component [graphics] -- Looking for ignition-common3-graphics -- found version 3.17.1 -- Searching for dependencies of ignition-common3-graphics -- Looking for ignition-math6 -- found version 6.15.1 -- Looking for ignition-fuel_tools4 -- found version 4.9.2 -- Searching for dependencies of ignition-fuel_tools4 -- Checking for module 'jsoncpp' -- Found jsoncpp, version 1.7.4 -- Checking for module 'yaml-0.1' -- Found yaml-0.1, version 0.2.2 -- Checking for module 'libzip' -- Found libzip, version 1.5.1 -- Looking for ignition-common3 -- found version 3.17.1 -- Looking for ignition-math6 -- found version 6.15.1 -- Looking for ignition-msgs5 -- found version 5.11.1 -- Found gazebo-classic 11.15.1, including sitl_gazebo-classic simulator and gazebo-classic targets -- Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE) -- ROMFS: ROMFS/px4fmu_common CMake Error at CMakeLists.txt:478 (include): include could not find load file: doxygen Architecture: amd64 ==> CPACK_INSTALL_PREFIX = @DEB_INSTALL_PREFIX@ -- Configuring incomplete, errors occurred! See also "/home/abc/catkin_ws/build_isolated/px4/devel/CMakeFiles/CMakeOutput.log". See also "/home/abc/catkin_ws/build_isolated/px4/devel/CMakeFiles/CMakeError.log". <== Failed to process package 'px4': Command '['/home/abc/catkin_ws/devel_isolated/mavros_px4_launch/env.sh', 'cmake', '/home/abc/catkin_ws/src/PX4-Autopilot', '-DCMAKE_INSTALL_PREFIX=/home/abc/catkin_ws/devel_isolated/px4', '-DCMAKE_MODULE_PATH=/usr/share/cmake/Modules', '-G', 'Unix Makefiles']' returned non-zero exit status 1. Reproduce this error by running: ==> cd /home/abc/catkin_ws/build_isolated/px4 && /home/abc/catkin_ws/devel_isolated/mavros_px4_launch/env.sh cmake /home/abc/catkin_ws/src/PX4-Autopilot -DCMAKE_INSTALL_PREFIX=/home/abc/catkin_ws/devel_isolated/px4 -DCMAKE_MODULE_PATH=/usr/share/cmake/Modules -G 'Unix Makefiles' Command failed, exiting.
最新发布
07-19
### 解决方案 当在终端中运行 `docker` 命令时遇到 `'bash: docker: command not found'` 错误,通常是因为系统的环境变量 PATH 中未包含 Docker 可执行文件的位置。以下是可能的原因以及解决方案: #### 1. **确认 Docker 是否已正确安装** 需要先验证 Docker 是否已经成功安装到系统上。可以通过以下命令检查是否存在 Docker 文件: ```bash which docker ``` 如果返回为空,则说明 Docker 尚未安装或路径配置错误。 若尚未安装 Docker,请按照官方文档指南完成安装过程[^1]。对于 macOS 用户,推荐通过 Homebrew 安装 Docker Desktop 或者直接下载官方 DMG 文件进行安装[^3]。 #### 2. **检查 PATH 环境变量** 即使 Docker 已经安装,如果其可执行文件所在的目录不在系统的 PATH 环境变量中,也会引发此问题。可以使用以下命令查看当前的 PATH 设置: ```bash echo $PATH ``` 默认情况下,Docker 的二进制文件一般位于 `/usr/local/bin/docker` 或 `/usr/bin/docker`。如果没有找到这些路径中的任意一个,可能是安装过程中出现问题或者手动调整过默认位置。 若要临时修复该问题,可以直接指定完整的路径来调用 Docker: ```bash /path/to/docker version ``` 要永久解决问题,需将 Docker 执行程序所在目录加入到用户的 `.bashrc`, `.zshrc` 或其他 Shell 初始化脚本中。例如,在 ~/.bash_profile 添加如下内容并重新加载配置文件: ```bash export PATH=$PATH:/path/to/docker source ~/.bash_profile ``` #### 3. **重启 Terminal 或重新登录会话** 修改 PATH 后,建议关闭再打开一个新的终端窗口以应用更改;也可以简单地刷新当前 session 使用上述提到过的 `source` 方法立即生效。 #### 4. **验证权限设置** 某些 Linux 发行版要求非 root 用户必须属于特定组才能访问 Docker Daemon。比如 Ubuntu 上,默认创建了一个名为 “docker” 的 Unix 组。确保当前用户已被添加至这个组里边去: ```bash sudo usermod -aG docker $USER newgrp docker ``` 进一步测试是否能够无需sudo前缀就能正常使用docker指令了: ```bash docker ps ``` #### 5. **排查服务状态** 此外还需注意的是,即使客户端工具可用,但如果后台守护进程没有正常运作的话同样会造成类似的报错现象。所以最后别忘了检验一下 daemon 自身的状态: 对于 systemd 控制的服务来说, ```bash systemctl status docker.service ``` 在 Mac OS X 下则是借助 Docker Desktop GUI 应用来管理启动停止等功能[^4]。 ```python import subprocess def check_docker_status(): try: result = subprocess.run(['docker', 'version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) if result.returncode != 0: print(f"Docker is NOT installed or configured properly.\nError Details:\n{result.stderr.decode()}") else: print("Docker installation verified successfully.") except FileNotFoundError: print("The 'docker' executable was not found on your system.") check_docker_status() ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值