I'm working with a code snippet that came with a bunch of import statements, which I copied as well. The problem is that the libraries apparently aren't packaged along with Intellij, so the usual Alt+Enter doesn't help. The IDE shows a "cannot resolve symbol" at almost all of the libraries. Now, I solved one of them by grabbing the correct .jar on the internet somewhere and adding it to the project structure, but I'm having a much harder time locating another one, plus this seems to me like an awfully inefficient way to work.
How do I locate, download, and add the required classes/libraries to the project in an efficient, clean way, based on import statements only?
Imports just for reference:
import org.apache.log4j.Logger;
import org.junit.Test;
import com.google.common.collect.Lists;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
You need to find out in which jar your class is included. I often use http://www.findjar.com/index.x to help finding it.
Then, you will find the download site for this jar. eg. http://www.java2s.com/Code/Jar/g/Downloadgson222jar.htm
Then you download it and you include the jar in the classpath of your project. Or you can include the folder where all your jars are in the classpath.
If you find this all too complicated, you can also try to migrate your project to Maven which you will tell the name of the requiered dependencies (easily found online) and it will take care of downloading the jar and include it in your classpath.
I think there is no particular way to do it. If you grabbed the source code from an entire project, I would suggest you to look at the build script. The dependencies would be listed down there.
Else please search for with the FQCN on search engine.
For your imports, I did it for you and found out the source.
Apache Log4j 1.2.17
google-collections
Gson
JUnit
Hope this helps!
Related
I have seen similar questions on SO and I'm just not getting it. I have a bunch of Java classes I need to import as a library. How do I make the jar file, save it in the right place, then tell Eclipse to import the jar file?
The classes I want in my library are here: StdIn library code
and this is the java code I want to import the library into:
Sattolo algorithm code
There is a further library I would need to import to make the Sattolo algorithm run, but once I get the general idea...
I am a very, very new Java coder, so please be patient with me not understanding what must seem very basic.
Step 1: create a jar from you classes, if your using eclipse then simply
https://www.cs.utexas.edu/~scottm/cs307/handouts/Eclipse%20Help/jarInEclipse.htm
Step 2: add the jar dependency to your eclipse project
How to import a jar in Eclipse
I'm trying to run the NWaling.java file found here. the code present at the link that I mentioned makes use of the jaligner library. I have downloaded this Java package from here. inside the zip folder there is a JAR file. I'm developing the code using eclipse. whenever I add this JAR file to the code there are some classes missing for example:
import jaligner.NeedlemanWunschGotoh;
&
import jaligner.matrix.MatrixGenerator;
also in the entire zipped folder there isn't any pom.xml file to allow me to import the entire folder as a maven project to eclipse. can somenone suggest me how to import this jaligner library and use it in eclipse? thanks.
You can download a community implementation of the jaligner algorithm from here.
Take a look at this project sources where you may perhaps find all the searched artifacts.
The full Eclipse project with the NWalign.java can be found here including .classpath file with all dependencies listed there.
I have found similar problems, and i applied all the suggested solutions, but none works so far. I may have overlooked something.I am working on Maven multi-module project. In one of the packages, one of the java files is trying to access class file in another package. Class file is an external dependency provided in a jar file, installed on local repository. Jar file is added in Java Build path-> Libraries under Maven Dependencies. It is even included in classpath variable. But when I try to declare package and access it, I get error
The declared package "net.java.swingfx.waitwithstyle" does not match the expected
package "com.giag.fo.application.utility"
I would really appreciate any suggestions. I have tried anything I could find. I am clueless now.
Here is the image to get better idea
use import instead of the keyword package.
like :-
package com.giag.fo.application.utility;
import net.java.swingfx.waitwithstyle.*;
Instead of
package net.java.swingfx.waitwithstyle;
use
import net.java.swingfx.waitwithstyle.InfiniteProgressAdapter;
You can read more about package and import here
I am trying to do this simple tutorial using the JARVIS Java Speech API:
https://github.com/The-Shadow/java-speech-api/wiki/Hello-World
These import lines lead me to think that I need to link to a .jar library.
import com.darkprograms.speech.microphone.Microphone;
import com.darkprograms.speech.recognizer.Recognizer;
import com.darkprograms.speech.recognizer.GoogleResponse;
But when I go to the gitHub site, the only option is to download the .java source files. How should I go about converting them into a .jar? Is that what I am supposed to do?
On that same GitHub page, you can download the jar :
https://github.com/The-Shadow/java-speech-api/releases
You should also acquire any additional jar required by Jarvis (it doesn't seem there are any from a quick look).
That said, if you want the very last version of that library (and the associated bug/problems if any), then you will need to compile it from source, ie, something like :
clone the git repositery
compile the java sources
create the jar
This is a very basic question, but I can't seem to find an answer. I've just installed BaseX (V.7.8.1 on Win7 PRO/64- bit) and have it running successfully through their GUI. I am now trying to run queries locally via their JAVA examples (from GitHub - specifically their RunQueries.java example). I've created a test project in Eclipse and placed the RunQueries.java code there to try to run it. But, the BaseX imports are not being resolved :
import org.basex.core.*;
import org.basex.core.cmd.*;
import org.basex.data.*;
import org.basex.io.serial.*;
import org.basex.query.*;
import org.basex.query.iter.*;
import org.basex.query.value.item.*;
Should the general install of BaseX put these packages in the correct place? If not, what do I need to do to find & get these package components properly into my directory structure? Appreciate any help.
You need to add the BaseX.jar file as an external JAR to your Eclipse project. You can do this by right-clicking on your project in Package Explorer, then Build Path > Add External Archives. I am assuming you also run their GUI from this JAR file, so you should have it. If not, you can download it here.
If you are also interested in the internal workings of BaseX; you can actually download their source from GitHub.