How to use a class from JAR in eclipse

后端 未结 4 752
温柔的废话
温柔的废话 2021-02-10 07:36

I have two jar files - jar1 and jar2. Both of them are located in C:\\Eclipse projects\\ and I have added the paths to both of them to the Environment Variable CLASSPATH as foll

4条回答
  •  难免孤独
    2021-02-10 08:06

    I've got the same problem as you today, And no answer from the web can solve it. However, I fixed it at last.

    In fact, there is nothing wrong with the setup, it is right to import those jars through "Add External JARs". The real problem is the location/package of you java code. I found that you have to put your .java file in the default package. For example, you will get errors if you put your java code in a package like com.xxx.yyy.ccc, below is an image which shows the right location/package you should use(see WTF.java). After doing that, you program will be able to run.

    enter image description here

    However, that is how i fixed my problem, i'm not sure that could work for everyone..

提交回复
热议问题