Yay, just got my hands on this baby w00t w00t 
Static imports yay, now I can use LWJGL OpenGL calls as C/C++, Pascal users do w00t x 2
glHappyKitten(HAPPY_KITTEN);
Yay, just got my hands on this baby w00t w00t 
Static imports yay, now I can use LWJGL OpenGL calls as C/C++, Pascal users do w00t x 2
glHappyKitten(HAPPY_KITTEN);
How f***** awesome is it to have your swimmer smoothly moving from one point to another creating realistic ripples, no more stuttering or freaking sudden jumps.
http://www.users.xith.org/JavaCoolDude/Pictures/swimmer.jpg
public void run(){
float frameInterval = 0;
long currentTime = 0,
frameTime = System.nanoTime(),
lastTime = System.nanoTime();
int fps = 0;
while (threadAlive){
currentTime = System.nanoTime();
fps++;
if(currentTime - lastTime >= 5e8){
if(!fullScreen)
parentFrame.setTitle("Water Simulation: FPS " + String.valueOf(fps<<1) );
lastTime = currentTime;
fps = 0;
}
frameInterval = ((float)(currentTime - frameTime))/5e8f;
frameTime = currentTime;
mouseEvents.checkRotationTranslationFlag();
rippleFactory.update(frameInterval);
processKeyboard();
view.renderOnce();
}
}
So anyone tried this yet?
I attempted making static imports and using the new ArrayList list = new ArrayList(); but it would give me a compiling error all the time…
Wtf?
You need to add -source 1.5 when you compile.
here is a simple example of some of the new fetures.
//static import
import static java.lang.Math.*;
public class Test {
public Test() {
}
public static void main(String… args) {
//auto boxing
Integer k = 1;
//generics
java.util.List l = new java.util.ArrayList();
java.util.Map<String,String> bob = System.getenv();
java.util.Set set = bob.keySet();
java.util.Iterator it = set.iterator();
System.out.println(pow(1.0,1.0));
test(“Hi”, “Testing”);
while(it.hasNext()) {
String s = it.next();
//c printf formatting
System.out.println(String.format("%1$s = %2$s", s,bob.get(s)));
}
}
//var arg
public static void test(String… s) {
for(int i =0; i < s.length; i++) {
System.out.println(s[i]);
}
}
}
That’s coz you forgot to add -source 1.5 on your javac command line I bet 
Cas 
True dat, now everything works ok 
yay for out.printf("%.2f\n", FPS);
Sorry for being such a pain, but what’s the benefit of static import?
Static import - only syntax sugar. Allows you to import static members of other class. It can be useful if you do a lot of math stuff, as you can omit Math. prefix everywhere, but it also should clean up ugly habit of implementing interfaces full of constants, just to have access to them.
In short, you can write sin(PI/2) instead of Math.sin(Math.PI/2)
Sweet. ;D
And the offline jre install of 13.5Mb? Still think it’s a problem. How much of that would really be used by someone if they are downloading a jre to play a game? Apparently there is a new smart installer/upgrader in 1.5 so why cant there be a very cut down jre install (2-3Mb - which is the overhead using gcj would give you) that is available for casual users? Surely not everyone needs all the features that the java api gives? Anything that was needed above this could then be downloaded later.
[quote]And the offline jre install of 13.5Mb? Still think it’s a problem. How much of that would really be used by someone if they are downloading a jre to play a game? Apparently there is a new smart installer/upgrader in 1.5 so why cant there be a very cut down jre install (2-3Mb - which is the overhead using gcj would give you) that is available for casual users? Surely not everyone needs all the features that the java api gives? Anything that was needed above this could then be downloaded later.
[/quote]
First of all, there’s also a 360k installer which will load only what is needed depending on whatever data (I don’t know). Whatever it does, it will install less and is faster than downloading the offline package. Just try it yourself.
Then, Karsten Lentzsch reported (both in javadesktop.org and the German Java usenet group) that he managed to pack his JDiskreport tool including the JRE 1.4.2 into 9,6MB using NSIS’s LZMA compression. For comparison:
zip (Jar + texte) 732 kB
exe ohne jre 778 kB
exe mit jre (zlib) 15.753 kB
exe mit jre (bzip2) 13.092 kB
exe mit jre (lzma) 9.660 kB
Quite interesting IMHO (now the question is, why’s the generic LZMA better than the specialized pack200 algorithm the Java installer uses?).
Last but not least (to add some oil to this old discussion), I looked at the statistics of Azureus (Azureus is an open source bittorrent client written in Java, bittorrent is a P2P protocol) at sourceforge. The tool is distributed without Java. They tell you to go and download the JRE. Still, they got more than 1,000,000 downloads so far and about 10,000 downloads a day.
For me, this means, people will download a JRE if they’re just interested enough. Of course, the typical P2P user probably has a fast connection but so what… 1 Mio downloads are quite impressive. (Sidenote: The original bittorrent client written in Python got more than 12,000,000 downloads).
Um, isn’t that just a facade though? The tiny download looks appealing, but really its just downloading the full JRE during the install process. Its still downloading the ful ~13Mb, so people of dial up and such are still screwed, but they end up looking at a different download screen.
AFAIK, no. Quoted from Sun’s page:[quote] This install first downloads and runs a small program that prompts the user for options to download and install. The user must be connected to the Internet in order to complete this installation. Includes support for additional languages, fonts and media.
[/quote]
If you don’t need all those asian/indian languages and can live without the lucida font, you can save a few MBs worth of download. Just try it.
It still brings down AWT, Swing, CORBA, Beans, XSLT, X500, etc. etc. etc. which I don’t need.
Back to LZMA - I got J2SE1.4.2_03 to 7Zip down to 8mb or something. But when I tried it on J2SE1.5beta, it’s 15mb! Aggh!
Cas 
Have you tried jpack (jsr200) or whatever it is called ? Specially optimized format for big archives, which you can later compress with whatever you want.
[quote]Back to LZMA - I got J2SE1.4.2_03 to 7Zip down to 8mb or something. But when I tried it on J2SE1.5beta, it’s 15mb! Aggh!
[/quote]
7Zip and NSIS use the same compression algorithm so both results should be similar.
For 1.5, I wanted to mention that you can remove classes.jsa from …/bin/client, but even without that file I get a 15 MB file. The obvious difference is that the rt.jar of 1.5 is about 12 MB larger than the one of 1.4.2 and he complete lib folder is some 16 MB larger. Is this all the new unicode support? There can be so many new classes. Perhaps the rt.jar still contains debug information? Or it is because I didn’t install a separate JRE but chose the combined jdk+jre install…?
Maybe it’s metadeta using the new facility in 1.5?
Now, why doesn’t this work (anyone seen mention of this as a “will be fixed for gold”?)
javac -source 1.5 -target 1.4
???
There are lots of features of 1.5 that we are assured include no changes to the class files, but do include changes to the compiler. Apparently, we’re not allowed to use them in that way - the compiler spits out:
javac: source release 1.5 requires target release 1.5
…in which case, what’s the point of making generics etc NOT use new byte codes, classfile formats, etc? Basically, we’re not allowed to take advantage of the compiler upgrade unless we also mandate the new JVM for all users. That sucks…
That used to work in earlier betas I heard. I can only assume that some sort of compatibility problem was discovered.
There has been lots of discussion of this in the generics forum. The new for loop and enum stuff require extensions to the existing libraries — in the case of the for loop, many classes now implement the Iterable interface. Autoboxing also requires some extra support.
So while generics largely doesn’t require a new JVM other details also added in 1.5 require updated libraries. The primary compatibility goal was not to allow generic code to run on an old JVM but rather to ensure that old code would still run on the new JVM even when the old code was passed objects that were instances of a generic class.
The message from Neil Gafter in this thread gives more details:
http://forum.java.sun.com/thread.jsp?forum=316&thread=321534