|
Anunnaki posted:My CS teacher's been telling me it's a "hybrid." vv That's somewhat correct, although it's a lazy way of explaining it. The bytecode is interpreted to machine code on the fly at first, until the hotspot just-in-time compiler identifies code that it should spend time compiling to native machine code. It looks for "hot spots" (hence the name) and it sends those units off for further optimization. At that point it's native code and therefore no longer interpreted.
|
# ? Sep 19, 2009 14:52 |
|
|
# ? May 11, 2024 06:57 |
|
TRex EaterofCars posted:That's somewhat correct, although it's a lazy way of explaining it. The same is true for many interpreted languages which use a jit interpreter. It is also why benchmarks can be nearly meaningless when comparing Java to statically compiled languages without having a sufficiently long runtime. Anyway, the biggest difference between the two virtual machines (32 and 64) is the maximum amount of addressable RAM. 32bit has an upper limit of something around ~1200MB (found by testing). I'm not sure of the limit on the 64bit version at the moment, as 4 gigs was good enough. HFX fucked around with this message at 15:23 on Sep 21, 2009 |
# ? Sep 21, 2009 15:20 |
|
HFX posted:The same is true for many interpreted languages which use a jit interpreter. It is also why benchmarks can be nearly meaningless when comparing Java to statically compiled languages without having a sufficiently long runtime. A 32 bit program (any 32 bit program) cannot access more than 4GB of ram (architecture limitations). In real-life 2GB is the max that normal Windows allows (2GB for the kernel, 2GB for apps). That is... the normal Windows. With PAE it can access more. You have found 1200MB to be the limit because of the other things the JVM needs RAM for (loading the classes for example, that Perm space). In a 64 bit program, the limitation is much much higher: 2^64 = huge number. On MSDN (http://msdn.microsoft.com/en-us/library/aa366778%28VS.85%29.aspx) MS says that the limit is 8TB. So...that should be enough or everybody, shouldn't it? Anyhow, the only case you would have to care about that, if your Java program is using JNI. Then you would have to make libraries available for whatever OS/Architecture you intend to support: A 64 bit dll for 64 bit windows with a 64 bit JVM A 32 bit dll for 64/32 bit windows with a 32 bit JVM A 64 bit .so for 64 bit Linux with a 64 bit JVM ... and so on and so forth for every Unix and JVM under the sun. But the Java program would not change. the JNI call will always be the same, just the actual native code may be different.
|
# ? Sep 21, 2009 16:11 |
|
Due to the limitations of hardware (and software), at present there is no (consumer-available) system that can address the full 64 bit range of memory on our current 4KB page standard x86 addressing model. What we do have, however, are systems that can do 40, 48, and etc. bits of physical memory and so we can have enough memory addressable for the foreseeable future while hardware can catch up to the needs of such software. In some sense, we already had 40-bit memory systems a long time ago due to how addresses work in modern "32-bit" x86 systems, but the 8 bits weren't usable for anything that JVM designers would want to expand. The reason you would care about a 64-bit JVM is if your Java application needs more than 3GB or so total of memory and you cannot distribute the data across multiple nodes in a distributed execution model. Also, due to fragmentation issues, you may require a 64-bit JVM even if you're not that close to 3GB of memory required.
|
# ? Sep 21, 2009 16:57 |
I'm having an issue using the POI HSSF library to write to an Excel file. There are 10,000+ rows that I am trying to output, each row is identified with a username. It appears one of the usernames is not playing nice with the HSSF stuff, and I get a "This spreadsheet has unreadable content..." message. I've been trying to narrow down which username is causing problems and I'm not getting anywhere. What is strange is I found that replacing every character:code:
code:
Any suggestions?
|
|
# ? Sep 22, 2009 00:34 |
|
rhag posted:A 32 bit program (any 32 bit program) cannot access more than 4GB of ram (architecture limitations). In real-life 2GB is the max that normal Windows allows (2GB for the kernel, 2GB for apps). That is... the normal Windows. With PAE it can access more. You have found 1200MB to be the limit because of the other things the JVM needs RAM for (loading the classes for example, that Perm space). Unless your customer keeps collecting more data per interval of processing units. I did have to have a session with my customer explaining how garbage collectors work and how you can only expect to have 1/2 the total ram on a given os available. Just for the record that was on RHEL4 32bit. Overall, I hated that code base. Java 1.5 was out for several months before this project began. Lead developer insisted upon 1.4. Program while having a huge number of threads was only single processor in effect as the threads deadlocked on each other except for I/O and the database side I wrote. The center core of the program had an algorithm that at best was 600n^3. It featured very many premature optimizations which would bite me later in the rear end when he left and I took over. Of course what do you do? It's only been in the last several months I've gotten my coworkers to start using at least Java 1.5 features.
|
# ? Sep 22, 2009 01:27 |
|
HFX posted:Unless your customer keeps collecting more data per interval of processing units. I did have to have a session with my customer explaining how garbage collectors work and how you can only expect to have 1/2 the total ram on a given os available. do you guys use any testing framework, or any QA at all?
|
# ? Sep 22, 2009 05:56 |
|
RussianManiac posted:do you guys use any testing framework, or any QA at all? Define testing and QA. Hell define specs. We sort of do QA at the top most user level at best. Now you know why I picked up a smoking habit while working there. The clients I deal with refuse to have anyone else from the company work on their code or their in field systems. There is a reason all have offered me a job if I want to change companies at some point. The sad part is much of my industry follows the same practices. You wonder why a certain consumer device in your home feels and works like utter poo poo. The bad thing is, I only consider myself a better then average programmer who just happened to have a couple good professors in college who opened his mind to good design, good languages, and an understanding of the basics. Technically, I am the only person with a computer science degree and almost had a masters so I suppose that is part of it. There is one manager who came in last year who shares my philosophy but so far his clients do not want to pay the cost of a US programmer. HFX fucked around with this message at 06:16 on Sep 22, 2009 |
# ? Sep 22, 2009 06:06 |
|
fletcher posted:Any suggestions? Maybe it doesn't like a username that has a number in a wrong place. Generally, to narrow it down you'll want to do a binary search on your rows, i.e add rows 1-5000 or rows 5001-10000, then depending on which one is invalid split that range in two until you have the offending row.
|
# ? Sep 22, 2009 08:43 |
|
Anunnaki posted:My CS teacher's been telling me it's a "hybrid." vv The distinction between "compiled languages" and "interpreted languages" is almost completely arbitrary fyi There are Java interpreters (and they're still used in embedded systems), there are Java JIT compilers and there's at least one Java compiler (gcj) although I'm not sure how well it works For some languages, one option of executing just makes more sense than others, for example interpreting C++ directly would be really slow and hard
|
# ? Sep 22, 2009 10:26 |
|
gcj can only be said to 'work' in the loosest sense of the word
|
# ? Sep 22, 2009 11:46 |
|
necrobobsledder posted:The reason you would care about a 64-bit JVM is if your Java application needs more than 3GB or so total of memory and you cannot distribute the data across multiple nodes in a distributed execution model. Also, due to fragmentation issues, you may require a 64-bit JVM even if you're not that close to 3GB of memory required. Does the Sun 32-bit hotspot JVM actually support 3GB of memory? I've never been able to get it to allocate more than ~1.5GB. Any more and it just refuses to start.
|
# ? Sep 22, 2009 15:20 |
|
Tulenian posted:Does the Sun 32-bit hotspot JVM actually support 3GB of memory? I've never been able to get it to allocate more than ~1.5GB. Any more and it just refuses to start.
|
# ? Sep 22, 2009 16:14 |
|
How does one convert types in Java? I'm new to Java, but I know my way around C pretty well. I'm trying to convert a variable of type AnyType to String, and another variable of type AnyType to float. How do I go about doing this?
|
# ? Sep 22, 2009 22:13 |
|
ACID POLICE posted:How does one convert types in Java? I'm new to Java, but I know my way around C pretty well. I'm trying to convert a variable of type AnyType to String, and another variable of type AnyType to float. How do I go about doing this? You cast it same as you normally would. Do know that it can throw exceptions if you don't check first. code:
|
# ? Sep 22, 2009 22:49 |
|
ACID POLICE posted:How does one convert types in Java? I'm new to Java, but I know my way around C pretty well. I'm trying to convert a variable of type AnyType to String, and another variable of type AnyType to float. How do I go about doing this? You can always cast to a more general types. That is to say, you can always cast to a super type of your current type. Casting to a more specific types (supertype to subtype) will result in a runtime error if the object is not that specific type. Specifically, in your case, you cannot cast AnyType to String unless Anytype inherits from string through extension since String in a class and not an interface. The fact you say you are trying to convert AnyType to a float also means that it cannot have inherited from string since float is a primative and the class Float is not a subclass of String. Shavnir posted:Edit : Do note that since float is a primitive you won't be able to cast objects as it, however you can cast them to Float. What Shavnir is talking about here is the autoboxing feature of the Java compiler. The reason this works is that the compiler will autobox a float into a Float. What is really going on behind the scenes is that the compiler is doing new Float(float) for you. It will autounbox for you also by calling the Float.floatvalue() function for you. Since you are coming from C and not C++ this behavior with casting may seem strange to you. However, it is because Java is a strongly typed language while C is weakly typed language. The language is trying to protect you, and honestly outside of a few very specific applications it is a good thing. HFX fucked around with this message at 00:43 on Sep 23, 2009 |
# ? Sep 23, 2009 00:39 |
|
Shavnir posted:You cast it same as you normally would. Do know that it can throw exceptions if you don't check first.
I doubt that ACID POLICE is dealing with something that's already a String; the general solution to his problem is to call the .toString() method on your object (casting is not conversion). If AnyType does not override toString(), then you'll get the default method defined in Object -- you get the class of the object and its hash code. If you can't implement toString() yourself, you should probably do something like code:
As for converting to a Float, you can call Float.parseFloat(String string) or 'new Float(value)'. It's hard to say which is better without any details about the type you're converting from.
|
# ? Sep 23, 2009 02:00 |
|
I'm trying to write a method that sets a third of my pictures pixels to a certain color, but just can't figure it out. here is my code so far:code:
|
# ? Sep 23, 2009 02:08 |
|
Vandorin posted:I'm trying to write a method that sets a third of my pictures pixels to a certain color, but just can't figure it out. here is my code so far: I am not sure what class you are using that in, but your loop is wrong. code:
|
# ? Sep 23, 2009 02:19 |
|
RussianManiac posted:I am not sure what class you are using that in, but your loop is wrong. Ah thanks. Now I've just got to figure out how to add in color for the other 2 thirds. Would I just mess with the for loop, making i > s and i == s?
|
# ? Sep 23, 2009 12:25 |
|
Vandorin posted:Ah thanks. Now I've just got to figure out how to add in color for the other 2 thirds. Would I just mess with the for loop, making i > s and i == s? Depends what do you want out of the image. One way would be to go from 0 to s, inside the for do int m=i%3;. Now, m can have 3 possible values: 0,1,2. If m=0 color it one way, if it equals 1 another way and if it equals 2 another way. Another alternative would be to go from 0 to s, but check the values that i has: if(i<s/3) do this, if(i>=s/3 && i<2*s/3) do that, if(i>2*s/3) do another thing. Or 3 for loops. The possibilities are endless .
|
# ? Sep 23, 2009 12:36 |
|
rhag posted:Depends what do you want out of the image. I tried the alternative code you mentioned (because I understand it better) but for some reason only the first third is getting filled. Here's what I've typed so far: code:
|
# ? Sep 23, 2009 13:54 |
|
0 is not >= len / 3, so that loop never runs (well, unless len == 0... too lazy to think about the other conjunct)
|
# ? Sep 23, 2009 14:05 |
|
OddObserver posted:0 is not >= len / 3, so that loop never runs (well, unless len == 0... too lazy to think about the other conjunct) edit: Just tried switching i to a number like 250, and it still doesn't run.
|
# ? Sep 23, 2009 14:07 |
|
Vandorin posted:edit: Just tried switching i to a number like 250, and it still doesn't run. What rhag was suggesting was logic inside your old for loop. Right now you're setting up a for loop that frankly makes no sense. Set up the for loop to iterate through all the pixels as before and try putting rhag's if block inside the loop, if that makes sense. EDIT : vvv Ah now I see what you were going for. I figured if he didn't even know how to throw together a for loop it wasn't worth trying to do a more complex for. Shavnir fucked around with this message at 14:29 on Sep 23, 2009 |
# ? Sep 23, 2009 14:23 |
|
Vandorin posted:I tried the alternative code you mentioned (because I understand it better) but for some reason only the first third is getting filled. Here's what I've typed so far: Try this: code:
So, for let's say: len=6. i starts at 2; runs until it gets to 2*6/3=4; That means, pixels 2 and 3 (in the zero based array) will get their blue color set to 2. To get the last third (4 and 5 pixels) you do this: code:
Lets say len =6; i starts at 0; The for loop as you wrote it runs until (0 >= 6/ 3 && 0 < 2 * 6/ 3)==false as you can see 0>=2 is false ,thus the entire expression is false . I assume you are a student and this is some school project. I hope that you're not a developer that somebody pays to write code. right?
|
# ? Sep 23, 2009 14:28 |
|
rhag posted:Try this: Wow, thanks for the detailed explanation . And I'm a student, taking my first java course.
|
# ? Sep 23, 2009 14:37 |
|
I have what's probably a retardedly simply question about moving objects using the acm.graphics import. All I want is an object to follow the mouse within the borders of the program (actually it only needs to move in the x-direction). So, I can click on an object and drag it using: code:
Since just following the mouse doesn't require association with a specific object, the mousePressed method is unnecessary, leaving me with: code:
Thanks in advance.
|
# ? Sep 24, 2009 04:35 |
|
Knowing the line that throws the NPE would help, but you aren't checking against null in your second example, so I'd guess that's the culprit. E: The line numbers are printed in the exception stacktrace. Max Facetime fucked around with this message at 08:26 on Sep 24, 2009 |
# ? Sep 24, 2009 08:23 |
|
Eclipse Console posted:Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException That's exactly what the eclipse console shows. If the numbers on the right are the line number, then the culprit is: code:
code:
I'm sure we can figure this out, there has got to be an easy solution.
|
# ? Sep 24, 2009 19:42 |
|
UnNethertrash posted:That's exactly what the eclipse console shows. If the numbers on the right are the line number, then the culprit is: Two things are dereferenced and so could be null here, paddle and e. It is extremely unlikely that the event dispatch thread will send you a null mouse event, and also you dereferenced it on the line before the exception is thrown, so I'd say you haven't created/set up your paddle yet. Add a if(paddle == null) return; first or something. Also it looks like you've swapped the two lines in that method. I'm pretty sure you want to keep lastX for the next frame, and so you should set it after you've moved the paddle. As it is now you're doing paddle.move(e.getX() - e.getX(), 0) which won't move it at all I guess.
|
# ? Sep 24, 2009 19:59 |
|
Ok, I changed it to this:code:
Here is my draw_paddle(); code:
I'll play around with it, and see what happens.
|
# ? Sep 24, 2009 21:31 |
|
Holy gently caress! It worked. For reference the new version is: code:
|
# ? Sep 24, 2009 21:37 |
|
^^^^ Oh OK then. Gah, nevermind this, I am dumb and also fat and I cannot read. UnNethertrash posted:Ok, I changed it to this: Since you're setting lastX before you're reading it, and e.getX() doesn't change between those two lines, what you're doing boils down to code:
code:
czg fucked around with this message at 21:46 on Sep 24, 2009 |
# ? Sep 24, 2009 21:42 |
|
Quick question. I'm new to Java and am having a bit of trouble with strings. I want to initialize an array of strings with values defined by int variables. The part I'm really having trouble with is that strings are constant. Basically, what I'm working on is a sort of basic appointment-book type application. The appointmentbook class accepts two variables for a start time and an end time in military format (800, 1500, etc.). I'm trying to find a way to create a String array holding each time at one-hour intervals between the start and end time. I can't just say like code:
EDIT: For now I'm just gonna say gently caress it and initialize an array with all 24 hours and just work from that because I'm not even sure if this is possible. I'm gonna leave my question up, though, because I'm curious. Alvie fucked around with this message at 02:43 on Sep 25, 2009 |
# ? Sep 25, 2009 02:17 |
|
Why do they need to be strings?
|
# ? Sep 25, 2009 02:41 |
|
Mr.Radar posted:Why do they need to be strings?
|
# ? Sep 25, 2009 02:45 |
|
Of course:code:
|
# ? Sep 25, 2009 02:57 |
|
Mr.Radar posted:Of course: Thanks, that's awesome. I think my biggest problem is that the rest of my code is all over the place so it's pretty tough to find out what specifically is wrong. When I read that strings are constants I assumed you couldn't change them after they're declared, but I guess when you use strings[i]="whatever", you're actually allocating a new string and assigning the pointer of the original one to the new one?
|
# ? Sep 25, 2009 03:06 |
|
|
# ? May 11, 2024 06:57 |
|
Strings are immutable (which means you can't change the value of a String instance), but references to strings (remember in Java that all object variables are really references to object instances or null) are definitely mutable.
|
# ? Sep 25, 2009 04:44 |