Add jena library to netbeans - java

I want to add the Jena library to Netbeans. When I visit http://www.apache.org/dist/jena/ to download Jena library there are two folders: binaries/ and source/. I don't really know whether I should download binary files or source files. In the binary folder there are also so many files some with extension .zip, .tar.gz, .tar.gz.asc etc...
Which one do I use?
Secondly, in the online tutorials, they say that only jar files need to be added. In one of the folders I downloaded (apache-jena-2.10.1.zip) jar files are present in lib, lib-src and src-examples.
Do I have to go in every folder and individually add it to library?
What about the other folders: bat, bin, java-docs? What am I supposed to do with them?
Kindly explain as comprehensively and clearly as possible, as I am new to this field with little knowledge about this stuff.

By the sound of it you want apache-jena-2.10.1.tar.gz or apache-jena-2.10.1.zip, which are different packagings of the same content -- the jena libraries, their dependencies, documentation and command line tools. asc, md5, and sha1 are present so that downloaders can check the integrity of the revelvant download.
So the zip you have is what you need. For working with jena you only need the jars in lib/. lib-src/ contains the jena source, and may be useful in netbeans if you want to look up the implementation of jena (for example when debugging).
java-docs/ contains a copy of the jena javadoc: the jena api documentation which is also available online.
bin/ provides command line tools for unix users. bat/ is the equivalent for windows users.
In the long run I recommend using netbeans with maven (see this answer for a quick guide). With maven libraries are downloaded as needed, so you don't need to manually locate the jena distribution and extract the libraries.

Related

Why don't I see code when viewing included Jar libraries in Eclipse?

There doesn't seem to be any code there. I expected to see class declarations so I could see what the code does but instead there's some
Are they somehow precompiled? What's the difference between included Jar file and a pure code?
You are looking at .class file, which is a generated when you compile .java file. To see what the program does, you have to look into .java file. You can refer official java documentation for that.
A .jar file is packaged file with .jar extension, it contains compiled java files and their class files. This file is usually imported into projects to use the classes defined in that package.
You can use "jar xf jar-file" command in command-prompt/terminal to extract the files from jar and look into the package.
A JAR will normally contain compiled class files. It may also contain source files or there may be a separate JAR that contains the source files, but not necessarily so.
If you want to use the library in your project, then a JAR of compiled class files is what you want. If you want the source code, then you'll have to see if it is available from wherever you downloaded this from. If all you want is to see how to use the classes, then probably what you want are JavaDocs for the library you are using. This is an HTML based API documentation.
Well, this is because you haven't attached any source for the mentioned dnsns.jar. You can attach source to existing JAR files in Eclipse. Refer this SO post: Is there an easy way to attach source in Eclipse?
For this specific dnsns.jar, it is part of your JRE, and if you are not able to see its source in your IDE, then it means that the Java that you have setup in IDE lacks the source. If your installation does not have the source (src.zip), then you can get it manually as mentioned on this SO post: Where to find Java JDK Source Code?
EDIT: Alternatively, you can also use a decompiler (e.g. http://jd.benow.ca/) to reverse engineer the source from byte code, though, it may not be the exact match to the original source but you can understand the overall idea. You can add the decompiler as the default program for opening .class files in eclipse Windows > Preferences > General > Editors > File Associations. Select *.class filter and add your decompiler as the program. Though, it is not as clean as attaching the source to JAR, but may work if you don't have access to source.
EDIT2: About your question
What's the difference between included Jar file and a pure code
Eclipse can find .java files for your own code because obviously they are in your workspace. But when you add a JAR file as library, it may have the source (.java) in it or not. If the source is available, eclipse can display it by default. If not, you have to add it manually.

How to use apache commons download

I've just downloaded apache commons-lang3-3.2.1 source and binary because I want to try out their Fraction class.
My first question is how to find the relevant file to add to the build path in Eclipse?
My second question is whether to use binary or source?
I've tried looking in both but I can only see executable JARs and JAVA files and I seem to remember they aren't what I need from past experience.
You need to decide to add source or binary to your eclipse buildpath, but i would always add just the complete binary to eclipse build path and if i need to see how the method internally really works we can any way have a look in the api source code without adding it to the buildpath.

GWT project and Eclipse linked resources

I have to use a Javascript file in my GWT Project. This Javascript is in a common library project and I deploy it together with my GWT Project using ANT.
So, I have no problem in production environment: but I cannot test it in development phase.
I tried to create an Eclipse link to Javascript resource but seem that GWT "can't see it".
Some behavior with other kind of resources (images, css etc.).
Is it a bug or is there another way to do?
I'm using Eclipse Juno, GWT 2.5.0 and Debian 7.0.
Thank you.
Can you just use script tag in your project's .html file?
If you're using some kind of source control, it usually has a way to make a link to a dependent project or file. Simply include that link in your GWT Project, and reference the file through there.
If you can't or don't want to do it through your source control, do it through your OS. Since you're using Linux, simply make a symbolic link to the common file/folder using ln -s (if you were using Windows, you'd need to run mklink from the command line), and reference the file that way.
In either case - source control or OS - you'll be able to see the file(s) when you refresh your project in Eclipse, and modifying one will modify the other in its own directory.
Edit - information on symbolic links in CVS
I haven't played with CVS in quite some time, so can't speak much about its capabilities for symbolic links. A bit of googling said it's not supported, though there are workarounds. One workaround is to add script files that run during checkout. That sounds like it may still be tough to make OS-agnostic. I did find one site that mentioned using module aliases to get the same result. Maybe that will give what you need. An excerpt from the site follows:
One common way to handle situations like this in CVS is to alias the
collection in a modules file rule. -Checkout the "CVSROOT" module and
you'll find the "modules" file; simply change it and check it in like
anything else, with the exception that when you check in CVSROOT files
they "activate" at the same time. The example below may look a little
kludgy, and it is because AFAIK you can't redefine a directory and alias
it at the same time, sadly. I'll use a typical Java situation as its
package system lends itself well to this kind of thing:
Real module directories are "a", "b", and "common"
Directory alias for all common srouce
_common_src_all -d src/com/mycompany/common common/src/com/mycompany/common
Full "A" project including common
a_all &a &_common_src_all
Full "B" project including common
b_all &b &_common_src_all

Archive a folder in Java using truezip

I need to create a service that finds specific folders and archives them into on zip file.
I saw all kind of examples, but it seems that have to read all the files in every folder. Am I right?
Is there another way to do that (maybe using truezip for that matter)?
I want to use truezip since I understood you could easily add files/folders to a zip file.
I've searched for a simple example of archiving a folder using truezip - but I couldn't find anything useful - I need a simple example of how to archive a given folder.
I'm using Java 6. How to archive a folder in Java using truezip?
EDIT:
Also found this example.
Using TrueZIP, all you need to call is
new TFile("folder").cp_rp(new TFile("archive.zip"));
I suggest to read it's tutorial in order to get a better understanding of what it all means: TrueZIP Tutorial

Where is the documentation for the GeoTIFF-jai Library

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).

Categories