views:

137

answers:

1

I have a Java project in Netbeans and I want to use some classes from Weka within my project.

I added the file C:\Program Files\Weka-3-7\weka-src.jar into my Libraries following the instructions here (project, properties, libraries ..)

So how do I now import the classes I want?

I tried importing like this:

import weka.core.converters.ConverterUtils.DataSource;

And for kicks, I also tried this which didn't work either:

import src.main.java.weka.core.converters.ConverterUtils.DataSource;

NetBeans says "package does not exist" for both.

Have I linked the libraries incorrectly? Do I need to phrase the import differently?

Much thanks for any insight into this you can provide.

Update:

In my Libraries folder of my projects tab I see:

weka-src.jar and under that I see: , META-INF, lib, src.main.java.weka.associations, and lots of other things from weka.

+2  A: 

I have downloaded Weka from here. I have added the JAR file you mentioned and I have also added weka-src.jar.

The problem is that although I have no problems with your first import:

import weka.core.converters.ConverterUtils.DataSource;

I can't see this package anywhere:

import src.main.java.weka.core.converters.ConverterUtils.DataSource;

To see if you have successfully imported a .jar file or a library, click on the "Projects" button on the left margin, find the Project you have added the resource to and expand the view (by pressing the + sign). You should have an item named "Libraries". If you expand that, you should be able to see the files you have added.

npinti
I do see it under that libraries folder. I updated my question to describe what I see.
Greg
Sorry, my bad, you have to also add weka.jar
npinti
Hmm I'll try that. Out of curiousity, why do I need both?
Greg
If I remeber correctly, the first import you are using lies within weka.jar, whilst the second one, even though it does not seem to exist in the weka-src.jar file, has a very similar stucture to the items found in weka-src.jar
npinti