0

I am a java beginner. I am trying a Java program in a unix system. I am getting the below error

Exception in thread "main" java.lang.ClassNotFoundException: com.sybase.jdbc.SybDriver
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at reportToCSVg.main(reportToCSVg.java:13)

I know that in eclipse i can just add the jconn.jar to make it work. please advise me the equivalent i need to do such that whenever i run the program in the server, i had included the jar file which is in a another path

Radu Murzea
  • 10,724
  • 10
  • 47
  • 69
crazypaladin
  • 453
  • 4
  • 7
  • 17

2 Answers2

0

you can set the classpath as follow: http://www.ehow.com/how_4784820_set-classpath-eclipse.html

and put your jar file in your projects classpath . or you can put your jar file as

  1. Select the library and click "Edit" (left side of the window)
  2. Click "User Libraries"
  3. Select the library again and click "Add JARs"

http://www.wikihow.com/Add-JARs-to-Project-Build-Paths-in-Eclipse-(Java)

Hemant Metalia
  • 29,730
  • 18
  • 72
  • 91
  • hi sorry if i had not put my question correctly. the thing i wanted to clear is if i cant use eclipse always,like above is it possible to create what is in the background of a eclipse project and how? yes i know its like going back , but i just wanted to know whats in the back ground.. – crazypaladin Jul 10 '12 at 15:50
  • @user737993 for that purpose you can see http://stackoverflow.com/questions/1953048/java-project-structure-explained-for-newbies the answer of Carl Smotricz here lib folder contains jars .. – Hemant Metalia Jul 11 '12 at 04:12
0

You can use Maven to package your -jar file containing all the dependencies if you are using Maven. If you are using plain Eclipse with Ant -Just use the Fat-jar Plugin.

For Maven add the assembly plugin to pom.xml

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
        <archive>
            <manifest>
                <mainClass>app.runner.Runner</mainClass>
            </manifest>
        </archive>
            <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
    </configuration>
</plugin>

For the Maven goal use the below -

maven assembly:single
Chan
  • 2,601
  • 6
  • 28
  • 45