Classpath jar files in eclipse

为君一笑 提交于 2021-01-29 18:01:14

问题


I am new to eclipse and I have a general question about referencing external Jar files.

I went to the buildpath -> configure build path and added my two jar files that I wanted to reference as parts of an external library but I can seem to make an instance object of the classes in that jar.

And also I tried just copy and pasting the jar files to the extension folder of the standard library too but this also doesn't work.

How can I use the instance objects of the classes included in these jar files?


回答1:


Even if you build path to external JARs you have to import the required classes because they do not actually exist inside the same package you are working at.




回答2:


if u want to add external jars into eclipse follow these steps

Rightclick on project - Select Configure Build Path... and the project properties window will appear showing your build path configurations.

Click Add Variable --Click Configure Variables Click New -Type a name for the new variable.--Browse to the directory that contains the JAR for the path. Click Ok to define the variable.--Click Ok to close the preferences dialog. Select the variable from the list.--Click Extend.. Select the JAR(s) that you want to add to the classpath.--Select the JAR(s) that you want to add to the classpath.-Click Ok to close the new classpath variable dialog.




回答3:


If you already added jar file into classpath and if it doesn't work I would try below on command prompt

java -classpath example.jar;


来源:https://stackoverflow.com/questions/26104786/classpath-jar-files-in-eclipse

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!