this may sound like a noob question, but it is a big problem for me. I have a file called yandex-translator-java-api-master.zip, and I tried adding that as an external JAR to my eclipse project, but the code wouldn't work; It wouldn't let me import.
This error comes up when i try to import "Translate"
Translate cannot be resolved
6 quick fixes available:
Create class, create constant, fix proj. setup...etc, etc.
How do i use this??? Where is the .jar i am supposed to import?
zip archive is not the same thing as jar. First, extract jar from zip archive and then add it as dependency. Then you'll be able to import.
UPD:
looking closely, I suppose you downloaded that archive from GitHub (or another VCS) and it's just sources of a library. You can not add it as a dependency, but you can, for example, just paste this code in your project's /src/main/. This is an easy solution. If you want to make things the right way, you can
a) Search for a compiled library
b) Create a module from downloaded sources and add it as dependency
Download this file:
And established it as a library.
Instruction is in this answer.
Related
Based on the gradle docs, to define external jars means adding to build.gradle the following snippet (considering you have {project_root}/libs/foo.jar) in place:
dependencies {
runtime files('libs/foo.jar')
}
However, using the same dependency declaration for *.war files doesn't work. Is this even possible? The project I'm trying to depend on builds to a war file.
Since war layout is different from jar file standard layout, it's not possible to declare war a dependency file to a java project. Possible ideas:
Clone the project and define it as a dependency (very stupid idea, I'm ashamed that I suggest sth like that)
Contact the author and ask him/her if you can just copy the class you need to use. If you can copy the class along with the credits.
Contact the author and ask him/her if it does make sense to make the codec open source (I know it is right now) and release it as a standalone jar library (maybe along with other classes used in the project).
I am trying to write a program in Java, which would collect a specified set of files from the physical location and place them in a jar in a certain directory.
I know I can use java.util.jar package for this. The package is great for sure, but I was wondering if there are any third party libraries that anyone at SO has used which they could recommend.
TL;DR: pick up files, create jar by placing them in pre-defined directories, all at run time in a java file.
P.S: I did not find any similar references to this question, but if there are then please refer me. Also, the title might be misleading, but I didn't find better words to explain my problem.
EDIT 1: I am not in anyway saying java.util.jar is bad or incomplete. All I am asking is if anyone has used any alternative solutions!
EDIT 2: I am trying to create the jar from inside the java program. The jar can be pretty big (~500mb) too. Trying to jar media files as well. So simply put, I pick up various files from certain locations on my drive and try to create a jar file by placing them in standard locations.
Thanks,
Ivar
Look at the java.util.zip package. Jars are just zip files with some extra stuff in 'em
I'm working on a java android project. this project requires to use specific commands.
these commands are all developed in c++/c but I've been given two files (.jar and .so) that are supposed to "turn them into" java, so I can use them in my java android project.
The thing is, what am I supposed to do with these 2 files?? I've read a lot of stuff (mostly about creating the .jar and .so, but I don't care about this step, for I already have the 2 files)
I tried to import the .jar (import external lib), I tried to add the .so via the static loading :
//static {
// System.loadLibrary("MySoFile");
// }
All I get is a stack overflow error or a problem with the DEX file...
Has anybody ever tried to do this??
I don't seem to get the point here...all I want to do is being able to use the commands in the .jar file.... ://
thanks in advance!!
Take a look at this answer about adding jar files. '.so' files can usually just be drag and dropped to the project.
All you need to do is make sure the jar is in your classpath and you can then access the classes within this jar. A jar is just an archive of classes, you don't need to load the library into memory or something similar.
You may want to read the answer to the question here How to use classes from .jar files?
I am trying to use the GeoTIFF-jai Library to generate a geo-rectified, raster image in Java. I have tried looking on the SourceForge site for the documentation on how to do this, but SourceForge says "Unfortunately, this project hasn't indicated the best way to get help." Has anyone else tried using this library and been able to find any documentation on it?
If there truly is no documentation, maybe you can answer this question. When I import the library .jar file into my Eclipse project (using right-click->Import...->Archive File) all of the .properties files import but not the .class files. I need the GeoTIFFFactory class from org.geotiff.images.jai in order to create a new GeoTIFF image but it's not available. Any idea why the .class files are not importing? Am I doing something wrong on the import? Is the .jar in the wrong directory?
Any help with either of these questions is greatly appreciated.
Thanks,
Ryan
When I import the library .jar file into my Eclipse project (using
right-click->Import...->Archive File) all of the .properties files
import but not the .class files. Am I doing something wrong on the import?
Yes. That's not how you use third-party jars in Eclipse. The wizard you invoked is used primarily for importing archives with source code to make changes to them. Instead create Java project to hold your source code and add a dependency on the jar via Project Properties -> Java Build Path. You can also attach a source code archive in the same place (get this from project's site on SourceForge). This will let you see any available javadoc and if there is no documentation at all, you can at least step through the code.
Regarding lack of documentation, you will be more likely to get help on that project's forum rather than on stack-overflow (since the odds of you finding help on stack-overflow with a particular library is inversely proportional to that library's popularity).
I was about to report a but to Eclipse, but I was thinking to give this a chance here first:
If I add an external package, the application cannot find the referenced native library, except in the case specified at the below:
If my workspace consists of a single project, and I import an external package 'EX_package.jar' from a folder outside of the project folder, I can assign a folder to the native library location via:
mouse over package ->
right click ->
properties ->
Native Library ->
Enter your folder.
This does not work. In runtime the application does not load the library, System.mapLibraryName(Path) also does not work.
Further more, if I create a User Library, and add the package to it and define a folder for the native library it still does not.
If it works for you then I have a major bug since it does not work on my computer I test this in any combination I could think of, including adding the path to the windows PATH parameter, and so many other ways I can't even start to remember, nothing worked, I played with this for hours and had a colleague try to assist me, but we both came up empty.
Further more, if I have a main project that is dependent on few other projects in my workspace, and they all need to use the same 'EX_package.jar' I MUST supply a HARD COPY INTO EACH OF THEM, it will ONLY (I can't stress the ONLYNESS, I got freaked out by this) work if I have a hard copy of the package in ALL of the project folders that the main project has a dependency on, and ONLY if I configure the Native path in each of them!!
This also didn't do the trick.
please tell me there is a solution to this, this drives me nuts...
Update:
if anyone wants to try this for them selfs you can try to use JMF.jar and to refer to the native dlls, or the jmf.properties file, on my XP, I refer to the dll files and I don't need the jmf.properties file.
Thanks,
Adam Zehavi.
I missed the point that Eclipse does not export the native library.
here is a solution to what I was facing: Other answer