[luau] Java question

Roderick Gammon, Ph.D. (AEG, Inc) AEG-Inc at hawaii.rr.com
Fri Apr 18 22:26:00 PDT 2003


Aloha-

The problem in the latest code snippet is naming- the main thread cannot
find the class "Scubatoolkit.java".

Try: "java -cp . Scubatoolkit"

It's an important point of convention, or idiom.  Technically there
shouldn't be class files in the source directories and class and source
files have different, standardized suffixes.

A Java source file, commonly suffixed ".java" is a plain text file
consisting entirely, one hopes, of strings intelligible to a Java compiler.

A class file, commonly suffixed ".class", is a binary file legible to a Java
Virtual Machine.  Thus a distribution's source directory should contain only
Java source files while a binary directory should have only Java class
files.  

Of course source and binary directories might contain various other
resources- XML, localization string files, images, and sounds for example.

Use the opportunity to learn though- note that the compiler gave a different
error from before.  Note also that no source code line number is given,
unlike before.  This indicates a different situation- in the first situation
a function couldn't work so it threw an error at a certain line.  The error
now is more "macro" level- a resource, a class file, couldn't be found in
the file system.  The general problem remains the same as before though- the
Java Virtual Machine cannot locate a class definition.

If you have no ".class" files anywhere, but lots of ".java", then what you
need to do is execute "javac" across your source tree.  You can get fancy
with ant, or execute "javac -sourcepath <list of directories> -d <dir to put
class files in>".  To my knowledge the sourcepath is not recursive- execute
javac from each directory, or name them all in the sourcepath.
http://java.sun.com should become a favorite rtm website soon.

If you are actively looking for Java software for a specific purpose, a
statement of context might allow us to help you better.  Are you looking to
set up a Scuba rental place?  Looking to explore how underwater simulations
are programmed?  

Good luck!
Rod Gammon

On 4/18/03 9:54 PM, "Ben Beeson" <beesond001 at hawaii.rr.com> wrote:

> To Rod, Don, Virgil, and Ray,
> 
>    My latest attempts all look like this:
> 
> [ben at VALinux SCUBATOOLS]$ java -cp . Scubatoolkit.java
> Exception in thread "main" java.lang.NoClassDefFoundError: Scubatoolkit/java
> [ben at VALinux SCUBATOOLS]$
> 
> In short, I believe all of you are correct, the class for scubatoolkit is
> nonexistant.  BTW, there are no .class files in any of the sources.  There
> are several .java files, but no .class files.  So, I think I know what I need
> to go fix now.  I just need to figure out how to do that as well.
> 
> Thanks for all your hlep,
> 
> Ben




More information about the LUAU mailing list