import weka.jar file - java

I am a student at a local university in Atlanta , Georgia. I am looking for incorporating Weka.jar file to my eclipse for my class project.
I have tried many time to incorporate the weka-3.4.jar file into our java build path in java project using Eclipse.
Each time, my program gave me an error saying that weka.core could not be resolved from my import statement in my java test program.
It seems very obvious that i did missed something very important but i could not figure it out.
If you know what 's happening, i would like to seek your help, please tell me what to do in order to fix this error message.

You can get weka jar file from the weka file
just go in program file => weka folder => there are 3 jar files. So you can add to your eclipse. Then,
go to your eclipse project then build path and add in libraries there,
it works!

Do you compile and run your program using Eclipse ("Run") or do you use the command line? If you use Eclipse to run your program you should add the jar file in your project properties under "Java Build Path" > "Libraries" > "Add external JARs...". When using the command line, use the -jar parameter, e.g., java -jar path_to_file/weka-3.4.jar yourprogram

Related

How do use these source files with java file name?

c++,python but have no experience working with java files. I found some tools suporting my work in python but they are in java .This is the code source
https://github.com/OneBusAway/onebusaway-gtfs-realtime-from-siri-cli/tree/master/src/main
Can anyone give some guidance on how to build or run these source files.
thanks
just clone the source from GitHub and import it to java IDE example; Eclipse, IntelliJ, Netbeans. to run just click the run button.
https://www.wikihow.com/Run-Java-Program-in-Eclipse for eclipse
you can also use command prompt without installing some IDE but make sure your device already installed java
open a command prompt window and go to the directory where you saved the java program (MyFirstJavaProgram.java). Assume it's C:.
Type 'javac MyFirstJavaProgram.java' and press enter to compile your code. If there are no errors in your code, the command prompt will take you to the next line (Assumption: The path variable is set).
Now, type ' java MyFirstJavaProgram ' to run your program.
You will be able to see the result printed on the window.
Get these sources: clone the project
The project is build with Maven, so you need to install it.
Dig into pom.xml (Maven build configation file) and find out, which version of Java it requires
Install porper version of Java SDK
Armed with Maven documentation, build an executable file out of the sources

Building Java Project can't access external jar referenced libraries?

My program runs exactly as it should when I run it out of eclipse, but when I try to build it into a runnable jar I get problems.
When I set Library Handling to Extract required libraries into generated JAR, or Copy required libraries into a sub-folder next to the generated JAR, the program runs but doesn't do anything that involves the external libraries. When I set it to Package required libraries into generated JAR, absolutely nothing happens when I try to run the JAR.
At this point I have no idea what to do after spending the past hour looking online for solutions, library handling seems to work fine for everyone else?
I'm using eclipse 4.4.1 if it makes a difference
First check to make sure you have the libraries. To do so open up the jar file with win rar or something similar. If the libraries are missing you can just copy and paste them into the jar file.
If they are there then you can create a batch file (If using windows) to run your jar file with the java command. Doing this will give you a console in command prompt to view output and stack-traces. This can help you find where the problem is.
Command for .bat file:
java -jar jarfile.jar
If you don't want to create a batch file and run it from command prompt, remember to make the cmd path the same as the jar file location.

How to add a jar file to an eclipse java project from command line?

I want to compile an eclipse java project from command line. To make it easier I've put all my java files and the jar file that I need in my program in one direcotry. The path to the said direcory is:
C:\Users\Besi\Desktop\Test\src
My main class is called Program.java
Now, I am having problems with importing the jar file and compiling my main class. I mean I cannot compile it without importing the jar file but at the same time I don't know how to this in the command line. I tried this:
javac -classpath ".:C:\Users\Besi\Desktop\Test\src\javatuples-1.2;" Program.java
but it doesn't work. Any advice?
Assuming this is your end goal (and not simply trying to "add a jar file to an Eclipse java project from the command line" as your actual question title states):
I want to compile an eclipse java project from command line.
Turns out that you can compile your Eclipse project from the command line without having to place your .jar files and .java files in the same directory.
I just did it (and ensured I had two .jar files in my Eclipse project) using the following command as executed from the workspace directory (which I modified using the information from your question, assuming C:\Users\Besi\Desktop\Test is the workspace of your project, and assuming you're running Windows):
eclipsec.exe -noSplash -data "C:\Users\Besi\Desktop\Test" -application org.eclipse.jdt.apt.core.aptBuild
Because I cannot yet comment, I am posting this as an answer, even though I adapted this answer based on the contents of a previous SO answer. Please edit accordingly if this causes any trouble, thanks.

How to copy my Java Eclipse project to desktop, and then run with the command line?

I have built a java program using Eclipse. Now my teacher wants all separate java files in one folder, and then the teacher will run my program through command line. I've tried copying the java files over to my desktop and running through command line, I get errors.
My program also has two packages as well in it. Anyone know how to fix this? without using any plugins or something, as my teacher will not have them.
Edit: I managed to fix it, it was because of my classpath had wrong directory
Just export your project in an runnable jar file, then go in cmd and execute:
java -jar .jar

Distributing a Java console program

I have created a Java console application using Netbeans. In the Netbeans dist directory I have the class file of the project. Now I need to give the executable files to someone else
who will run them on another PC.
Which file I should send? How can he run them on his PC? Is there any way to create an exe type file?
Both PCs have the JDK installed.
Build a jar file with a main class specified in it.
If he has Java installed and .jar is associated with that, he should be able to just double-click on it.
Alternatively from a command line he'd be able to run:
java -jar program.jar
There are programs around to create executable wrappers around this, but a jar file is a simpler solution in terms of packaging - it's worth trying that to start with.
In additon to Jons answer:
If you have a runnable jar to start with, it is frequently much easier to package it up in an EXE file. If you have the need search Stackoverflow for JSmooth and one-jar.
NetBeans actually answers your question. If I do a Clean/Build, the output says:
To run this application from the command line without Ant, try:
java -jar "insert_your_project_name_here.jar"
theres a handy page about this here:
java tools tutorial
It describes creating jar files a little further down the page
You can go to run menu and select clean and build project or shift+f11 after this go to dist folder in project folder and use .jar file and run that by hint say in over .

Categories