|
Here's how it's done manually Adding Classes to the JAR File's Classpath and using an IDE just makes it easier.
|
# ? Nov 27, 2011 07:01 |
|
|
# ? May 10, 2024 22:47 |
|
Sorry if I'm being an idiot here, but this is the exact situation I find myself in: https://github.com/zeromq/jzmq/issues/29 So I don't think this problem is quite as simple as adding a jar. I have lots of other jars working without issue. This is the first time I've done anything with a native library. So I don't understand why I have to tell the JVM where to find the native library, but, whatever, I will figure out something one way or another.
|
# ? Nov 27, 2011 14:38 |
|
On a somewhat related topic, this ZMQ stuff is pretty cool. But the guy who wrote the intro document is a huge douchebag. It basically goes something like this: Brokerless messaging is where it's at. If your architecture uses a broker, it's slow and you suck balls. ... So here is our optimal architecture, it includes a broker right in the middle, and as you can see, it makes everything really way super awesome.
|
# ? Nov 29, 2011 15:23 |
|
Can anyone recommend an easy-to-use UML-generating plugin for Eclipse? I really hate making the myself (or at least I just really hate Visio), but they're so helpful at times.
Sab669 fucked around with this message at 00:56 on Dec 1, 2011 |
# ? Dec 1, 2011 00:40 |
|
I am trying to read from a file and place one like into an array. Which will eventually be enclosed in tags and written to an xml file. But for now I just need help breaking up this string properly code:
code:
Edit: I have to rethink this as some of the entrys are 7 parts and some are 8.. And sometimes the last portion of the entry is multiple lines of text long. DholmbladRU fucked around with this message at 22:49 on Dec 2, 2011 |
# ? Dec 2, 2011 20:37 |
|
code:
|
# ? Dec 2, 2011 22:20 |
|
I was altering a method that was origonally using a scanner, the while was checking for EOF. Im probably doing it wrong...
|
# ? Dec 2, 2011 22:45 |
|
DholmbladRU posted:I was altering a method that was origonally using a scanner, the while was checking for EOF. Im probably doing it wrong... Yup. readLine returns null at EOF - so you should be doing something like this instead: code:
|
# ? Dec 2, 2011 23:24 |
|
personally I prefer the: String line; while((line = scanner.nextLine) != null) { } syntax.
|
# ? Dec 2, 2011 23:34 |
|
Ranma posted:personally I prefer the:
|
# ? Dec 3, 2011 19:00 |
|
DholmbladRU posted:
Well, you can do this with regular expressions! I assume you have an idea of how to use them, since you're using one in your split, so I'll just leave this here: code:
Quick note on your split expression though, you're using the wrong '\' to escape your brackets. Also, you need to escape the escape character. So "\\[". If you end up using my regular expression you don't need to split anything, all of the groupings are set. You're going to be using a Pattern class for the regular expression, and a Matcher to match your input string with the Pattern. Then you call yourMatcher.group(#), and that gives you the string with your desired value to shove into the array. Ahh, I guess I ended up explaining how to use regex after all.. edit: Cleaned up the giant unnecessary quote. Sarcophallus fucked around with this message at 20:19 on Dec 5, 2011 |
# ? Dec 5, 2011 19:40 |
|
Now he has two problems.
|
# ? Dec 5, 2011 20:22 |
|
Jabor posted:Now he has two problems. Three if you count java.
|
# ? Dec 5, 2011 20:39 |
|
from http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Integer.html: toString() - Returns a String object representing this Integer's value. toString(int i) - Returns a String object representing the specified integer. The Integer class has a no arg toString method. But doing something like this code:
code:
What am I misunderstanding about the no-arg method?
|
# ? Dec 9, 2011 03:49 |
|
int is not the same as Integer.
|
# ? Dec 9, 2011 03:51 |
|
Technically, int is a primitive and Integer is a wrapper class, but autoboxing allows you to treat them basically the same way (aside from calling instance methods from them).
|
# ? Dec 9, 2011 04:09 |
|
String also has the valueOf() method which is overloaded to take any of the primitives and return a string representation.
|
# ? Dec 9, 2011 04:18 |
|
code:
|
# ? Dec 9, 2011 04:30 |
|
toString() is the standard method of getting a string representation from an object, so use that, even if they do the same thing internally.
|
# ? Dec 9, 2011 05:17 |
|
But the problem is that in the case of primitives you're still not getting the string representation of the object you're dereferencing, but of the parameter you're passing in. Probably just a case of use what's been used earlier in the project or use whichever you prefer if there's no precedent; certainly the JDK documentation doesn't comment on either or.
|
# ? Dec 9, 2011 07:22 |
|
The Integer implementation has an 2-argument overload Integer.toString(int i, int radix) which lets you generate non-base 10 strings (there's also toHexString, toOctalString, and toBinaryString). If you ever plan on using that functionality, it might be worth using the Integer.toString variant just so code doesn't look weird. Having said that although it's untidy that there's a couple of ways to do this, if you're agonising over which is the "right" one to do, you're probably focusing on the wrong thing.
|
# ? Dec 9, 2011 11:02 |
|
Use Integer variants when converting text to ints and vice versa: int value = Integer.parseInt(splitText[0]); String valueHex = Integer.toHexString(value); Use String variants when creating debug output: log("Important value is '" + (someCondition == false ? "" : String.valueOf(variable)) + "'"); It's not a big deal.
|
# ? Dec 9, 2011 12:52 |
|
String concatenation is so passé these days.code:
|
# ? Dec 9, 2011 13:47 |
|
I'm not sure I understand exactly what's going on with 'int' not being the same as 'Integer', but thanks for the discussion. Things to think about! Another question, this one purely debugging: code:
Any suggestions on how I'm misreading this?
|
# ? Dec 9, 2011 17:23 |
|
Newf posted:I'm getting an 'incompatible types' error on the last return statement, even though qSort seems to me to consistently return ArrayList<Integer> objects. addAll() doesn't return what you think it returns.
|
# ? Dec 9, 2011 17:37 |
|
I see! Thanks.
|
# ? Dec 9, 2011 18:08 |
|
MEAT TREAT posted:The fact that String has a valueOf method and Integer has a toString method is confusing. I can't decide which is better, but i'm leaning towards Integer.toString. If you look at the source, they basically do the same thing with IIRC Integer.toString bottoming out at Integer.valueOf. As mentioned above, the various overloaded forms of Integer.valueOf give you more flexibility with formatting. The utility of the toString method is more indirect via the polymorphic behavior of calls dispatched from Object.toString - so loggers and debuggers have a consistent way of dumping the string form of an arbitrary object. If you have explicit knowledge that a reference is an Integer type, I believe valueOf is the "proper" way, as a line of code that reads Integer.valueOf(foo) reads to a human as unambiguously typed, whereas foo.valueOf() requires the extra cognitive leap of looking up the type of foo to know that it is an explicit call to Integer.toString (as opposed to Object.toString or any other toString). In actuality it is just incredibly nit-picky to worry about.
|
# ? Dec 9, 2011 20:25 |
|
How's it going guys. I'm trying to write a Person class that provides a few methods, then write a test class that creates some person objects, and I'm having trouble with a certain method. I'm supposed to implement: public boolean isLike ( Person otherPerson) - compares the current object person to otherPerson. The method will return true if the first and last names of both objects are the same; otherwise it will return false. what I have for this is code:
After this I need to call the isLike method, but for whatever reason I cannot how should I go about doing this? iscis fucked around with this message at 05:50 on Dec 12, 2011 |
# ? Dec 12, 2011 01:24 |
|
iscis posted:How's it going guys. I'm trying to write a Person class that provides a few methods, then write a test class that creates some person objects, and I'm having trouble with a certain method. You have a number of issues going on. First is that isLike() is taking the place of equals() which may be necessary if you're not clear on class casting yet. Next is your indentation. Your code looks like sweaty monkey balls. It should look something like this: code:
code:
code:
|
# ? Dec 12, 2011 01:39 |
|
It's not an equals method. It's comparing only the first and last names, but a Person also has a middle name.
|
# ? Dec 12, 2011 01:52 |
|
baquerd posted:useful stuff code:
iscis fucked around with this message at 05:49 on Dec 12, 2011 |
# ? Dec 12, 2011 02:01 |
|
code:
|
# ? Dec 12, 2011 02:25 |
|
MEAT TREAT posted:
I implemented this code, however it will not throw the exception and simply outputs cylinder information: Radius: -2.1 Height: -8.6 Surface Area: 141.18 Volume: -119.15
|
# ? Dec 12, 2011 02:33 |
|
Does your constructor also check for valid values? Might want to call setHeight/Radius in the constructor so you get the validation there too rather than just setting the values directly.
|
# ? Dec 12, 2011 03:28 |
|
I've been spoiled by web frameworks for too long and now I need to write a gritty ServletFilter myself and I need a little help on how to do it. The purpose of the filter is to run last in the filter chain, take all the html that is meant to be returned as the response, and strip out all the content except for the elements that match a given id, and return the fragmented response. Parsing aside, how do I go about getting the html body from the response, and resend a modified version of it? How do I ensure that the response won't get partially flushed while I'm working on it?
|
# ? Dec 13, 2011 15:46 |
|
MEAT TREAT posted:
if (height > 0) this.height = height; else throw new IllegalArgumentException("Can't have a negative height."); } This may just simply do the same thing but this is how I've been writing my mutator methods. Edit: I'm an idiot for not reading before posting. On a better note it gives me reason to ask: why do we "throws IllegalArgumentException" in the method header? Kreczor fucked around with this message at 17:36 on Dec 13, 2011 |
# ? Dec 13, 2011 17:33 |
|
Because otherwise other people that use your code won't have any clue that the method will throw that exception until someone actually passes in a negative value.
|
# ? Dec 13, 2011 17:58 |
|
FateFree posted:I've been spoiled by web frameworks for too long and now I need to write a gritty ServletFilter myself and I need a little help on how to do it. Maybe something like this high-level design would work: - Create MyHttpServletResponse, which wraps the original Response and forwards or buffers the data that would have gone to it. - Create MyOutputStream which buffers the rendered HTML. This will be given out by MyHttpServletResponse. - Put MyFilter first in the filter chain so it can wrap all or some of the responses. - Do the parsing and processing and sending after the wrapping outputstream or response has been closed or committed. Caveat: this could break some badly coded filters or servlets if they cast ServletResponse to something other than HttpServletResponse.
|
# ? Dec 13, 2011 18:16 |
|
Thanks thats a great high level explanation, I'll get looking into that. Appreciate it
|
# ? Dec 13, 2011 21:00 |
|
|
# ? May 10, 2024 22:47 |
|
rhag posted:The most common answer I've seen on the forums from the devs is to use a Set. I can see their reasoning, and it's a sound one. However, using a Set poses a different set of problems (namely, one cannot just add children to the parent without an ID set. That is...before the children are saved). This doesn't have to be a limitation. My solution to the equals/hashcode problem with hibernate is two have two primary keys, an autoincremented pk, and a String UID which is just mapped as a unique field. However my hashcode/equals only bothers looking at the uid, which gets created on object creation through UUID.randomUID.toString. So this way you can put any object in a set before persisting it, and the equals will work after you persist it because hibernate will set the UUID it received from the table. Make sense?
|
# ? Dec 13, 2011 21:37 |