NetBeans 引入的java,如何使用NetBeans中导入的库中的类(java)

This must be the simplest thing. I have been trying to do this for hours. I know how to import libraries into netbeans but how do I use classes in these libraries using imports? I have been trying unsuccessfully for hours to use the javacv library on 64bit linux and when I try to import the necessary files from the library netbeans tells me the package does not exist. I want to access a java file example.java inside com.googlecode.javacv.cpp.linux-x86_64 which is inside opencv-2.4.8-linux-x86_64.jar. How do I actually import this so I can do the following: example obj = new example?

Also, in almost every reference to javacv I see this import com.googlecode.javacv.CanvasFrame; but nowhere have I actually seen this in any of the files readily available by google. What's the deal?

解决方案

Please give this a try, I will be as specific as possible:

Copy the library folder you want to use

Paste it in the "src" folder of your project folder

Once you completed the above two tasks, you can import different classes from the library using the following code:

import nameOfLibraryFolder.*;

The above code will import all the classes from within the library. Replace "nameOfLibraryFolder" with the name of the library folder, to be more specific, the folder that contains all the classes of the library, to be even more specific, the folder that you placed in your project's subfolder called "src".

In order to import a specific class from the library, you need to replace the * symbol with the class name.

For example:

import nameOfLibraryFolder.className;

but if the class is in a subfolder, then:

import nameOfLibraryFolder.subFolderName.className;

I hope this is specific enough, and I hope it helps.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值