|
The list of new features is here. The stuff from Coin that made it in seems pretty nice, and I'm interested in playing with Gervill, a new audio synthesizer. The Coin features include:
* Binary integral literals and underscores in numeric literals * Multi-catch and more precise rethrow * Improved type inference for generic instance creation (diamond) * try-with-resources statement * Simplified varargs method invocation
|
# ? Jul 28, 2011 17:21 |
|
|
# ? May 26, 2024 08:27 |
|
I can't wait to see some real benchmarks with invokedynamic in Scala, Groovy, etc.
|
# ? Jul 28, 2011 17:32 |
|
Internet Janitor posted:I'm probably going to regret posting this, but the more I think about packing stuff into longs the more I think it might not be that bad: There's also ByteBuffer, which is really nice for packing various data formats into an array of bytes.
|
# ? Jul 28, 2011 17:32 |
|
Aleksei Vasiliev posted:Java 7 was just released. Give me closures or give me death. Don't care about Java 7 since they pushed that back. The Javadocs don't look like rear end that came out of the mid-1990s web though, that's nice.
|
# ? Jul 28, 2011 17:44 |
|
Geekner posted:There's also ByteBuffer, which is really nice for packing various data formats into an array of bytes. ByteBuffers are really spiffy, but remember that the original problem involved avoiding the creation/destruction of objects. Longs are primitive and passed on the stack, but an array would need to be heap allocated. ...Unless you're suggesting you have a couple big arrays and essentially write your own malloc() for it, using ByteBuffers as a way to conveniently unpack different types from the arrays.
|
# ? Jul 28, 2011 17:52 |
|
TRex EaterofCars posted:I can't wait to see some real benchmarks with invokedynamic in Scala, Groovy, etc. I'm betting that the effects of invokedynamic are going to be pretty exciting.
|
# ? Jul 28, 2011 19:01 |
|
Java 7 fixed some bugscode:
|
# ? Jul 29, 2011 04:03 |
|
Brain Candy posted:Java 7 fixed some bugs The also introduced some bugs, if your code has loops in it.
|
# ? Jul 29, 2011 07:14 |
|
Jabor posted:The also introduced some bugs, if your code has loops in it.
|
# ? Jul 29, 2011 12:02 |
|
Brain Candy posted:Java 7 fixed some bugs Haha, I got the impression from reading the note for this change that it was easier to change the compiler than rewrite part of the specification.
|
# ? Jul 29, 2011 12:30 |
|
Jabor posted:The also introduced some bugs, if your code has loops in it. What bug is that?
|
# ? Jul 29, 2011 14:12 |
|
MEAT TREAT posted:What bug is that?
|
# ? Jul 29, 2011 14:27 |
|
TRex EaterofCars posted:I can't wait to see some real benchmarks with invokedynamic in Scala, Groovy, etc. I don't know if Scala will be able to take advantage of it, since it's not a dynamically typed language, but Groovy, Rhino, and JRuby will probably get a significant bump, as Hotspot will get a much better shot at JITting.
|
# ? Jul 31, 2011 03:51 |
|
Exxon Hess posted:I don't know if Scala will be able to take advantage of it, since it's not a dynamically typed language, but Groovy, Rhino, and JRuby will probably get a significant bump, as Hotspot will get a much better shot at JITting.
|
# ? Aug 1, 2011 13:05 |
|
Scala's probably going to get more use out of the MethodHandles as a way to handle eta expansion without generating new anonymous classes. That's also the direction that Java 8 looks to be going with lambda definitions with some way to make a single MethodHandle with a given MethodType impersonate an interface or abstract class with a single abstract method of the same MethodType. Also, the escape analysis being enabled by default in Java 7 (and I think Java 1.6u23 and up as well) will probably have a bigger impact on Scala programs. Being able to stack allocate millions of tiny objects with short lifespans turns them from cheap into effectively free. This has caused some (highly contrived) microbenchmarks to run several times faster in tests but the average Scala program's still going to benefit somewhat since it does allocate a lot of the aforementioned tiny objects with short lifespans.
|
# ? Aug 1, 2011 13:51 |
|
I just started my attempt at learning to program. I am having a problem with one of my exercises in my book though. I am trying to have a console application that asks for an input of either U or L. Depending on what is entered, it should display the alphabet in either upper or lower. This is what I have under my getChoice method but its not working.code:
Can someone help me out? I suck at this.
|
# ? Aug 2, 2011 21:50 |
|
quote:The compiler says it is undefined for that type of scanner. http://download.oracle.com/javase/6/docs/api/java/util/Scanner.html If you still want to use a Scanner to do this, use scan.next() and then get the first char from that String code:
http://download.oracle.com/javase/6/docs/api/java/io/InputStreamReader.html e: or you could just work with Strings instead of characters Tamba fucked around with this message at 22:22 on Aug 2, 2011 |
# ? Aug 2, 2011 22:19 |
|
I'm actually happy to here about NIO.2. I just implemented a project that relies on concurrent and nio heavily. Now if I just had closures I would be in heaven.
|
# ? Aug 3, 2011 06:01 |
|
I have a loving retarded question. I have a double, lets aay the value is 160.0, and I need it to be formatted as 160.00 (yeah, the cardinal sin of using doubles for currency, don't blame me, it wasn't my idea). I have tried Math.round, DecimalFormat etc and I'm pretty well out of ideas. There has to be a way of forcing it to 2dp and staying that way whilst also keeping it as a double but I can't for the life of me think what and it's now starting to really gently caress me of. Ideas?
|
# ? Aug 3, 2011 11:03 |
|
Blacknose posted:I have a loving retarded question. I have a double, lets aay the value is 160.0, and I need it to be formatted as 160.00 (yeah, the cardinal sin of using doubles for currency, don't blame me, it wasn't my idea). code:
|
# ? Aug 3, 2011 12:27 |
|
Already tried that and it returns a string, I need to end up with a double, same as when I started. I'm not actually 100% convinced it's possible.
|
# ? Aug 3, 2011 13:21 |
|
Blacknose posted:Already tried that and it returns a string, I need to end up with a double, same as when I started. I'm not actually 100% convinced it's possible. A double is just a number. "160.0" and "160.00" are both strings, that represent a number. There is no such thing as a double that has a particular formatting. It's just a double. A collection of bits that represent a number. You decide when you print it out how you actually want to display it. You are asking a question that has no answer - not because what you want to do is impossible, but because it's meaningless. What are you actually trying to achieve?
|
# ? Aug 3, 2011 13:48 |
|
Blacknose posted:Already tried that and it returns a string, I need to end up with a double, same as when I started. I'm not actually 100% convinced it's possible. As a double, there is no distinction between 160.0 and 160.00. Until the number is put into a String there isn't a way to "format" it. code:
code:
baquerd fucked around with this message at 13:55 on Aug 3, 2011 |
# ? Aug 3, 2011 13:51 |
|
Yeah I was really scraping the bottom of the barrel by asking. It has to remain as a double, which obviously is a binary representation of a value, whih is then passed to an external api (jxl I believe) which then sticks it in an excel file. I didn't know if there was a way to attach formatting data to a double without using a string. The client is almost certainly going to want a numeric value with formatting which as far as I can tell just isn't possible. It's one of those situations where you're basically boned but I thought someone might know some miraculous way of doing it that defies the laws of coding.
|
# ? Aug 3, 2011 14:00 |
|
If it gets stuck into an excel spreadsheet, you can set the formatting for those cells to have two decimal places displayed programmatically through Excel, but it's a giant pain in the rear end to get Office Interop working with Java in the first place, let alone actually doing useful things with it.
|
# ? Aug 3, 2011 14:04 |
|
If it's going into Excel, why isn't a string suitable? As far as I'm aware Excel treats a cell containing the string "160.00" pretty much the same as one containing the number 160 when it comes to calculations?
|
# ? Aug 3, 2011 14:11 |
|
Blacknose posted:I didn't know if there was a way to attach formatting data to a double without using a string. The client is almost certainly going to want a numeric value with formatting which as far as I can tell just isn't possible. I don't think you're getting it. To "attach formatting data to a double" is senseless. You can round the value, or floor/ceil it, but numbers don't have "formats". Strings do, though, so when you print your double, you can say "print two decimal places" so it looks like what you want. If you want some way of keeping this information "with" the double, you could make a little class... code:
|
# ? Aug 3, 2011 14:13 |
|
epswing posted:If you want some way of keeping this information "with" the double, you could make a little class... He's then got to code support for this into JXL though, that would be "fun".
|
# ? Aug 3, 2011 14:19 |
|
Jabor posted:If it's going into Excel, why isn't a string suitable? The client wants a numeric field in the spreadsheet for the software that will then read the excel file. Not my choice unfortunately. epswing posted:I don't think you're getting it. To "attach formatting data to a double" is senseless. You can round the value, or floor/ceil it, but numbers don't have "formats". Trust me I get it; I know they don't. That's why I said attach formatting to it as opposed ot 'format it'. I could probably have worded it better however. I'm not about to start pulling JXL apart, the client is just going to have to live with either a text field in excel or no dp, their choice.
|
# ? Aug 3, 2011 14:29 |
|
Doesn't JXL have the concept of a cell format? I mean, that's basically the "right way" to solve this problem.
|
# ? Aug 3, 2011 14:33 |
|
I thought the JXL formatters only dealt with fonts, borders etc but turns out that hidden away is the ability to format numeric cells. To get 2 decimal places on a numeric value use:code:
|
# ? Aug 4, 2011 10:25 |
|
How do I install a new package for java? I'm trying to create a plugin for OSS (open search server) and it won't compile because it's missing a package. I set my java classpath in my bash_profile file and moved what I think is the package there (these files, but compiled to .class : http://opensearchserve.svn.sourceforge.net/viewvc/opensearchserve/trunk/src/java/com/jaeksoft/searchlib/index/). I still get an error when I attempt to compile. The missing package is com.jaeksoft.searchlib.index, so in my classpath I have com/jaeksoft/searchlib/index/<.class files>. I also have basically no idea what I'm doing in both linux and java so please tell me that's wrong and how to set this up correctly.
|
# ? Aug 5, 2011 00:54 |
|
If the class files are located at <BASE_LOCATION>/com/jaeksoft/searchlib/index you want to have <BASE_LOCATION> on the classpath, not the whole thing.
|
# ? Aug 5, 2011 05:49 |
|
Contra Duck posted:If the class files are located at <BASE_LOCATION>/com/jaeksoft/searchlib/index you want to have <BASE_LOCATION> on the classpath, not the whole thing. I had that set correctly, it looks like I just had to restart for it to actually update. I don't know why I didn't try that earlier but at least it works now.
|
# ? Aug 5, 2011 19:34 |
|
I have a Spring/JMS/ActiveMQ/Tomcat question: Our group has multiple projects/wars to deploy to a tomcat install. We want a single ActiveMQ install with a couple of queues set up in it. Submissions to the queues will come from the various projects. Deploying the ActiveMQ web console appears to automatically start the broker up, but it shouldn't necessarily be required to run ActiveMQ. In fact, the ActiveMQ Manning book doesn't even really mention the web console. Anyways, I'm trying to figure out how the queue setup should work. Should I develop a separate project/war which manages the broker startup and other configuration issues and then have each Spring project submit to the brokerURL independently?
|
# ? Aug 10, 2011 19:02 |
|
Problem: I'm in the beginning phase of creating my first game using Java with JLWGL and Slick. My problem is sort of generic in programming nature. I am building an entity/component system and I would like to have a list of entity templates with associated components, so that I can have just one method for creating entities with the parameter being the ID of the entity template. Pseudo code example: code:
The question: How do I make these different entity templates efficiently, and without giving the user the ability to edit them? Please note: I am a beginner programmer, but catching on fast - some solutions might be too advanced for me. Edit: Do I use enums? I have no experience with those so I don't know! Abrahamsen fucked around with this message at 21:21 on Aug 14, 2011 |
# ? Aug 14, 2011 20:19 |
|
The simple if-else-if -chain (or string-switch with Java 7) gives plenty of flexibility:code:
Enums have a quite rigid structure in comparison and if what you want to do doesn't fit it exactly they can turn into a huge mess.
|
# ? Aug 15, 2011 01:15 |
|
Is it possible to have a java program listen for global keypresses? For example have the program running while browsing the web or something and have the program do something when a certain key is pressed. The whole time the java program not having focus. Is this possible in java?
|
# ? Aug 15, 2011 21:08 |
|
Clank posted:Is it possible to have a java program listen for global keypresses? For example have the program running while browsing the web or something and have the program do something when a certain key is pressed. The whole time the java program not having focus. Is this possible in java? You would have to also implement an OS level virtual machine in the same program and so basically the answer is no for all practical purposes. Edit: or the native interface apparently. At any rate, Java's not a great choice for a keylogger.
|
# ? Aug 15, 2011 21:25 |
|
|
# ? May 26, 2024 08:27 |
|
Not with just Java. But here's a library that should do what you want: https://github.com/tulskiy/jkeymaster
|
# ? Aug 15, 2011 21:28 |