[Biojava-l] It's me once again

Matthew Pocock matthew_pocock@yahoo.co.uk
Tue, 10 Dec 2002 17:16:01 +0000 (GMT)


Hi,

Try reading through this tutorial. It should help fill
the gaps.

http://java.sun.com/docs/books/tutorial/java/interpack/packages.html

> I tried to put the .class in this directory
> (relative to my CLASSPATH)
> :/org/biojava/bio/program/PdbToXMLConverter.class
> But it does'nt solve the problem.
> If I put the .class in the directory where I run the
> program, the error is the same.
> On the other hand, if the .class is ONLY in the
> package directory (the org/biojava....), I mean if I
> remove the .class from the current directory, the
> problem is: 
> 
> [jon@diana ~]$ java PdbToXMLConverter 1FS1.pdb
> Exception in thread "main"
> java.lang.NoClassDefFoundError: PdbToXMLConverter
> [jon@diana ~]$

In this configuration, you would need to type:

java org.biojava.bio.program.PdbToXMLConverter
lFSl.pdb

Notice that the package prefix to the class matches
the package of the classes package & it's location.

> 
> I tried removing the package line "package
> org.biojava.bio.program" but the following error
> ocurred while compiling:
> 
> [jon@diana ~]$ javac PdbToXMLConverter2.java
> PdbToXMLConverter2.java:69: invalid method
> declaration; return type required
>     public PdbToXMLConverter(String poInput) {
>            ^
> 1 error

This is because you have renamed the class to
PdbToXMLConverter2, but have not renamed the
constructor to match the class name. Rename this
constructor to match the class name and try again.
Make sure that you use

java PdbToXMLConverter2 lFSl.pdb

OH. The name of a java class and of it's file must
match if it is a public class. So, if you have a class
called Foo, it must be in a file called Foo.java and
will produce a class file Foo.class and will have a
constructor called Foo() and you would run its main
method as java Foo <args>..

If it is in package bar, then the class is bar.Foo,
and it will be in a file bar/Foo.java and will produce
a class file bar/Foo.class and if it has a main method
you run it as java bar.Foo <args>.

Best,

Matthew

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com