0

I am trying to build my maven project in IntelliJ. I added the dependency in the pom file as shown.

  <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>sqljdbc4</artifactId>
        <version>4.0</version>
        <scope>system</scope>
        <systemPath>${basedir}/lib/sqljdbc4-2.0.jar</systemPath>
    </dependency>

I also have the sqljdbc4-2.0.jar in the /lib folder. I am able to successfully clean the project and package it. However, when i run the jar on my linux machine it gives me following exception:

java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver

Please help. Struggling with this for quite some time. Thanks.

Kabhi
  • 135
  • 1
  • 12
  • 1
    Do you specify the classpath when you run the jar? Maven will not package your dependencies in your jar file. There are however a number of maven plugins that will let you do so. – Robby Cornelissen Oct 27 '16 at 09:12
  • I am on my linux machine and i run: `java -jar file.jar`. Can you help me in how do i specify the classpath ? I am kind of new to java. Thanks! – Kabhi Oct 27 '16 at 09:34
  • 1
    http://stackoverflow.com/questions/18413014/run-a-jar-file-from-the-command-line-and-specify-classpath – Robby Cornelissen Oct 27 '16 at 09:48
  • @RobbyCornelissen Thanks. Might work. Do i need to have the `sqljdbc4-2.0.jar` file on my machine directory where i am running my project's jar ? – Kabhi Oct 27 '16 at 10:02
  • @RobbyCornelissen Thank you very much. I got it working. – Kabhi Oct 27 '16 at 10:07

0 Answers0