Slashdot Mirror


Have a Nice Steaming Cup of Java 5

wap writes "The language/VM/religion that everyone loves to hate is now serving another cup: Java 1.5 is ready for download. The new features of 1.5 have been discussed here before. I, for one, welcome our new virtual machine overlord. I have been using the release candidate, and startup times are noticeably faster, as is overall performance, and the new features like typesafe collections and static imports are great to have. Let the Java flames begin!"

14 of 859 comments (clear)

  1. Finally! by arhar · · Score: 4, Informative

    I've been waiting for this for a long time! Now waiting for Eclipse to release a working plugin (well, there's this ,but it's not that great.

  2. Release notes by BlurredOne · · Score: 5, Informative

    If any one is interested in reading the release notes, they can be found at http://java.sun.com/j2se/1.5.0/docs/relnotes/featu res.html

  3. The new for loop and type safe collections rock by ShatteredDream · · Score: 5, Informative

    The new For loop may seem to be just syntactic sugar, but it isn't. It really does make the code look a lot cleaner when you are iterating over a collection or an array. The type safe collections are also very handy--no more class cast exceptions and stuff like that.

    It would be nice though if Sun would make Groovy or Jython a standard part of their java distribution. That would definitely make it competitive with .NET

  4. Re:Still no operators... by timbloid · · Score: 4, Informative

    > ok, it got faster, but still not as fast as C++ too.
    > I guess this will finally come but when ?

    Errr...

    Java 1.4 was comparable in speed to C++ (except obviously for Trig which got a huge overhaul in 1.4 and slowed down some)

    It really depends how you write you code... Sloppy C++ code can be slow too.. ;-)

  5. Re:Bytecode Compatibility by Z-MaxX · · Score: 4, Informative

    You need to use the "-target 1.4" option to javac to tell it to produce the older version of class files.

    --
    Dr Superlove 300ml. I use my powers for awesome
  6. Swing on OpenGL by tesmako · · Score: 5, Informative
    One of the new features of Java 1.5 that has not been mentioned much yet is the OpenGL acceleration of Java2D (which underlies Swing and AWT). Adding the flag
    -Dsun.java2d.opengl=true
    (or by setting the system property in the program) makes pretty much all Java2D calls go directly into OpenGL.

    This does indeed work too, I have played around with it and graphically intensive Swing applications really fly with OpenGL activated (given that your graphics card and drivers are sufficiently bug-free and modern). Read about it here

    And yes, it does work under Linux, and Windows and Solaris (and most likely will under OS X, though that is up to Apple to implement).

    Even without OpenGL acceleration the Swing responsiveness improvements are very impressive, coupled with the much better both default theme and theme mimicking in 1.5 I'd say it is time to retire the Swing troll.

  7. Eclipse 3.1 betas by trajano · · Score: 4, Informative

    The Eclipse 3.1 betas support 1.5 constructs. I normally use the integration builds.

    --
    Archie - CIO-for-hire :-)
  8. Re:How long will the MacOS X release take? by Cederic · · Score: 5, Informative

    >> what is the point in coding in Java if it won't work on the #2 desktop OS?

    Perhaps because it will work on the #1..n server OSes?

  9. Re:Bytecode Compatibility by angel'o'sphere · · Score: 4, Informative

    (i.e. you can't have "-target 1.4 -source 1.5") . Yes, you can have it!
    But what about your classpath, does it reference the 1.5 JRE? E.g. if the 1.5 java.lang.String gets loaded by an old JVM you might get that errro as well.
    angel'o'sphere

    --
    Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  10. Re:Bytecode Compatibility by julesh · · Score: 4, Informative

    I thought that the compiled Java would remain compatible with the bytecode format used by previous versions.

    The bytecode format is still identical. The version number on the file was incremented because classes that depend on assertions could break badly if used on a JVM that doesn't implement them (which is actually a feature of a few classes in java.lang, not a bytecode interpreter feature). Use the '-target' commands recommended by the other posters whenever producing code that doesn't rely on one of the new features.

  11. Re:Dear Sun by iso · · Score: 4, Informative

    Why don't you try this?

    1) go to java.com
    2) click the big "get it now" button
    3) download the EXE

    Now quit trolling.

  12. Re:Passe... by Jon+Pryor · · Score: 5, Informative

    My apologies for the horrible look of the code samples. Slashdot won't let me use nice, short lines, as it results in lines which are too short. Gah! Apparently I need ~40 characters per line (average) to get past the @#$% filter... This has to be the most annoying filter I've ever come across; I've spent more time getting past the filter than responding to your question!

    Iterators are similar to java.util.Iterator. C# iterators are compiler support for implementing the System.Collections.IEnumerator interface. For example, in Java you'd write:

    public class MyIterator implements Iterator {
    private String[] hw = {"hello", "world"};
    private int pos = 0;
    public boolean hasNext () {
    if (pos >= 0 && pos < hw.length) return true;
    return false;
    }
    public Object next () {return hw[pos++];}
    public void remove () {throw new UnsupportedOperationException ();}
    }

    public void UseIterator ()
    { Iterator e = new MyIterator ();
    while (e.hasNext())
    System.out.println (e.next().toString());}

    C# iterators make this much easier:

    public IEnumerable SayHello ()
    { yield return "hello";
    yield return "world";}

    public void UseIterator ()
    { foreach (string s in SayHello())
    Console.WriteLine (s);}

    C# iterators are particularly useful when implementing your own collection objects. Google for them; they're very powerful.

    Anonymous Methods are methods without a name, just like Java anonymous classes are classes without a name. Same basic idea, fewer braces. They also act as full closures; while Java requires that all stack variables referenced from an anonymous class be final, C# doesn't require this.

    int n = 42;
    EventHandler h = delegate {Console.WriteLine ("something happened:" + n);};
    h ();

    The above example is bad, but you can let your imagination run wild. This is very useful for event handlers.

    Partial Types

    allow you to split a single class definition across multiple files. This is useful to prevent > 50 KB source files (yech!), and makes it easier to have part of a class machine generated (by a GUI builder) and part hand-written. Some people hate it, others are ambivalent, but it can be handy:

    // File a1.cs
    partial class Foo {public int a;}

    // File a2.cs
    partial class Foo {public int b;}

    Nullable types are primarily useful for database support in the .NET type system. DB types can be "nullable" -- not present. For reference types, this is easy -- use null. For .NET value types, this isn't possible, as value types can't be null. The solution is to introduce a generic class System.Nullable<T>, which can wrap value types such as int.

    The C# compiler adds syntactic sugar to this, to simplify usage:

    int? nullable_int = GetMyNullableInt ();
    if (nullable_int.HasValue) /* use nullable_int */

    Nullable types are more special purpose, but are useful for those who need them.

    Ignore the rest of this: it's just garbage to get past Slashdot's wonderful "too few characters per line" problem: lk jfjdlkajdsfl;kja sdfl;kja fjklsafjd l;kj lasjd lkjds fl;kja sdflkajsd lkj afs lk jfjdlkajdsfl;kja sdfl;kja fjklsafjd l;kj lasjd lkjds fl;kja sdflkajsd lkj afs lk jfjdlkajdsfl;kja sdfl;kja the quick brown fox jumps over the lazy dog l;kajdsfl;kj;lkj l;kjasdilfj l;kjoiewqruq[op 0-9314u75 lkfjx ;lkajdsfmopiac un0p3u5n1-0329u kl 0a9u 3214o5ilj hello out there in tv land! q 09

  13. Re:STUPID MODS by ElGuapoGolf · · Score: 5, Informative

    Are you aware that the vast majority of games you play on any phone (except Verizon phones) are written in Java?

    Thought not.

  14. Re:Passe... by Baki · · Score: 4, Informative
    In Java5 you would write the C# iterator just about the same.

    For example

    for (Shape tShape : pList) {
    System.out.println("X is " + tShape.getX());
    }