Starting A5

12 views
Skip to first unread message

Mike Johnson

unread,
Nov 18, 2010, 11:54:33 AM11/18/10
to Cornell CS 2110
When I imported A5 into eclipse this morning, I noticed that all of
the files are .class file types, meaning there's no source (.java)
files for skeleton code.

Should we just create our Naturalist.java file ourselves, or was it
intended to be included in the A5.jar?

Lonnie Princehouse

unread,
Nov 18, 2010, 12:47:01 PM11/18/10
to cornell...@googlegroups.com
Make your own MyNaturalist class (or whatever you want to call it; name doesn't matter, although CMS will rename it MyNaturalist automatically), but it must extend cs2110.assignment5.Naturalist.   Note that you don't need the source code of a superclass in order to create a subclass.  a5.jar must be in your build path for that to work.



--
You received this message because you are subscribed to the Google Groups "Cornell CS 2110" group.
To post to this group, send email to cornell...@googlegroups.com.
To unsubscribe from this group, send email to cornell-cs211...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cornell-cs2110?hl=en.


ninelife

unread,
Nov 19, 2010, 3:10:21 PM11/19/10
to cornell...@googlegroups.com
Can't figure out how this gonna to work. I imported the a5.jar into src as usual and since it doesn't contain java source codes Eclipse simply shows it's an empty package (well...it says no java resources found). I attempted to import the assignment5 package and extend MyNaturalist class to Naturalist class. Then Eclipse yelled at me that Naturalist class is not found. When I attempt to run the simulator, Eclipse again says "no main type" found. When I attempt to use run configuration to search main class, nothing is found under assignment5. Can someone provide a detailed instruction on import and run the simulator for this one? Screenshots might even be better to convince me it indeed works! Thx

ninelife

unread,
Nov 19, 2010, 3:12:27 PM11/19/10
to cornell...@googlegroups.com
Nevermind...just got it...simply right click and under build path, click add to build path....

Lonnie Princehouse

unread,
Nov 19, 2010, 3:16:16 PM11/19/10
to cornell...@googlegroups.com
Exactly.  

To elaborate, the jar in this assignment contains no source. The source jars we've been using for class are unusual in the real world, and it is common to use an API without having its source code.  Even for open source projects (such as Apache or Google's "Guava"), you typically don't download the source code if you just want to use the library.

ninelife

unread,
Nov 19, 2010, 3:42:34 PM11/19/10
to cornell...@googlegroups.com
That suddenly makes more sense to me. I would complain a bit though Visual Studio seems to be much more straight forward to import a library...lol
 
One more question, I attempted to run the program with the example class but I got: "Error: Class "RandomWalkNaturalist" not found." I supplied "RandomWalkNaturalist" (w/o quotation marks) as argument.

Lonnie Princehouse

unread,
Nov 19, 2010, 3:47:16 PM11/19/10
to cornell...@googlegroups.com
Argument needs to be fully qualified:  cs2110.assignment5.examples.RandomWalkNaturalist

Tim

unread,
Nov 21, 2010, 3:39:12 PM11/21/10
to Cornell CS 2110
Can we get detailed instructions on how to set up the program. I'm
still having trouble extending the Naturalist class.

Lonnie Princehouse

unread,
Nov 21, 2010, 3:43:09 PM11/21/10
to cornell...@googlegroups.com
1. Add a5.jar to your build path
2. Make a new class that extends cs2110.assignment5.Naturalist
3. Implement the run method (public void run() )



Brian

unread,
Nov 24, 2010, 3:11:35 PM11/24/10
to Cornell CS 2110

And then what?

I tried running the simulator with the argument MyNaturalist (and with
the .java and .class), and changing the working directory, but it
always says

Initializing map... OK
Error: Class "MyNaturalist" not found.

And when I try to run RandomWalkNaturalist, it says Fatal Exception
occurred.

I really can't figure out how to get any part of this to run.

Theodore Ni

unread,
Nov 24, 2010, 3:22:16 PM11/24/10
to cornell...@googlegroups.com
Have you tried the full class name, including the package name:

cs2110.assignment5.examples.RandomWalkNaturalist

Or, in the case of MyNaturalist, I'm guessing it's in some package.

Teddy


--

Brian

unread,
Nov 24, 2010, 3:44:53 PM11/24/10
to Cornell CS 2110
Thanks! I could've sworn I tried that. I guess changing the working
directory didn't help at all.

On Nov 24, 3:22 pm, Theodore Ni <tn...@cornell.edu> wrote:
> Have you tried the full class name, including the package name:
>
> cs2110.assignment5.examples.RandomWalkNaturalist
>
> Or, in the case of MyNaturalist, I'm guessing it's in some package.
>
> Teddy
>
> On Wed, Nov 24, 2010 at 3:11 PM, Brian <bddst...@gmail.com> wrote:
>
> > And then what?
>
> > I tried running the simulator with the argument MyNaturalist (and with
> > the .java and .class), and changing the working directory, but it
> > always says
>
> > Initializing map... OK
> > Error: Class "MyNaturalist" not found.
>
> > And when I try to run RandomWalkNaturalist, it says Fatal Exception
> > occurred.
>
> > I really can't figure out how to get any part of this to run.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Cornell CS 2110" group.
> > To post to this group, send email to cornell...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > cornell-cs211...@googlegroups.com<cornell-cs2110%2Bunsu...@googlegroups.com>
> > .

Kevin Zhou

unread,
Nov 24, 2010, 6:54:46 PM11/24/10
to Cornell CS 2110
I'm also having trouble starting this project
so what I did was first add the a5.jar to the build path via configure
build path > add external jar > selected a5.jar
then in SRC folder i created a new package called
cs2110.assignment5.examples
in that package i created a class called MyNaturalist which extends
Naturalist
I copied the code from the website in that example, making the
appropraite naming changes
for run configs I have

proj: cs2110
main class: cs2110.assignment5.Simulator

arguments: cs2110.assignment5.examples.MyNaturalist

but when I try to run it it shoots me

Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad
version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:676)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:
124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:317)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:375)

Am I doing some step wrong?

Greg

unread,
Nov 24, 2010, 7:31:06 PM11/24/10
to Cornell CS 2110
I am getting the same error as Kevin.

Lonnie Princehouse

unread,
Nov 24, 2010, 7:44:54 PM11/24/10
to cornell...@googlegroups.com
In your Eclipse project, there should be a "JRE System Library" icon, followed by the JVM version. Mine says [JavaSE-1.6] ... what version is yours?  And are you on Mac/Windows/Linux?

Are you able to run the example, cs2110.assignment5.examples.RandomWalkNaturalist ?



--
You received this message because you are subscribed to the Google Groups "Cornell CS 2110" group.
To post to this group, send email to cornell...@googlegroups.com.
To unsubscribe from this group, send email to cornell-cs211...@googlegroups.com.

Kevin Zhou

unread,
Nov 24, 2010, 7:47:27 PM11/24/10
to Cornell CS 2110
Next to my JRE Sys Library it prints [J2SE-1.5]
I am on a Mac.

On Nov 24, 7:44 pm, Lonnie Princehouse <lon...@cs.cornell.edu> wrote:
> In your Eclipse project, there should be a "JRE System Library" icon,
> followed by the JVM version. Mine says [JavaSE-1.6] ... what version is
> yours?  And are you on Mac/Windows/Linux?
>
> Are you able to run the example,
> cs2110.assignment5.examples.RandomWalkNaturalist ?
>
> > cornell-cs211...@googlegroups.com<cornell-cs2110%2Bunsu...@googlegroups.com>
> > .

Kevin Zhou

unread,
Nov 24, 2010, 7:58:15 PM11/24/10
to Cornell CS 2110
and no, attempting to run
cs2110.assignment5.examples.RandomWalkNaturalist as the args results
in the same exceptions as trying to run my self made class

Greg

unread,
Nov 24, 2010, 8:32:50 PM11/24/10
to Cornell CS 2110
I also have [J2SE-1.5] next to my JRE System Library icon on mac osx
10.5. The example doesn't work for me either.

Greg

unread,
Nov 24, 2010, 9:18:06 PM11/24/10
to Cornell CS 2110
It appears to be working now after choosing "Alternate JRE" --> "JVM
1.6.0" in the run configuration.

Kevin Zhou

unread,
Nov 24, 2010, 9:32:07 PM11/24/10
to Cornell CS 2110
Good find Greg, it worked for me too

Lonnie Princehouse

unread,
Nov 24, 2010, 10:10:35 PM11/24/10
to cornell...@googlegroups.com
The problem is that you're using Java 1.5.  Has anyone reading this successfully upgraded Eclipse on Mac to use JRE 1.6?


To unsubscribe from this group, send email to cornell-cs211...@googlegroups.com.

Lonnie Princehouse

unread,
Nov 24, 2010, 10:11:10 PM11/24/10
to cornell...@googlegroups.com
Ah, good.

To unsubscribe from this group, send email to cornell-cs211...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages