The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > Java


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 06-04-2008, 09:09 AM
MrPickle's Avatar
MrPickle MrPickle is offline
Sr. Programmer
Join Date: Nov 2007
Location: England, Lincolnshire
Posts: 255
iTrader: (0)
MrPickle is on a distinguished roadMrPickle is on a distinguished roadMrPickle is on a distinguished road
Java programs not showing

I am trying to test out Java but for some reason, my applets won't show in the web page and I don't know why.

Here's the code:
PHP Code:
import java.applet.*;
import java.awt.*;

public class SampleApplet extends Applet implements Runnable
{
    
int PosX 10;
    
int PosY 10;
    
int Radius 20;
    
    
public void Init(){
        
setBackground(Color.blue);
    }

    
public void Start(){
        
final Thread th = new Thread(this);
        
th.start();
    }

    
public void Stop(){ }

    
public void Destroy(){ }

    
public void run(){
        
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
        while(
true)
        {
            
PosX++;
            
repaint();
            
try
            
{
                
Thread.sleep(20);
            }
            
catch (final InterruptedException ex)
            {
            
            }
            
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
        } 
    }

    
public void Paint(Graphics g){
        
g.setColor(Color.white);
        
g.fillRect(00200100);
        
g.setColor(Color.black);
        
g.drawString("Sample Applet"2020);
        
g.setColor(Color.blue);        
    }

Here's the html code:
HTML Code:
<html> <body> <p><applet code = "SampleApplet.class" width = "500"  height = "500" /></p> </body> </html>

__________________
PM me and tell me your name or a phrase and I shall write it in Elf for you. English Tengwar to be precise.
Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #2 (permalink)  
Old 06-04-2008, 01:14 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,109
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Is there exception? Sorry, I never done any Java applet programming..

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!

Last edited by HelloWorld : 06-04-2008 at 01:16 PM.
Reply With Quote
  #3 (permalink)  
Old 06-04-2008, 01:17 PM
MrPickle's Avatar
MrPickle MrPickle is offline
Sr. Programmer
Join Date: Nov 2007
Location: England, Lincolnshire
Posts: 255
iTrader: (0)
MrPickle is on a distinguished roadMrPickle is on a distinguished roadMrPickle is on a distinguished road
Eclipse says:
Quote:
Exception in thread "main" java.lang.NoClassDefFoundError: sun.applet.AppletViewer
at gnu.java.lang.MainThread.run(libgcj.so.81)
Caused by: java.lang.ClassNotFoundException: sun.applet.AppletViewer not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/home/james/Desktop/Scripts/Java/Game/], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.81)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj .so.81)
at java.lang.ClassLoader.loadClass(libgcj.so.81)
at java.lang.ClassLoader.loadClass(libgcj.so.81)
at gnu.java.lang.MainThread.run(libgcj.so.81)

__________________
PM me and tell me your name or a phrase and I shall write it in Elf for you. English Tengwar to be precise.
Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #4 (permalink)  
Old 06-04-2008, 01:22 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,109
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
I'm not familiar with applet programming, I never done it, but I suggest you to start with the easier sample first.. here's a good official tutorial from Sun:

Getting Started with Applets (The Java™ Tutorials > Deployment > Applets)

The link will get you to the Hello World program for Java applet

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 04:26 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50