0

I am trying to run some old java applets from the old book "Algorithms and Data Structures In Java" by Robert LaFore.

https://sites.fas.harvard.edu/~cscie119/resources/lafore/

or

https://cs.brynmawr.edu/Courses/cs206/spring2004/lafore.html

I have JDK 1.8 / Java 8 installed and it includes appletviewer.exe C:\Program Files\Java\jdk1.8.0_251\bin\appletviewer.exe

I don't have any recollection of how one would run them.

I've got appletviewer.exe in my path.

C:\aaa>path=%path%;C:\Program Files\Java\jdk1.8.0_251\bin

C:\aaa>appletviewer
Usage: appletviewer <options> url(s)

where <options> include:
  -debug                  Start the applet viewer in the Java debugger
  -encoding <encoding>    Specify character encoding used by HTML files
  -J<runtime flag>        Pass argument to the java interpreter

The -J option is non-standard and subject to change without notice.

C:\aaa>wget https://cs.brynmawr.edu/Courses/cs206/spring2004/WorkshopApplets/Chap02/Array/Array.class
--2020-05-19 07:00:11--  https://cs.brynmawr.edu/Courses/cs206/spring2004/WorkshopApplets/Chap02/Array/Array.class
Resolving cs.brynmawr.edu (cs.brynmawr.edu)... 165.106.10.107
Connecting to cs.brynmawr.edu (cs.brynmawr.edu)|165.106.10.107|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3967 (3.9K) [application/octet-stream]
Saving to: 'Array.class'

Array.class                           100%[=======================================================================>]   3.87K  --.-KB/s    in 0s

2020-05-19 07:00:11 (18.7 MB/s) - 'Array.class' saved [3967/3967]


C:\aaa>dir Array.class
 Volume in drive C has no label.
 Volume Serial Number is 4645-5DCE

 Directory of C:\aaa

03/01/2005  15:59             3,967 Array.class
               1 File(s)          3,967 bytes
               0 Dir(s)  335,436,058,624 bytes free

C:\aaa>wget https://cs.brynmawr.edu/Courses/cs206/spring2004/WorkshopApplets/Chap02/Array/Array.java
--2020-05-19 07:00:24--  https://cs.brynmawr.edu/Courses/cs206/spring2004/WorkshopApplets/Chap02/Array/Array.java
Resolving cs.brynmawr.edu (cs.brynmawr.edu)... 165.106.10.107
Connecting to cs.brynmawr.edu (cs.brynmawr.edu)|165.106.10.107|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2020-05-19 07:00:25 ERROR 404: Not Found.


C:\aaa>appletviewer Array.class

C:\aaa>appletviewer Array
I/O exception while reading: C:\aaa\Array (The system cannot find the file specified)

C:\aaa>

As another route I just tried https://sourceforge.net/projects/portableapps/files/Mozilla%20Firefox%2C%20Portable%20Ed./ Mozilla Firefox, Portable Edition 2.0.0.8 2007-10-22

But Firefox doesn't come with the plugin and can't install it

enter image description here

Added

Going back to trying with appletviewer, I found from googling that error, that appletviewer is meant to run be given an HTML file.

So I tried

C:\aaa>wget https://cs.brynmawr.edu/Courses/cs206/spring2004/WorkshopApplets/Chap02/Array/Array.html

And I get

C:\aaa>Appletviewer Array.html
java.lang.NoClassDefFoundError: personGroup
        at Array.init(Array.java:746)
        at sun.applet.AppletPanel.run(AppletPanel.java:434)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: personGroup
        at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:219)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:152)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        ... 3 more

I tried jd-gui-windows-1.6.6 and opened Array.class and I see that it has private personGroup thePersonGroup;

At this URL

https://cs.brynmawr.edu/Courses/cs206/spring2004/WorkshopApplets/Chap02/Array/....

No doubt that is a reference to a file system

There is Chap02/Array/Array.html and Chap02/Array/Array.class but I can't see any personGroup.class or personGroup.java

2 Answers 2

1

You have only downloaded Array.class which is the "startup-class". However this class loads other classes that resides in the same directory. For example the class personGroup is also available in this directory:

https://cs.brynmawr.edu/Courses/cs206/spring2004/WorkshopApplets/Chap02/Array/personGroup.class

Hence you have to download every class that is linked in every class you download unless you got all involved classes.

As the web server denies folder listing you have to identify and download each class one-by-one.

What class to download next is visible in the NoClassDefFoundError exception(s) you will get.

2
  • yes i'm not sure why I didn't spot it but there's a person.class and a personGroup.class there.. Ah I see I missed it because I got the case wrong. Those two person class files the URL has to be that case.. lowercase first letter.. the camelcase style.. whereas Array.class is not.
    – barlop
    May 21, 2020 at 17:02
  • Is that normal convention re casing in java? he has Array.class but person.class and personGroup.class
    – barlop
    May 21, 2020 at 17:18
0

I'll keep the accepted answer as is.

The key that solved it for me was the case!

One has to get the case correct

https://cs.brynmawr.edu/Courses/cs206/spring2004/lafore.html
https://cs.brynmawr.edu/Courses/cs206/spring2004/WorkshopApplets/Chap02/Array/Array.html

And having done

C:\aaa>path=%path%;C:\Program Files\Java\jdk1.8.0_251\bin

C:\aaa\fff>appletviewer Array.html load: class Array.class not found. ...

wget https://cs.brynmawr.edu/Courses/cs206/spring2004/WorkshopApplets/Chap02/Array/Array.class

C:\aaa\fff\ff>appletviewer Array.html
java.lang.NoClassDefFoundError: personGroup

Note that that class has lowercase p! Different to the array class that has uppercase A!

wget https://cs.brynmawr.edu/Courses/cs206/spring2004/WorkshopApplets/Chap02/Array/personGroup.class

C:\aaa\fff\ff>appletviewer Array.html
java.lang.NoClassDefFoundError: person

Again a lowercase first letter on that class

wget https://cs.brynmawr.edu/Courses/cs206/spring2004/WorkshopApplets/Chap02/Array/person.class And then it starts

enter image description here

So, that web server they have is case sensitive.. and appletviewer does take case into account when it shows the filename.. which is good. And unfortunately the program wasn't following any consistent casing that i'm aware of for naming class files as it had Array.class and person.class and personGroup.class so a mixture there. I don't know if that's any standard convention, it may be. But I wasn't aware of it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.