|
|
Apple Java which Browser to use ? Safari throwing NullPointerException with clean Applet code
Hi All,I am programming for the first time on an Apple platform, and in factprogramming Java for the first time in a while, so forgive me if thisis newbie-ish.Mac OS X v 10.4.10Java/JRE /VM 1.50_07-87Using IDE Creator v 2.1 (which is not the issue)>> BROWSER : SAFARI 2.0.4(419.3) <<with the code below (which I think is clean - but to be honest this isthe first attempt at programming in a while, so there could be anissue - builds clean. My Safari browser is throwing aNullPointerException.Q: Is my code incorrect ?Q: Is it Safari ?Q: Is it an interaction with Java JVM 1.05 ? Should I downgrade ?Q: Which browser is optimal to use for Apple ?Q: Opinions on whether Mac OSX 10.4 is decent for Applet programming.There was a time when Mac was insufficient.Thanks All,Jacquelinejackiespiegel@optonline.netCode and Exception follows.=============== Java Console===============================================basic: Referencing classloader: sun.plugin.ClassLoaderInfo@2d0483,refcount=1basic: Added progress listener: sun.plugin.util.GrayBoxPainter@c39410basic: Loading applet ...basic: Initializing applet ...basic: Starting applet ...java.lang.NullPointerException at HelloWorld.<init>(HelloWorld.java:22) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(NativeMethod) atsun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) atsun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at java.lang.Class.newInstance0(Class.java:350) at java.lang.Class.newInstance(Class.java:303) at sun.applet.AppletPanel.createApplet(AppletPanel.java:721) at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1826) at sun.applet.AppletPanel.runLoader(AppletPanel.java:650) at sun.applet.AppletPanel.run(AppletPanel.java:324) at java.lang.Thread.run(Thread.java:613)===================== Java Code =============================import java.awt.*;import javax.swing.JApplet;//No need to extend JApplet, since we don't add any components;//we just paint.public class HelloWorldApplet extends JApplet { StringBuffer buffer; public void init() { buffer = new StringBuffer(); System.out.println("initializing... "); } public void start() { System.out.println("starting... "); repaint(); } public void stop() { System.out.println("stopping... "); } public void destroy() { System.out.println("preparing for unloading..."); } public void paint(Graphics g) { //Draw a Rectangle around the applet's display area. g.drawRect(0, 0, getWidth() - 1, getHeight() - 1); //Draw the current string inside the rectangle. g.drawString("Hello World", 5, 15); }}
|
|
0
|
|
|
|
Reply
|
jackiespiegel (1)
|
10/24/2007 4:25:35 PM |
|
In article <1193243135.574799.35950@i38g2000prf.googlegroups.com>, jackiespiegel@optonline.net wrote:> I am programming for the first time on an Apple platformYou may want to cross-post this in comp.sys.mac.programmer.help.-- Note: Please send all responses to the relevant news group. If you must contact me through e-mail, let me know when you send email to this address so that your email doesn't get eaten by my SPAM filter.JR
|
|
0
|
|
|
|
Reply
|
Jolly
|
10/24/2007 4:30:34 PM
|
|
On Wed, 24 Oct 2007 17:25:35 +0100, <jackiespiegel@optonline.net> wrote:> Hi All,>> I am programming for the first time on an Apple platform, and in fact> programming Java for the first time in a while, so forgive me if this> is newbie-ish.>> Mac OS X v 10.4.10> Java/JRE /VM 1.50_07-87> Using IDE Creator v 2.1 (which is not the issue)>>> BROWSER : SAFARI 2.0.4(419.3) <<>> with the code below (which I think is clean - but to be honest this is> the first attempt at programming in a while, so there could be an> issue - builds clean. My Safari browser is throwing a> NullPointerException.>> Q: Is my code incorrect ?> Q: Is it Safari ?> Q: Is it an interaction with Java JVM 1.05 ? Should I downgrade ?> Q: Which browser is optimal to use for Apple ?> Q: Opinions on whether Mac OSX 10.4 is decent for Applet programming.> There was a time when Mac was insufficient.>Is that *really* the code that you are running? The exception was in a class called HelloWorld, your class is called HelloWorldApplet. The exception is in the constructor for HelloWorld, your class doesn't have an explicit constructor.The Mac is fine for Java development, the only real complaint is that the JVM that Apple ships is not the most recent. It will be interesting to see if Java 6 is present in OS X 10.5 when it is released.Which browser you use shouldn't make any difference, they all use Apple's Java plug-in.Dan.-- Daniel Dyerhttp//www.uncommons.org
|
|
0
|
|
|
|
Reply
|
Daniel
|
10/24/2007 5:52:54 PM
|
|
Thank you Daniel - exactly correct... New IDE. Apologies. Muchappreciated.
|
|
0
|
|
|
|
Reply
|
jackiespiegel
|
10/25/2007 4:32:56 PM
|
|
|
3 Replies
121 Views
(page loaded in 0.057 seconds)
Similiar Articles:7/10/2012 12:47:14 AM
|
|
|
|
|
|
|
|
|