File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Writing my first program - need a little help! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Writing my first program - need a little help!" Watch "Writing my first program - need a little help!" New topic
Author

Writing my first program - need a little help!

Linsey Johnson
Greenhorn

Joined: Oct 01, 2002
Posts: 4
I wrote my very first program for an Intro to Java class. My program compiles without any errors, but instead of running it gives me the following message:
The class App is not a subclass of java.awt.Applet
If anyone could tell me what on earth this means and/or help me to fix it, I would greatly appreciate it.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Does your first line look like this:

public class App extends java.applet.Applet

??

I'm not familiar with a java.awt.Applet class.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Linsey Johnson
Greenhorn

Joined: Oct 01, 2002
Posts: 4
My first lines read:

public class App
{
public static void main(String[] args)
{
then I begin declaring variables.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
If you want to use your class as if it were an Applet, then it needs to be an Applet (by extending java.applet.Applet - or that Swing version). Take a look at The Writing Applets Trail of Sun's Java Tutorial.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
How are you trying to run it?

When you run the program, you should type
"java App" on the command line (at the DOS prompt).

Are you trying run this application in your browser or appletviewer by any chance?
[ October 01, 2002: Message edited by: Marilyn de Queiroz ]
Linsey Johnson
Greenhorn

Joined: Oct 01, 2002
Posts: 4
I am using JBuilder 4 Foundation (it came with our textbook) to write the program, and I am just clicking the run button to run it.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
My best guess is the something in the setup of JBuilder was set to run your stuff as an applet ... and you didn't write an applet. This is one reason most instructors don't promote beginners using an IDE. You spend more time learning about the IDE than about the language (in this case Java). Check your "preferences"/"options" in JBuilder. Ask questions about JBuilder in the IDE forum (further down the list of forums here).

Maybe you can find something on this page that will be helpful to you. It won't help you with the JBuilder stuff, though.
Linsey Johnson
Greenhorn

Joined: Oct 01, 2002
Posts: 4
I managed to fix my first problem by basically starting a new project and copying in all of my code. However, I managed to get a new problem. When I compile, I get three warnings:
Warning #: 908 : check sourcepath; source d:\Project2\App\src\app\App.java cannot be found on sourcepath by appending \App.java to each sourcepath entry
I get one for each class in my project.
What does this mean, and how do I fix it??
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Is JBuilder a REQUIREMENT for this course?? It is hard for a beginner to separate the issues that belong to each.
Why don't you try working outside of JBuilder.
Download the sdk from Sun and use that instead.
Just use notepad.exe.
You will get better help here if you do.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Ryan Newcombe
Greenhorn

Joined: Oct 02, 2002
Posts: 24
I had the same problem as you did at first because I was clicking the run button. I had to right click on app.jav in the upper left quadrant of Jbuilder---then click run from there.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Writing my first program - need a little help!