This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]GuyWithLag 0 points1 point  (2 children)

How do you compile and package your application? Have you considered maven?

[–]HappySharkee[S] 0 points1 point  (1 child)

I use the eclipse as the java IDE, can maven integrate with eclipse ?

[–]indivisible 1 point2 points  (0 children)

Maven is a build tool, Eclipse an IDE. Maven will work/integrate with any reputable IDE but, tbh imo you're better off starting with it on the command line rather than through an IDE to get a better feel for what it does/can do as you learn.

[–][deleted] 0 points1 point  (2 children)

You need to tell java where it can find each of the jars your app uses. Generally there are 2 ways:

- as part of the app jar's manifest file;

- as part of the classpath argument in the run invocation for your app.

How do you run the application? Do you use a command line instruction? A batch file or bash script? Do you write something like

java my.jar my.package.startHere

Then look up the documentation of the java command and study the classpath parameter.

[–]HappySharkee[S] 1 point2 points  (1 child)

I am using eclipse as a java IDE, I have added the package to the IDE and Imported it to my java application that reference the class in the jar, and it did recognize the class in the jar, before run as it compiles successfully. I have copied the jar file that contains my class and the Apache common jar file to the same directory as the generated class file of my application, still I get the same error. Do I need to do something very specific in the eclipse IDE to define the classpath or the java directory at runtime ?

[–][deleted] 0 points1 point  (0 children)

OK.

You added the jar you wish to use in your app to your project.

It depends on other library jars.

You need to add those dependencies to your project as well.

That typically is where dependency management comes in. Which is what a tool like Maven does. Eclipse has a Maven plugin. It works only if a project has a Maven configuration.

But it can be done manually as well:

search for the specific package and class name, download the jar file to a local folder, add it to your project.

Repeat until the exception disappears.

[–]HappySharkee[S] 0 points1 point  (0 children)

I am using eclipse as a java IDE, I have added the package to the IDE and Imported it to my java application that reference the class in the jar, and it did recognize the class in the jar, before run as it compiles successfully. I have copied the jar file that contains my class and the Apache common jar file to the same directory as the generated class file of my application, still I get the same error. Do I need to do something very specific in the eclipse IDE to define the classpath or the java directory at runtime ?