LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-05-2012, 10:02 PM   #1
Andy Alkaline
Member
 
Registered: Jun 2004
Location: Minnesota, USA
Distribution: Slackware32-stable, Debian-wheezy-amd64, LFS 7.1
Posts: 347

Rep: Reputation: 27
code from java book not working


I got the book for my nephew, "Programming Video Games for the Evil Genius by Ian Cinnamon" Noticed typos in the first several programs. I'm not familiar with java, but have some experience with C.

Anyway, my 10 yr old nephew spent three hours typing this program, but we only get the title bar when it runs. After compiling successfully on Windows, tried on my Debian Linux box with openjdk, then switched to sun. Each time got the same result (the title bar, "Super Racing."), and this was in the terminal window.

Quote:
andy@debian:~$ java RP1
Mar 5, 2012 9:51:39 PM com.sun.corba.se.impl.ior.IORImpl getProfile
WARNING: "IOP00511201: (INV_OBJREF) IOR must have at least one IIOP profile"
org.omg.CORBA.INV_OBJREF: vmcid: SUN minor code: 1201 completed: No
at com.sun.corba.se.impl.logging.IORSystemException.iorMustHaveIiopProfile(IORSystemException.java:473)
at com.sun.corba.se.impl.logging.IORSystemException.iorMustHaveIiopProfile(IORSystemException.java:495)
at com.sun.corba.se.impl.ior.IORImpl.getProfile(IORImpl.java:334)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_Object(CDRInputStream_1_0.java:787)
at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_Object(CDRInputStream_1_0.java:761)
at com.sun.corba.se.impl.encoding.CDRInputStream.read_Object(CDRInputStream.java:231)
at com.sun.corba.se.impl.resolver.INSURLOperationImpl.getIORFromString(INSURLOperationImpl.java:120)
at com.sun.corba.se.impl.resolver.INSURLOperationImpl.operate(INSURLOperationImpl.java:130)
at com.sun.corba.se.impl.orb.ORBImpl.string_to_object(ORBImpl.java:836)
at org.GNOME.Accessibility.AccessUtil.getRegistryObject(AccessUtil.java:143)
at org.GNOME.Accessibility.JavaBridge.registerApplication(JavaBridge.java:1154)
at org.GNOME.Accessibility.JavaBridge.<init>(JavaBridge.java:405)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at java.lang.Class.newInstance0(Class.java:372)
at java.lang.Class.newInstance(Class.java:325)
at java.awt.Toolkit.loadAssistiveTechnologies(Toolkit.java:786)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:875)
at java.awt.Window.getToolkit(Window.java:1170)
at java.awt.Window.init(Window.java:400)
at java.awt.Window.<init>(Window.java:438)
at java.awt.Frame.<init>(Frame.java:419)
at javax.swing.JFrame.<init>(JFrame.java:218)
at RP1.<init>(RP1.java:58)
at RP1.main(RP1.java:91)
Here's the actual code. Right now when it compiles, there are no error or warnings being issued.
Code:
/*
 * RP1.java */

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;

public class RP1 extends JFrame 
{	
	final int WIDTH = 900, Height = 650;
    
    Rectangle left = new Rectangle(0,0,WIDTH/9, HEIGHT);
    Rectangle right = new Rectangle((WIDTH/9)*9,0,WIDTH/9,HEIGHT);      
    Rectangle top = new Rectangle(0,0,WIDTH, HEIGHT/9);
    Rectangle bottom = new Rectangle(0, (HEIGHT/9)*9,WIDTH,HEIGHT/9);
    Rectangle center = new
        Rectangle((int)((WIDTH/9)*2.5),(int)
              ((HEIGHT/9)*2.5), (int) ((WIDTH/9)*5),(HEIGHT/9)*4);
              Rectangle obstacle = new
                Rectangle(WIDTH/2,(int)((HEIGHT/9)*7),WIDTH/10,HEIGHT/9);
              Rectangle obstacle2 = new
                Rectangle(WIDTH/3,(int)((HEIGHT/9)*5),WIDTH/10,HEIGHT/4);             
              Rectangle obstacle3 = new
                Rectangle(2*(WIDTH/3),(int)((HEIGHT/9)*5),WIDTH/10,HEIGHT/4);
              Rectangle obstacle4 = new Rectangle(WIDTH/3,HEIGHT/9,WIDTH/30,HEIGHT/9);
              Rectangle obstacle5 = new Rectangle (WIDTH/2,(int)((HEIGHT/9)*1.5),WIDTH/30,HEIGHT/4);
              Rectangle finish = new Rectangle(WIDTH/9,(HEIGHT/2)-HEIGHT/9, (int)((WIDTH/9)*1.5),HEIGHT/70);
              
              Rectangle lineO = new
                  Rectangle(WIDTH/9,HEIGHT/2,(int)((WIDTH/9)*1.5)/2,HEIGHT/140);
              Rectangle lineI = new Rectangle(((WIDTH/9)+((int)((WIDTH/9)*1.5)/2)),
                        (HEIGHT/2)+(HEIGHT/10),
                        (int)((WIDTH/9)*1.5)/2,HEIGHT/140);
                        
              public RP1()
              {
				  super("Super Racing!");
				  setSize(WIDTH,HEIGHT);
				  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				  setVisible(true);
			  }
			  public void paint(Graphics g)
			  {
				  super.paint(g);
				  
				  g.setColor(Color.DARK_GRAY);
				  g.fillRect(0,0,WIDTH,HEIGHT);
				  
				  g.setColor(Color.GREEN);
				  
				  g.fillRect(left.x,left.y,left.width,left.height);
				  g.fillRect(right.x,right.y,left.width,left.height);
                  g.fillRect(top.x,top.y,top.width,top.height);
                  g.fillRect(bottom.x,bottom.y,bottom.width,bottom.height);
                  g.fillRect(center.x,center.y,center.width,bottom.height);
                  g.fillRect(obstacle.x,obstacle.y,obstacle.width,obstacle.height);
                  g.fillRect(obstacle2.x,obstacle2.y,obstacle2.width,obstacle2.height);
                  g.fillRect(obstacle3.x,obstacle3.y,obstacle3.width,obstacle3.height);
                  g.fillRect(obstacle4.x,obstacle4.y,obstacle4.width,obstacle4.height);
                  g.fillRect(obstacle5.x,obstacle5.y,obstacle5.width,obstacle5.height);
                  g.setColor(Color.WHITE);
                  g.fillRect(lineO.x,lineO.y,lineO.width,lineO.height);
                  g.fillRect(lineI.x,lineI.y,lineI.width,lineI.height); 
                  g.setColor(Color.YELLOW);
                  g.fillRect(finish.x,finish.y,finish.width,finish.height);
			  }
			  
			  public static void main (String[] args)
			  {
				  new RP1();
			  }
			 }
 
Old 03-05-2012, 10:23 PM   #2
Andy Alkaline
Member
 
Registered: Jun 2004
Location: Minnesota, USA
Distribution: Slackware32-stable, Debian-wheezy-amd64, LFS 7.1
Posts: 347

Original Poster
Rep: Reputation: 27
Quote:
final int WIDTH = 900, Height = 650;
I saw "Height" was not all uppercase. Fixed, and the race track now displays.

BTW, the Height was a typo by my nephew, not from the book.

Last edited by Andy Alkaline; 03-15-2012 at 08:07 PM. Reason: credit where credit is due
 
  


Reply

Tags
games, java, source code


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why my java code for networking is not working??? phase_ram Linux - Networking 2 11-26-2008 03:56 AM
Using sample C++ code from a book...won't compile Baix Programming 4 03-05-2005 02:04 PM
Trying to compile souce code that came with AUP book.... Scrag Programming 4 11-16-2004 09:24 PM
Book about writing secure code Covel Linux - Security 1 06-12-2004 01:53 AM
W.Richard Steven BOOK source code atiato Linux - General 1 06-26-2002 08:52 AM


All times are GMT -5. The time now is 08:23 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration