Java 1.5beta compilation help

I don't know if anyone here has tried the new(ish) java 1.5.0beta, but I can't get it to work for the life of me. If anyone knows why it still seems to compile like 1.4, or if anyone knows where I can get more help, please let me know...
Specifically, the new Generics functionality should allow me to compile:
ArrayList<String> listOfStrings = new ArrayList<String>();
instead of the old version without the "<String>". This isn't compiling with javac 1.5.0, saying that a "(" is expected (just like you'd expect if you tried compiling it with javac 1.4. My version of the compiler is definitely correct (according to javac -version, anyway).
Any ideas?
D

It's ok, I've solved it.
To compile in 1.5 mode, you need to specify "javac -source 1.5 <filename>". Seems rather roundabout, but I no longer have a problem...
D

Similar Messages

  • Java(FX) Property Compiler

    Hi!
    We implemented a small Java(FX) Property Compiler which enables you to use a powerful PropertyHint-annotation. The "compiler" is implemented as an Post-"Java Compiler"-Bytecode-Modification-Tool (using asm-4).
    Here are 3 small example so you can get the idea.
    First Example
    public class Case1 {
        @PropertyHint public String one;
        public enum Two { Zero, One, Two }
        @PropertyHint public Two two;
    }If you compile this class with Java Compiler and the Property Compiler you get the following byte-code-equivalent (I used Java Decompiler to reflect the code):
    public class Case1
      public String one;
      public Two two;
      private SimpleObjectProperty<Two> _twoField;
      private SimpleStringProperty _oneField;
      @Property(writeable=true, name="two", dataSignature="Lde/chimos/property/test1/Case1$Two;", dataSignatureGeneric="", humanReadableName="")
      public final ObjectProperty<Two> twoProperty()
        if (this._twoField == null)
          this._twoField = new SimpleObjectProperty(this, "two");
        return (ObjectProperty)this._twoField;
      private final Two _getTwo()
        return (Two)twoProperty().getValue();
      @XmlElement
      public Two getTwo()
        return _getTwo();
      private final void _setTwo(Two value)
        twoProperty().setValue(value);
      public void setTwo(Two value)
        _setTwo(value);
      @Property(writeable=true, name="one", dataSignature="Ljava/lang/String;", dataSignatureGeneric="", humanReadableName="")
      public final StringProperty oneProperty()
        if (this._oneField == null)
          this._oneField = new SimpleStringProperty(this, "one");
        return (StringProperty)this._oneField;
      private final String _getOne()
        return (String)oneProperty().getValue();
      @XmlElement
      public String getOne()
        return _getOne();
      private final void _setOne(String value)
        oneProperty().setValue(value);
      public void setOne(String value)
        _setOne(value);
      public static enum Two
        Zero, One, Two;
    }The fields "public String one" and "public Two two" are still in there to keep the Java Compiler (representing the first pass of the compiling process) working. It is possible to configure the Property Compiler via a setting called "dummyFields".
    All references to these fields (dummy fields) are replaced by getter and setter calls. As you can see in the next example.
    Second Example
    This is what you type and compile:
    public class Main {
         * @param args the command line arguments
        public static void main(String[] args)
            Case1 case1 = new Case1();
            case1.one = "Test";
            case1.two = Case1.Two.Two;
            System.out.println("case1.one = "+case1.one);
            System.out.println("case1.two = "+case1.two);
            Case3 case3 = new Case3();
            System.out.println("case3.one = "+case3.one);
            case3.update();
            System.out.println("case3.one = "+case3.one);
            Case4 case4 = new Case4();
            case4.one = Case4.One.Two;
            System.out.println("case4.one = "+case4.one);
            case4.one = Case4.One.Zero;
            System.out.println("case4.one = "+case4.one);
            Case5 case5 = new Case5();
            case5.one = Case5.One.Two;
            System.out.println("case5.one = "+case5.one);
    }This is what you really get (reflected via Java Decompiler):
    public class Main
      public static void main(String[] args)
        Case1 case1 = new Case1();
        case1.setOne("Test");
        case1.setTwo(Case1.Two.Two);
        System.out.println("case1.one = " + case1.getOne());
        System.out.println("case1.two = " + case1.getTwo());
        Case3 case3 = new Case3();
        System.out.println("case3.one = " + case3.getOne());
        case3.update();
        System.out.println("case3.one = " + case3.getOne());
        Case4 case4 = new Case4();
        case4.setOne(Case4.One.Two);
        System.out.println("case4.one = " + case4.getOne());
        case4.setOne(Case4.One.Zero);
        System.out.println("case4.one = " + case4.getOne());
        Case5 case5 = new Case5();
        case5.setOne(Case5.One.Two);
        System.out.println("case5.one = " + case5.getOne());
    }Amazing, right?
    Third Example
    In case you provide a getter or setter it is used automatically:
    public class Case5 {
        public enum One { Zero, One, Two }
        @PropertyHint public One one;
        public One getOne()
            System.out.println("Case5.getOne()");
            if(one == One.Two)
                return One.Zero;
            return one;
    }This is what you get (reflected via Java Decompiler):
    public class Case5
      public One one;
      private SimpleObjectProperty<One> _oneField;
      public One getOne()
        System.out.println("Case5.getOne()");
        if (_getOne() == One.Two)
          return One.Zero;
        return _getOne();
      @Property(writeable=true, name="one", dataSignature="Lde/chimos/property/test1/Case5$One;", dataSignatureGeneric="", humanReadableName="")
      public final ObjectProperty<One> oneProperty()
        if (this._oneField == null)
          this._oneField = new SimpleObjectProperty(this, "one");
        return (ObjectProperty)this._oneField;
      private final One _getOne()
        return (One)oneProperty().getValue();
      private final void _setOne(One value)
        oneProperty().setValue(value);
      public void setOne(One value)
        _setOne(value);
      public static enum One
        Zero, One, Two;
    Sourcecode and documentation
    We published the code as LGPL. The project an more examples are available on http://code.google.com/p/java-property-compiler/source/browse/
    The first draft of documentation is still work in progress (Gerrit is currently working on the documentation).
    IDE integration
    The Eclipse-integration is done via an ant-builder. It works but is not perfect. Apart from the fact that the configuration requires some mouse clicks, you have to manually activate the "auto,clean" trigger. We would like to implement a real builder-plugin. Can anyone help us?
    We tried a Netbeans-integration via "-post-compile", etc.. But that does not work properly. If you try to debug a project which uses the Property Compiler, the post-compiled byte-code is simply ignored and you run the unprocessed bytecode. Any idea?
    JavaFX-Tree Chart
    There is another project called "javafx-treechart": http://code.google.com/p/javafx-treechart/wiki/TreeChart
    Gerrit will write about it as soon as the documentation is online.
    Regards, Niklas
    Edited by: Niklas on 28.11.2011 16:23

    Hi all!
    Thank you for your responses and comments!
    Sorry for the late response. I am in Australia on vacation at the moment (just visited Brisbane and Whitsundays - and I am going to visit Sydney tomorrow :-).
    @zonski:
    Lombok is really a masterpiece. I had a look at the code. They use AST and (if I'm not mistaken) byte code manipulation too. I think we can learn a lot from Lombok.
    The IDE integration of Lombok is kind of black magic - my personal point of view. I simply don't like those Eclipse API interceptions which are implemented in the Eclipse agent. I rather stick to standard interfaces - like a custom Eclipse-Builder, etc... (I still don't know the Netbeans-way, but I am going to figure that out).
    This is one of the reasons why I decided to use the (awesome) Lombok source code as inspiration, but not to use my resources at hand to extend Lombok itself.
    Further reasons:
    a) We developed a different annotation philosophy (not implemented yet but we are going too).
    b) I developed a small "deterministic destructor" mechanism based on byte-code manipulation and some (important) variable assignment restrictions - to keep performance up and avoid side effects. We want to provide an annotation for this mechanism.
    We probably stick to byte code-manipulation. Not sure if we use AST (makes IDE integration very hard - see Jonathan Giles' comment).
    @bouye:
    I understand the concerns regarding "manual code tweaking", but I really hate the property boilerplate code - it results in unreadable source code. Our implementation still allows custom implementations of getter and setter in case you want to tweak your code. We extended our concept to allow even more flexibility (not implemented yet).
    @Richard Bair:
    I agree, developers might be confused if the know plain java and have no idea about the magic going on. But this is a matter of documentation and communication. If you know the concepts and the tools the code is easier to read.
    I agree with you that Java really needs native property support. The annotation solutions are just placeholder solutions.
    @Jonathan Giles:
    IDE support is definitely an issue. That’s the reason why I want to stick to byte code manipulation. You can integrate the required build steps in Eclipse easily (still not sure about Netbeans). Using AST requires a lot of black magic as you can see in the Lombok source code.
    Actually I had absolutely no debugging issues with our approach if we talk about Eclipse. If there is a way to hook into the Netbeans build process properly it shouldn't be a problem either. Of course the injected code needs to be crafted and tested carefully (no surprises policy).
    The next version of our post-compiler will be splitted in two parts. The first part can be used within the regular build process and does a lot of modification (probably based on the ASM tree API). The second part gets called from a class loader and performs some final tweaks, e.g. dropping unnecessary fields (based on the fast ASM core API). In case the loaded class file did not pass the first part (detected while loading), it is entirely processed within the loading sequence. This should avoid surprises. The post-compiler can be restricted to specific namespaces.
    Our current big commercial project is going to depend heavily on the post-compiler. We decided to provide the post-compiler as open source as we want to contribute to the Java community.
    I'll keep you posted!
    Niklas

  • Java 2 SDK compilator for beginners

    Hi to all here.
    I am really sorry to disturb you all,
    I am beginner in Java and I need to download Java 2 SDK compilator in order to compile my homeworks. I went lost in all the reliese EE, SE and so on I saw in Sun homepage.
    Which one is the right one ?
    I have Windows Vista Home edition in my computer.
    Thanks for helping me.
    Flavio

    Download and install a Java SE 6 JDK for your Windows platform which is available here:
    http://java.sun.com/javase/downloads/index.jsp
    If you want some GUI Application you may choose the version containing NetBeans, if you only want the compiler and runtime environment install the first option (JDK 6 Update 4).
    Edited by: mezler on Feb 20, 2008 2:13 PM

  • Is there a Java utility class to help with data management in a desktop UI?

    Is there a Java utility class to help with data management in a desktop UI?
    I am writing a UI to configure a network device that will be connected to the serial port of the computer while it is being configured. There is no web server or database for my application. The UI has a large number of fields (50+) spread across 16 tabs. I will write the UI in Java FX. It should run inside the browser when launched, and issue commands to the network device through the serial port. A UI has several input fields spread across tabs and one single Submit button. If a field is edited, and the submit button clicked, it issues a command and sends the new datum to the device, retrieves current value and any errors. so if input field has bad data, it is indicated for example, the field has a red border.
    Is there a standard design pattern or Java utility class to accomplish the frequently encountered, 'generic' parts of this scenario? lazy loading, submitting only what fields changed, displaying what fields have errors etc. (I dont want to reinvent the wheel if it is already there). Otherwise I can write such a class and share it back here if it is useful.
    someone recommended JGoodies Bindings for Swing - will this work well and in FX?

    Many thanks for the reply.
    In the servlet create an Arraylist and in th efor
    loop put the insances of the csqabean in this
    ArrayList. Exit the for loop and then add the
    ArrayList as an attribute to the session.I am making the use of Vector and did the same thing as u mentioned.I am using scriplets...
    >
    In the jsp retrieve the array list from the session
    and in a for loop step through the ArrayList
    retrieving each CourseSectionQABean and displaying.
    You can do this in a scriptlet but should also check
    out the jstl tags.I am able to remove this problem.Thanks again for the suggestion.
    AS

  • How to track the information/error of java code while compiling.

    Hi,
    I want all the information or errors of java code during compilation.
    So that I can use this information or I can show these errors with different style.
    How to get the java syntax errors?

    Hi,
    I want all the information or errors of java code
    during compilation.
    So that I can use this information or I can show these
    errors with different style.
    How to get the java syntax errors?Redirect the STDOUT/STDERR from the the JAVA/JAVAC command to a file is one way...
    For instance at the commmand line:
    javac myClass.java > STDOUT.txt 2> STDERR.txt (Works for Unix variants or Windows OS's)
    Then you can do what ever you want with the data contained in the files.
    Hope this helps

  • Popups work in preview but not in compiled help

    Hello,
    I am using Robohelp 8 and have been having problems displaying popups in my compiled help. When I view a topic that contains popup links in the WYSIWYG, I can preview the popup topics with no problem, but when I compile and click on a link that contains a popup, nothing happens. I get a warning in the bottom of the browser window that says "Error on page" with no further details. Is there a setting somewhere that I need to adjust. I have never had this problem before.
    Thank you in advance for any input.
    Adrienne

    Hi there
    The popup functionality depends on the ehlpdhtm.js file. Years ago I had a large project where popups broke in topics that were heavily buried in a deep folder structure. I managed to make them work by amending the path to the js file so it was shorter. This also meant I had to copy the js file to the folder where the popups were broken.
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7, 8 or 9 within the day!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • Java.awt.Toolkit - Coldfusion - HELP

    Greetings.
    I am having a hard time with the following code:
    <cfobject action="create" type="java" class="java.awt.Toolkit" name="fileObj">
    <cfscript>
    img = fileObj.getDefaultToolkit().getImage("images/products/39321.jpg");
    width = img.getwidth();
    height = img.getheight();
    </cfscript>
    <cfoutput>#height#</cfoutput>
    I keep getting the following error:
    java.lang.NoClassDefFoundError
    My version of Java is 1.4.2. I'm running Redhat Linux 4.0. Coldfusion MX 6.1.
    I know this isn't a Coldfusion forum, but I really need some help here.
    I'm new to Java technologies, so any help will be greatly appreciated.

    can ColdFusion load Java objects?
    Presuming that it can, then ColdFusion probably needs some configuration to tell it the Java directory or where the class files are (JavaHome/jre/lib/rt.jar)

  • Java is a Compiler or Interpreter?

    Java is a Compiler or Interpreter?

    If you mean the executable called "java" that comes with the jre, it is actually both... it's an interpreter that compiles parts of the code it's interpreting to machine code to make it run faster.

  • Getting java code to compile on unix/linux

    I have been using borland JBuilder to run and compile my java code. Recently i tried moving the code to a linux machine in which i have downloaded the JDK to. My classes only use standard java classes with the exception of a jbcl.jar file which has a class that one of my classes relies on. It turns out when i try to run my class i get error messages because it cant find the jar file. Where should I put this jar file? by the way in my class i use the statement: where jbcl.layout is the class i need.
    import jbcl.layout.*;

    another question. In my class I use the statement
    import jbcl.layout.*;
    so all i need to do is add the jbcl.jar to my class
    path? is my import statement correctIf it compiles in your IDE, then it's correct. You shouldn't have to change anything at all in your source code to use a different compiler or to compile on a different platform. You just have set up the proper environment and parameters--tell it which .java files to compile, which jars or directories to search for classes in (classpath), etc. For IDEs you do that with the Preferences or Options menu item. For command line compilation you do this with command line arguments, config files (a la build.xml for ant), or environment variables (although relying on the CLASSPATH env var is generally a bad idea).

  • Java.io.IOException: Compiler failed executable.exec

    I m trying to deploy a EAR file which has a single EJB.
    It deploys fine but when i try to start it it throws the exception trac
    ebelow.
    Any ideas on how to solve ? I ve put Jrockit javac in path, set BEA_HOME
    and tried a few other things with no luck.
    Any ideas ?
    /s
    Unable to deploy EJB: hello_ejb_wls9.jar from hello_ejb_wls9.jar:
    There are 1 nested errors:
    java.io.IOException: Compiler failed executable.exec
    at
    weblogic.utils.compiler.CompilerInvoker.compileMaybeExit(CompilerInvo
    ker.java:435)
    at
    weblogic.utils.compiler.CompilerInvoker.compile(CompilerInvoker.java:
    295)
    at
    weblogic.utils.compiler.CompilerInvoker.compile(CompilerInvoker.java:
    303)
    at weblogic.ejb20.ejbc.EJBCompiler.doCompile(EJBCompiler.java:284)
    at weblogic.ejb20.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:470)
    at weblogic.ejb20.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:439)
    at
    weblogic.ejb20.deployer.EJBDeployer.runEJBC(EJBDeployer.java:436)
    The server compiler and ejb compiler are set as javac in the options.

    Hi,
    I think you are not creating that ear correctly.
    Could you check the following points ?
    1. make sure all the files you need are there
    2. make sure folder hierararchy is ok
    If that's cool: And its still doesnt work:
    Export your example ear from weblogic and use that one
    Regards
    Anilkumar kari

  • Hiding topics in compiled help

    Is there a way to hide a topic so that it is included in the
    compiled help but can only be found by searching with a specific
    keyword? I don't want to exclude it from the compiled help; I just
    don't want it to be visible to the general public but still
    accessible to those of us who need it.

    Any topic that is not indexed, not in the TOC and not linked
    from other topics etc can only be accessed by searching. However
    the search will catch all text rather than just a keyword.
    There are threads here describing how to exclude topics from
    a search. How about excluding the topic from a search but making
    the topic accessible by some hidden means in another topic. For
    example, create a small icon the same colour as the background of a
    page so that it cannot be seen. Make that a hyperlink to the topic.
    I accept it is a kludge but it is only for a small number of people
    in the know as to where that graphic is, it would work.

  • There is no rt.jar in java lib could anyone help me downloading it ,or tell me where is this rt.jar, there is no rt.jar in java lib could anyone help me downloading it ,or tell me where is this rt.jar

    there is no rt.jar in java lib could anyone help me downloading it ,or tell me where is this rt.jar, there is no rt.jar in java lib could anyone help me downloading it ,or tell me where is this rt.jar

    thx for your suggestion ..but i did try to skip my code..but i am sure if u guy understand what i am trying to ask ..so i try to show my all program for u guy better undrstand my problem ...the first three paragraph of code i hope u guy could focus on it ....i try ask the user to input the cd`s title to our insert list by using a function call readString( ) and i use this method to ask the user what cd they want to be delete from the list ...but it doesn`t work when i try to perform the delete cd funtion. At first, i think it should be my deleteCd( ) problem ..but i do some testing on it..it works fine if i pass a String directly to my function instead of using readString() function to perform ...therefore, i am sure my delete function working fine....i am thinking if it is my readString() problem make my deletion does not perform well...thx for u guy help

  • Hello Sorry for the inconvenience, but I have a problem in Java I can not open files, audio chat, which type of jnlp after the last update of the Java 2012-004 Please help me in solving this problem.

    Hello Sorry for the inconvenience, but I have a problem in Java I can not open files, audio chat, which type of jnlp after the last update of the Java 2012-004
    Please help me in solving this problem. 

    Make sure Java is enable in your browser's security settings.
    Open Java Preferences (in Utilities folder)
    Make sure Web-start applications are enabled.
    Drag Java 32-bit to the top of the list.
    jnlp isn't an audio file format. It's just a java web-start program (Java Network Launching Protocol).

  • Simple Java created with compilation errors.

    Hi,
    While I am using Oracle for many years (currently 9.2.0.6.0) I am completely new to Java in the database.
    I found a very simple example to get started (please see SQL*Plus dump below) ... but I get a compilation error. Can anyone tell what I am doing wrong?
    SQL> CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED Fibonacci AS
    2 public class Fibonacci
    3 {
    4 public static int fib (int n)
    5 {
    6 if (n == 1 || n == 2)
    7 return 1;
    8 else
    9 return fib(n - 1) + fib(n - 2);
    10 }
    11 }
    12 /
    Warning: Java created with compilation errors.
    SQL> show errors java source Fibonacci
    No errors.
    SQL>
    (It must be a simple thing, the example I found seems correct, but what about grants, settings etc.)
    Thanks in advance,
    Stefan

    Stefan,
    I cannot see anything in your code that would cause a compilation error. However, according to the example in the "Oracle 9i SQL Reference", it looks like you need to enclose the name in double quotes, as in:
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Fibonacci" AS ...Alternatively (and this is the way I do it), you could compile the class outside of the database, and load the compiled class file. Just create a file called "Fibonacci.java" (that contains your java code), compile it, and then use the "loadjava" tool to load the "Fibonacci.class" file into the database. Please refer to the Oracle 9i Java Developer's Guide for more details.
    Good Luck,
    Avi.

  • Java.lang.NoSuchMethod: main - Help pls

    This is the code i got off a book but it seems like it's not working. I got an error which says 'java.lang.NoSuchMethod: main' Help pls...
    import java.io.*;
    import java.util.*;
    class PostfixInterpreter {
         private String postfixString, outputString;
    private boolean isOperator(char c) {
         return (c == '+' || c == '-' || c == '*' || c == '/' || c == '^' );
    private boolean isSpace(char c) {
         return (c == ' ');
    }//end isSpace
    public void interpretPostfix() {
         Stack evalStack= new Stack();
         double leftOperand, rightOperand;
         char c;
         StringTokenizer parser = new StringTokenizer(postfixString,"+-*/^ ", true);
         while (parser.hasMoreTokens()){
              String token = parser.nextToken();
              c = token.charAt(0);
              if ((token.length() == 1) && isOperator(c)) {
                   rightOperand = ((Double)evalStack.pop()).doubleValue();
                   leftOperand = ((Double)evalStack.pop()).doubleValue();
                   switch (c) {
                        case'+': evalStack.push(new Double(leftOperand+rightOperand));
                                       break;
                        case'-': evalStack.push(new Double(leftOperand-rightOperand));
                                       break;
                        case'*': evalStack.push(new Double(leftOperand*rightOperand));
                                       break;
                        case'/': evalStack.push(new Double(leftOperand/rightOperand));
                                       break;
                        case'^': evalStack.push(new Double(Math.exp(Math.log(leftOperand)*rightOperand)));
                                       break;
                        default:
                                       break;
                   }//end of switch
              }else if((token.length() == 1)&& isSpace(c)){
              }else {
                   evalStack.push(Double.valueOf(token));
              }//end if
         }//end while
    // remove final result from stack and output it
    output("value of postfix expression = " + evalStack.pop());
    }//end interpretPostfix
    private void output(String input){
         postfixString = input;
         }//end setInput
    public String getOutput(){
         return outputString;
    }//end getOutput
    }//end class PostfixInterpreter
    /*Stack class*/
    class Stack {
         private int count;
         private int capacity;
         private int capacityIncrement;
         private Object[] itemArray;
    //the following defines a no-arg constrcutor for Stack objects
    public Stack() {
         count = 0;
         capacity = 100;
         capacityIncrement = 5;
         itemArray = new Object[capacity];
         public boolean empty() {
              return (count ==0);
         public void push(Object X) {
              //if the itemArray does not have enough capacity
              //expend the itemArray by the capacity increment
                   if(count == capacity) {
                        capacity += capacityIncrement;
                        Object[] tempArray = new Object[capacity];
                        for (int i=0; i<count;i++){
                             tempArray[i] = itemArray;
                   itemArray=tempArray;
              //insert the new item X at the end of the current item sequence
              //and increase the stack's count by one
                   itemArray[count++]=X;
    public Object pop() {
         if(count==0){
              return null;
         }else{
              return itemArray[--count];
    }//end of pop()
    public Object peek() {
         if (count == 0){
              return null;
         }else{
              return itemArray[count-1];
    }//end peek()

    First, when posting code in the future, use the code /code tags. Just highlight the code and click the code. button.
    The error probably occurred when you tried to launch the class as an application by entering "java PostfixInterpreter" The java application launcher looks for a method in the PostfixInterpreter class whose signature is exactly public static void main(String[] args)(except 'args' can be any legal variable name). Since your PostfixInterpreter class doesn't have this method, you get the error. If you want this class to run, you have to include the method and code inside the method that runs the application.

Maybe you are looking for