1

Java code using JSch package was not compiling using maven. I found this solution and as suggested by @flash. I included an additional repository. The code compiles now. However, while execution I still get this error

Exception in thread "main" java.lang.NoClassDefFoundError: com/jcraft/jsch/JSchException

This shows a solution for similar problem for eclipse. However I don't know how to solve this with maven. Any help will be appreciated.

Community
  • 1
  • 1
PHcoDer
  • 1,166
  • 10
  • 23
  • Not quite enough data to help with this. Are you trying to compile the Jsch code? (per "Jsch was not compiling using maven") or something that depends on it (per the exception) – Mykel Alvis May 27 '16 at 22:00
  • @MykelAlvis edited the question. – PHcoDer May 28 '16 at 00:05
  • The JSCH jar file (and its dependencies) has to be present at runtime. This may mean that you need to install the jar into your runtime environment, or running java with the correct command-line arguments to find the jar. It's difficult to be specific without knowing what kind of application this is and how it's being run. – Kenster May 28 '16 at 11:57
  • @Kenster Thanks. Seems like I am missing something. I have started using maven and java recently. If we need to have the JScH jar file to be present in run time. Then whats the point of giving an online repository link in pom file? Doesn't the compiler fetches desired things online and stores them appropriately? – PHcoDer May 28 '16 at 14:16

1 Answers1

0

I was having the same issue, but adding the maven-shade-plugin build on pom.xml resolve my problem.

<project>
   ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.0</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  ...
</project> 

Found the solution in here.

Renan21_
  • 9
  • 2
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/29968657) – Dragonthoughts Oct 01 '21 at 15:24
  • Sorry, I fixed. – Renan21_ Oct 01 '21 at 18:22