Nipun Alahakoon
Nipun Alahakoon

Reputation: 2862

How to compile and run a java file that contain weka libraries in dos?

I am not much familiar with java but i know the usual method we are compile a java file is

path = C:\Program Files\Java\jdk1.8.0_25\bin
javac main.java
java main

But when i try that weka libraries do not working. I am using jre 1.7 with weka for my program . Please anyone enlighten me how to include the weka libraries and compile the java code.

Upvotes: 0

Views: 959

Answers (1)

GiriB
GiriB

Reputation: 1303

You need to know two things .

  1. how to add a directory to a class path .
  2. where your weka.jar and/or weka-src.jar files are

Now ,

STEP 1. COMPILE THE CODE

To compile the code you need to give the following command .

javac -classpath "path/to/lib1:path/to/lib2" main.java

This line tells javac to compile 'main.java' and use the libraries if it needs to .

STEP 2.RUN THE CODE

To run the code you just need to the same thing as above but along with the path/to/libs you should also add the path/to/yourpresentdirectory/ just to be on the safe side as there might be some extra .class files generated after compilation that JVM need to use .

java -classpath "path/to/lib1.jar:path/to/lib2.jar:path/to/yourpresentdirectory/" main

This should do the trick.

PS: I have given the commands for linux (i am using ubuntu 14.04). They should work just fine on Windows with slight changes ( you need to use '\'instead of '/' and use ';' instead of ':' where you separate the paths).

Upvotes: 1

Related Questions