Alpha compuler cant compile enums or static imports?!?

Pardon me if this is the wrong place to ask this question but I couldnt find any forums specific to CAP program members:
When trying to compile enums and static imports that work with the public prototype compiler, I get the following errors:
C:\dev\hcj\tiger\src>c:\j2sdk1.5.0\bin\javac -version oreilly/hcj/tiger/*.java
javac 1.5.0-beta
oreilly/hcj/tiger/EnumAttach.java:18: 'class' or 'interface' expected
public abstract enum EnumAttach {
                ^
oreilly/hcj/tiger/EnumAttach.java:35: 'class' or 'interface' expected
^
oreilly/hcj/tiger/ErrorLevel.java:20: 'class' or 'interface' expected
public enum ErrorLevel {
       ^
oreilly/hcj/tiger/ErrorLevel.java:31: 'class' or 'interface' expected
^
oreilly/hcj/tiger/ForEach.java:49: ';' expected
                for (String person: importantPeople) {
                                  ^
oreilly/hcj/tiger/ForEach.java:55: illegal start of expression
        ^
oreilly/hcj/tiger/ForEach.java:81: ';' expected
                for (String person: people) {
                                  ^
oreilly/hcj/tiger/ForEach.java:87: illegal start of expression
        ^
oreilly/hcj/tiger/StaticImports.java:15: <identifier> expected
import static StatusColors.*;
       ^
oreilly/hcj/tiger/StaticImports.java:15: '.' expected
import static StatusColors.*;
                            ^
oreilly/hcj/tiger/StaticImports.java:16: <identifier> expected
import static java.lang.Math.*.
       ^
oreilly/hcj/tiger/StaticImports.java:21: '.' expected
public class StaticImports {
       ^
12 errorsIs there something I am doing wrong or is this known bug?

Use the compiler flag -source 1.5

Similar Messages

  • Cant compile client prg

    Hello all,
    am using weblogic8.1, first of all I would like to know do we need to give a name("Advisor") in JNDI in weblogic, as its mentioned in HFEJB page52 for RI Server. if you say that we have give the JNDI name in weblogic,
    where do we ned to give?
    this is place where I stand now...
    AdviceBean.ejb
    package headfirst;
    import javax.ejb.*;
    import weblogic.ejb.*;
    import headfirst.*;
    * @ejbgen:session
    * ejb-name = "Advice"
    * @ejbgen:jndi-name
    * remote = "ejb.AdviceRemoteHome"
    * @ejbgen:file-generation remote-class = "true" remote-class-name = "AdviceRemote" remote-home = "true" remote-home-name = "AdviceHome" local-class = "false" local-class-name = "AdviceLocal" local-home = "false" local-home-name = "AdviceLocalHome"
    public class AdviceBean implements SessionBean {
    // OK, not very exciting advice! You should come up with something better...
    private String[] adviceStrings = {"test", "test1", "test2", "test3"};
    public void ejbActivate() {
    System.out.println("ejb activate");
    public void ejbPassivate() {
    System.out.println("ejb passivate");
    public void ejbRemove() {
    System.out.println("ejb remove");
    public void setSessionContext(SessionContext ctx) {
    System.out.println("session context");
    // this business method name is changed from the book, because
    // there of a bug on some versions of the J2EE RI
    public String getMessage() {
    System.out.println("in get advice");
    int random = (int) (Math.random() * adviceStrings.length);
    return adviceStrings[random];
    public void ejbCreate() {
    System.out.println("in ejb create");
    AdviceClient.java
    package headfirst;
    import javax.naming.*;
    import java.rmi.*;
    import javax.rmi.*;
    import headfirst.*;
    import javax.ejb.*;
    // not all of these imports are used in this code...
    // but in a real client you'd probably need at least
    // java.rmi.RemoteException and javax.ejb.CreateException
    public class AdviceClient {
    public static void main(String[] args) {
    new AdviceClient().go();
    public void go() {
    try {
    Context ic = new InitialContext();
    Object o = ic.lookup("Advisor"); // replace with YOUR JNDI name for the bean
    AdviceHome home = (AdviceHome) PortableRemoteObject.narrow(o, AdviceHome.class);
    Advice advisor = home.create();
    System.out.println(advisor.getMessage());
    } catch (Exception ex) {
    ex.printStackTrace();
    I cant able to build with this file D:\Weblogic\user_projects\AdviceApp\AdviceApp\headfirst\AdviceClient.java
    So I remove this client file for a while to build the .jar
    after removing this client file, I can able to build. Done, now i got the AdviceApp.jar. again I brought back the client file to the same place..
    I tried from cmd
    D:\Weblogic\user_projects\AdviceApp\AdviceApp\headfirst>javac -classpath "C:\Program Files\j2sdkee1.3.1\lib\j2ee.jar";"D:\Weblogic\user_projects\AdviceApp\Advic
    eApp\AdviceApp.jar" AdviceClient.java
    AdviceClient.java:28: cannot resolve symbol
    symbol : class Advice
    location: class headfirst.AdviceClient
    Advice advisor = home.create();
    ^
    1 error
    Please tel me how to get rid of this issue...

    1008783 wrote:
    Hi
    I cant compile and excute this function
    /* Where can I declare or execute this fields */
    CREATE TYPE typ_get_brandings as object(
    BRANDING_CODE varchar2(200),
    NAME_DESC varchar2(200)
    /* Where can I declare or execute this fields */
    CREATE TYPE tab_get_brandings is table of typ_get_brandings
    CREATE FUNCTION get_brandings
    RETURN tab_get_brandings
    IS
    l_brandings tab_get_brandings;
    BEGIN
    SELECT typ_get_brandings( b.BRANDING_CODE,C.NAME_DESC)
    into l_brandings
    from development.brandings b,godot.company c
    where b.company_id = c.company_id
    return l_brandings;
    EXCEPTION
    WHEN OTHERS THEN
    CORPORATE.COMMON.EXCEPTION_LOG( 'DEVELOPMENT.BRANDING_ADMIN.GET_BRANDING', SQLCODE, SQLERRM, null, FALSE );
    return SQLCODE;
    END;
    Please helpHi ,
    Why you wanna create object ? any specific requirement?
    create table plch_test(id number,name varchar2(30));
    insert into plch_test values(1,'ram');
    insert into plch_test values(2,'abhi');
    insert into plch_test values(3,'aksi');
    CREATE OR REPLACE FUNCTION PLCH_FNC(p_id IN plch_test.id%TYPE)
    RETURN plch_test%ROWTYPE
    IS
    rec_plch_test plch_test%ROWTYPE;
    BEGIN
    SELECT id,name
    INTO rec_plch_test
    FROM plch_test
    WHERE id=p_id;
    EXCEPTION WHEN NO_DATA_FOUND THEN
    rec_plch_test:=null;
    RETURN rec_plch_test;
    END;Call the function
    SQL> set serveroutput on
    SQL> DECLARE
      2  rec_plch plch_test%ROWTYPE;
      3  BEGIN
      4  rec_plch:=PLCH_FNC(1);
      5  dbms_output.put_line('ID'||' '||rec_plch.id||' '||'NAME'||' '||rec_plch.name);
      6  END;
      7  .
    SQL> /
    ID 1 NAME ram
    PL/SQL procedure successfully completed.
    SQL> DECLARE
      2  rec_plch plch_test%ROWTYPE;
      3  BEGIN
      4  rec_plch:=PLCH_FNC(2);
      5  dbms_output.put_line('ID'||' '||rec_plch.id||' '||'NAME'||' '||rec_plch.name);
      6  END;
      7  .
    SQL> /
    ID 2 NAME abhi
    PL/SQL procedure successfully completed.
    SQL> Regards,
    Achyut Kotekal
    Edited by: Achyut K on Jun 6, 2013 12:03 AM

  • Cannot static import in JSP (WebLogic 10.3)

    I am facing a problem with the use of 'static import' in JSP. This is on WebLogic 10.3. Please help/advise.
    Running weblogic.jspc results in the following error:+
    $ java weblogic.jspc -verboseJspc -keepgenerated -d /tmp/jsp WEB-INF/jspf/fragment.jspf
    \[jspc\] Overriding descriptor option 'keepgenerated' with value specified on command-line 'true'
    \[jspc\] Compiling /WEB-INF/jspf/fragment.jspf
    jspc failed with errors :weblogic.servlet.jsp.CompilationException: fragment.jspf:6:17: Syntax error on token "static", Identifier expected after this token
    <%@page import="static java.util.Collections.EMPTY_LIST" %>
    ^-------------------------------------^
    fragment.jspf:6:17: The import java.util.Collections.EMPTY_LIST cannot be resolved
    <%@page import="static java.util.Collections.EMPTY_LIST" %>
    ^-------------------------------------^
    The generated Java file is not correct; the static import is split into multiple imports+
    $ head /tmp/jsp/jsp_servlet/_web_45_inf/_jspf/__fragment_jspf.java
    package jsp_servlet._web_45_inf._jspf;
    import java.lang.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import static;
    import java.util.Collections.EMPTY_LIST;
    public final class __fragment_jspf extends weblogic.servlet.jsp.JspBase implements weblogic.servlet.jsp.StaleIndicator {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    I'm not sure that JSPC supports static imports, I would open a support case to get clarification.

  • BUG: JDeveloper code editor shows valid static import call as error

    I've noticed what appears to be a bug in the JDeveloper code validator when dealing with static imports.
    The following classes demonstrate the problem:
    package test;
    public class Parent {
      public static void parentMethod() {
        System.out.println("called parentMethod.");
    package test;
    public class Child extends Parent {
      public static void childMethod() {
        System.out.println("called childMethod.");
    package test;
    import static test.Child.*;
    public class StaticInheritanceTest {
      public static void main(String[] args) {
        Child.childMethod();
        Child.parentMethod();
        childMethod();
        parentMethod();  //<-- this line is highlighted as an error
    }Notice how on lines 7 and 8 of StaticInheritanceTest, the code validator does recognise that both parentMethod and childMethod are static methods of the Child class.
    Since 'Child' has been statically imported, then parentMethod should be available. Although parentMethod is presented as an 'auto-suggest' at line 11 in StaticInheritanceTest, when you try to call it the code editor shows the call as an error and the Ctrl-Click (to drill down into the method) doesn't work.
    When I run the class, it compiles successfully and runs with the following output:
    called childMethod.
    called parentMethod.
    called childMethod.
    called parentMethod.This might seem like an obscure and theoretical problem, but I've hit this whilst using Mockito, which uses exactly this kind of inherited static method to provide matchers.

    Hi,
    thanks. Will file a bug. This seems to be a designtime only issue that does not present a show stopper.
    Frank

  • Static import of member of class in same unnamed package fails

    I think I found a bug in the JDK 1.5 (Tiger) javac compiler. It involves static import and unnamed packages.
    Consider the following compilation unit:
    import static D.x;
    class C {
        int foo() { return x; }
    class D {
        static final int x = 1;
    }Running javac from the Tiger beta 2 SDK generates the following output:
    Test.java:1: cannot find symbol
    symbol: class D
    import static D.x;
                  ^
    Test.java:1: static import only from classes and interfaces
    import static D.x;
    ^
    Test.java:4: cannot find symbol
    symbol  : variable x
    location: class C
        int foo() { return x; }
                           ^
    3 errorsIn my opinion, this is a bug. This compilation unit should compile without errors.
    Note that the following compilation unit compiles without errors with Tiger beta 2:
    package p;
    import static p.D.x;
    class C {
        int foo() { return x; }
    class D {
        static final int x = 1;
    }Note that this issue is distinct from the issue of importing a class from an unnamed package into a named package. I totally agree that the latter is not allowed. However, the current issue is a different matter, since here I am importing members from the same package (which happens to be an unnamed package).

    The unnamed package feature is deprecated. Even if this is a bug (which I sort of doubt), this may never be fixed.

  • Using static import

    I just downloaded the 2.2ea. I tried using the static import feature. When I try to import my own classes f.ex.
    import static test1.test2.TestInferface;
    i get the error
    cannot find symbol
    symbol : class test2
    location: package test1
    import static test1.test2.TestInferface;
    ^
    if I try the static import from the example
    import static java.lang.Math.*; // import static
    it compiles fine. What have I got wrong here?

    Doh, you were right :). Importing test1.test2.TestInterface.*; is what is needed. Works now. Thanks.
    Thought I had already tried that but I guess I was wrong. I guess I was too stuck in the old way of thinking of importing classes and interfaces as a whole, I guess the static import imports class and interface members then.. Am I right?

  • Static imports in 1.5

    same static variable and same static method exists in two diffrent classes, while importing these two in my own implementation class follwing different output is coming why? Using j2se version1.5
    while using variable imports like
    import static package.Class1.variable1;
    import static package.Class2.variable1;
    //giving compilation errros
    while using method imports like
    import static package.Class1.method1;
    import static package.Class2.method1;
    //it is not giving any compilation error.
    Can anyone explain?

    >
    ah ok, when i wrote "Clearly" above i was assuming
    that the spec. when it does arrive (or when i can find
    it..) will disallow static imports of same signature
    methods (or possibly even just same named methods?) -
    and clearly any contravention of the spec should be
    reported to the userIf the spec says is should do something then it should do that.
    >
    on the other hand, the more the compiler can do the
    better since its a single point used by lots of
    people, so any small extra only has to be done once
    and is multiplied in the payoff - any individual
    trivial error message or warning might be
    questionable, but if lots are done then it saves time
    I doubt that a lot of people are going to be attempting to apply static imports to the same named item.
    not completely the same things, but i like the jikes
    feature where it says something like "it look like
    you're trying to invoke <SOME API METHOD> - this
    doesn't exist but a similar method does with
    signature: ... "
    I suspect that happens and is going to continue to happen far more frequently than duplicate static imports.
    And of course a compiler can add additional things like that. But that is rather different than suggesting that it is required.
    when a case is left in the grey area then at the very
    least a dozen developers will come across it and
    because of the lack of some text saying ERROR will
    start to question themselves - i don't see this as
    pandering to the developers laziness
    And yet none of the compilers warn against the "i = i++" construct.
    i've not verified this, and also the lang. spec does
    not seem to have been updated for 1.5???
    it sounds like the compiler should just complain in
    both cases?Yes but given that neither has been used I suspect
    that it will complain once they are used. If it
    doesn't then that is a bug.hm, a similar piece of code
    import java.util.List; import java.awt.List;
    complains immediately if you try to compile it - i guess this
    isn't that important but i like the
    complain-loudly-and-early approach - i think they also
    possibly made unused imports or duplicate imports
    errors or warnings for 1.5?Could be. However, the spec itself drags significantly behind the additional material. For example note that the 'current' spec doesn't have assert. So tracking down what should really be in the spec can be somewhat complicated.
    Note also that I haven't really seen the OP clarify that they expect an error for both cases rather than that they expect that no error at all should show up (because they really want to use both.) And although the first is nice the second is clearly wrong. Hopefully that point is clear.

  • Static Import question

    It is a very easy (down to earth) question.
    Are static imports of methods having the same name as
    Object methods forbidden?public class StaticUse1 { 
      public static boolean equals(StaticUse1 su1,StaticUse1 su2) {
        return true;
      public static boolean equal(StaticUse1 su1,StaticUse1 su2) {
        return false;
    }An import somewhere else:import static apackage.StaticUse1.*;
    public class Test {
      public static void main(String[] args) {
        //System.out.println(equals(new StaticUse1(),new StaticUse1()));  // error
        System.out.println(equal(new StaticUse1(),new StaticUse1()));
    }Compiler complains about ... equals(java.lang.Object) ...

    Such static imports are allowed, but they won't work because of the scoping rules of the language. The equals(Object) for the current class always shadow such methods from the static import.

  • Static import bug?

    Hey just discovered something new...does this sound like a bug to you guys?
    I have a class with a static method called, say, omgMethod()
    and I have another class with a method (not static) with the same name (omgMethod) but different signature.
    now when I try to use import static classA.omgMethod in the second class, it generates a compiler error:
    cannot find symbol method omgMethod( etc...)
    any thoughts? i'm thinking about adding it to the bug report.
    -Cuppo

    I'm not so sure about that. I have never used static import so I checked out Sun's tutorial which is here:
    http://java.sun.com/j2se/1.5.0/docs/guide/language/static-import.html
    It talks about importing "members" and says you can import "members" individually. And (I had to look this up too in the JLS), "members" means classes, interfaces, fields, and methods.
    So that says to me that you can indeed import a static method from another class, and then use it without qualification. Yeah, I'm surprised too. But you're just importing the method's name, not its signature. So if that name conflicts with a name of a method in your class, then I don't know what is supposed to happen. I looked through the JLS a bit and section 6.5.7.1 says
    "The Identifier must name at least one visible (�6.3.1) method that is in scope at the point where the Identifier appear or a method imported by a single-static-import declaration (�7.5.3) or static-import-on-demand declaration (�7.5.4) within the compilation unit within which the Identifier appears.
    See �15.12 for further discussion of the interpretation of simple method names in method invocation expressions."
    Possibly section 15.12 discusses conflict resolution in this case. But I will let you carry on from there.

  • Need help in static imports

    import static java.lang.Integer.*; // 2
    public class TestStaticImport {
    public static void main(String[] args) {
    System.out.println(Integer.MAX_VALUE); // 3
    System.out.println(MAX_VALUE); // 4
    }above code compiles fine but when i compile code given below
    it doesnt work y??
    // file 1 in respective package
    package com.sun;
    public class PkgAccess {
       public static int tiger = 1414;  }
    //file2
    import static com.sun.PkgAccess.*;
      public class PkgAccess2 {
        int x1 = PkgAccess.tiger;//1
        int x2 = tiger;//2
      }in above code if v remove 1 den it works y whts prb in line if we can use Integer.MAX_VAULE den y not PkgAccess.tiger????

    See,
    all the classes in the package java.lang are imported by itself and you don't have to import for using any classes in the java.lang package.
    Since "_Integer_" is a class in the java.lang package compiler was able to find it .
    Now in your second case when you are writing PkgAccess.tiger,compiler needs to find PkgAcess class but unfortunately it won't be able to find it because you have not imported the package.
    import static com.sun.PkgAccess.*;
    This statement only imports the static fields of the PkgAcess class and not the class.So for it to compile successfully you should import the class by writing
    import com.sun.PkgAccess;
    I hope you understood.This was my first attempt to explain something to someone.
    Edited by: AnkitSinghal on Jun 30, 2009 1:37 AM

  • Enum vs static final String

    I was going to use static final Strings as enumerated constants in my application, but would like to see if I should be using enums instead.
    In terms of efficiency, if I have, say, 5 enumerated elements, will only one copy of the enumerated element be in memory, like a static final String? So regardless of how many times I refer to it, all references point to the same instance (I'm not sure if what I just said even makes sense in the context of enums, but perhaps you could clarify).
    Are there any reasons why for enumerated constants that are known at development time, why static final Strings (or static final anything, for that matter) should be used instead of enums if you're using JDK 1.5?
    Thanks.

    In terms of efficiency, if I have, say, 5 enumerated elements, will only one copy of
    the enumerated element be in memory, like a static final String?I don't know if it addesses your concerns, but the the Java Language Specification says this about enums: "It is a compile-time error to attempt to explicitly instantiate an enum type (�15.9.1). The final clone method in Enum ensures that enum constants can never be cloned, and the special treatment by the serialization mechanism ensures that duplicate instances are never created as a result of deserialization. Reflective instantiation of enum types is prohibited. Together, these four things ensure that no instances of an enum type exist beyond those defined by the enum constants." (http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.9)
    As for the problems of memory usage, how big are these strings anyway?
    The advantages of using enums over static final strings are discussed in the "technotes" accompanying 1.5 http://java.sun.com/javase/6/docs/technotes/guides/language/enums.html They list the following as problems with the static final "antipattern"
      * It is not typesafe (methods that expect one of your constants can be sent any old string)
      * There is no name space - so you must continually be sure that your constants don't have names that may be confused
      * Brittleness. Your strings will be compiled into the clients that use them. Then later you add a new constant...
    �  * Printed values will be uninformative. Perhaps less of a problem for Strings, but, still, simply printing the string will leave its semantic significance obscure.

  • Static import from SE5 (Ex 16 on p. 91 in Thinking in Java Edn 4 by Eckel)

    The following line of code is underlined:
    import static net.mindview.util.Print.*;with this error displayed:
    static import declarations are not supported in -source 1.4
    (try -source 1.5 to enable static import declarations).
    My Path variable contains these:
    C:\Program Files\Java\jdk1.6.0\bin;C:\Program Files\Java\jre1.6.0\bin;D:\java\TIJ4\code
    D:\java\TIJ4\code is the root folder for net.mindview.util.Print.
    JRE1.6 and JDK1.6 are installed.
    I also have:
    i.e. a dot, in my CLASSPATH variable.
    This is from the 4th edn of Thinking in Java by Bruce Eckel. If you are or have been through this stuff I would really appreciate it if we could meet on Skype every now and then to talk about issues like the one described above.
    Thanks for your help,
    b

    Now same code is underlined:
    import static net.mindview.util.Print.*;but with this error message:
    package net.mindview.util does not exist
    However it is mapped like this:
    D:\java\TIJ4\code\net\mindview etc..
    So, I have put this in to the Path variable:
    D:\java\TIJ4\code because it is the root folder of net.mindview.util.
    Is there something else I should do? Is is ok to have a non C directory in the Path variable?
    Thanks for any help,
    B

  • Trouble with compiling class that contains "import com.sun.xacml.*;"

    I think the package com.sun.xacml is included in j2sdk 1.4.2 (the one that I have)
    but every time I try to compile a class that importes this package classes, the compiler dosen't recognize the package.
    It's a problem of updating the CLASSPATH?
    Thanks in advance

    I don't think this would be part of any standard java distribution.
    But I found a couple of jars (versions) available for download at
    http://ebxmlrr.sourceforge.net/maven/repository/xacml/jars/

  • Is it possible to compile under Forte with import com.ms.security.*;

    Is it possible to compile under Forte with import com.ms.security.*; included in a java applet or do I need to compile from Microsoft JDK only? I would like to thank you on advanced.

    Yes; just include the cab/zip file containing those classes in your project. You'll find them from somewhere in your system.
    I would like to thank you on advanced. I don't give you the permission to do that. :)

  • Database full compile while doing schema import using impdp

    hi,
    oracle 10g
    Database full compile while doing schema import using impdp..
    what is happening here..
    regards,
    Deepak

    My scenario
    I need to import the particular schema from the full export dump. which has taken by using expdp. while importing i am using remap_schema for a single schema.
    But it try to import the full dump and compile all the schema objects.
    regards,
    Deepak

Maybe you are looking for

  • How to download a file from a server

    Hi, I have a question with a general design implementation. Hope anyone more skilled than me helps me. I want to do an application based on an android client and a java server. Local wifi transmission, no 3G. Basically, the client must connect to the

  • IMac 27" i5 backorder status

    I ordered the above iMac yesterday (10-2) and received an email tonight that the item is now on backorder. A one to two week backorder period was estimated. How accurate is this based on actual experience? I am disappointed that there was no mention

  • Lost Connections

    Hi I am using a WRT110, 1 wired desktop, 2 wireless laptop a Lenovo T61 laptop, which is the one I am having an issue. Every time I reboot or shutdown this laptop, when I restart again, all other connections are lost, including this laptop, once I go

  • MiniDVI to HDMI adapter FOUND

    all, I found this adapter so that i can enjoy my mac book movies on my plasma. However before I buy, i want to know anyone has experienced in using this product or any other similar product. *Product Name* - Kanex™ Mini DisplayPort to HDMI Adapter ht

  • Update Contract Account in Background - BOR "ISUACCOUNT" Method "Change"

    Hi Experts, We are trying to update the "Dispatch Control" & "Alternative Bill Recipient" fields on the Contract Account in background. We are using BOR - "ISUACCOUNT" and Method - "Change". The Method is unable to update the field values but not giv