|
Outlaw Programmer posted:According to this site, the JVM will take care of any endian problems for you. I guess you only run into endian problems if your output is being read by a non-Java process (or your file is being generated by a non-Java process). You could also run into problems if you were using the FloatBuffer to encapsulate data read from a binary-packed network stream, which would probably be in Network Byte Order (big endian).
|
# ? Aug 5, 2008 14:21 |
|
|
# ? May 8, 2024 06:49 |
|
schzim posted:JavaSeverFaces and JavaServerPage Goons to the rescue please k thnx. I believe what you're after is the pageContext.setAttribute method, to be used like so: code:
|
# ? Aug 5, 2008 17:42 |
|
I'm stupid aren't I? I'm new to Java, infact, programming all together. Started a part time course and we've got Java and Databases as my classes. Databases is pretty simple but I just can't get to grips with Java. In this exercise we're supposed to get input on various things, first name, last name, age, height, gender and if they can drive yet. code:
edit: I'm also JCreator to compile the code, but since I installed it at home today, when I run the program or file, I don't get the black box which I got at uni wehn using it. I get the build output so I can view any errors, but when at Uni the black box would pop-up and display the errors as well, if the program worked it'd be where you input stuff to make the program run etc. But for some reason it's not working at home. drunkill fucked around with this message at 07:58 on Aug 6, 2008 |
# ? Aug 6, 2008 07:54 |
|
drunkill posted:I'm stupid aren't I? Don't worry, it'll all come together and start making sense pretty quickly. drunkill posted:edit: I'm also JCreator to compile the code, but since I installed it at home today, when I run the program or file, I don't get the black box which I got at uni wehn using it. I get the build output so I can view any errors, but when at Uni the black box would pop-up and display the errors as well, if the program worked it'd be where you input stuff to make the program run etc. But for some reason it's not working at home. I'm not familiar with JCreator, but are you able to compile and run your code from the command line? eg: javac Exercise1.java java Exercise1
|
# ? Aug 6, 2008 11:00 |
|
Well another problem with your code is that you trying to save their name as an int when you should be saving them as Strings. The only things that are ints are their age and height. You should also tell them to specify their height in inches, that way you don't have to parse feet and inches. You are also missing the types for the fields first, last, hieght, gender, and your drivers license field is repeating. edit: About JCreator, don't worry about the black box, your output will be in a small white box at the bottom of the screen. The reason you can't type in it is because of all the compiler errors I mentioned above. Janitor Prime fucked around with this message at 13:04 on Aug 6, 2008 |
# ? Aug 6, 2008 12:59 |
|
Hey, I can use some help here. I have a program where I have an array of objects and I want to output them to a .csv file. Right now the object just holds variables for name and grade, both of them are strings (Although I should parse an int from the grade but I can do that later). So essentially I want to output to a fie the name and the grade separated by a comma. I can't figure out what kind of stream I need to use or how I would set it up. I would basically want this: code:
Can anyone help me out please?
|
# ? Aug 9, 2008 00:19 |
|
Startacus posted:Hey, I can use some help here. I have a program where I have an array of objects and I want to output them to a .csv file. Right now the object just holds variables for name and grade, both of them are strings (Although I should parse an int from the grade but I can do that later). code:
JingleBells fucked around with this message at 01:25 on Aug 9, 2008 |
# ? Aug 9, 2008 00:34 |
|
JingleBells posted:This should do it: That works great except for some reason it doesn't add a comma every other time. So I will have a name and grade separated by a comma on one line, like it's supposed to. Then on the next line I will just have a name and the line after that, just a grade. It does that back and forth, weird.
|
# ? Aug 9, 2008 01:18 |
|
Startacus posted:That works great except for some reason it doesn't add a comma every other time. So I will have a name and grade separated by a comma on one line, like it's supposed to. Then on the next line I will just have a name and the line after that, just a grade. It does that back and forth, weird. It might be worth adding .trim() to your calls to getName() and getGrade() then, it sounds like your values may have carriage returns/new lines in it? code:
|
# ? Aug 9, 2008 01:24 |
|
JingleBells posted:It might be worth adding .trim() to your calls to getName() and getGrade() then, it sounds like your values may have carriage returns/new lines in it? When I add the trim method to the functions I get a null pointer exception at that line. My returns don't have new lines, all that's in the two get function is "return variableName".
|
# ? Aug 9, 2008 06:21 |
|
drunkill posted:
This code shouldn't compile. You're missing data types in front of your variables, and you also have a problem with missing + signs in that last System.out.println() row. You need to put it between things that should be glued together (concatenated would be the correct term) to form a new string. The thing about data types as someone mentioned, think of them in database terms since you're comfortable with databases. You wouldn't declare that a column should include integer numbers if you're going to store names in there in a database. Same thing with Java -- figure out the correct type, then store data in there. Good luck, you'll do this stuff easily within a matter of days!
|
# ? Aug 9, 2008 07:07 |
|
Startacus posted:When I add the trim method to the functions I get a null pointer exception at that line. My returns don't have new lines, all that's in the two get function is "return variableName".
|
# ? Aug 9, 2008 12:20 |
|
Fehler posted:Then you probably have some objects in there where the name and/or the grade is not set (null). Also, the variables themselves might have newlines in them, depending on where you get their values from. The information is being imported from another .csv file. The information is just "name,grade" And yes, I do have a lot of objects set to null, I will have to go through where I assign all of the information to figure out what I did.
|
# ? Aug 9, 2008 17:51 |
|
it seems that now I need a little help on the reading front, this is what is causing the problems with the write. This is what I have thus far:code:
So rather then having assignValues[0] be a name and assignValues[1] be a grade, assignValues[0] is both a name and a grade separated by a newline. Can someone help me fix this little problem?
|
# ? Aug 11, 2008 06:36 |
|
Startacus posted:Can someone help me fix this little problem? You could either firstly split the values into individual lines then split based on the coma into a new array, or use regular expression in the split method like split("[,\\n]") (I haven't tested that this works but it should be alright). Also it seems odd that you have 2 different pieces of information in the same array, you'd probably be better making a small class with name and grade fields and have an array of those to store the information. Depends what you're doing it for I guess . Twitchy fucked around with this message at 14:51 on Aug 11, 2008 |
# ? Aug 11, 2008 14:46 |
|
Twitchy posted:You could either firstly split the values into individual lines then split based on the coma into a new array, or use regular expression in the split method like split("[,\\n]") (I haven't tested that this works but it should be alright). Wow, thanks a lot, that regular expression worked like a charm. Yea, those values can stay as Strings. What I'm basically doing is writing a program for my old highschool that will take their schools roster and automatically assign all the students auditorium seats and locker numbers. I've only taken one Java class second semester last year and I wanted to refresh my memory before I leave for college because I'm going to be skipping the intro classes though. I appreciate the help though, we didn't really cover file I/O too indepthly in the class so I'm a bit shaky on that material.
|
# ? Aug 11, 2008 22:16 |
|
What's the easiest way to register a Windows file association from a Java program? For example, if I want my program to open all files with a .crap extension automatically, how do I register that with Windows? Also, how do I get the current Windows idle time, e.g. how long the user has not given any input to the computer? I realize that I might be better served with C++/C# for these problems, but... perihare fucked around with this message at 00:32 on Aug 12, 2008 |
# ? Aug 12, 2008 00:10 |
|
I have a very weird problem. I made a web-start application that utilizes Java OpenGL bindings. It runs fine on Windows, but on linux and solaris it starts fine but freezes at one point. And there is no way for me to close the window, it is basically non-responsive at all. What could be causing this? Usually this happens when I switch shaders in my program, or when I start generating iso surface. I don't believe I use any native resources by that point since I read the shaders in at the start and the program doesn't freeze right after I read in the volume data itself. What could potentially be causing this? If it would help, here is the application itself - http://giga2.cs.ohiou.edu/~neiman/jstart/jung/volume.jnlp Try to load a file in (please do not load anything higher than 15mb), and try to switch shaders. The Java console freezes as well by this point so there is no way for me to know if any exceptions are thrown or anything.
|
# ? Aug 13, 2008 00:57 |
|
Ok, I compiled my project in netbeans in ubuntu and ran it that way, and it was fine. This problem only appears to be with web start version of my application.
|
# ? Aug 14, 2008 03:12 |
|
Does it make a difference whether you request full permissions for your app in the JNLP file?
|
# ? Aug 14, 2008 10:11 |
|
Fehler posted:Does it make a difference whether you request full permissions for your app in the JNLP file? Yes. My app needs to be able to write and read files to work. So it needs full permissions. You might be on to something. I think this might be just web start's version of JOGL binaries for linux that are messing this up tho.
|
# ? Aug 14, 2008 14:13 |
|
a_passerby posted:What's the easiest way to register a Windows file association from a Java program? For example, if I want my program to open all files with a .crap extension automatically, how do I register that with Windows?
|
# ? Aug 14, 2008 15:52 |
|
Studying for the SCJP and have some syntax question. 1. Right now the following program prints "OHGOD" (as expected). How do I change it so it prints out "0 1 2 3" using the "x" variables defined in the nested classes? code:
Chuu fucked around with this message at 15:07 on Aug 15, 2008 |
# ? Aug 15, 2008 14:50 |
|
That's loving retarded, why would you ever want that. Since your fields aren't private and they are all in the same package, I think you should be able to access each one's X by placing the class name dot x. TestClass.x NestedTest.x NestedNestedTest.x and x
|
# ? Aug 15, 2008 15:25 |
|
I think you actually want TestClass.this.x and NestedTest.this.x ... etc.
|
# ? Aug 15, 2008 18:36 |
|
Recommendations for a Java memory profiler? I don't want to attach it to any IDE as I need to run it all remotely. We're using Java 1.5.
|
# ? Aug 15, 2008 20:15 |
|
MEAT TREAT posted:That's loving retarded, why would you ever want that. I agree that it's retarded, but a large part of the exam are things that you would never do in real life, but are there to see if you understand the language spec. That example was pretty simple, I could make it more complex to stop you from "cheating," but what I really want to know is how to fully qualify names of shadowed data members. The only way I know how to do it is with "this" but that isn't enough with multiple-nested classes. edit : Actually, if you don't think Anonymous classes are retarded, this sort of thing could happen really easily with Anonymous classes, in that you need a reference to an object that's not the top level or bottom level class. Chuu fucked around with this message at 21:01 on Aug 15, 2008 |
# ? Aug 15, 2008 20:45 |
|
Maybe the super keyword can help you. I don't know if it actually works for anything other than methods.
|
# ? Aug 15, 2008 21:50 |
|
This will print out what you want (inside the printStuff() method):code:
code:
Personally, 99% of the time my inner classes are declared static.
|
# ? Aug 16, 2008 01:12 |
|
GT_Onizuka posted:Recommendations for a Java memory profiler? I don't want to attach it to any IDE as I need to run it all remotely. We're using Java 1.5.
|
# ? Aug 16, 2008 10:03 |
|
Outlaw Programmer posted:This will print out what you want (inside the printStuff() method)...: Thanks a ton. That's the first use of Anonymous classes I've ever seen that actually seemed useful and not incredibly contrived.
|
# ? Aug 16, 2008 11:07 |
|
Another syntax question! This time regarding class locks. We have this code: code:
Implementation 1: code:
Implementation 2: code:
Implementation 3: code:
Chuu fucked around with this message at 12:48 on Aug 16, 2008 |
# ? Aug 16, 2008 12:34 |
|
Chuu posted:According to the book I'm using to study, this should be equivalent to Implementation #1. Read naively, to me this means "Wait for the class lock before executing "counter()" then "Wait for the class lock before executing the return statement" i.e. it should automatically deadlock. Since it's functionally equivalent though, I assumed the "synchronized" keyword meant "somewhere in this method something is synchronized, not necessarily the entire method, unless you do not see a synchronized block, then the entire method is synchronized" i.e. it won't deadlock. Does what's expected, prints "hi". The problem is . . . Chuu posted:So what exactly is the difference in #2 and #3, or is there something going on here that my trivial example isn't showing? All three programs are equivalent but a synchronized block on the class within a synchronized method as in 2 will never do anything. As an extreme example, here's another equivalent program: code:
zootm fucked around with this message at 15:00 on Aug 16, 2008 |
# ? Aug 16, 2008 14:55 |
|
Ahh, ok, thanks a lot. I assumed they work the same was as mutexes on *nix. To make sure, so if you have code like: static synchronized void a(){...} static synchronized void b(){...} Any code which has control of the lock and executing a() will block any other threads from running b(), since the class level lock is associated with all static synchronized code in the entire class? Chuu fucked around with this message at 17:20 on Aug 16, 2008 |
# ? Aug 16, 2008 17:13 |
|
Chuu posted:Ahh, ok, thanks a lot. I assumed they work the same was as mutexes on *nix. zootm fucked around with this message at 17:46 on Aug 16, 2008 |
# ? Aug 16, 2008 17:37 |
|
Thread necromancy! I'm looking for a good, lightweight Java database. It should run in <64M and use a well-known language. I was looking at SQLITE, but it seems that the database connector isn't very feature-complete yet. Anyone have other recommendations? Thanks.
|
# ? Aug 20, 2008 23:49 |
|
Apache Derby claims to be fairly lightweight but I don't have much experience with it.
|
# ? Aug 20, 2008 23:57 |
|
Java 6 comes with derby now if that means anything.
|
# ? Aug 21, 2008 00:29 |
|
1337JiveTurkey posted:Apache Derby claims to be fairly lightweight but I don't have much experience with it. Sounds cool, but I see it takes SQL commands as raw text. Is there a sanitize function available? I can't find one by searching the site or Google. Thanks!
|
# ? Aug 21, 2008 00:45 |
|
|
# ? May 8, 2024 06:49 |
|
Can you clarify what you're looking for? You should be able to communicate with Derby/JavaDB via the JDBC interfaces, just like any other database. I think standard operating procedure for avoiding SQL injection is to just use PreparedStatements. I don't see any reason why JavaDB would be any different than any other vendor.
|
# ? Aug 21, 2008 04:16 |