Jump to content

Compiling Problems

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
nivek

nivek

    Newbie

  • Members
  • Pip
  • 3 posts
Hi, I am trying to compile this clases:



import java.util.ArrayList;

import java.awt.*;


class Test {

	public static void main(String[] args){

		System.out.println("Prueba");

		MyWindow win1 = new MyWindow ("ventana");

	}

}




import java.awt.*;

import java.awt.event.*;

class MyWindow extends Frame implements WindowListener {

	public MyWindow () {

		super();

		}

	public MyWindow (String title) {

		super(title);

		setSize(500,500);

		addWindowListener(this);

	}

	public void windowActivated (WindowEvent e) {;}

	public void windowClosed (WindowEvent e) {;}

	public void windowClosing (WindowEvent e) {;System.exit(0);}

	public void windowDeactivated (WindowEvent e) {;}

	public void windowDeiconified (WindowEvent e) {;}

	public void windowIconified (WindowEvent e) {;}

	public void windowOpened (WindowEvent e) {;}

}






Thanks!

#2
nivek

nivek

    Newbie

  • Members
  • Pip
  • 3 posts
This is the error:

Posted Image

Thanks!

#3
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
You're compiling the two source-files separately, so the first code-example you showed are not able to find the class declared and implemented in the other code. You need to compile them together.

#4
nivek

nivek

    Newbie

  • Members
  • Pip
  • 3 posts

v0id said:

You're compiling the two source-files separately, so the first code-example you showed are not able to find the class declared and implemented in the other code. You need to compile them together.

Thanks, and how do I do that ?

#5
CPlusPlus

CPlusPlus

    Newbie

  • Members
  • PipPip
  • 29 posts
Put this in your compiler:

title Compiler

color 7f

javac *.java

pause

and if that doesn't go well, swap 'javac' for:

"C:\Documents and Settings\Nivek\blahblah" *.java

Not exactly that, but wherever javac is -.-

Happy to help.

And put the two source files in the SAME directory

#6
gszauer

gszauer

    Programmer

  • Members
  • PipPipPipPip
  • 113 posts
Posted Image

Place the two files in the same directory.
When you compile Test.java the JDK will actually create 2 classes MyWindow.class, and Test.class
You can not compile MyWindow.java because it has no main method.

Delete all the class files you have made, and compile only Test.java

(The above image is what i got after i compiled the files. Both class files where created with the command you see on the Screenshot)

~Aristotle said:

It is the mark of an educated mind to entertain a tought without accepting it
If my post was helpful, please help me build some rep Posted Image

#7
devilsmaster

devilsmaster

    Newbie

  • Members
  • PipPip
  • 20 posts
You can do that by just putting the both files on the single folder and then try to recompile it, if still it gives an error than tell us.
Please visit my blog on
IPOD Downloads