Problems compiling FlagMaker1.java

import java.awt.*;
import java.awt.event.*;
class FlagMaker1 extends Frame
     FlagMaker1 ()
          add ("Center", new Flag ());
          addWindowsListener(new WindowAdapter ()
          public void windowClosing(WindowEvent e)
          System.exit(0);
          setTitle ("A Flag!");
          setSize (300,200);
          setVisible (true);
class Flag extends Canvas
     public void paint (Graphics g)
          g.setColor (Color.black);
          g.fillRect (40,40,200,40);
          g.setColor (Color.red);
          g.fillRect (40,80,200,40);
          g.setColor (Color.yellow);
          g.fillRect (40,120,200,40);
          g.setColor (Color.black);
          g.drawString ("Deutschland",100,180);
compiling gives the following error:
--------------------Configuration: sdk 1-4-1 <Default>----------------
E:\SysEng\SysEng1\Java\FlagMaker1.java:9: cannot resolve symbol
symbol : method addWindowsListener (<anonymous java.awt.event.WindowAdapter>)
location: class FlagMaker1
          addWindowsListener(new WindowAdapter ()
^
1 error

aha ,,not a good mistake,you have to check you spelling~~
addWindowListener(this)
Robbies
1.java IDE tool : JawaBeginer
2.Java Jar tool : JavaJar
http://www.pivotonic.com

Similar Messages

  • Problem compilling a java file

    I've got problems using my jdk1.2 .
    When i try to compile a java file using ms-dos console or kawa program, appears this error text:
    Javaw.exe has generated an error it's gonna be closed by windows , you must restart the program.
    A error register is gonna be created.
    UI have to tell tha this is a free translation that the text appears in spanish.
    thanks a lot

    Maybe you should compile with javac.

  • XML Schema Class Generator Problem compiling generated java programs

    Hi,
    I ran oracg on the po.xsd schema from X3Cs XML Schema Part 0: Primer which successfully generated the java codes. I ran into problems when I compile the generated classes. Here's what I'm getting:
    C:\oracle\xml\xdk\demo\java\classgen\Po2>javac -classpath ".;C:\oracle\xml/lib/xmlparserv2.jar;C:\oracle\xml/lib/xschema.jar;C:\oracle\xml/l
    ib/classgen.jar;.;C:\Program Files\VicunaJ521\java\lib\collections.jar;C:\Program Files\VicunaJ521\java\lib\vicunalite.jar;C:\Program Files\
    XConverter\XConverter.jar;C:\Program Files\XConverter\IDLGenerator.jar; c:\jdk1.2.2\lib\dt.jar;c:\jdk1.2.2\lib\jvm.jar;c:\jdk1.2.2\lib\tools
    .jar;c:\oracle\ora81\jdbc\lib\classes12.zip;c:\oracle\ora81\jdbc\nls_charset12.zip;C:\oracle\xml\lib\classgen.jar;C:\oracle\xml\lib\xmlparse
    rv2.jar" *.java
    .\types\PurchaseOrderType.java:75: Type expected.
    public void addComment(null.Comment thecomment)
    ^
    .\types\Items.java:141: Type expected.
    public void addComment(null.Comment thecomment)
    ^
    2 errors
    Running the demo which comes with oracles version of po.xsd was OK. What's the difference between the po.xsd from oracle and the po.xsd from W3C? Are there any W3C recommendation for XML Schema not supported by Oracle's class generator?

    Which po.xsd do you use? Would you post it?
    Thanks. Here's the copy of the po.xsd from the W3C website. (http://www.w3.org/TR/xmlschema-0/#po.xsd)
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:annotation>
    <xsd:documentation xml:lang="en">
    Purchase order schema for Example.com.
    Copyright 2000 Example.com. All rights reserved.
    </xsd:documentation>
    </xsd:annotation>
    <xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
    <xsd:element name="comment" type="xsd:string"/>
    <xsd:complexType name="PurchaseOrderType">
    <xsd:sequence>
    <xsd:element name="shipTo" type="USAddress"/>
    <xsd:element name="billTo" type="USAddress"/>
    <xsd:element ref="comment" minOccurs="0"/>
    <xsd:element name="items" type="Items"/>
    </xsd:sequence>
    <xsd:attribute name="orderDate" type="xsd:date"/>
    </xsd:complexType>
    <xsd:complexType name="USAddress">
    <xsd:sequence>
    <xsd:element name="name" type="xsd:string"/>
    <xsd:element name="street" type="xsd:string"/>
    <xsd:element name="city" type="xsd:string"/>
    <xsd:element name="state" type="xsd:string"/>
    <xsd:element name="zip" type="xsd:decimal"/>
    </xsd:sequence>
    <xsd:attribute name="country" type="xsd:NMTOKEN"
    fixed="US"/>
    </xsd:complexType>
    <xsd:complexType name="Items">
    <xsd:sequence>
    <xsd:element name="item" minOccurs="0" maxOccurs="unbounded">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="productName" type="xsd:string"/>
    <xsd:element name="quantity">
    <xsd:simpleType>
    <xsd:restriction base="xsd:positiveInteger">
    <xsd:maxExclusive value="100"/>
    </xsd:restriction>
    </xsd:simpleType>
    </xsd:element>
    <xsd:element name="USPrice" type="xsd:decimal"/>
    <xsd:element ref="comment" minOccurs="0"/>
    <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
    </xsd:sequence>
    <xsd:attribute name="partNum" type="SKU" use="required"/>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    <!-- Stock Keeping Unit, a code for identifying products -->
    <xsd:simpleType name="SKU">
    <xsd:restriction base="xsd:string">
    <xsd:pattern value="\d{3}-[A-Z]{2}"/>
    </xsd:restriction>
    </xsd:simpleType>
    </xsd:schema>

  • Problem compiling Abstract class

    Hi
    I have writting an abstract class Sort.java and another class BubbleSort.java. I am having problems compiling BubbleSort.java class.
    The following is the error message
    BubbleSort.java:8: missing method body, or declare abstract
         public int doSorting(int[] array);
    ^
    BubbleSort.java:11: return outside method
              return num;
    ^
    The following is the code
    public abstract class Sort
    public abstract int doSorting(int[] array);
    }// End of class
    public class BubbleSort extends Sort
    private int num = 2;
    public int doSorting(int[] array);
    num = num + 2;
    return num;
    } // end of class

    Remove the semi-colon.
    public int doSorting(int[] array); // <------- there

  • Having problems compiling *.java with import javax.servlet.jsp......

    I've been trying to do the tutorials in a book titled Apache Jakarta-Tomcat as part of my introduction to JSP. I'm new to Java but do know the basics. I have on my machine Java 1.3, Java 1.4, Java FrameWorks 2.1 and Jython 2.1 on Win2000 Pro. So enough about my configuration. I have never worked with packages also.
    I downloaded the files from the books site due to the fact I make a lot of typos when hand coding Java (I've become a pretty good debugger of my own code). But everytime I go to compile the *.java I get error messages. So below you will find HelloTag.java and beneath that the error messages that are thrown when I try and compile it. I tested other bits of *.java and have had no problem compiling them. Is there a JSP module I'm missing?
    Am I doing something wrong or am I missing something from my configuration.
    Marijan Madunic
    package chapter2;
    import javax.servlet.jsp.JspException;
    import javax.servlet.jsp.JspTagException;
    import javax.servlet.jsp.tagext.TagSupport;
    public class HelloTag extends TagSupport
    public void HelloTag() {
    // Method called when the closing hello tag is encountered
    public int doEndTag() throws JspException {
    try {
    // We use the pageContext to get a Writer
    // We then print the text string Hello
    pageContext.getOut().print("Hello");
    catch (Exception e) {
    throw new JspTagException(e.getMessage());
    // We want to return SKIP_BODY because this Tag does not support
    // a Tag Body
    return SKIP_BODY;
    public void release() {
    // Call the parent's release to release any resources
    // used by the parent tag.
    // This is just good practice for when you start creating
    // hierarchies of tags.
    super.release();
    D:\Java\JDK 1.3\bin>javac HelloTag.java
    HelloTag.java:3: cannot resolve symbol
    symbol : class JspException
    location: package jsp
    import javax.servlet.jsp.JspException;
    ^
    HelloTag.java:4: cannot resolve symbol
    symbol : class JspTagException
    location: package jsp
    import javax.servlet.jsp.JspTagException;
    ^
    HelloTag.java:5: cannot resolve symbol
    symbol : class TagSupport
    location: package tagext
    import javax.servlet.jsp.tagext.TagSupport;
    ^
    HelloTag.java:7: cannot resolve symbol
    symbol : class TagSupport
    location: class chapter2.HelloTag
    public class HelloTag extends TagSupport
    ^
    HelloTag.java:14: cannot resolve symbol
    symbol : class JspException
    location: class chapter2.HelloTag
    public int doEndTag() throws JspException {
    ^
    HelloTag.java:20: cannot resolve symbol
    symbol : variable pageContext
    location: class chapter2.HelloTag
    pageContext.getOut().print("Hello");
    ^
    HelloTag.java:24: cannot resolve symbol
    symbol : class JspTagException
    location: class chapter2.HelloTag
    throw new JspTagException(e.getMessage());
    ^
    HelloTag.java:28: cannot resolve symbol
    symbol : variable SKIP_BODY
    location: class chapter2.HelloTag
    return SKIP_BODY;
    ^
    HelloTag.java:37: cannot resolve symbol
    symbol : variable super
    location: class chapter2.HelloTag
    super.release();
    ^
    9 errors

    Well, it looks like you've not got the servlet development kit JAR on your classpath. I think it'll probably be called servlet.jar on your system. Add that to the classpath if it's not already there.
    Incidentally, you've bumped into one of the areas Java's slightly lenient - declaring a method that looks like a constructor:
    public HelloTag() { }
    public void HelloTag() { }The first is a constructor, the second is a normal method. I'm assuming you intended to have the former instead of the latter.
    Anyway, hope this helps.

  • Problem compiling Java on XP

    i'm new to java, just went through the tutorial just now..
    tried compilling my program the first time on XP, but the system doesn't recognise the command JAVAC,
    i've installed the java compiler (j2re-1_4_1_01-windows-i586.exe)
    but it still isn't working.. any help?
    thanks!

    then again.. i'm still having problems compiling..
    i managed to install the right sdk, but.. i have to run the command javac from the bin directory.. else the command prompt won't recognise it..
    anyway to get around this?
    also.. because of this.. i can't compile my program.. :(

  • Problem in compiling this java need help

    package test;
    public class simpleTest{
         public simpleTest(){
              int a =0;
    import test.*;
    public class testPackage{
         public static void main(String [] args){
              simpleTest sT=new simpleTest();
              System.out.println("Package from Test A value = "+a);
    }error got when compile this codes.
    --------------------Configuration: <Default>--------------------
    C:\Notes\testPackage.java:4: cannot access simpleTest
    bad class file: C:\Notes\simpleTest.java
    file does not contain class simpleTest
    Please remove or make sure it appears in the correct subdirectory of the classpath.
    simpleTest sT=new simpleTest();
    ^
    1 error
    Process completed.

    package test;
    public class simpleTest{
    private int a;
         public simpleTest(int a){
              // int a =0;
    this.a = a;
    public int getA() {
    return a;
    =============== 2 diff files===================
    import test.*;
    public class testPackage{
         public static void main(String [] args){
              simpleTest sT=new simpleTest();
    System.out.println("Package from Test A value =
    = "+st.getA());
    }- Saishu can compile the java package?

  • Problem compiling a simple java file

    Hi,
    When I try to compile the following simple java file
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HowdyServlet extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {
    PrintWriter out = response.getWriter();
    response.setContentType("text/html");
    out.println("<html>");
    out.println("<body>");
    out.println("<center><h1>Hi</h1></center>");
    out.println("</body>");
    out.println("</html>");
    at the command prompt as follows
    C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac -classpath
    "C:\Program Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip" *.java
    Or
    C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac *.java
    Or
    C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac HowdyServlet.java
    I get the following errors and I cannot compile this java file -
    HowdyServlet.java:2: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    HowdyServlet.java:3: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    HowdyServlet.java:5: cannot find symbol
    symbol: class HttpServlet
    public class HowdyServlet extends HttpServlet {
    ^
    HowdyServlet.java:6: cannot find symbol
    symbol : class HttpServletRequest
    location: class HowdyServlet
    public void doGet(HttpServletRequest request,
    ^
    HowdyServlet.java:7: cannot find symbol
    symbol : class HttpServletResponse
    location: class HowdyServlet
    HttpServletResponse response)
    ^
    HowdyServlet.java:8: cannot find symbol
    symbol : class ServletException
    location: class HowdyServlet
    throws IOException, ServletException {
    ^
    6 errors
    I have installed the latest JEE 5 SDK on Win XP Home. I have the following variable set as follows,
    CLASSPATH = .;C:\Program Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip
    PATH = C:\Sun\AppServer\jdk\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\QuickTime\QTSystem;C:\Sun\AppServer\lib\ant\bin
    ANT_HOME = C:\Sun\AppServer\lib\ant
    I have spent hours scratching my head but don?t have a clue. I was wondering if you have any idea as why I might be getting these errors.
    Thank you for your time.
    Green

    Hello, did you read the answers?
    You have to put j2ee.jar or servlet-api.jar in your classpath. Those JAR files are included in the Java EE package somewhere. Remove the QTJava.zip junk from the classpath.
    If you don't know what the classpath is and how to set it, read this:
    Setting the class path
    How Classes are Found
    And I'll repeat what the others say: if you are very new to Java, then Java EE will probably be way over your head. First learn the language and the standard API. If you understand that well, start with Java EE. Or do you already know what servlets are, and that you need a servlet container to run them, and how to deploy them etc.?

  • Urgent! Pls help me! Can't compile any *.java files

    I am a new user to Java2SDK. I am using Win2K sever and I have installed Java2SDK1.4.0 in D drive. When I compile any *.java files, a message " 'javac' is not recognized as an internal or external command, operable program or batch file" appears. How can I solve this problem?
    Please help me. I am busy with my homework. Thank you very much.

    In your PATH variable include %JAVA_HOME%\bin;
    For example:
    C:\jdk1.4\bin;

  • How to compile in Java Source???

    Hello,
    I'm studying a way to compile java files to class files in the java source. I have use the sun.tools.javac.Main to do this, but I have noticed that it aint recomended to use. I also wan't to get the possible errors from the compiler (if java file was wrongly made). The problem using the sun.tools.javac.Main is that it won't guarantee that it works in every platform or in future releases of JDK. Does the JDK 1.4 even support it? (My IDE environment prevents to use JDK 1.4). So the question is: is there a way to compile on the fly (to memory or to class files)? Do I really have to run some external process that compiles the file and then try to get somehow possible errors? That seems to me litle too indecent to use. Any suggestions?
    Thanks,
    Petri Tuomaala

    Hi guys,
    I have also needed to compile Java source from within a Java application. Here is the best solution I came up with:
    Process proc = Runtime.getRuntime().exec( "
    C:\\Temp\\Jikes -bootclasspath C:\\jdk\\jre\\lib\\rt.jar C:\\Java\\com\\sts\\utility\\Utility.java" );
    BufferedReader br = new BufferedReader( new InputStreamReader( proc.getErrorStream() ) );
    String line = null;
    while( (line = br.readLine()) != null ) {
    System.out.println( line );
    proc.waitFor();
    I used Jikes http://oss.software.ibm.com/developerworks/opensource/jikes/ because it compiled my source quicker than Javac did - 250 millseconds for Jikes compared to 2750 milliseconds for Javac.

  • Ojc bug compiling simple java class

    Hi,
    I am trying to compile some very old Java code with JDeveloper 10.1.2.1.0 (Build 1913) and running into a very strange problem.
    I cannot use the "import" statement to import classes, which are stored in root without a package name specification.
    I think that the simple example will describe it better:
    Class1
    public class Class1
      public Class1()
      public String myGetClassName()
        return "Class1";
    }Class2
    import Class1;
    public class Class2
      public Class2()
      public static void main(String[] args)
        Class2 class2 = new Class2();
        Class1 cl1 = new Class1();
        System.out.println(cl1.myGetClassName());
    }The error message I am getting is pointing to the line 1 in the Class2.java, complaining that it needs a dot (.) after the Class1
    If I compile these classes with javac - it works fine
    Is it a bug or am I doing something wrong?
    Thank you,
    Vitaliy
    [2005-09-27] Logged a TAR with Oracle on Metalink
    Message was edited by:
    c001803

    yes, you are right, but then if I import the Class1 into, lets say, mypackage.Class3, I am having the same issue.
    Actually I received the problem resolution from Oracle. Here it is
    27-SEP-05 16:43:41 GMT
    Hello,
    There is no problem with your java source: no problem using your javac
    command (I think older than 1.4.x).
    You meet here the new JAVA feature which says something like "each
    class should belong to a package for the security problem". Please go to
    the sun site for more information on the new JDK feature.I was using JDK1.3.1_13 to compile the code with javac

  • Having problems compiling script

    I am rather new to java an started a couple of days ago and I ran into a problem compiling this script in the command line
    class VariableDemo {
    public static void main (String args[]) {
    int num = 1000;
    System.out.println (num + " is the value of num") ;
    At first I forgot to capitolize the 'S' in System (which is why I was getting errors) but after I had corrected it , I still could not get it to compile in a command prompt
    even after I corrected my mistakes, I still get this error:
    error: cannot read: VariableDemo.java
    1 error
    When I ran it through JCreator it compiled it just fine and found no errors. SO I just want to know if it is some thing that has to do with the command line or is there an error I am not seeing?
    I am running Windows XP Pro with service pack 2 and using JCreator 3.50.010

    Sorry, I am new to this I just called it script out of ignorance, but, yes it is in the same directory. I even Pathed it out again to be sure.

  • How To Compile Within Java

    Hi Everybody,
    I have a serious problem. I want to compile a Java file withing another Java program, without using the "javac" command or this compiler. Is there any function or class which helps compile a Java source file created withing another Java Class file, So that the new Java source file will not be available to the outside world?
    Thanks,
    TechnoSam.

    I'm pretty sure that you can create a class in memory by passing it a stream of bytecode. From this you could create a new instance and then proceed as normal. However, you're going to need to know how to create that bytecode and I guess that you don't want to have to implement a 'virtual' compiler from scratch. I don't know of anything that can do this for you but I wouldn't be surprised to find that somebody's had a go in the past.
    Perhaps your requirements would be satisfied by compiling your dynamically created source using javac to a temp file and then deleting that once you had instantiated the object? This would do something like what I think that you're after but even then you would need to accept that others would be able to access your class definition by reverse-engineering your source-writing routine, (whether or not it was obsufacated).
    Can you say anymore about what you're trying to achieve?

  • Error when compiling SearchBean.jav

    IN the scheduler portlet installation steps using the latest JPDK 3.0.9.1, when compiling SearchBean.java i get the following error :
    D:\OiAS\Apache\Apache\htdocs\schedulerportlet>javac ConnectionParams.java
    D:\OiAS\Apache\Apache\htdocs\schedulerportlet>javac SearchBean.java
    SearchBean.java:607: Undefined variable or class name: ConnectionParams
    "(DESCRIPTION=(ADDRESS=(HOST="+ConnectionParams.s_hostName+")"+
    ^
    SearchBean.java:608: Undefined variable or class name: ConnectionParams
    "(PROTOCOL=tcp)(PORT="+ConnectionParams.s_portNumber+"))"+
    ^
    SearchBean.java:609: Undefined variable or class name: ConnectionParams
    "(CONNECT_DATA=(SID="+ConnectionParams.s_databaseSID+")))";
    ^
    3 errors
    D:\OiAS\Apache\Apache\htdocs\schedulerportlet>
    Can any one tell me the reason of these 3 errors ?
    please I need help
    null

    I've got exactly the same problem.
    Some advices would be nice.
    Thanks.

  • Jdk 1.4.2 problem compiling code

    I've spent the last two years developing an application on jdk1.3.1_04 with 9 class files and it works ok. However when I try to run it on jdk1.4.2 with NetBean ide3.5, I get ...
    "java.lang.NoClassDefFoundError:UAD/Applications/MarketAnalyzer3 Exception in thread main".
    I also get the same exception if I create new files and try to compile them on the ide3.5 platform.
    This also happens when I try to run it from the xp CMD window after changing the directory to where the class files are located. The only way I could get a simple one class file to run from the CMD window was to type "java.exe -classpath "." MyColorChooserApp"
    My system environmental variables are set as follows:
    BobTrader c:\ide-userdir\sampledir\BobTrader (this is where the class files are stored)
    JAVA_HOME c:\java\jdk1.4.2\j3sdk1.4.2
    jre c:\jdk1.3.1_04\jre\bin
    QTJAVA c:\ProgramFiles\jaa\jre1.5.0_04\lib\ext\QTJava.zip
    I've been trying to understand what may be the problem with class path and/or the sdk1.4.2, and I've found some reference to change back to windows sp1 or download jkd1.5. I'm not sure what to do next since sdk1.3.1 will no longer be supported.
    Any advice is appreciated.
    I'd like to get my application to run on the recommended sdk before I try to learn how to run it on any PC ...
    - using the CMD window to show it offs
    - learning how to use WebStart to offer it as a service, and/or
    - creating an exe if I decide to offer some of it as a product.
    Still have a lot to learn.
    codingAlone

    I guess jdk1.3.1 uses c:\ide-userdir\sampledir and I put my java application and class files under BobTrader.
    I just read something to help me with Classpath and path.
    My Path includes c:\java\jdk1.4.2\j2sdk1.4.2/bin so I believe that tells Windows where java exe files are and therefore allowed me to perform javac and java on a simple file. but not on a package of files.
    My Classpath does not include where my class files are located. So should I add the following to my Classpath: c:\ide-userdir\sampledir\BobTrader? The MarketAnalyzer3 class and other classes are under BobTrader. I have to compile multiple *.java files.
    Hopefully this will allow the sdk1.4.2 to work. I will try adding the BobTrader class files to the Classpath and see.
    My package is also named BobTrader. Not sure why I created a package since I do not import any of it, just that all files are related. Will I have to do anything special if I compile and/or run from the CMD window?
    For example:
    - javac c:\BobTrader\BobTrader\*.java (ie, javac c:\foldername\packagename\*.java). I assume the *.java is needed since I need to compile multiple files; otherwise I might get some exception that the others are not understood by the compiler.
    Then run the application using....
    - java BobTrader.MarketAnalyzer3 (java packagename.filename)
    This assumes I am in the BobTrader folder.
    Also, how do I add ?.? To the Classpath so I don?t have to type java.exe ?classpath ?.? Filename class. I know how to add c:\foldername\; using environmental variables but not sure how to add ?.? Do i add ?.?;at the beginning of the Classpath followed by what is currently there now, or do I add it to the end. For example:
    -     ?.?;c:\ProgramFiles\Java\jrel.5.0_04\lib\ext\QTJava.zip, or
    -     .;c:\ProgramFiles\etc?., or
    -     c:\ProgramFiles\Java\jrel.5.0_04\lib\ext\QTJava.zip;. or ;?.?

Maybe you are looking for