|
Can one use IntelliJ or Netbeans if they're developing Java RCP applications that target the Eclipse framework itself, or does that lock one into having to use Eclipse? I'm doing this at work, but I can't friggin' stand Eclipse. It's slower than an rear end in a hat.
|
# ¿ Feb 24, 2008 16:56 |
|
|
# ¿ Apr 27, 2024 11:17 |
|
Java 1.5: I'm trying to figure out how to load a text file contained inside my program's JAR (into a FileReader if that matters). java.util.ResourceBundle was the first place I looked, but it seems to want to split the file into key/value pairs and that's not what I'm going for. The JAR layout: code:
|
# ¿ Mar 1, 2008 00:49 |
|
Ranma4703 posted:I just started a co-op (my first job programming), and one thing I see in a lot of the code is the following: It's strange, yes, and you're right to recognize it as odd. That said, they may very well have a good reason in whatever context it exists (though it had better be good for something like that). This happens a lot when you hit the Real World, it's not often black-and-white this-is-good-and-this-is-bad. Ask another developer why it is like it is, but don't sound like a stuck-up academic prick about it
|
# ¿ Mar 18, 2008 22:57 |
|
Twitchy posted:I think you've got it a little confused Actually he's got it exactly right. The reference to the object is passed by value; you can modify the object, but not the reference to it.
|
# ¿ Apr 18, 2008 22:02 |
|
This, this right here, is why schools that don't teach C/C++/[pointers] any more are causing Problems
|
# ¿ Apr 18, 2008 22:26 |
|
CrusaderSean posted:I'm reading up on design patterns and I saw this interface declaration: It doesn't for classes, but an interface can extend (and a class can implement) multiple base interfaces.
|
# ¿ May 2, 2008 19:55 |
|
shodanjr_gr posted:Ive got a library that allows for the execution of Win32 Native Call via Java. However, i cant for the love of my life find a LIST of all the possible API calls. What i want to do, is open a file, or open the directory a file is in. (mind you that as far as native WINDOWS program goes, ive done very very little, so i dont know my way around it). You're batshit insane if you want to do filesystem stuff via the Win32 API rather than Java (which, on Windows, just wraps the Win32 calls), but MSDN is your friend.
|
# ¿ May 24, 2008 17:10 |
|
Opening files in programs and opening Explorer to certain directories has absolutely nothing to do with the Win32 API. It's all about command line arguments to those particular programs. There's no comprehensive list, just google for the programs you want and how to open files with them via command line.
|
# ¿ May 24, 2008 17:35 |
|
shodanjr_gr posted:If i go to the command prompt and do a "foo.jpg", the image will open in the default program that ive selected to handle that kind of file. I dont have to use the filename as an argument while running the program...(which seems pretty reasonable, since it would make any sort of search application impossible to develop - which is what i am making). That only works because Windows Explorer has a file extension association to open things that end with .jpg by running "mspaint %filename%" Also, what the hell do you mean it would make a search application "impossible to develop" - how would you not have the filename as a search result? Maybe you need to be very clear about what you're doing.
|
# ¿ May 24, 2008 17:41 |
|
mister_gosh posted:I'm not sure I understand the question, but why not just use a Java IDE like Netbeans (or Eclipse)? If you spell a variable wrong, it'll let you know. He wants the code for a spell checker, not a spell checker for his code
|
# ¿ Jun 10, 2008 18:26 |
|
Entheogen posted:Perhaps there is an option in Eclipse to also add a new method to class and tell it that it is from some interface, and that should also copy/paste comments. When you tell Eclipse to implement an interface, @see Javadoc tags are inserted that reference the interface, but it doesn't put in the comments verbatim. Alt+Shift+J on the method does the same thing. Also why are you using @Override on an interface method?
|
# ¿ Jun 26, 2008 18:05 |
|
Implement a method StepTwo, make it a no-op in the base class, then override it in the childrencode:
|
# ¿ Jul 14, 2008 17:02 |
|
Triple Tech posted:Also, I forgot to add, this block of code should never be called by itself or be exposed to the public. It only exists as part of the process. That's why I figured a plain old virtual method wouldn't be as classy as something more formal. What sort of metric is "classy," and how are virtual methods informal? A virtual (abstract) method is exactly what you want here, and like 10011 said it'd just be protected if you didn't want callers to access it*. * barring Java's retarded implementation of protected, there, I said it
|
# ¿ Jul 14, 2008 18:22 |
|
mister_gosh posted:What don't I understand here? It's wrong because xyz is static (it "belongs" to the class, not an instance of the class), so it doesn't exist in this. Technically you can reference it with this, but it's not semantically correct so Netbeans 6 promoted it to a warning. A static analysis tool like Findbugs would've flagged it. You can properly reference it with abc.xyz. edit: And also you might be questioning your design when you have instance methods getting and setting a static member variable.
|
# ¿ Aug 4, 2008 16:11 |
|
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 |
|
Boz0r posted:Ok, but when I've used wrap and gotten a ByteBuffer with the bytes in it, how do I get it out in the different types, as I still can't use the getLong(), getShort()... methods? What do you mean, you can't use the getLong, getShort, etc. methods? Any object returned by wrap or allocate will have those methods defined, even if what it's returning is an instance of the abstract base class. You're not supposed to need to know the precise implementation, HeapByteBuffer or whatever.
|
# ¿ Sep 21, 2008 18:36 |
|
Boz0r posted:You, sir, are win. Really? quote:Is it possible to assign the same value to two different destinations at the same time, like: Try it and see if a compiler error results. Should work just fine
|
# ¿ Sep 22, 2008 19:39 |
|
Boz0r posted:Well, he knows more Java than me, so by that definition, most people in this thread are win. What I meant was, didn't calling something "win" used to be probatable?
|
# ¿ Sep 22, 2008 20:49 |
|
Boz0r posted:When I read the bytes, I don't get them in hex, I get the {00, 60, ff, ff} like {0, 96, -1, -1}. I'd like to work with them in hex, but I haven't really found a way to do that. Um, this by itself is meaningless; -1 == 0xFF == 1111 1111 to the computer, numbers are numbers are numbers and the base doesn't matter. If you mean display them in the debugger as hexadecimal, that's one thing. If you mean put them into strings so that the characters represent the number in hexadecimal, that's another. What do you want to do? Boz0r posted:Also, how do I define a parameter to be an array of any primitive type instead of just one? In Java, I don't think you can. The closest you can get is an array of object and let the primitive types get autoboxed.
|
# ¿ Sep 23, 2008 20:39 |
|
The Light Eternal posted:But it creates repeats. I learned from #cobol that I need to add the numbers to a list and then shuffle the list. How do I do that? I must not've been in #cobol at the time Shuffling isn't the answer here. You're creating a new Random on each iteration of the while loop. By default, the Random object is seeded by the system time, which in a fast loop will be the same on each iteration of the loop. Two Random objects initialized with the same seed are guaranteed to produce the same pseudorandom sequence. That's why you're getting repeats. Always seed random objects outside of a loop unless you know why you're doing it any other way. code:
|
# ¿ Nov 4, 2008 19:44 |
|
BELL END posted:While that's true, it won't necessarily stop the same number coming up more than once. True, though it's a hell of a lot less likely. Anyway, I suspect his "repeats" problem looks something like this: 4 4 4 4 4 4 4 4 4 4 4 4 7 7 7 7 7 7 7 7 7 7 7 7 3 3 3 3 3 3 3 3 3 3 3 3 Besides, how is shuffling an answer to "preventing repeats" in the first place? It might space them further apart from each other, but they'd still be repeated in the sequence. Seriously shuffling is just not a solution to anything that has to do with repeats, unless your requirement is that two identical numbers can't be next to each other - and even then it's not a guarantee.
|
# ¿ Nov 4, 2008 19:55 |
|
BELL END posted:In my example (assuming it works) you're creating an array of [1, 2, 3, 4, 5...] and then shuffling it so you know the numbers are different. The fact remains that shuffling is never ever ever going to eliminate repeats or reliably spread them around if your sequence has repeats in it in the first place. I don't have a javac in front of me, but here's The Light Eternal's code in C#: code:
code:
code:
code:
code:
|
# ¿ Nov 4, 2008 20:24 |
|
BELL END posted:I completely agree with what you are saying, I'm just saying that as far as I understand the problem, he needs to permute a list of distinct integers (or objects) to seed a tournament. You can't have the same team playing twice at the same stage, or leave teams out. Like I say I might be completely misunderstanding him. If that's the problem to be solved then that makes perfect sense. I think I might have skipped over the "tournament" part and focused on the "random" - if he truly wants randomly placed distinct integers, the shuffle you posted is definitely the way to go and the Random should've been taken out of consideration entirely. #cobol really dropped the ball here <> quote:#cobol (who uses IRC in this day and age?!) I do, when my cable modem can go five minutes without pissing itself
|
# ¿ Nov 4, 2008 20:46 |
|
The Light Eternal posted:Shuffling should solve the problem. Here's what my output looks like now: Do exactly what BELL END posted, starting at 1. e: unless you're trying to describe some hidden pattern, I can't tell if that '6 7 8' at the end was intentional. What precisely is it that you want? BELL END's method will get you a sequence of numbers from 1 to num, inclusive, that are shuffled randomly.
|
# ¿ Nov 4, 2008 21:01 |
|
The Light Eternal posted:What do I put for the second List? I'm getting an error there that says something about List being a parameterized type. What second list? There's only one in the code you posted. Is it a compiler error or an exception? Copy and paste it here. e: Oh code:
|
# ¿ Nov 4, 2008 21:13 |
|
The Light Eternal posted:ArrayList cannot be resolved to a type. Make sure you're importing java.util, and also using Java 5 or higher. ArrayList javadoc.
|
# ¿ Nov 4, 2008 21:15 |
|
zokie posted:And I can't for the love of all that is unholy understand why you would want to use the get and set methods while still in the class. What if your set method did this: code:
|
# ¿ Dec 4, 2008 20:16 |
|
import statements have to go at the top of the file. I don't know how it got into the middle, but that's very wrong; the compiler even says exactly that (illegal start of expression). e: What probably happened is the author intended each class to be their own files. e2: Or maybe not because you defined GameHelper to be an inner class. Was that the author's code or your own? e3: Hell, your braces don't line up to anything that lets me figure out what you or the author were going for here. Post complete code if there's a problem with it. csammis fucked around with this message at 22:29 on Jan 6, 2009 |
# ¿ Jan 6, 2009 22:27 |
|
Moon Whaler posted:Yeah but telling me my program finishes 3ms before it starts seems a little off Is it possible that the data type you're using to store the nanoTime result (or the subtraction result) is overflowing and wrapping?
|
# ¿ Mar 5, 2009 17:08 |
|
Huckle posted:Have any ideas for the randomization feature? I can't just randomize it all - I need the computer to make random legal moves. I'm lost here. code:
|
# ¿ Mar 26, 2009 13:17 |
|
ayb posted:I tried and it gave me a whole host of errors. This means there's either something wrong with your code or with the command line you're using to run it. Post both.
|
# ¿ Mar 31, 2009 18:06 |
|
capr1ce posted:What I need to do is store it in a database, and then it needs to be searched against and displayed, and maybe edited in an html form. Is there anything I can do to convert this string back to the 硼 character in the Java code, or is it perfectly fine to put the HTML String into the database and search on that? Think about this: if all 硼 characters appear to your application as 硼, then when your user searches for "硼," your application will see "硼." Why would you need to convert it into something human-readable when it's the machine doing the searching?
|
# ¿ Apr 6, 2009 13:28 |
|
Warblade posted:This question is kind of language agnostic, but I'm dealing with Java so maybe there's some kind of Java convention for doing this. Say you write a class that accepts some kind of listener. At some point you'll be iterating through all of your listeners to notify them that something significant happened. Maybe the method call is listener.sendEvent(). I can't speak for Java, but in the .NET asynchronous model the responsibility for defensive programming rests with the receiver, as it can make no guarantees about the behavior of the sender. The sender should most likely not use a worker thread to raise events, because then the receiver has to contend with events happening out-of-expected-order (or the sender has to ensure that one event has been fully dispatched before raising another).
|
# ¿ Apr 9, 2009 00:43 |
|
Warblade posted:I like putting a try/catch in the finally for closing streams. Except the exception handler doesn't do anything aside from maybe printing out some kind of warning. There's really no way to recover from that. You're closing the stream anyway. Just move on. Which of course begs the question of why streams were engineered to throw exceptions on close in the first place, since you're right and there's basically nothing to be done at that point. This is something I've never figured out for myself but maybe there's a good reason v v
|
# ¿ Apr 15, 2009 22:22 |
|
I think rjmccall and HatfulOfHollow might know all that, and I think it might have been covered repeatedly in this thread rhag posted:Please please, go back to CS101 and brush up on these very simple concepts. Come back after that and we'll talk. Didn't call him a gay babby, still not up to AD's standards HatfulOfHollow posted:I loving love this argument. What round is this? 43 pages mod 5ish, probably round 8.
|
# ¿ Jul 15, 2009 22:21 |
|
Gonna throw out that a CS101 class that uses Java is absolutely worthless
|
# ¿ Jul 16, 2009 13:11 |
|
You write JUnit tests to ensure that calling the print method doesn't alter the set And the first Google hit on "java const correctness" quote:There is no way to declare that you will not modify the object pointed to by a reference through that reference in Java. Thus there are also no const methods. Const-correctness cannot be enforced in Java, although by use of interfaces and defining a read-only interface to your class and passing this around, you have a means to ensure that you can pass your objects around the system in a way they cannot be modified.
|
# ¿ Sep 1, 2009 16:36 |
|
zootm posted:I suppose so. I guess if you're writing platform-specific code, though, the devs are just gonna have to have that platform. Interesting that there isn't an obvious way to do this generically, I guess domains maybe don't generalise all that well. There are definitely cross-platform LDAP connectors, but I don't know of any in Java (the one my company uses is C). A little bit of native library + JNI could solve the problem.
|
# ¿ Jan 29, 2010 14:19 |
|
Actually I just realized I read his problem incorrectly...LDAP can tell you if a user exists in a domain (as long as it is based on Active Directory, I think) but I don't believe it can tell you if the user is logged in. Oh well
|
# ¿ Jan 29, 2010 14:55 |
|
|
# ¿ Apr 27, 2024 11:17 |
|
fart factory posted:Is there a way to remove all text from a Java Swing TextArea component? It seems like there should be, but on looking through the documentation I can't find a method to do so. setText(""); ?
|
# ¿ Jul 26, 2010 15:57 |