Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / August 2004

Tip: Looking for answers? Try searching our database.

Can someone help me with: Applet Hello2 not intended

Thread view: 
Mark - 29 Aug 2004 19:40 GMT
I tried a simple tutorial and it won't work :(
I am new to java and just installed: j2sdk1.4.2_05. This looks ok to me
(thanks zoopy).
But can anyone get me started with this?

The appletviewer does not work also with this simple program...(start
applet not initialized)

<this is the tut>
/**
* The HelloWorldApp class implements an application that
* simply displays "Hello World!" to the standard output.
*/
class Hello2 {
   public static void main(String[] args) {
       System.out.println("Hello World!"); //Display the string.
   }
}
</this is the tut>

java console:
load: Hello.class is not public or has no public constructor.

same with this one:

import java.applet.*;
import java.awt.*;

class Hello extends Applet {
   Label tekstLabel = new Label("Hello");
   public void init(){
       add(tekstLabel);
   }
}

thanks,
Mark
Andrew Thompson - 29 Aug 2004 21:19 GMT
> I tried a simple tutorial and it won't work :(
> I am new to java and just installed: j2sdk1.4.2_05. This looks ok to me
[quoted text clipped - 7 lines]
> /**
>  * The HelloWorldApp class implements an application that

Notice how you said 'applet not initialized' when it
is an *application*.  Applet viewer was not designed
to run applications.  You need to start them from the
command line, or a batch file (or other things that
are not AppletViewer)...

..
> java console:
> load: Hello.class is not public or has no public constructor.
..
> class Hello extends Applet {

public class Hello extends Applet {

HTH

Signature

Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

Mark - 29 Aug 2004 22:51 GMT
>><this is the tut>
>>/**
[quoted text clipped - 8 lines]
>
>..

? I am not sure what you mean. I make a .htm file with the applet and
then run appletviewer from the commandline. Is this not ok?
Get the same results (more or less) if i open the .htm file in a browser.

>  
>
[quoted text clipped - 12 lines]
>HTH
>  

Does not work. This gives the compiler:  class Hello3 is public, should
be declared in a file named Hello3.java

What goes wrong? I run IIS also for .asp pages; does this conflict?

Thanks,
Mark
Paul Lutus - 29 Aug 2004 23:39 GMT
>>><this is the tut>
>>>/**
[quoted text clipped - 34 lines]
>
> What goes wrong?

The error message tells you exactly what the problem is. Your class "Hello3"
must be in a file named "Hello3.java".

Signature

Paul Lutus
http://www.arachnoid.com

Mark - 30 Aug 2004 16:26 GMT
><snip>
>
[quoted text clipped - 14 lines]
>
:0) all was good... almost.
It should all be case censitive files!

So, now i have a file: Hello3.java, containing:

<code>
import java.applet.*;
import java.awt.*;

public class Hello3 extends Applet {
       public void paint(Graphics g)         {
               g.drawString("Hello, Web!", 10, 10);
       }
}
</code>

and now i have a files: Hello3.class

This works fine (the .htm doesn't mind the H or h).

Anyway, my first java works now.

Thanks!

Mark
Paul Lutus - 30 Aug 2004 16:54 GMT
>><snip>
>>
[quoted text clipped - 15 lines]
> :0) all was good... almost.
> It should all be case censitive files!

Yes, just as in my example above. Java, and all civilized operating systems,
are case-sensitive. Windows is neither civilized nor is it case-sensitive.

> So, now i have a file: Hello3.java, containing:
>
[quoted text clipped - 12 lines]
>
> This works fine (the .htm doesn't mind the H or h).

Yes, but only on Windows. When you upload your HTML pages to the Web, where
there are civilized operating systems, if you had been locally ignoring the
case of your file names, once uploaded your site will suddenly and
inexplicably stop working.

Please remember this. It is the single most common problem for people who
develop Web content using Windows.

Signature

Paul Lutus
http://www.arachnoid.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.