Reputation: 41
i want to write some new java code on my IDE about weka, and i also want to use all source codes of weka. I open weka-src.jar
file but i cannot see the inside of Eclipse or Netbeans.
How can i add all source code on my IDE? i saw this site: https://svn.cms.waikato.ac.nz/svn/weka/tags/dev-3-5-8/weka/. However, i think i have to download one by one on this site. I know it is very simple but i didn't find any information on the internet. It is all about using some weka libraries on java.
Upvotes: 1
Views: 1435
Reputation: 9043
That's a very good question and it deserves a solid answer. I'll try to give you one for the Eclipse IDE.
Create a new folder somewhere in your dev workspace: weka-sample
. Next, within this folder, open a text editor (e.g., TextEdit) and create a file named pom.xml
. Insert this content to the file and save it afterwards:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sample</groupId> <!-- Change it: your project or company-->
<artifactId>weka-sample</artifactId> <!-- Change it: your project name-->
<version>0.1-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source> <!-- For Java 11: use "11"-->
<maven.compiler.target>1.8</maven.compiler.target> <!-- For Java 11: use "11"-->
<weka.version>3.8.3</weka.version>
</properties>
<dependencies>
<dependency>
<groupId>nz.ac.waikato.cms.weka</groupId>
<artifactId>weka-stable</artifactId>
<version>${weka.version}</version>
</dependency>
</dependencies>
</project>
Make sure you've installed a recent Eclipse IDE (2018-12). If this is present on your machine, continue with:
pom.xml
fileIf all of these steps worked, you will see a screen similar as below. Now, right click on the top-level of the project and click "Update Project". Make sure, your machine is connected to the Internet as the build tool (Maven) will now download several libraries from the central Maven repositories; most important: the latest version of the weka-stable
artifact (3.8.x).
We're almost done here. However, one important step remains.
Right click on the top level of the project again, select Maven, and click Download Sources.
In the background, Eclipse will now download several source artefacts for you and link them correctly to the libraries you'll find below the Maven Dependencies entry of the project (see screenshot above). Just click on it and you'll see several jar files, among them: weka-stable-3.8.3.jar
Finally
Create new folders src/main/java
and src/test/java
and add these to the Build-Path of the project. I'm assuming that you are familiar with this step. Note: The aforementioned directories comply with the standard layout in Maven projects. I'd recommend, you configure it like this in your Weka and other future projects.
Add your own source files to src/main/java
. If you now click on one of the classes imported from the weka
package... taaaadaaaa! You should now see the corresponding source code in the editor window of the IDE!
Hope it helps.
Upvotes: 2