I believe this is the appropriate forum, but if it is not please let me know and I will move it to the OSX forum.

I have an assignment that requires me to play with a specific jar file. I am currently running OSX 10.6 and I have Java 6 installed. Xcode is my main IDE but I recently downloaded eclipse after reading that it was better for Java development. Now when I click on this Jar file OSX tells me that it cant be launched. This file is called FRTsniffer.jar and here are the classes the code tries to import:

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.*;

import org.biojava.bio.BioException;
import org.biojava.bio.seq.DNATools;
import org.biojava.bio.symbol.Alphabet;
import org.biojava.bio.symbol.Symbol;
import org.biojava.bio.symbol.SymbolList;
import org.biojavax.RichObjectFactory;
import org.biojavax.bio.seq.RichSequence;
import org.biojavax.bio.seq.RichSequenceIterator;

I realize I do not have these Biojava libraries. My understanding was that these were trying to be accessed from the internet hence the URL. This did not work so I attempted to download the Biojava libraries and they also did not run. I could not find a guide on what to do with them either. So I am at a complete loss on what to do here.

In summary, my questions are:

1) Are my jar files supposed to just run like an executable if I have the proper libraries installed?

2) Do I have to do anything special to use the URL imports and if so,is there a good guide?

3) If I download the Biojava libraries and install them should the jar files work the same as using the URL imports?

4) Is there a guide to install these Biojava libraries that are Jar files because I have clicked on them and they also do not run?

If I am missing any information for you please let me know. I am a sophomore computer science major with moderate programming experience in Java but I have never had to modify the libraries or anything remotely that technical. Thank you for your time--Robert

The "url" import as you put it is not a url, you cannot import libraries from across the internet, not like that. If you open a jar file in winrar or winzip, you can see several folders matching the names of the imports. Essentially, the import points to a package location, which a package is stored as a series of sub-directories.

The jar file (library package) has to be saved in a location that's included in your CLASSPATH, a system variable. Or you could save the file anywhere and add its location to the classpath so the JVM knows where to look for it.

XCode might have a preference to load additional libraries itself, but I couldn't say for sure and I don't have it installed on my system (thought I did) because I've been using netbeans.

Hi, I realize that it has been a while but, I have been busy with other school work and have returned to this project. I have began using netbeans and have added all of the nescessary jar files to the libraries. I'm still getting a classpath errors though. It is this error right here

" java.lang.NoClassDefFoundError: org/biojava/utils/bytecode/CodeException"

I searched the jars that I had just added and found the biojava/utils/bytecode/CodeException though. So I know it is there. I put it where it was supposed to be. So if I added the jars properly and I'm looking at what it is telling me it is missing. What do you think the problem could be?

Use java -cp FRTsniffer.jar Class in Terminal.

Before I explain what happened I'm going to start over. I'm going to list everything I have tried today.I have been give a project that uses the biojava libraries. I have uploaded all of the source code to this rapidshare link.

http://rapidshare.com/files/344172662/BIOCStuff.zip.html?killcode=17379056641979851891

If someone would like to try to compile the code.

Ok, the project is source code that uses the biojava libraries. The code is supposedly already compiled and includes the original source code, an xml file, and a jar file. I downloaded all of the biojava libraries. I followed the tutorial on their website to add the libraries to my classpath,the link is here, “http://www.biojava.org/wiki/BioJava:GetStarted

After trying to run the jar file which is included in the project files. It is suppose to already work and you should be allowed to pass command line arguments and everything to it. I ran it with these commands and recieved the error.

“java -jar FRTsniffer.jar -c classes.txt -in frt_output.txt” This gave me the error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/biojava/utils/bytecode/CodeException
at org.biojava.bio.seq.FeatureFilter$OnlyChildren.<clinit>(FeatureFilter.java:1270)
at org.biojava.bio.seq.FeatureFilter.<clinit>(FeatureFilter.java:1813)
at org.biojava.bio.seq.SimpleFeatureHolder.<init>(SimpleFeatureHolder.java:54)
at org.biojavax.bio.seq.RichFeature$Tools.makeEmptyFeature(RichFeature.java:167)
at org.biojavax.bio.seq.io.RichSeqIOAdapter.<init>(RichSeqIOAdapter.java:61)
at org.biojavax.bio.seq.io.SimpleRichSequenceBuilder.<init>(SimpleRichSequenceBuilder.java:100)
at org.biojavax.bio.seq.io.SimpleRichSequenceBuilder.<init>(SimpleRichSequenceBuilder.java:81)
at org.biojavax.bio.seq.io.SimpleRichSequenceBuilderFactory.makeSequenceBuilder(SimpleRichSequenceBuilderFactory.java:68)
at org.biojavax.bio.seq.io.RichStreamReader.nextRichSequence(RichStreamReader.java:109)
at src.FRTclassifier.getClasses(FRTclassifier.java)
at src.FRTclassifier.classifyPatterns(FRTclassifier.java)
at src.FRTsniffer.main(FRTsniffer.java)

I then tired “java -cp -jar FRTsniffer.jar -c classes.txt -in frt_output.txt”

It gave me the error:
Exception in thread "main" java.lang.NoClassDefFoundError: FRTsniffer/jar
Caused by: java.lang.ClassNotFoundException: FRTsniffer.jar
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:315)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330)
at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)


So I attempted to recompile it myself. I downloaded Netbeans, added the libraries to my libraries folder by following a tutoiral and I recompiled. I then received the exact same error that I received the very first time I tried to run the jar file.

I have now just attempted “java -cp FRTsniffer.jar Class” and received this error:

Exception in thread "main" java.lang.NoClassDefFoundError: FRTsniffer/jar
Caused by: java.lang.ClassNotFoundException: FRTsniffer.jar
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:315)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330)
at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)

Although I do not think that the last suggestion is what I really needed since I need to run the jar file. Although I should have posted all of this information before responding earlier today. I apologize for that. I'm honestly at my wits end. I have read several tutorials on classpaths today and I have tired several things but none of them have resolved these errors. Are there any more suggestions? Thank you all for the help so far though.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.