• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Stanford CS106a help running programs

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I just started watching the videos for Stanford's CS106a course online and am trying to do the homework. I've downloaded the stanford version of eclipse and the other software as required. I can run the karel programs and the programs that come with the book (i've downloaded the ACM package aswell). I'm having trouble doing the assignments in eclipse. I've made a new project, created a file (.java) where I've put my source code. I then tried to link the acm package to the project ( Project > Properties > Project Build Path > Add External JARs). But when I run the .java file, I get the following: at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at acm.program.Program.main(Program.java:1338)

I really need some help creating a project, program in eclipse to run from scratch with the ACM package. Anny help is really appreciate. thanks
 
Marshal
Posts: 79174
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I suggest you stop using Eclipse at this stage, and use a decent text editor, e.g. NotePad+, Notepad2, jEdit, not Microsoft Notepad.
Create a “Java” or similar folder and put all your work in that.
Copy all the Stanford classes into the same folder structure as you are working in probably with their highest‑level folder named to match the package names (maybe “edu”).
Write out the programs in text. Write import declarations for any of the Stanford classes you need to use.
t will be rather like HelloWorld or MooseGreetings, only bigger.
 
gabe fro
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ritchie,

Question is how do I run them in windows console? How do I import the acm package?
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using a text editor, you still do the regular "import" statements in your program.

Then when you compile, set the classpath to the jar file(s). Everything (compiling and running) will be through command. So get acquainted with the javac and java commands.
 
Campbell Ritchie
Marshal
Posts: 79174
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

gabe fro wrote: . . . Question is how do I run them in windows console?

Same way as you run MooseGreetings.

How do I import the acm package?

Same way as you import anything else.

You can cheat and put the root folder of the ACM package inside your Java folder. Then you can dispense with a classpath.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic