'how to solve /bin/sh: protoc: command not found?

I have installed protobuf 2.5.0 in my CentOs,

when i execute the command protoc --version, it yields

libprotoc 2.5.0

as output.

but Once I have pulled code from git and when I try to compile it using Maven3, the proto module throws error saying,

protoc failed error: /bin/sh: protoc: command not found

I refereed many blogs and also did try to change my bashrc path as follows,

export JAVA_HOME=/opt/java/jdk1.7.0_67

export PATH=$PATH:/opt/java/jdk1.7.0_67/bin

export PATH=$PATH:/usr/local/lib

but if I execute,

sudo yum install protobuf-compiler

it installs protobuf2.3 compiler and this particular error gets solved. But since my pom file has protobuf 2.5.0, java abstract method error arises during the next compilation. I'm stuck on how to proceed. I've spend many hrs in it, so any help is much appreciated.

my pom file for the proto module,

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>GradPower</artifactId>
        <groupId>org.screative.gardpower</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <groupId>proto</groupId>
    <artifactId>proto</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    </properties>
    <dependencies>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>2.5.0</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>com.google.protobuf.tools</groupId>
                <artifactId>maven-protoc-plugin</artifactId>
                <version>0.1.10</version>
                <configuration>
                    <protocExecutable>protoc</protocExecutable>
                    <protoSourceRoot>${project.basedir}/src/main/proto/</protoSourceRoot>

                    <languageSpecifications>
                        <LanguageSpecification>
                            <language>JAVA</language>
                            <outputDirectory>
                                ${project.basedir}/target/generated-sources/protoc
                            </outputDirectory>
                        </LanguageSpecification>
                    </languageSpecifications>

                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArgument></compilerArgument>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <pluginRepositories>
        <pluginRepository>
            <id>dtrott</id>
            <url>http://maven.davidtrott.com/repository</url>
        </pluginRepository>
    </pluginRepositories>



</project>

Thanks in advance.

EDIT: I solved it. I copied protoc file from /usr/local/lib to /usr/bin

and it solved it. A silly mistake :P



Solution 1:[1]

You should run 'sudo ldconfig' to finish the installation.

I guessed you set LD_LIBRARY_PATH to add /usr/local/lib in your environment setting. And it doesn't take effect when building project with maven/sbt and other build tools.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jared