Java – add external in eclipse Jar file

I'm adding a download for a java project There was a problem with the jar file This is really my first time using eclipse, so please wait for me (for some reason) (I don't know why), I find it a little confusing

I know that in order to reference different class files, you just need to create a class library and add it to the build path From there on, all the work that needs to be done (unless I misunderstand this for some reason) will be necessary to use the "import" keyword jar,. Java or class / . Import the interface file into the project

I use mine I tried I refer to it in the build path (all I do is copy the jar to the project directory and then add it externally using the build path option), but when I try to call the object "delegator", it is obviously Jar file, which will not be read

Did I miss anything here? Seriously, anyone who knows the answer - you're relieving your headache mother Before anyone asks - yes, I've searched this person I found a similar problem, but nothing is better than what I want Anyway, or I really just lack common sense

Solution

There are several possible reasons, because the problem does not mention the specific failure and where it happened The possible reasons I can think of are listed below, but this may not be exhaustive:

>Classes can be imported in different packages only if they are public The only exception is when you use this class in the same package If this class is an inner class marked private, you are really lucky The offending delegate class may not be exposed, which is why you may not be able to use it This problem should be caught by the compiler. > The directory structure in the jar may not match the package import statement in your class This may not be necessary because eclipse should provide a possible fix, but it's best to verify it Similarly, if this is the case, the compiler should complain. > If the problem is at runtime, it is likely that jars are not available in the runtime classpath You need to configure the runtime configuration to add jars to the runtime classpath If you need to know how to change the runtime classpath, see the eclipse documentation on run configurations

be careful:

>Exporting build classpath entries is very important for other projects that depend on related projects; If needed in other projects, you must re - import items that are not imported This does not apply to run configurations

to update

Each Java application needs a main (string [] args] method to start execution. This is the entry point of the application. From the comments, the main method is in different classes. If so, the class should be used to start the application. In eclipse, "run configuration" It may be used for classes that lack this entry point, resulting in the described error This problem can be corrected by creating a new run configuration for the class with the entry point This can be done in one of the following ways:

>Edit the existing run configuration to use the required class (class using the main method) Please refer to the link above in the third point Edit the value of the class to start. > Create a new run configuration for the required class Typically, you need to traverse the required classes and run your application from them (using the ALT shift x J shortcut)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>