Unable to find CsvReader no matter what I try - java

So I am trying to make the following code work "https://github.com/jintrone/TEVA", only problem is that I am a Java newbie. At first I got compilation error "it.uniroma1.dis.wsngroup.gexf4j.core does not exist" which I solved by downloading and adding gexf4j jar into the ./lib/ folder. Now the compilation is successful but I get:
Exception in thread "main" java.lang.NoClassDefFoundError: com/csvreader/CsvReader
The file I get this from does the following import com.csvreader.*; I downloaded opencsv-2.4.jar and opencsv-3.7.jar and put them in lib but to no avail (also, lib already contains javacsv.jar). I tried to modify the code to import opencsv.csvreader, import au.com.csvreader'... only to get error: package ... does not exist.
Anyone have an idea? these lang issues are tough on a newbie.
Thank you all

Find below a working step by step howto
get the source repository, either by git clone https://github.com/jintrone/TEvA.git or downloading the ZIP file https://github.com/jintrone/TEvA/archive/master.zip
download a missing library from http://central.maven.org/maven2/it/uniroma1/dis/wsngroup/gexf4j/gexf4j/1.0.0/gexf4j-1.0.0.jar and store it in the lib/ directory
build the project ant
The build will finish with some warnings (had no look after that).
Then you can start the example as (for more information check the README.md of the project)
cd deploy/
java -cp TEvA.jar edu.mit.cci.teva.example.RunSampleCsv ...
edit You might need to amend the file resources/cfinderbatch.properties (before the build with ant) and change the path to the cfinder application.
cfinderapplication=/usr/local/bin/cfinder
Change the path to your binary CFinder_commandline (e.g. cfinderapplication=/your/path/CFinder_commandline). Following the manual it should be in the top directory where you have extracted the CFinder*.zip archive. Most probably you need to set the executable flag chmod +x CFinder_commandline.
If all this doesn't solve your problem you might try to contact the CFinder people.

Related

Error in making jar file: "No configuration setting found for key 'akka.remote.artery'"

I wrote a Flink program to parse streaming data. I can run it without any problem. But when I make a jar file of that, the jar file is not run.
To make jar file, I follow this path:
Flile ---> Project Structure ---> Artifacts ---> jar ---> From modules with dependencies
I change the directory for META-INF to resources. After that I build the artifact. The jar file is built; even though, I can not run it. When I want to run it, I receive this error:
Exception in thread "main" java.lang.Exception: Could not create actor system
at org.apache.flink.runtime.clusterframework.BootstrapTools.startActorSystem(BootstrapTools.java:276)
at org.apache.flink.runtime.clusterframework.BootstrapTools.startActorSystem(BootstrapTools.java:162)
at org.apache.flink.runtime.metrics.util.MetricUtils.startMetricsActorSystem(MetricUtils.java:126)
at org.apache.flink.runtime.minicluster.MiniCluster.start(MiniCluster.java:260)
at org.apache.flink.streaming.api.environment.LocalStreamEnvironment.execute(LocalStreamEnvironment.java:120)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1510)
at PooyaCo.App.main(App.java:38)
Caused by: com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka.remote.artery'
The strange things is that I follow above steps to make jar file for helloworld program and the jar file is run without any issues. I think the problem is because of flink dependencies.
Would you please guide me to solve the issue?
Any help would be very much appreciated.
Yes, getting this setup correctly is non-trivial. Your best bet is to follow the quickstart guide in the documentation -- https://ci.apache.org/projects/flink/flink-docs-release-1.8/dev/projectsetup/java_api_quickstart.html -- which shows how to do this with both maven and gradle.

Java -jar ERROR: could not find or load main class

I am making a 2d game, which I have compiled into a .jar to test if it works.
When in run the jar file with java -jar command I get the following error:
Error: Could not find or load main class com.grizeldi.splatoon.Main
I know that there are many solutions here on StackOveflow, but I have tried updating java, messing with -cp... Nothing worked so far.
Code: github repo
Help anyone?
EDIT1: I have my code on a USB stick, but I have tried moving it to C: and D: but nothing worked.
EDIT2: I have added the .jar on the github.
One way is to update the Manifest with the classpath to the other jars:
Class-Path: lib.jar
An alternative is to add the contents of the jars your main jar depends on to your main jar, so you have only one jar file. Make sure you don't add the jars themselves to the main jar, as nested jars won't work.
When dealing with native libraries (.so, .dll), simply place these in the same directory as the jar. The downside of this is that you have multiple files.
In that case, it might be easiest to just add a startup script (.sh, .bat), specifying the classpath and the classname of Main, aswell as a -Djava.library.path.
There is also another way: extract the native library from the jar at runtime, save it to a temporary location, and load it explicitly. See here for more info on that.

modify weka source code in netbeans

i wanna use weka source code (not jar file!)and i download weka-src.jar from this address
http://www.java2s.com/Code/Jar/w/Downloadwekadev379sourcesjar.htm
and i wanna have weka project in netbeanes in windows .i do step by step this site instruction
http://weka.wikispaces.com/Netbeans+6.0+%28weka-src.jar%29
when i extract jar file into src directory in my project,it give me a lot of error
such as:
package java_cup.runtime does not exist
and a lot of other error.
anyone can tell me how can i do that without any error ?? i am working on this problem for a week and i'm so tired.
please help me if you can.
you have to download java-cup.jar file And add this jar to your classpath
if you didn't find java-cup.jar then you can download jflex.jar jflex also contain java-cup classes so you can download jflex.jar from link below
click on this link

Java: How can I import Trident into my project?

I'm trying to use the Trident animation library in my project. I've added the trident.jar to the build path in my Eclipse project but I'm still getting a build path error. The archive required for the library is missing.
Maybe I'm being stupid, but I can't seem to find anything like this on the website. I thought the .jar was the only thing I needed based on examples from around the net. And there doesn't seem to be a full Eclipse project to import either.
If I'm missing something silly, please let me know. Thanks!
Here is the exact error: Description Resource Path Location Type
Archive for required library: '/home/josh/Software/Eclipse Java EE/Trident/trident.jar' in project 'SP-Reversi' cannot be read or is not a valid ZIP file SP-Reversi Build path Build Path Problem
The trident.jaris the only jar you need. The error message indicates, that your trident.jar is corrupted. Try to unjar the file:
jar -xvf trident.jar
IMHO this will produce an error. Try to download the jar once again...

How to run examples of an API (which is already having workspace) using eclipse IDE

I am new to Java and I am not sure how apt is my question title. Please suggest any better title.
I have got a Java API which has many executable modules which do various things related to parsing MS Outlook's .pst files. And my problem is that I am getting this exception when I run the execute command to execute a .class file of one module of the API(java -classpath /opt/Java/libs/JPST/lib/jpst.jar /opt/Java/libs/JPST/examples/GetInboxMessages/bin/Example)-
Exception in thread "main" java.lang.NoClassDefFoundError: /opt/Java/libs/JPST/examples/GetInboxMessages/bin/Example
Caused by: java.lang.ClassNotFoundException: .opt.Java.libs.JPST.examples.GetInboxMessages.bin.Example
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: /opt/Java/libs/JPST/examples/GetInboxMessages/bin/Example. Program will exit.
So far ...
You can check my previous question where I concluded that I was correctly running the compile and execute commands. But I am still getting the above mentioned `exception.
I asked the API's developer who says that I should get Eclipse or Netbeans IDE. He said that the
examples folder inside the API's
folder structure is entire Eclipse
workspace.
and also said that
It is easier to compile and run all
examples.
And now ...
So, I have setup Eclipse Helios for Java. Can anyone tell me how is it easy to compile and run all the examples (I think the modules inside the examples folder) using the IDE. I have earlier worked with Eclipse for PHP but never for Java.
Folder structure of the API
I need to execute a .class file of one of those modules (many module folders are present inside examples directory). There are many such modules present inside the examples folder of the API. Each of these modules folders contain a bin folder (containing .class file) and src folder (containing .java file) . I need to execute one such .class file.
There is a lib directory containing a .jar file (which is needed to be referenced by my target .class file). The lib directory is at the same level as the examples directory.
Solution
I have verified that the solution given by Jonathan works (verified only without-using-elipse case). To make it more clear the classpath needs to include all the class locations in both compile and execute commands. So, if you need to compile and execute an Example.java file with a dependency Parent.jar do this:-
Compile
javac -classpath /path/to/Parent.jar/file/Parent.jar:/path/to/Example.java/file/ Example.java
Execute
java -classpath /path/to/Parent.jar/file/Parent.jar:/path/to/Example.class/file Example
And note the separator - should be : for linux and ; for windows.
Thanks,
Sandeepan
When Eclipse starts it should ask you which workspace to use. Select the examples folder and, if it really is an eclipse workspace, you should see all the projects already set up (it may take some time to build everything depending on the size of the projects and the speed of your machine). Then simply find the class you want and run it. If everything is set up correctly it should just work. If not you may have to go back to the developer for more details.
But I don't think you need Eclipse to run that one class. Looking at the stacktrace you provided at the beginning of your question it looks like it failed to run because you haven't set your classpath properly. Try:
java -classpath /opt/Java/libs/JPST/lib/jpst.jar:/opt/Java/libs/JPST/examples/GetInboxMessages/bin Example
To very briefly explain: The classpath lists the places where Java looks for the classes it needs. You specify the class to run relative to the classpath, not as a file path. Since the class you are trying to run in in the folder "/opt/Java/libs/JPST/examples/GetInboxMessages/bin" this folder must be on the classpath (note, I am assuming a unix based system, if you are using windows use ';' to separate entries not ':'). Then simply specify the class to run by itself relative to the classpath (which in this case is just the class name by itself).
Please be aware this is a very basic overview, things get a more complex if you start using packages (folders that would appear below the bin folder). This is one advantage of using a program like Eclipse since it will handle a lot of this for you.
Sounds like a classpath issue.
Right click on your project in eclipse.
Go to buildPath > configure build path
Make sure the jar file is referenced in the libraries tab and if it isn't add it.

Categories