[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: No VM02 at KFest?



In article 
<f585a368-ca9f-4396-a18d-b9f646347529@b4g2000pra.googlegroups.com>,
 DaveSchmenk <dschmenk@gmail.com> wrote:

> On Jul 22, 5:23 pm, dog_...@macgui.com (D Finnigan) wrote:
> > DaveSchmenk wrote:
[...]
> > I was compiling some things for it, but got stuck with what I think 
> > is a javac problem. I can't figure out how to compile a single 
> > .java file with multiple classes into just one file. It seems like 
> > VM02 wants everything in one file, but maybe that's not the case, 
> > either.
> 
> You just need to specify where the classes are - no need to build one
> huge class file.  VM02 just can't handle .jar files.  Look how the
> samples include the classes for the gui and apple2 classes, i.e.:
> 
> import apple2.*;
> import org.vm02.cui.*;
> 
> When javac goes traipsing through the directories looking for
> the .class files, it will build them from the .java source if it
> doesn't find them.  In my makefile (I'm the worst makefile author in
> the world) I try to build all the class files up front so that I can
> copy them to ProDOS image directory.  I've had a few bugs when javac
> would update a class file before the makefile got to it so it never
> got copied to the ProDOS image.  Arrggghhh.
> 
> Drop me a line if you need more info.
> 
> Dave...

I couldn't see a way to do nested classes; ProDOS rejects the filename. 
Alternatively, "a single source file may declare any number of classes, 
but only one may be public."

<http://stackoverflow.com/questions/2366531>

For example,

import apple2.*;

public class Main {
        
    public static void main(String args[]) {
        System.out.println("Hello, world!");
        System.out.println("Answer: " + Answer.n);
    }
}

class Answer {
    static int n = 42;
}

You have to copy both classes to the destination:

DISK=java.2mg
CLASSPATH=.:/Users/Shared/vm02/src

Main: Main.java
    javac  -cp ${CLASSPATH} Main.java
    ac -d ${DISK} Main
    ac -p ${DISK} Main bin < Main.class
    ac -d ${DISK} Answer
    ac -p ${DISK} Answer bin < Answer.class

Oddly, if I put both classes in a subdirectory, Main runs, but the vm 
looks for Answer in the root directory.

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>