http://stackoverflow.com/a/70618634
type: Answer
has body: In terms of List functionality differences, the other responses already answered this question. In terms of applicable rules of Java generics, it's a complicated topic. I wrote an in-depth article about Java generics rules, this is the link: https://medium.com/@royalilin/java-generics-rules-1d05de86e9cb
score: 0
answers question: http://stackoverflow.com/q/490091

http://stackoverflow.com/comment/85381402
score: 4
type: AnswerComment
comment on: http://stackoverflow.com/a/49188073
type: Comment
has text: and why would that be an issue?

http://stackoverflow.com/a/381934
has comment: http://stackoverflow.com/comment/209664
accepted answer of: http://stackoverflow.com/q/381546
type: Answer
upvote count: 21
answers question: http://stackoverflow.com/q/381546
score: 21
has body: I don't know how to get eclipse's detail formatter to automagically display byte arrays as Strings, but you can display a particular byte array by adding new String(byteArray) as a watch expression.
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/1608558

ascii
tags question: http://stackoverflow.com/q/464874
tags question: http://stackoverflow.com/q/368603
type: Tag
tag name: ascii
tags question: http://stackoverflow.com/q/585452

http://stackoverflow.com/q/363325
has answer: http://stackoverflow.com/a/363435
score: 1
favorite count: 0
tagged with: parsing
tagged with: http://stackoverflow.com/tag/xml
has answer: http://stackoverflow.com/a/363727
type: Question
has answer: http://stackoverflow.com/a/363636
tagged with: sax
tagged with: java
answer count: 3
upvote count: 1
tagged with: dom
has body: I would like to parse a document using SAX, and create a subdocument from some of the elements, while processing others purely with SAX. So, given this document: &lt;DOC&gt; &lt;small&gt; &lt;element /&gt; &lt;/small&gt; &lt;entries&gt; &lt;!-- thousands here --&gt; &lt;/entries&gt; &lt;/DOC&gt; I would like to parse the DOC and DOC/entries elements using the SAX ContentHandler, but when I hit &lt;small&gt; I want to create a new document containing just the &lt;small&gt; and its children. Is there an easy way to do this, or do I have to build the DOM myself, by hand?
accepted answer: http://stackoverflow.com/a/363636
has title: Nesting SAX ContentHandlers
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/363435
downvote count: 0

http://stackoverflow.com/comment/376871
has text: Since your dataSet it coming from the xml file it is not a surprise that you can see that the data is there. Again, check if the table is there in the test database - dbunit will not create it for you - it only tries to load it with the data.
comment on: http://stackoverflow.com/q/563531
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/386627
has answer: http://stackoverflow.com/a/386701
has answer: http://stackoverflow.com/a/386735
upvote count: 1
possible better answer: http://stackoverflow.com/a/386699
tagged with: silverlight
accepted answer: http://stackoverflow.com/a/386646
has answer: http://stackoverflow.com/a/386891
favorite count: 0
has answer: http://stackoverflow.com/a/386638
answer count: 9
has body: Can we use Java in Silverlight?
has answer: http://stackoverflow.com/a/394971
has answer: http://stackoverflow.com/a/386646
has answer: http://stackoverflow.com/a/387240
has title: Java in Silverlight?
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/387590
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/386699
type: Question

http://stackoverflow.com/a/439505
has comment: http://stackoverflow.com/comment/139974971
has body: Use single quotes for literal chars, double quotes for string literals, like so: char c = 'a'; String s = "hello"; They cannot be used any other way around (like in Python, for example).
upvote count: 188
type: Answer
has comment: http://stackoverflow.com/comment/118121620
has comment: http://stackoverflow.com/comment/118121922
has comment: http://stackoverflow.com/comment/118133239
downvote count: 1
accepted answer of: http://stackoverflow.com/q/439485
answers question: http://stackoverflow.com/q/439485
has comment: http://stackoverflow.com/comment/118120630
score: 187
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/78645054
has comment: http://stackoverflow.com/comment/261798

http://stackoverflow.com/comment/59738328
comment on: http://stackoverflow.com/a/20906602
type: AnswerComment
has text: @BasilBourque Sure, but the information available in the question is that of a `LocalDate`.
score: 0
type: Comment

http://stackoverflow.com/a/641968
has body: One simple solution would be to convert each object in the model to HTML and append the strings to create an HTML document that can be set on the JEditorPane.
answers question: http://stackoverflow.com/q/640957
upvote count: 2
has comment: http://stackoverflow.com/comment/455971
type: Answer
has comment: http://stackoverflow.com/comment/455824
score: 2
downvote count: 0

http://stackoverflow.com/a/452393
has body: Hibernate, because it's basically the defacto standard in Java and was one of the driving forces in the creation of the JPA. It's got excellent support in Spring, and almost every Java framework supports it. Finally, GORM is a really cool wrapper around it doing dynamic finders and so on using Groovy. It's even been ported to .NET (NHibernate) so you can use it there too.
downvote count: 4
type: Answer
has comment: http://stackoverflow.com/comment/273173
score: 61
upvote count: 65
answers question: http://stackoverflow.com/q/452385

http://stackoverflow.com/comment/233024
score: 0
comment on: http://stackoverflow.com/a/408035
type: Comment
type: AnswerComment
has text: I would assume that it's meant to update the signature iteratively for the given input, and at the end you call some "finish()" method... do you have a link to a page that describes the Signature class? I couldn't find it other than some vague description.

http://stackoverflow.com/comment/49878467
score: 0
has text: As an addition to the answers below: If you do not want to have the method with new transaction in your local interface, you can annotate your bean implementation with both `@Local(Foo.class)` and `@LocalBean` and have the method as public method in the implementation class only.
comment on: http://stackoverflow.com/q/633687
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/211211
type: Comment
has text: actually the method proposed by the OP can produce guaranteed unique codes for up to MAXINT strings.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/383582

http://stackoverflow.com/comment/402379
has text: email me at scott@javadude.com to chat about this
comment on: http://stackoverflow.com/a/586913
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/110937660
comment on: http://stackoverflow.com/a/40073597
type: AnswerComment
score: 0
type: Comment
has text: @NathanRussell great article! I've simplified it a bit and rewrote it in Kotlin https://gist.github.com/felipecsl/de84eae52172a4fdccef403f6810366c

http://stackoverflow.com/comment/48381469
has text: Consider [this](http://en.wikipedia.org/wiki/Break_key) and its general impact on "To take a thread dump on Windows, CTRL+BREAK". It's actually dependent on the engineering decision of the manufacturer. FE, Lenova, IIRC, is cntrl+fn+p.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/18880485
type: Comment

http://stackoverflow.com/a/561357
type: Answer
upvote count: 4
answers question: http://stackoverflow.com/q/561245
has comment: http://stackoverflow.com/comment/372546
downvote count: 0
has comment: http://stackoverflow.com/comment/372573
has comment: http://stackoverflow.com/comment/372482
has comment: http://stackoverflow.com/comment/372533
has comment: http://stackoverflow.com/comment/372500
score: 4
has body: Just a thought, but you may check the influence of a ulimit -v option. That is not an actual solution since it would limit address space available for all process, but that would allow you to check the behavior of your application with a limited virtual memory.
has comment: http://stackoverflow.com/comment/372494

http://stackoverflow.com/comment/232370
score: 2
has text: @Jon - I have no idea what the OP is actually doing with the intermediate value. Just thought it was an option worth considering.
type: Comment
comment on: http://stackoverflow.com/a/407298
type: AnswerComment

instantiation
tags question: http://stackoverflow.com/q/452969
type: Tag
tags question: http://stackoverflow.com/q/564938
tags question: http://stackoverflow.com/q/405826
tag name: instantiation
tags question: http://stackoverflow.com/q/529085

http://stackoverflow.com/a/600568
type: Answer
score: 1
has body: If you're using the asp.net calendar control, use the DayRender event to check each day against the date limit you wish to impose. protected void Calendar_DayRender(object sender, DayRenderEventArgs e) { //Get date in past relative to current date. DateTime dateInPast = DateTime.Now.Subtract(TimeSpan.FromDays(10)); if (e.Day.Date &lt; dateInPast || e.Day.Date &gt; DateTime.Now) { e.Day.IsSelectable = false; } }
answers question: http://stackoverflow.com/q/596684
accepted answer of: http://stackoverflow.com/q/596684
upvote count: 1
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/420519

http://stackoverflow.com/comment/193771
type: Comment
comment on: http://stackoverflow.com/a/363313
score: 0
type: AnswerComment
has text: It also makes it a lot harder to simply create a new Address, since you now require a factory to hide the implementation.

http://stackoverflow.com/a/671370
answers question: http://stackoverflow.com/q/645746
downvote count: 0
type: Answer
has body: Javarebel can greatly reduce time spent during web development using Java. Let me quote here the official website: JavaRebel is a JVM plugin (-javaagent) that enables you to see changes to your code immediately, without the need to redeploy an application or perform a container restart. If you're tired of watching the logs roll by, and want to see your changes so that you can keep going - JavaRebel is your new best friend.
upvote count: 5
score: 5

converters
tags question: http://stackoverflow.com/q/435238
tag name: converters
type: Tag

shell
tags question: http://stackoverflow.com/q/529474
tag name: shell
type: Tag
tags question: http://stackoverflow.com/q/609888
tags question: http://stackoverflow.com/q/435740
tags question: http://stackoverflow.com/q/609762
tags question: http://stackoverflow.com/q/525212
tags question: http://stackoverflow.com/q/484355
tags question: http://stackoverflow.com/q/467399

http://stackoverflow.com/comment/240783
type: Comment
comment on: http://stackoverflow.com/a/416398
score: 0
type: AnswerComment
has text: oh so the jar files contain all the class files for java packages found in the sdk.isnt it frank ? thanks a lot for your patient answers pal.

http://stackoverflow.com/comment/9375008
type: Comment
has text: @styfle... yes... add \- before ] to support hyphens
comment on: http://stackoverflow.com/a/460295
score: 0
type: AnswerComment

http://stackoverflow.com/q/644262
tagged with: eclipse
has title: F2 focus in Eclipse for deprecated members
answer count: 1
has body: In Eclipse, the F2/focus or a hover on a member gives you a popup with the javadocs. However, if the member is deprecated, you only get a message like 'The field blahblah is deprecated'. Does anyone know if this is a known bug/feature? If yes, is there a handy shortcut to get a javadoc popup for deprecated members? Typically the alternate use of the a deprecated member is in the @deprecated javadoc tag. Hence the interest.
favorite count: 0
accepted answer: http://stackoverflow.com/a/644352
upvote count: 4
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/644352
tagged with: java
type: Question
score: 4

http://stackoverflow.com/a/514728
has body: Try a flush after writing to snoopOut.
has comment: http://stackoverflow.com/comment/328464
score: 0
type: Answer
answers question: http://stackoverflow.com/q/514714

http://stackoverflow.com/comment/25847069
type: AnswerComment
has text: That is not how it works for most projects. Usually there is not just a single branch. While you are right that there should be no failing tests (but should only be for the master/main branch). Other branches that do not constitute a release will usually have failing tests.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/5860128

http://stackoverflow.com/comment/309156
type: AnswerComment
comment on: http://stackoverflow.com/a/493432
score: 0
has text: Thanks. This looks a bit simpler than my solution because it does it all in terms of the setRange method.
type: Comment

utf
tag name: utf
tags question: http://stackoverflow.com/q/488448
type: Tag

jfreechart
type: Tag
tags question: http://stackoverflow.com/q/427603
tags question: http://stackoverflow.com/q/388411
tags question: http://stackoverflow.com/q/596696
tags question: http://stackoverflow.com/q/424603
tags question: http://stackoverflow.com/q/583118
tags question: http://stackoverflow.com/q/465229
tags question: http://stackoverflow.com/q/419157
tags question: http://stackoverflow.com/q/492457
tags question: http://stackoverflow.com/q/419770
tags question: http://stackoverflow.com/q/424264
tag name: jfreechart
tags question: http://stackoverflow.com/q/421020
tags question: http://stackoverflow.com/q/528827

http://stackoverflow.com/a/394313
type: AcceptedAnswer
has body: You could use the Visitor pattern. class Basket { void AddBall(LegalBall l) { System.out.println("LegalBall added to basket"); } void AddBall(IllegalBall i) { System.out.println("IllegalBall added to basket"); } } interface Ball { void AddBall(Basket b); } class LegalBall implements Ball { void AddBall(Basket b) { b.AddBall(this); } } class IllegalBall implements Ball { void AddBall(Basket b) { b.AddBall(this); } } or to make it more general: interface BallVisitor { void visit(LegalBall l); void visit(IllegalBall i); } interface Ball { void accept(BallVisitor v); } class LegalBall implements Ball { void accept(BallVisitor v) { v.visit(this); } } class IllegalBall implements Ball { void accept(BallVisitor v) { v.visit(this); } } class Basket implements BallVisitor { void visit(LegalBall l) { System.out.println("LegalBall added to basket"); } void visit(IllegalBall i) { System.out.println("IllegalBall added to basket"); } }
type: Answer
score: 6
upvote count: 7
downvote count: 1
has comment: http://stackoverflow.com/comment/221203
accepted answer of: http://stackoverflow.com/q/394299
has comment: http://stackoverflow.com/comment/221252
answers question: http://stackoverflow.com/q/394299

http://stackoverflow.com/a/447753
score: 0
answers question: http://stackoverflow.com/q/447739
type: Answer
has body: Well that is just one part of performance testing. Depending on the thing you are testing you may have to look at heap size, thread count, network traffic or a whole host of other things. Otherwise I use that technique for simple things that I just want to see how long they take to run.

http://stackoverflow.com/a/473947
type: Answer
has body: My pet peeve is "architects" who don't understand relational concepts and try to make things work in an object fashion when databases perform better in a set-based fashion and should be designed to be used that way. (Databases should not be designed by object oriented programmers turned architects, they should be designed by database specialists) And architects who think it is more "Elegant" to put multiple things in one main base table (overgeneralization) and then end up with over 100 foreign keys to that table and every query referencing it and a major performance nightmare (as well as a ridiculous process to go through to delete a record).
answers question: http://stackoverflow.com/q/473088
score: 0

send
type: Tag
tags question: http://stackoverflow.com/q/545441
tag name: send

http://stackoverflow.com/q/529997
answer count: 3
tagged with: groovy
has answer: http://stackoverflow.com/a/21724977
tagged with: jruby
favorite count: 0
score: 11
has body: I'm looking to run some un-verified scripts (written in a yet-to-be-determined language, but needs to be Java-based, so JRuby, Groovy, Jython, BeanShell, etc are all candidates). I want these scripts to be able to do some things and restricted from doing other things. Normally, I'd just go use Java's SecurityManager and be done with it. That's pretty simple and lets me restrict file and network access, the ability to shutdown the JVM, etc. And that will work well for the high level stuff I want to block off. But there is some stuff I want to allow, but only via my custom API/library that I've providing. For example, I don't want to allow direct network access to open up a URLConnection to yahoo.com, but I am OK if it is done with MyURLConnection. That is - there is a set of methods/classes that I want to allow and then everything else I want to be off limits. I don't believe this type of security can be done with the standard Java security model, but perhaps it can. I don't have a specific requirement for performance or flexibility in the scripting language itself (the scripts will be simple procedural calls to my API with basic looping/branching). So even a "large" overhead that checks a security check on every reflection call is fine by me. Suggestions?
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/530277
tagged with: java
has title: Security with Java Scripting (JRuby, Jython, Groovy, BeanShell, etc)
type: Question
possible better answer: http://stackoverflow.com/a/530277
tagged with: jython
has answer: http://stackoverflow.com/a/530056
accepted answer: http://stackoverflow.com/a/530056
upvote count: 11
tagged with: security

http://stackoverflow.com/a/530941
has body: There is nothing wrong with using new like how it's shown in your code snippet. Consider the case of wanting to append String snippets. Why would you want to ask the injector for a StringBuilder ? In another situation that I've faced, I needed to have a thread running in accordance to the lifecycle of my container. In that case, I had to do a new Thread() because my Injector was created after the callback method for container startup was called. And once the injector was ready, I hand injected some managed classes into my Thread subclass.
score: 4
type: Answer
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/530923

http://stackoverflow.com/a/42510348
has comment: http://stackoverflow.com/comment/131812299
has body: Numeric Promotion Rules If two values have different data types, Java will automatically promote one of the values to the larger of the two data types. If one of the values is integral and the other is floating-point, Java will automatically promote the integral value to the floating-point value’s data type. Smaller data types, namely byte, short, and char, are first promoted to int any time they’re used with a Java binary arithmetic operator, even if neither of the operands is int. After all promotion has occurred and the operands have the same data type, the resulting value will have the same data type as its promoted operands
has comment: http://stackoverflow.com/comment/136221898
upvote count: 6
answers question: http://stackoverflow.com/q/576302
type: Answer
downvote count: 0
score: 6

http://stackoverflow.com/comment/9870414
type: Comment
comment on: http://stackoverflow.com/a/4257978
score: 1
type: AnswerComment
has text: This just sleeps the thread that called thread.sleep(). Not data is read / received / handled by calling thread.sleep(). The only this that happens, is th call sleeps in hopes that more data comes.

http://stackoverflow.com/comment/308029
has text: @Eddie: If you set the env variables before you invoke java.exe, you can ignore the registry entires. It is perfectly safe to copy a Java install; you can even copy it to a machine which does not have the registry entires and it will work.
comment on: http://stackoverflow.com/a/492228
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/278968
has text: Worked perfectly. Code sample below. Thanks again. :)
comment on: http://stackoverflow.com/a/459658
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/30118243
upvote count: 1
has body: SyndFeedInput fr = new SyndFeedInput(); SyndFeed sf = fr.build(new XmlReader(myInputStream)); List&lt;?&gt; entries = sf.getEntries();
score: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/48349171
answers question: http://stackoverflow.com/q/367626
type: Answer

http://stackoverflow.com/a/490820
score: 2
downvote count: 0
upvote count: 2
answers question: http://stackoverflow.com/q/490557
has body: There is no global answer. The map interface let the choice to the users. Unfortunately, I think that all the implementations in the jdk use the fail-fast implementation (here is the definition of fail-fast, as it stated in the HashMap Javadoc): The iterators returned by all of this class's "collection view methods" are fail-fast: if the map is structurally modified at any time after the iterator is created, in any way except through the iterator's own remove method, the iterator will throw a ConcurrentModificationException. Thus, in the face of concurrent modification, the iterator fails quickly and cleanly, rather than risking arbitrary, non-deterministic behavior at an undetermined time in the future.
type: Answer

http://stackoverflow.com/comment/88673213
comment on: http://stackoverflow.com/a/492224
has text: As stated before, think twice before depending on google reflections. It's not stable because it depends on guava which does not manage versions very well. https://github.com/ronmamo/reflections/issues/194
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/542424
answers question: http://stackoverflow.com/q/541832
type: Answer
downvote count: 0
has body: IBM's GC toolkit does exactly what you ask. https://www.ibm.com/developerworks/java/jdk/tools/gcmv/ I'm not sure if it's compatible with GC logs from Sun's JVM though.
has comment: http://stackoverflow.com/comment/11567177
score: 17
has comment: http://stackoverflow.com/comment/18883651
type: AcceptedAnswer
upvote count: 17
accepted answer of: http://stackoverflow.com/q/541832
has comment: http://stackoverflow.com/comment/358191

http://stackoverflow.com/comment/17056239
score: 1
has text: Just a word of caution in my case, the tony19 fork on Github doesn't work on Android as of 0.1.8.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/1095737

http://stackoverflow.com/comment/44549141
type: AnswerComment
type: Comment
score: 7
has text: false for mru and true for lru
comment on: http://stackoverflow.com/a/583913

http://stackoverflow.com/q/492091
type: Question
tagged with: c#
tagged with: java
answer count: 6
has body: I'm writing a scanner as part of a compiler. I'm having a major headache trying to write this one portion: I need to be able to parse a stream of tokens and push them one by one into a vector, ignoring whitespace and tokenizing special symbols (simple case, lets just consider parentheses and braces) Example: int main(){ } should parse into 6 different tokens: int main ( ) { } How would you go about solving this? I'm writing this in C++, but a java/C# solution would be appreciated as well. Some points: and no, I can't use Boost, I can't guarantee that the libraries will be available to me. (don't ask...) I don't want to use lex, or any other special tools. I've never done this before and just want to try this once to say I've done it.
upvote count: 2
has answer: http://stackoverflow.com/a/492242
possible better answer: http://stackoverflow.com/a/492119
has answer: http://stackoverflow.com/a/492119
accepted answer: http://stackoverflow.com/a/492143
has title: C++ scanner (string-fu!)
tagged with: string
favorite count: 0
has answer: http://stackoverflow.com/a/492406
has answer: http://stackoverflow.com/a/492143
tagged with: c++
score: 2
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/492167
has answer: http://stackoverflow.com/a/492295

http://stackoverflow.com/q/390150
has body: I have a simple task of authenticating against Active Directory using Java. Just verifying credentials and nothing else. Let's say my domain is "fun.xyz.tld", OU path is unknown, and username/password is testu/testp. I know there's a few Java libraries out there that simplify this task, but I wasn't successful at implementing them. Most examples that I've found addressed LDAP in general, not specifically Active Directory. Issuing LDAP request means sending an OU path in it, which I don't have. Also, the application that issues LDAP request should be already bound to Active Directory in order to access it... Insecure, since the credentials would have to be stored someplace discoverable. I would like a test bind with test credentials, if possible - this would mean that account is valid. Last, if possible, is there a way to make such authentication mechanism encrypted? I know that AD uses Kerberos, but not sure if Java's LDAP methods do. Does anyone has an example of working code? Thanks.
favorite count: 0
accepted answer: http://stackoverflow.com/a/394193
has answer: http://stackoverflow.com/a/1674857
answer count: 9
tagged with: authentication
has answer: http://stackoverflow.com/a/453751
has answer: http://stackoverflow.com/a/1772866
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/453751
tagged with: java
tagged with: active-directory
has answer: http://stackoverflow.com/a/390222
type: Question
has answer: http://stackoverflow.com/a/394193
downvote count: 0
score: 75
has answer: http://stackoverflow.com/a/11089385
has answer: http://stackoverflow.com/a/8195495
upvote count: 75
has title: Authenticating against Active Directory with Java on Linux
tagged with: ldap
has answer: http://stackoverflow.com/a/390437
has answer: http://stackoverflow.com/a/390169

http://stackoverflow.com/q/408989
score: 0
has comment: http://stackoverflow.com/comment/236859
has answer: http://stackoverflow.com/a/412061
has answer: http://stackoverflow.com/a/409078
has comment: http://stackoverflow.com/comment/255128
has title: Java(Swing): influence height of JList in GridBagLayout
possible better answer: http://stackoverflow.com/a/409066
has comment: http://stackoverflow.com/comment/234071
has answer: http://stackoverflow.com/a/409066
answer count: 4
has body: I want to build a dialog in Java with a List and a couple of buttons underneath it. The list ends up with the same height as the buttons (about one line) and the whole dialog is about two lines of height. However, I'd like the dialog to be taller (maybe 10 lines) and the JList to take up most of the space .. I've played around with the parameters, but for the life of it can't get it to work. Any ideas? Here's my current code: //layout setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; int y = 0; //List gbc.gridx = 0; gbc.gridy = y; gbc.weighty = 3; gbc.weightx = 1; gbc.gridwidth= 3; add(new JScrollPane(_myList), gbc); _myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // Buttons gbc.gridx = 1; gbc.gridy = ++y; gbc.gridwidth = 1; gbc.weighty = 0; add(_Save, gbc); gbc.gridx = 2; add(_Cancel, gbc);
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/409063
accepted answer: http://stackoverflow.com/a/409078
tagged with: java
tagged with: swing
type: Question

http://stackoverflow.com/q/465245
score: 3
tagged with: java
type: Question
upvote count: 3
answer count: 1
favorite count: 0
tagged with: shapefile
has title: Which open-source java-library provides an easy way to read and write ESRI Shapefiles?
has body: For a project I need to read and write ESRI shapefiles. It should be very easy, as I don't need advanced features. Is something out there?
downvote count: 0
has answer: http://stackoverflow.com/a/465518
accepted answer: http://stackoverflow.com/a/465518
type: AnsweredQuestion
tagged with: open-source

http://stackoverflow.com/a/498245
answers question: http://stackoverflow.com/q/498217
type: Answer
has body: As I heard it when java first came out, the theory was that Throwable might be used for transfer of control in other cases besides exceptions. I've never seen it used that way though (and that's probably a Very Good Thing). So just catch Exception (or better yet, a more fine-grained exception).
score: 0

http://stackoverflow.com/a/525556
has comment: http://stackoverflow.com/comment/338791
has comment: http://stackoverflow.com/comment/45338565
has comment: http://stackoverflow.com/comment/338853
has comment: http://stackoverflow.com/comment/338799
answers question: http://stackoverflow.com/q/525548
has comment: http://stackoverflow.com/comment/45326145
upvote count: 54
has comment: http://stackoverflow.com/comment/338794
has body: Constructors are not inherited. Also, the initialization of fields is done by the virtual machine, not the default constructor. The default constructor just invokes the default constructor of the superclass, and the default constructor of Object is empty. The good point of this design is that there is no way to ever access uninitialized fields.
type: Answer
downvote count: 0
score: 54

http://stackoverflow.com/a/428247
has body: I don't have any myself, but if I have a problem along these lines I have often found the best place for 3D programming and Java advice is over at JavaGaming.org - I've not been there for a while, but it was always a helpful and knowledgeable community.
upvote count: 3
answers question: http://stackoverflow.com/q/428225
type: Answer
downvote count: 0
score: 3

http://stackoverflow.com/a/1816177
answers question: http://stackoverflow.com/q/407612
has comment: http://stackoverflow.com/comment/8425686
has body: In addition to using the mentioned jconsole/visualvm, you can use jstack -l &lt;vm-id&gt; on another command line window, and capture that output. The &lt;vm-id&gt; can be found using the task manager (it is the process id on windows and unix), or using jps. Both jstack and jps are include in the Sun JDK version 6 and higher.
score: 22
upvote count: 22
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/8487647

http://stackoverflow.com/a/403922
downvote count: 1
score: 0
answers question: http://stackoverflow.com/q/403902
type: Answer
upvote count: 1
has body: Use Ant property files, and build with "-Dbrand=X".

http://stackoverflow.com/comment/9780206
comment on: http://stackoverflow.com/a/446671
score: 0
type: AnswerComment
has text: @marcus, if toString() is not overrriden (which it does not need to be), then the string code could just be the enum value toString() which would be DATABASE, or DUPLICATE_USER in this case.
type: Comment

http://stackoverflow.com/q/515397
downvote count: 1
type: Question
tagged with: jakarta-ee
tagged with: .net-3.5
has answer: http://stackoverflow.com/a/515949
has answer: http://stackoverflow.com/a/3034779
score: 7
tagged with: java
answer count: 6
has title: Looking for a .NET 3.5 / J2EE architecture concept comparison article/chart
tagged with: .net
has answer: http://stackoverflow.com/a/516294
favorite count: 0
has answer: http://stackoverflow.com/a/516564
has answer: http://stackoverflow.com/a/1319890
upvote count: 8
has answer: http://stackoverflow.com/a/567580
type: UnansweredQuestion
has body: We are thinking about combining .NET technology with Java technology (WCF, JBoss/ESB, MOM, WPF, WF) and I need to have a high-level idea of what are the apples and oranges in the .NET 3.5 and Java worlds. Does anyone know of a good, clear article or better yet a simple chart which answers questions such as: WCF in the Java world is ______ the equivalent of WPF in the Java world is _____ the closes thing to JBoss in the .NET world is _____ the JVM and CLR are essentially the same except for these differences: .... in the Java world you don't have the concept of WF/WCF/WPF, instead you have .... there is no "LINQ" in the Java world yet, but you can use ___ the closest you get to ADO.NET Data Services in the Java world is .... I'm not looking to debate this so I'm not looking for "fighting points", I just need a neutral what-is-what chart comparing the two worlds.

http://stackoverflow.com/q/367104
downvote count: 0
answer count: 7
favorite count: 0
possible better answer: http://stackoverflow.com/a/367123
has answer: http://stackoverflow.com/a/24524882
has answer: http://stackoverflow.com/a/367128
upvote count: 13
tagged with: coding-style
type: AnsweredQuestion
has body: In java &lt;1.5, constants would be implemented like this public class MyClass { public static int VERTICAL = 0; public static int HORIZONTAL = 1; private int orientation; public MyClass(int orientation) { this.orientation = orientation; } ... and you would use it like this: MyClass myClass = new MyClass(MyClass.VERTICAL); Now, in 1.5 obviously you should be using enums: public class MyClass { public static enum Orientation { VERTICAL, HORIZONTAL; } private Orientation orientation; public MyClass(Orientation orientation) { this.orientation = orientation; } ... and now you would use it like this: MyClass myClass = new MyClass(MyClass.Orientation.VERTICAL); Which I find slightly ugly. Now I could easily add a couple of static variables: public class MyClass { public static Orientation VERTICAL = Orientation.VERTICAL; public static Orientation HORIZONTAL = Orientation.HORIZONTAL; public static enum Orientation { VERTICAL, HORIZONTAL; } private Orientation orientation; public MyClass(Orientation orientation) { this.orientation = orientation; } ... And now I can do this again: MyClass myClass = new MyClass(MyClass.VERTICAL); With all the type-safe goodness of enums. Is this good style, bad style or neither. Can you think of a better solution? Update Vilx- was the first one to highlight what I feel I was missing - that the enum should be a first-class citizen. In java this means it gets its own file in the package - we don't have namespaces. I had thought this would be a bit heavyweight, but having actually done it, it definitely feels right. Yuval's answer is fine, but it didn't really emphasise the non-nested enum. Also, as for 1.4 - there are plenty of places in the JDK that use integers, and I was really looking for a way to evolve that sort of code.
has title: Should you always use enums instead of constants in Java
has comment: http://stackoverflow.com/comment/196419
tagged with: java
has answer: http://stackoverflow.com/a/367113
type: Question
has answer: http://stackoverflow.com/a/367117
tagged with: enums
has answer: http://stackoverflow.com/a/367105
has comment: http://stackoverflow.com/comment/196417
score: 13
has answer: http://stackoverflow.com/a/367123
accepted answer: http://stackoverflow.com/a/367113
has answer: http://stackoverflow.com/a/367129

http://stackoverflow.com/comment/452895
has text: In a multi-tier system that you suggest, Pregzt will have to be careful about transactional integrity- if machine holding the queue crashes, for example, [s]he may lose some data. JMS does include transaction awareness, but the performance characteristics of that are implementation dependent.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/639332

http://stackoverflow.com/comment/41756125
has text: Not per se -- the issues are more logistical (you could end up with the same exception logged several times -- is this confusing? the enclosing method must then be declared as throwing Throwable...). But the VM itself doesn't care about these issues.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/581935
type: AnswerComment

http://stackoverflow.com/a/565445
has comment: http://stackoverflow.com/comment/376672
has body: Console See the Wikipedia page on ANSI escapes for the full collection of sequences, including the colors. But for one simple example (Printing in red) in Java (as you tagged this as Java) do: System.out.println("\u001B31;1mhello world!"); The 3 indicates change color, the first 1 indicates red (green would be 2) and the second 1 indicates do it in "bright" mode. GUI However, if you want to print to a GUI the easiest way is to use html: JEditorPane pane = new new JEditorPane(); pane.setText(" hello world! "); For more details on this sort of thing, see the Swing Tutorial. It is also possible by using styles in a JTextPane. Here is a helpful example of code to do this easily with a JTextPane (added from helpful comment). JTextArea is a single coloured Text component, as described here. It can only display in one color. You can set the color for the whole JTextArea like this: JTextArea area = new JTextArea("hello world"); area.setForeground(Color.red)
has comment: http://stackoverflow.com/comment/376758
has comment: http://stackoverflow.com/comment/376706
score: 23
has comment: http://stackoverflow.com/comment/376663
type: Answer
has comment: http://stackoverflow.com/comment/35016870
upvote count: 24
has comment: http://stackoverflow.com/comment/376779
has comment: http://stackoverflow.com/comment/376757
has comment: http://stackoverflow.com/comment/376739
has comment: http://stackoverflow.com/comment/376712
has comment: http://stackoverflow.com/comment/376737
answers question: http://stackoverflow.com/q/565252
has comment: http://stackoverflow.com/comment/376762
downvote count: 1

http://stackoverflow.com/comment/127626488
comment on: http://stackoverflow.com/a/47568605
type: AnswerComment
score: 0
type: Comment
has text: Using recursion means you're open to stack overflows, and it tends to be inefficient (repeated `ch + word` plus function call overhead).

http://stackoverflow.com/a/544534
type: Answer
downvote count: 1
has body: You can encode the CD and the batch file in the value for cmd.exe /K. From the doco (cmd /?): Note that multiple commands separated by the command separator '&amp;&amp;' are accepted for string if surrounded by quotes. For Example: cmd /C "CD C:\ &amp;&amp; Dir" cmd /C "CD C:\Windows &amp;&amp; Dir" cmd /C "CD C:\Windows &amp;&amp; MySuperSuperBatchFile" For more detail, run: cmd /? from the command line.
upvote count: 9
answers question: http://stackoverflow.com/q/544519
score: 8

http://stackoverflow.com/a/27381033
upvote count: 1
has body: First,i think you should know that there are two types of break and continue in Java which are labeled break,unlabeled break,labeled continue and unlabeled continue.Now, i will talk about the difference between them. class BreakDemo { public static void main(String[] args) { int[] arrayOfInts = { 32, 87, 3, 589, 12, 1076, 2000, 8, 622, 127 }; int searchfor = 12; int i; boolean foundIt = false; for (i = 0; i &lt; arrayOfInts.length; i++) { if (arrayOfInts[i] == searchfor) { foundIt = true; break;//this is an unlabeled break,an unlabeled break statement terminates the innermost switch,for,while,do-while statement. } } if (foundIt) { System.out.println("Found " + searchfor + " at index " + i); } else { System.out.println(searchfor + " not in the array"); } } An unlabeled break statement terminates the innermost switch ,for ,while ,do-while statement. public class BreakWithLabelDemo { public static void main(String[] args) { search: for (int i = 0; i &lt; 3; i++) { for (int j = 0; j &lt; 5; j++) { System.out.println(i + " - " + j); if (j == 3) break search;//this is an labeled break.To notice the lab which is search. } } } A labeled break terminates an outer statement.if you javac and java this demo,you will get: 0 - 0 0 - 1 0 - 2 0 - 3 class ContinueDemo { public static void main(String[] args) { String searchMe = "peter piper picked a " + "peck of pickled peppers"; int max = searchMe.length(); int numPs = 0; for (int i = 0; i &lt; max; i++) { // interested only in p's if (searchMe.charAt(i) != 'p') continue;//this is an unlabeled continue. // process p's numPs++; } System.out.println("Found " + numPs + " p's in the string."); } An unlabeled continue statement skips the current iteration of a for,while,do-while statement. public class ContinueWithLabelDemo { public static void main(String[] args) { search: for (int i = 0; i &lt; 3; i++) { for (int j = 0; j &lt; 5; j++) { System.out.println(i + " - " + j); if (j == 3) continue search;//this is an labeled continue.Notice…
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/462373
type: Answer

windows
tags question: http://stackoverflow.com/q/512555
tags question: http://stackoverflow.com/q/486938
tags question: http://stackoverflow.com/q/583141
tags question: http://stackoverflow.com/q/577846
tags question: http://stackoverflow.com/q/606820
tags question: http://stackoverflow.com/q/473379
tags question: http://stackoverflow.com/q/450676
tags question: http://stackoverflow.com/q/625516
tags question: http://stackoverflow.com/q/638301
tags question: http://stackoverflow.com/q/643346
tags question: http://stackoverflow.com/q/443543
tags question: http://stackoverflow.com/q/393733
tags question: http://stackoverflow.com/q/457655
tags question: http://stackoverflow.com/q/477701
tags question: http://stackoverflow.com/q/544507
tags question: http://stackoverflow.com/q/370114
tags question: http://stackoverflow.com/q/492207
tags question: http://stackoverflow.com/q/496847
tags question: http://stackoverflow.com/q/529732
tags question: http://stackoverflow.com/q/421662
tags question: http://stackoverflow.com/q/642706
tags question: http://stackoverflow.com/q/503467
tags question: http://stackoverflow.com/q/524081
tags question: http://stackoverflow.com/q/478240
tags question: http://stackoverflow.com/q/490970
tags question: http://stackoverflow.com/q/362198
type: Tag
tags question: http://stackoverflow.com/q/481379
tags question: http://stackoverflow.com/q/462110
tags question: http://stackoverflow.com/q/382878
tags question: http://stackoverflow.com/q/570401
tags question: http://stackoverflow.com/q/583950
tags question: http://stackoverflow.com/q/634564
tags question: http://stackoverflow.com/q/434581
tags question: http://stackoverflow.com/q/553175
tags question: http://stackoverflow.com/q/570384
tags question: http://stackoverflow.com/q/450069
tags question: http://stackoverflow.com/q/359213
tags question: http://stackoverflow.com/q/493177
tags question: http://stackoverflow.com/q/378625
tag name: windows
tags question: http://stackoverflow.com/q/570376
tags question: http://stackoverflow.com/q/404118
tags question: http://stackoverflow.com/q/551668
tags question: http://stackoverflow.com/q/396448

http://stackoverflow.com/q/530012
upvote count: 517
tagged with: sql
has answer: http://stackoverflow.com/a/11197724
has answer: http://stackoverflow.com/a/18979351
downvote count: 0
has answer: http://stackoverflow.com/a/29405968
has comment: http://stackoverflow.com/comment/69163780
score: 517
has comment: http://stackoverflow.com/comment/29185534
answer count: 17
favorite count: 0
has answer: http://stackoverflow.com/a/39413772
tagged with: datetime
has body: I am trying to use a java.util.Date as input and then creating a query with it - so I need a java.sql.Date. I was surprised to find that it couldn't do the conversion implicitly or explicitly - but I don't even know how I would do this, as the Java API is still fairly new to me.
has answer: http://stackoverflow.com/a/31237429
has answer: http://stackoverflow.com/a/35910504
has answer: http://stackoverflow.com/a/530022
has comment: http://stackoverflow.com/comment/53380527
linked to: http://stackoverflow.com/q/2305973
has answer: http://stackoverflow.com/a/31238011
has answer: http://stackoverflow.com/a/35435182
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/31238011
has answer: http://stackoverflow.com/a/27618832
linked to: http://stackoverflow.com/q/12131068
has title: How to convert java.util.Date to java.sql.Date?
tagged with: java
has answer: http://stackoverflow.com/a/4097430
has comment: http://stackoverflow.com/comment/47963463
possible better answer: http://stackoverflow.com/a/530022
has answer: http://stackoverflow.com/a/39164744
type: Question
has answer: http://stackoverflow.com/a/20551199
has answer: http://stackoverflow.com/a/17104417
linked to: http://stackoverflow.com/q/38922754
has answer: http://stackoverflow.com/a/21588812
has answer: http://stackoverflow.com/a/19181593
tagged with: date
has answer: http://stackoverflow.com/a/38048908

http://stackoverflow.com/q/461896
has answer: http://stackoverflow.com/a/461984
has answer: http://stackoverflow.com/a/462630
score: 198
has body: This is a poll of sorts about common concurrency problems in Java. An example might be the classic deadlock or race condition or perhaps EDT threading bugs in Swing. I'm interested both in a breadth of possible issues but also in what issues are most common. So, please leave one specific answer of a Java concurrency bug per comment and vote up if you see one you've encountered.
has answer: http://stackoverflow.com/a/461913
has answer: http://stackoverflow.com/a/464457
has answer: http://stackoverflow.com/a/4569677
type: Question
has answer: http://stackoverflow.com/a/1983025
has answer: http://stackoverflow.com/a/464894
has answer: http://stackoverflow.com/a/462108
has answer: http://stackoverflow.com/a/461977
has answer: http://stackoverflow.com/a/462179
has answer: http://stackoverflow.com/a/492928
has answer: http://stackoverflow.com/a/462391
has answer: http://stackoverflow.com/a/462170
downvote count: 5
has answer: http://stackoverflow.com/a/462657
tagged with: concurrency
has answer: http://stackoverflow.com/a/462050
has answer: http://stackoverflow.com/a/462648
has answer: http://stackoverflow.com/a/462035
has answer: http://stackoverflow.com/a/462728
has answer: http://stackoverflow.com/a/464415
has answer: http://stackoverflow.com/a/461922
has comment: http://stackoverflow.com/comment/24195291
has answer: http://stackoverflow.com/a/461994
has answer: http://stackoverflow.com/a/462174
answer count: 49
has answer: http://stackoverflow.com/a/464529
linked to: http://stackoverflow.com/q/6457109
has answer: http://stackoverflow.com/a/477729
has answer: http://stackoverflow.com/a/462095
has answer: http://stackoverflow.com/a/463437
has title: What is the most frequent concurrency issue you've encountered in Java?
has comment: http://stackoverflow.com/comment/101932878
favorite count: 0
has answer: http://stackoverflow.com/a/461964
has answer: http://stackoverflow.com/a/462295
has answer: http://stackoverflow.com/a/468126
has answer: http://stackoverflow.com/a/1412440
has answer: http://stackoverflow.com/a/462714
has answer: http://stackoverflow.com/a/462371
has answer: http://stackoverflow.com/a/463065
has answer: http://stackoverflow.com/a/531130
has comment: http://stackoverflow.com/comment/33661155
possible better answer: http://stackoverflow.com/a/463437
has answer: http://stackoverflow.com/a/461961
accepted answer: http://stackoverflow.com/a/462648
has answer: http://stackoverflow.com/a/464810
has answer: http://stackoverflow.com/a/462131
has answer: http://stackoverflow.com/a/4569410
has comment: http://stackoverflow.com/comment/22339825
has answer: http://stackoverflow.com/a/462259
has answer: http://stackoverflow.com/a/461990
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/464613
has answer: http://stackoverflow.com/a/462149
has answer: http://stackoverflow.com/a/464344
has answer: http://stackoverflow.com/a/468144
has answer: http://stackoverflow.com/a/461910
has answer: http://stackoverflow.com/a/490290
has answer: http://stackoverflow.com/a/461947
upvote count: 203
has answer: http://stackoverflow.com/a/462058
tagged with: java
has answer: http://stackoverflow.com/a/466334
tagged with: multithreading

http://stackoverflow.com/q/485984
has title: JDBC Connection Issue
has body: I have create a getDBConnection method in my Java application. This returns a connection object, and hence I haven't closed this connection in this method itself. Now, I am invoking this method from various methods in my application at regular intervals, and closing them inside a try - finally block. I thought this should free up the connection after use. However, I am seeing a large number of connections opened (about 50) in the MySQL Administrator's Server Connections tab. //Defining a method to retrieve a database connection // PropDemo is a properties class that retrieves Database related values from a file public Connection getDBConnection() { //Instantiating the Properties object PropDemo prop = new PropDemo(); Connection con = null; // Retrieving values from the parameters.properties file String JdbcDriver = prop.getMessage("JdbcDriver"); String JdbcUrlPrefix = prop.getMessage("JdbcUrlPrefix"); String DBIP = prop.getMessage("DBIP"); String DBName = prop.getMessage("DBName"); String DBUser = prop.getMessage("DBUser"); String DBPassword = prop.getMessage("DBPassword"); try { // Loading and instantiating the JDBC MySQL connector driver class Class.forName(JdbcDriver).newInstance(); con = DriverManager.getConnection(JdbcUrlPrefix + DBIP + "/" + DBName, DBUser, DBPassword); if (con.isClosed()) Logger.log("Connection cannot be established", "vm"); } catch (Exception e) { Logger.log("Exception: " + e, "vm"); Logger.log(Logger.stack2string(e), "vm"); } return con; } I am also closing the associated ResultSet and Statement Objects. What could be missing here? I am planning to replace all the Statements with PreparedStatements for efficiency and security reasons. Will that help significantly? What else can be done? EDIT: This is just a core java application that is repeatedly quering for changes in some fields in a MySQL database through MySQL-JDBC connector. I am not using any framework like Spring or Hibernate.
has answer: http://stackoverflow.com/a/487854
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/486081
score: 1
has comment: http://stackoverflow.com/comment/302592
tagged with: java
possible better answer: http://stackoverflow.com/a/486024
type: Question
downvote count: 0
upvote count: 1
tagged with: jdbc
has answer: http://stackoverflow.com/a/486024
has answer: http://stackoverflow.com/a/488849
accepted answer: http://stackoverflow.com/a/488849
tagged with: connection
answer count: 4
favorite count: 0

http://stackoverflow.com/comment/224754
type: AnswerComment
comment on: http://stackoverflow.com/a/397088
type: Comment
has text: Totally agree with this one. Spring makes this SO easy. It also makes testing very easy if you use the transactional stuff.
score: 0

http://stackoverflow.com/a/1356533
has body: http://ojalgo.org/generated/org/ojalgo/optimisation/linear/LinearSolver.html
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/531049
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/5289461

http://stackoverflow.com/a/539584
has comment: http://stackoverflow.com/comment/1278702
has body: My advice, learn C#. These days almost 50% of the job listings were Java and almost the other 50% were C#, there were only a few listing C++. That said, the people using C++ know why they are using it and probably have good use cases for it... meaning you would really learn how to use the language at the highest levels... meanwhile companies slogging out business logic applications in Java/C# will probably not teach you as much about programming as quickly. If you do decide to take a C++ job, make sure the shop uses the STL effectively and that they are using Boost. Not looking at using Boost/STL, but actually using it.
answers question: http://stackoverflow.com/q/537595
upvote count: 5
score: 5
downvote count: 0
type: Answer

http://stackoverflow.com/comment/61079539
type: Comment
has text: @JoachimSauer what you mean by that version? I'm using Java 8.
type: AnswerComment
comment on: http://stackoverflow.com/a/380828
score: 0

http://stackoverflow.com/a/35253545
upvote count: 6
downvote count: 0
has body: The @Context annotation (see answers in this question :What does context annotation do in Spring?) will cause it to be injected for you. I had to use @Context private HttpServletRequest request;
type: Answer
score: 6
answers question: http://stackoverflow.com/q/559155

http://stackoverflow.com/comment/61183618
has text: I couldn't agree more with your answer! Having a smaller set of available integer types, and making byte unsigned are both good points I wholeheartedly support.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/430553

http://stackoverflow.com/a/460616
answers question: http://stackoverflow.com/q/460602
type: Answer
downvote count: 0
score: 1
has body: What is the definition of "is from another list"? Is it the object equality? Then what you have is good, but you might consider a (Hash)Set for better clarity. If it is reference equality you need then look up IdentityHashMap, or use a HashSet of IdentityHashcode
upvote count: 1

http://stackoverflow.com/comment/37587768
type: AnswerComment
has text: Alas, there is no static method for isNullOrEmpty(), and no custom overloading of operators, which makes this part of Java clunkier than in C# or Python. And since Java doesn't have extension methods, you can't write your own utility to extend java.lang.String. Right? Any thoughts on subclassing String, adding that static utility method, and then always using MyString instead? A static method with two parameters for doing null-safe comparisons would be nice to have in that subclass too.
type: Comment
score: 8
comment on: http://stackoverflow.com/a/513935

http://stackoverflow.com/a/2314214
has body: You might get some traction by establishing a filechannel lock on the file before renaming it (and deleting the file you're going to overwrite once you have the lock). -r
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/595631
downvote count: 0
score: 1

http://stackoverflow.com/comment/139549226
comment on: http://stackoverflow.com/a/614357
score: 0
type: AnswerComment
has text: This only outputs if the CPU is idle, not if there was no user activity.
type: Comment

http://stackoverflow.com/a/627766
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/627588
upvote count: 1
has body: While JavaHelp is a good api, Eclipse has its own api for help, and (IMO) it's a much better option for SWT based applications. See this developerworks article on developing help using the Eclipse help system. If you're actually creating a swing application, and want to package java help with it, you'll need to create the help documents (help topics, helpset file, map file, TOC, index, full-text search db) and then package those files into a jar for distribution with your application. See the JavaHelp Users Guide for details. For running the help viewer from the Eclipse IDE (and from your application at runtime), all you need is the jar file jhall.jar from the JavaHelp distribution.

http://stackoverflow.com/a/583548
upvote count: 2
answers question: http://stackoverflow.com/q/583454
has body: First of all, it's micro optimization. So no need to worry much about it. But to answer your question, you need to reduce it to just one line. (as all your code does is to set it to NULL). foo = NULL; Reasons being that, Comparison is a much much costlier operation than assignment. (As comparison eats up many assembly instructions comparatively. Generally a subtraction and a comparison to zero or an XOR and comparison to zero). Assignment takes up fewer instructions.
downvote count: 0
has comment: http://stackoverflow.com/comment/32560280
type: Answer
score: 2

http://stackoverflow.com/comment/437375
comment on: http://stackoverflow.com/a/624508
has text: I don't think reflection would help here (I was going to say the same thing)... I think what he wants to do is to actually change the method to avoid the check. But perhaps I read it wrong... but regardless reflection will negate any speed improvements.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/600740
score: 285
has body: You should be able to use non-greedy quantifiers, specifically *?. You're going to probably want the following: Pattern MY_PATTERN = Pattern.compile("\\[(.*?)\\]"); This will give you a pattern that will match your string and put the text within the square brackets in the first group. Have a look at the Pattern API Documentation for more information. To extract the string, you could use something like the following: Matcher m = MY_PATTERN.matcher("FOO[BAR]"); while (m.find()) { String s = m.group(1); // s now contains "BAR" }
has comment: http://stackoverflow.com/comment/413455
accepted answer of: http://stackoverflow.com/q/600733
upvote count: 285
answers question: http://stackoverflow.com/q/600733
type: Answer
has comment: http://stackoverflow.com/comment/413038
downvote count: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/413007

http://stackoverflow.com/a/621849
upvote count: 54
has comment: http://stackoverflow.com/comment/22013441
has comment: http://stackoverflow.com/comment/434772
score: 54
answers question: http://stackoverflow.com/q/621835
has body: If the sprites area read into a BufferedImage, the getSubimage method can be used to get a subimage of the sprite sheet. The getSubimage method will take the x, y, and the width and height of the desired subimage, so the desired sprite can be obtained. Since most of the sprites seem to be the same size, I would think most of them can be retrieved by a nested for loop to iterate through the large image. For example, if the sprite image is loaded using the ImageIO class (such as the read method), and each sprite is 10 pixels by 10 pixels in size, where are 5 rows by 5 columns of sprites, the sprites can be obtained by the following: BufferedImage bigImg = ImageIO.read(new File("sheet.png")); // The above line throws an checked IOException which must be caught. final int width = 10; final int height = 10; final int rows = 5; final int cols = 5; BufferedImage[] sprites = new BufferedImage[rows * cols]; for (int i = 0; i &lt; rows; i++) { for (int j = 0; j &lt; cols; j++) { sprites[(i * cols) + j] = bigImg.getSubimage( j * width, i * height, width, height ); } } The catch is, of course, the above code will only work if all the sprites are the same size, so there will need to be some adjustment performed in order to work for the given sprite sheet. (As the top right-hand corner seems to be different in size from the others.)
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/13939984
accepted answer of: http://stackoverflow.com/q/621835
type: Answer
has comment: http://stackoverflow.com/comment/14651411

http://stackoverflow.com/a/437205
upvote count: 9
has body: BeanComparator of Apache commons is what you are looking for. Update. A simple example that compares JavaBeans with one property (comparation is made agains only one property, you should create as many BeanComparators as properties you want to match). import org.apache.commons.beanutils.BeanComparator; public class TestBeanComparator { public TestBeanComparator() { } public class TestBean { int value; public TestBean() { } public int getValue() { return value; } public void setValue(int value) { this.value = value; } } public static void main(String[] args) { TestBeanComparator tbc = new TestBeanComparator(); tbc.go(); } public void go() { TestBean tbs [] = new TestBean[10]; for (int i = 0; i &lt; tbs.length; i++) { tbs[i] = new TestBeanComparator.TestBean(); tbs[i].setValue((int) (Math.random() * 10)); System.out.println("TestBean["+i+"] = " + tbs[i].getValue()); } BeanComparator bc = new BeanComparator("value"); System.out.println(""); System.out.println("Value to match: " + tbs[0].getValue()); for (int i = 1; i &lt; tbs.length; i++) { if(bc.compare(tbs[i], tbs[0]) == 0) { System.out.println("Match found in bean "+ i); } } } } After some tests one result is successful. This is the output: TestBean[0] = 0 TestBean[1] = 4 TestBean[2] = 0 TestBean[3] = 2 TestBean[4] = 7 TestBean[5] = 3 TestBean[6] = 0 TestBean[7] = 3 TestBean[8] = 7 TestBean[9] = 3 Value to match: 0 Match found in bean 2 Match found in bean 6 Obviously increasing TestBean array size will increase the chances to get matches. You need to import to your project the following jars: commons-logging-version.jar, commons-beanutils-version.jar, commons-beanutils-core-version.jar, commons-beanutils-bean-collections-version.jar, commons-collections-version.jar. The files are included inside commons-logging, commons-beanutils and commons-collections APIs.
type: Answer
answers question: http://stackoverflow.com/q/437093
score: 8
downvote count: 1
has comment: http://stackoverflow.com/comment/44051533

http://stackoverflow.com/a/610103
downvote count: 0
score: 19
accepted answer of: http://stackoverflow.com/q/610062
has body: Advantages of Velocity: strict separation of view from business logic simple syntax that can be understood by graphic designers
answers question: http://stackoverflow.com/q/610062
type: AcceptedAnswer
upvote count: 19
type: Answer

http://stackoverflow.com/a/376878
downvote count: 0
score: 5
answers question: http://stackoverflow.com/q/376798
upvote count: 5
type: Answer
has body: If I make my own wrapper class like this; I always prefer to make strongly typed getters for the values, instead of exposing all the inner workings through the static final variables. private static final String DATABASE_NAME = "database_name" private static final String DATABASE_USER = "database_user" public String getDatabaseName(){ return getProperty(MyAppProps.DATABASE_NAME); } public String getDatabaseUser(){ return getProperty(MyAppProps.DATABASE_USER); } A static initializer looks like this; static { init(); } This being said, I will readily say that I am no big fan of static initializers. You may consider looking into dependency injection (DI) frameworks like spring or guice, these will let you inject the appropriate value directly into the places you need to use them, instead of going through the indirection of the additional class. A lot of people find that using these frameworks reduces focus on this kind of plumbing code - but only after you've finished the learning curve of the framework. (DI frameworks are quick to learn but take quite some time to master, so this may be a bigger hammer than you really want)

http://stackoverflow.com/a/377484
has comment: http://stackoverflow.com/comment/25803163
answers question: http://stackoverflow.com/q/375420
score: 60
upvote count: 60
downvote count: 0
has comment: http://stackoverflow.com/comment/82126254
has body: Trying to emulate PHP's callback feature seems an awful lot of work when you could just use appendReplacement() and appendTail() in a loop: StringBuffer resultString = new StringBuffer(); Pattern regex = Pattern.compile("regex"); Matcher regexMatcher = regex.matcher(subjectString); while (regexMatcher.find()) { // You can vary the replacement text for each match on-the-fly regexMatcher.appendReplacement(resultString, "replacement"); } regexMatcher.appendTail(resultString);
has comment: http://stackoverflow.com/comment/25487370
type: Answer
has comment: http://stackoverflow.com/comment/27066337
has comment: http://stackoverflow.com/comment/25815851

http://stackoverflow.com/comment/223588
type: Comment
has text: Cool. I think you decision to go with groovy only was a wise one.
type: AnswerComment
comment on: http://stackoverflow.com/a/397308
score: 2

http://stackoverflow.com/a/513699
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/327470
score: 2
has body: Do you need UberProject? I have the same layout but have multiple top-level projects created with File|New project. If not, can you make it a General rather than Java project?
answers question: http://stackoverflow.com/q/513697
downvote count: 0

http://stackoverflow.com/comment/385003
score: 0
type: Comment
has text: ok, and what if my click handler is into a different class extarnal to the frame?
comment on: http://stackoverflow.com/a/573321
type: AnswerComment

http://stackoverflow.com/a/387605
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/387417
type: Answer
has body: >Should I create a PreparedStatement for the var SQL and nest it inside of SQL2 No >Or should there be multiple PreparedStatements based on SQL2 without nesting Yes Furthermore: If you could create one string per query that would be better. I don't really like to mix SQL with code. It makes it harder to debug and to understand, you can't copy/paste to a SQL tool to test it easily. By separating the SQL from your code you'll isolate your query from the operation ( the actual fetch ) and it would be easier to maintain. Plus if the code is not yours it will be a lot easier to understand. It doesn't matter it looks like your're repeating strings, the point would be to simplify the statements as much as possible. I would do something like this: final class DatabaseQueries { public final static String SOME_SCENARIO = "SELECT z WHERE x &gt; y JOIN A, B "; public final static String SOME_OTHER_SCENARIO = "SELECT z WHERE x &lt;= y JOIN A, B"; } And then use it from your class: PreparedStatement pstmt = getCon().prepareStatement( getQuery() ); private String getQuery() { if( x != null ) { return DatabaseQueries.SOME_SCENARIO; } else { return DatabaseQueries.SOME_OTHER_SCENARIO; } } While creating the class "DatabaseQueries" you'll find you're repeating a lot of strings, I think it would be fine to susbtitute some part with other constants. final class DataBaseQueries { // this one is private private final static String JOIN_A_B = " join A, B "; public final static String SOME_SCENARIO = "SELECT z WHERE x &gt; y " + JOIN_A_B ; public final static String SOME_OTHER_SCENARIO = "SELECT z WHERE x &lt;= y " + JOIN_A_B ; } The point here is to make things simpler. This is the first step. In a second step you can create a class to create those queries that are really really complex, but probably YAGNI. If the queries are too much you can replace it to load them from a ResourceBundle like in this question I hope this helps.
accepted answer of: http://stackoverflow.com/q/387417
score: 4
downvote count: 0
upvote count: 4

http://stackoverflow.com/a/476770
score: 1
answers question: http://stackoverflow.com/q/476576
upvote count: 1
has body: Or, more concisely: output.print((char)M); This assumes M is a numeric value representing an ASCII character from 0-127 (or an ISO 8859-1 character from 0-255, or a Unicode character from 0-65535). It also assumes output is a PrintWriter or PrintStream, one of which is System.out (a FileOutputStream is easily wrapped by a PrintOutputStream, or PrintWriter(new OutputStreamWriter)).
downvote count: 0
type: Answer

http://stackoverflow.com/comment/21074444
score: 0
type: Comment
comment on: http://stackoverflow.com/a/12330628
type: AnswerComment
has text: Interesting hack, i am wondering if there any overall disadvantages from doing this apart from been inconsistent with the general consensus that EJB and Spring work through transactional proxies and thus transaction annotations etc. are ignored in local method calls, which obviously affects the design

http://stackoverflow.com/q/646288
accepted answer: http://stackoverflow.com/a/646302
score: 7
tagged with: java
has answer: http://stackoverflow.com/a/646320
type: Question
answer count: 2
downvote count: 0
tagged with: jlist
upvote count: 7
possible better answer: http://stackoverflow.com/a/646320
favorite count: 0
tagged with: swing
has title: Why do JList selections occur twice?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/646302
has body: I have a JList with some items. I've added a listener for when a item in the list is selected. Here is the code for what happens when an item in the list is selected: private void questionaireNamesListValueChanged(ListSelectionEvent evt) { try { inputPanel.setEnabled(false); inputPanel.setVisible(false); inputTextField.setText(""); inputStatusLabel.setText(""); int questionaireIndex = questionaireNamesList.getSelectedIndex(); // Why will this be printed twice? System.out.println("Questionaire Index: " + questionaireIndex); if (remoteQuestionServer.getQuestionCount(questionaireIndex) == 5) { answerQuestionButton.setEnabled(true); addQuestionButton.setEnabled(false); } else { addQuestionButton.setEnabled(true); answerQuestionButton.setEnabled(false); } } catch (RemoteException ex) { ex.printStackTrace(); } } As you can above I put a System.out.print statement in and every time I click on something in the list I get two ouputs for that item, eg. Questionaire Index: 4 Questionaire Index: 4 Questionaire Index: 2 Questionaire Index: 2 Questionaire Index: 0 Questionaire Index: 0 Questionaire Index: 2 Questionaire Index: 2 Any idea why this is happening? Thanks, Patrick

http://stackoverflow.com/a/33957727
has comment: http://stackoverflow.com/comment/124687997
answers question: http://stackoverflow.com/q/623892
has body: Apache's commons collections: org.apache.commons.collections4.trie.PatriciaTrie
type: Answer
downvote count: 1
score: 1
upvote count: 2

http://stackoverflow.com/a/385433
upvote count: 5
score: 4
type: Answer
has body: I'm fond of using Ant with Ivy. Ivy uses Maven repositories to fetch library dependencies without forcing you to change your entire build system to suit Maven.
downvote count: 1
answers question: http://stackoverflow.com/q/385401

http://stackoverflow.com/q/368194
type: Question
upvote count: 2
answer count: 2
tagged with: tablelayout
tagged with: jscrollpane
tagged with: jtextarea
has answer: http://stackoverflow.com/a/368246
favorite count: 0
has answer: http://stackoverflow.com/a/368294
has title: Java JFrame: howto parse recursively through componets (i.e. if using JScrollPane)
accepted answer: http://stackoverflow.com/a/368294
tagged with: swing
type: AnsweredQuestion
score: 2
downvote count: 0
possible better answer: http://stackoverflow.com/a/368246
has body: I'm using TableLayout for my swing GUI. Initially only some basic labels, buttons and text fields where required which I could later on access by: public Component getComponent(String componentName) { return getComponent(componentName, this.frame.getContentPane()); } private Component getComponent(String componentName, Component component) { Component found = null; if (component.getName() != null &amp;&amp; component.getName().equals(componentName)) { found = component; } else { for (Component child : ((Container) component).getComponents()) { found = getComponent(componentName, child); if (found != null) break; } } return found; } Unfortunately I ran into issues after using using JScrollPane to support scrolling in JTextArea and JTable's, which I did with: JTextArea ta = new JTextArea(); ta.setName("fooburg"); JScrollPane scr = new JScrollPane(ta); frame.getContentPane().add(scr, "1, 1"); // EDIT: changed, tkx bruno After suggestions, I've been able to access through getComponent("fooburg") the desired component (the version above is the final one). Many thanks to Dan and Bruno!
tagged with: java

http://stackoverflow.com/q/475655
has answer: http://stackoverflow.com/a/475706
has answer: http://stackoverflow.com/a/475981
downvote count: 0
possible better answer: http://stackoverflow.com/a/475706
favorite count: 0
has title: Is there a way for reading/writing serializable objects to a RandomAccesFile?
has body: How can I read/write serializable object instances to a RandomAccessFile in Java? I want to be able to do this the same way you do it in c++ through structs. In java only ObjectInputStreams/ObjectOutputStreamscan can read/Write objects. I am amazed Java does not have something already implemented.
tagged with: serialization
answer count: 3
has answer: http://stackoverflow.com/a/475704
accepted answer: http://stackoverflow.com/a/475981
upvote count: 3
type: AnsweredQuestion
score: 3
tagged with: java
type: Question

http://stackoverflow.com/comment/80187996
comment on: http://stackoverflow.com/q/415580
type: Comment
type: QuestionComment
has text: @tchrist In 2009 there was no JDK7.
score: 3

http://stackoverflow.com/comment/201351
type: QuestionComment
has text: I'm assuming this is all because you can't create generic arrays. Have you considered using an ArrayList<T> instead?
score: 0
comment on: http://stackoverflow.com/q/372250
type: Comment

ide
tags question: http://stackoverflow.com/q/456409
tags question: http://stackoverflow.com/q/474725
tag name: ide
tags question: http://stackoverflow.com/q/369889
tags question: http://stackoverflow.com/q/574756
tags question: http://stackoverflow.com/q/399760
tags question: http://stackoverflow.com/q/646431
type: Tag
tags question: http://stackoverflow.com/q/478883
tags question: http://stackoverflow.com/q/426163
tags question: http://stackoverflow.com/q/461255
tags question: http://stackoverflow.com/q/374900
tags question: http://stackoverflow.com/q/625076
tags question: http://stackoverflow.com/q/376765
tags question: http://stackoverflow.com/q/643346
tags question: http://stackoverflow.com/q/552332
tags question: http://stackoverflow.com/q/381680

http://stackoverflow.com/a/582451
upvote count: 2
answers question: http://stackoverflow.com/q/582352
type: Answer
has comment: http://stackoverflow.com/comment/53753206
downvote count: 1
has comment: http://stackoverflow.com/comment/121055305
score: 1
has body: Sorry, got it right now using a XMLSerializer instead of the Transformer...

http://stackoverflow.com/comment/11406849
type: Comment
has text: Instead of asserting that '% coverage' never goes down, you can assert that "number of uncovered lines" never goes up. If you could assert such a thing. Which you can't. Wheee.
comment on: http://stackoverflow.com/a/389696
score: 1
type: AnswerComment

http://stackoverflow.com/comment/29723884
type: Comment
has text: Leaving a link to my explanation on why `==` works the way it does on Objects: http://stackoverflow.com/a/19966154/2284641
score: 0
comment on: http://stackoverflow.com/q/513832
type: QuestionComment

http://stackoverflow.com/a/65095101
upvote count: 3
downvote count: 0
has body: Here a possible printing function: public static void printArray (int [] array){ System.out.print(&quot;{ &quot;); for (int i = 0; i &lt; array.length; i++){ System.out.print(&quot;[&quot; + array[i] + &quot;] &quot;); } System.out.print(&quot;}&quot;); } For example, if main is like this public static void main (String [] args){ int [] array = {1, 2, 3, 4}; printArray(array); } the output will be { [1] [2] [3] [4] }
answers question: http://stackoverflow.com/q/409784
type: Answer
score: 3

http://stackoverflow.com/q/460446
has answer: http://stackoverflow.com/a/460488
has answer: http://stackoverflow.com/a/1007046
tagged with: vtable
has answer: http://stackoverflow.com/a/460511
favorite count: 0
answer count: 6
tagged with: virtual
type: Question
score: 20
has answer: http://stackoverflow.com/a/5823175
downvote count: 1
has body: How do the virtual functions work in C# and Java? Does it use same vtable and vpointer concept similar to C++ or is it something totally different?
has answer: http://stackoverflow.com/a/460464
tagged with: java
upvote count: 21
has comment: http://stackoverflow.com/comment/69188063
has answer: http://stackoverflow.com/a/17726937
tagged with: c#
type: UnansweredQuestion
has title: How do virtual functions work in C# and Java?

http://stackoverflow.com/a/518944
downvote count: 0
score: 16
type: Answer
has comment: http://stackoverflow.com/comment/575553
has comment: http://stackoverflow.com/comment/575536
answers question: http://stackoverflow.com/q/518936
upvote count: 16
has body: I would store them in one large ArrayList and worry about (possibly unnecessary) optimisations later on. Being inherently lazy, I don't think it's a good idea to optimise unless there's a demonstrated need. Otherwise, you're just wasting effort that could be better spent elsewhere. In fact, if you can set an upper bound to your word count and you don't need any of the fancy List operations, I'd opt for a normal (native) array of string objects with an integer holding the actual number. This is likely to be faster than a class-based approach. This gives you the greatest speed in accessing the individual elements whilst still retaining the ability to do all that wonderful string manipulation. Note I haven't benchmarked native arrays against ArrayLists. They may be just as fast as native arrays, so you should check this yourself if you have less blind faith in my abilities than I do :-). If they do turn out to be just as fast (or even close), the added benefits (expandability, for one) may be enough to justify their use.
has comment: http://stackoverflow.com/comment/575503

java
tags question: http://stackoverflow.com/q/521407
tags question: http://stackoverflow.com/q/373518
tags question: http://stackoverflow.com/q/522395
tags question: http://stackoverflow.com/q/524622
tags question: http://stackoverflow.com/q/407506
tags question: http://stackoverflow.com/q/628049
tags question: http://stackoverflow.com/q/635935
tags question: http://stackoverflow.com/q/381546
tags question: http://stackoverflow.com/q/543896
tags question: http://stackoverflow.com/q/545082
tags question: http://stackoverflow.com/q/443730
tags question: http://stackoverflow.com/q/561107
tags question: http://stackoverflow.com/q/416500
tags question: http://stackoverflow.com/q/545258
tags question: http://stackoverflow.com/q/491812
tags question: http://stackoverflow.com/q/455255
tags question: http://stackoverflow.com/q/545194
tags question: http://stackoverflow.com/q/615948
tags question: http://stackoverflow.com/q/609002
tags question: http://stackoverflow.com/q/453960
tags question: http://stackoverflow.com/q/473685
tags question: http://stackoverflow.com/q/385088
tags question: http://stackoverflow.com/q/631066
tags question: http://stackoverflow.com/q/635301
tags question: http://stackoverflow.com/q/555831
tags question: http://stackoverflow.com/q/623892
tags question: http://stackoverflow.com/q/504441
tags question: http://stackoverflow.com/q/393510
tags question: http://stackoverflow.com/q/613175
tags question: http://stackoverflow.com/q/646990
tags question: http://stackoverflow.com/q/593671
tags question: http://stackoverflow.com/q/401598
tags question: http://stackoverflow.com/q/595130
tags question: http://stackoverflow.com/q/424696
tags question: http://stackoverflow.com/q/589145
tags question: http://stackoverflow.com/q/477965
tags question: http://stackoverflow.com/q/560708
tags question: http://stackoverflow.com/q/487126
tags question: http://stackoverflow.com/q/627769
tags question: http://stackoverflow.com/q/562018
tags question: http://stackoverflow.com/q/539668
tags question: http://stackoverflow.com/q/425039
tags question: http://stackoverflow.com/q/380639
tags question: http://stackoverflow.com/q/525100
tags question: http://stackoverflow.com/q/426005
tags question: http://stackoverflow.com/q/406963
tags question: http://stackoverflow.com/q/483054
tags question: http://stackoverflow.com/q/505172
tags question: http://stackoverflow.com/q/377924
tags question: http://stackoverflow.com/q/401748
tags question: http://stackoverflow.com/q/615257
tags question: http://stackoverflow.com/q/409173
tags question: http://stackoverflow.com/q/531451
tags question: http://stackoverflow.com/q/437756
tags question: http://stackoverflow.com/q/494171
tags question: http://stackoverflow.com/q/507602
tags question: http://stackoverflow.com/q/546097
tags question: http://stackoverflow.com/q/534494
tags question: http://stackoverflow.com/q/471932
tags question: http://stackoverflow.com/q/588242
tags question: http://stackoverflow.com/q/498534
tags question: http://stackoverflow.com/q/475655
tags question: http://stackoverflow.com/q/546365
tags question: http://stackoverflow.com/q/636172
tags question: http://stackoverflow.com/q/576253
tags question: http://stackoverflow.com/q/519807
tags question: http://stackoverflow.com/q/497893
tags question: http://stackoverflow.com/q/473401
tags question: http://stackoverflow.com/q/416004
tags question: http://stackoverflow.com/q/601804
tags question: http://stackoverflow.com/q/484355
tags question: http://stackoverflow.com/q/510270
tags question: http://stackoverflow.com/q/538579
tags question: http://stackoverflow.com/q/548502
tags question: http://stackoverflow.com/q/580269
tags question: http://stackoverflow.com/q/609293
tags question: http://stackoverflow.com/q/380952
tags question: http://stackoverflow.com/q/589838
tags question: http://stackoverflow.com/q/622375
tags question: http://stackoverflow.com/q/538870

http://stackoverflow.com/a/570244
has comment: http://stackoverflow.com/comment/3384515
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/570218
has comment: http://stackoverflow.com/comment/381742
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/381921
has body: Most surefire bet: download the source and run Javadoc over it yourself, and stick it on an internal web server. (FWIW - I can't reach their javadocs from my internal network right now either.)
has comment: http://stackoverflow.com/comment/382105
has comment: http://stackoverflow.com/comment/381901

http://stackoverflow.com/q/600651
answer count: 10
upvote count: 15
has answer: http://stackoverflow.com/a/600659
has answer: http://stackoverflow.com/a/600663
tagged with: http://stackoverflow.com/tag/c
has answer: http://stackoverflow.com/a/600664
tagged with: pointers
possible better answer: http://stackoverflow.com/a/600694
has answer: http://stackoverflow.com/a/600694
has answer: http://stackoverflow.com/a/600667
has answer: http://stackoverflow.com/a/600717
type: AnsweredQuestion
has title: What is the difference between passing by reference in Java and passing a pointer in C?
downvote count: 0
favorite count: 0
type: Question
has body: I have been studying Java for a few months and am now starting to learn C. I am a little confused, I was under the impression that passing an object by reference and passing a pointer to that object were the same thing: I thought the difference was that in Java all passing of objects is done with pointers automatically, where as in C one has to actually sprinkle little asterisks and ampersands here and there. Recently, in conversation, I was assured that there was a difference! What is the difference between passing by reference and passing a pointer?
tagged with: pass-by-reference
accepted answer: http://stackoverflow.com/a/600667
score: 15
has answer: http://stackoverflow.com/a/6628716
has answer: http://stackoverflow.com/a/600666
tagged with: java
has answer: http://stackoverflow.com/a/600662
has answer: http://stackoverflow.com/a/600658

http://stackoverflow.com/comment/10915812
score: 16
comment on: http://stackoverflow.com/a/664213
type: AnswerComment
type: Comment
has text: This is exactly the reverse, AES is a subset of Rijndael

http://stackoverflow.com/comment/87050556
comment on: http://stackoverflow.com/a/38814972
has text: create-drop is contradicted when compare "Explanation of the behaviour" and "Important Points" statements.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/15257046
has text: I'm surprised that the built-in Java ISO-8859-1 encoding doesn't automatically convert that one from UTF, since the glyph exists in both.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/631786
type: Comment

http://stackoverflow.com/a/75229823
score: 0
answers question: http://stackoverflow.com/q/388461
type: Answer
has comment: http://stackoverflow.com/comment/133462604
has body: Writing your own function for this is probably simpler than other answers. private static String padRight(String str, String padChar, int n) { String paddedString = str; while (paddedString.length() &lt; n) { paddedString = padChar + str; } return paddedString; } private static String padLeft(String str, String padChar, int n) { String paddedString = str; while (paddedString.length() &lt; n) { paddedString += padChar; } return paddedString; }
has comment: http://stackoverflow.com/comment/135488378

http://stackoverflow.com/a/9793645
downvote count: 0
type: Answer
upvote count: 2
has body: The clojure collections (map, set, list, vector) can all be nested and are immutable by default. For pure java, there is this library: http://code.google.com/p/pcollections/
answers question: http://stackoverflow.com/q/415967
score: 2

http://stackoverflow.com/comment/307394
comment on: http://stackoverflow.com/a/488184
type: AnswerComment
type: Comment
score: 1
has text: The DAOs communicate with the web services. DAO is just a pattern - an object that retrieves another - so it's just as valid for them to connect to a SQL database as it as a web service.

http://stackoverflow.com/a/499551
type: Answer
has body: If you read this post from the android-developer mailing list you can see that android.provider.Telephony is part of the Open Source releases, but never included as part of the Official SDK. Meaning you are free to view it, to gain a understanding of how the underlying system works, but you can't actually reference and compile against it in your Android application(s).
score: 5
has comment: http://stackoverflow.com/comment/7670065
answers question: http://stackoverflow.com/q/499528
upvote count: 5
downvote count: 0

http://stackoverflow.com/a/18955785
answers question: http://stackoverflow.com/q/363681
has body: I think this code will work for it. Please try this: import java.util.Random; public final class RandomNumber { public static final void main(String... aArgs) { log("Generating 10 random integers in range 1..10."); int START = 1; int END = 10; Random randomGenerator = new Random(); for (int idx=1; idx&lt;=10; ++idx) { // int randomInt=randomGenerator.nextInt(100); // log("Generated : " + randomInt); showRandomInteger(START,END,randomGenerator); } log("Done"); } private static void log(String aMessage) { System.out.println(aMessage); } private static void showRandomInteger(int aStart, int aEnd, Random aRandom) { if (aStart &gt; aEnd) { throw new IllegalArgumentException("Start cannot exceed End."); } long range = (long)aEnd - (long)aStart + 1; long fraction = (long) (range * aRandom.nextDouble()); int randomNumber = (int) (fraction + aStart); log("Generated" + randomNumber); } }
type: Answer
score: 2
downvote count: 3
upvote count: 5

http://stackoverflow.com/a/439496
upvote count: 7
type: AcceptedAnswer
has body: I've worked out where the unwanted conversationId query string parameter is coming from. The &lt;redirect/&gt; results in a call to org.jboss.seam.faces.FacesManager.redirect(String viewId, Map&lt;String, Object&gt; parameters, boolean includeConversationId) This is called from the following code in org.jboss.seam.faces.Navigator which sets includeConversationId to true: FacesManager.instance().redirect(viewId, parameters, true); I cannot see any way to avoid this, so the fix/workaround is to do the redirect programmatically in the action method with: FacesManager.instance().redirect(viewId, parameters, false);
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/431652
score: 7
accepted answer of: http://stackoverflow.com/q/431652

http://stackoverflow.com/a/495204
answers question: http://stackoverflow.com/q/495155
downvote count: 0
type: Answer
score: 1
has body: Also consider using NIO for file copying, as it is likely that you'll get better performance which should be noticable with such a large file: Take a look at this post from JavaLobby, which shows a static file copy method using java.io.FileChannels to do the grunt work.
upvote count: 1

http://stackoverflow.com/a/425652
type: AcceptedAnswer
downvote count: 0
score: 4
has comment: http://stackoverflow.com/comment/249643
type: Answer
has body: I'm pretty sure you can have ANTLR do this for you. The grammatic looks very simple ( from here ) :P
accepted answer of: http://stackoverflow.com/q/425631
answers question: http://stackoverflow.com/q/425631
upvote count: 4

http://stackoverflow.com/q/362972
has answer: http://stackoverflow.com/a/366087
possible better answer: http://stackoverflow.com/a/366116
tagged with: grails
has body: I am new to grails.I am doing web application that uploads the image from client side and it stores that in server. My Gsp code is: &lt;g:uploadForm action="saveImage"&gt; &lt;input type="file" name="image"&gt; &lt;input type="submit" value="Submit"&gt; &lt;/g:uploadForm&gt; My saveImage action in controller is: def saveImage={ def file = request.getFile('image') if (file &amp;&amp; !file.empty) { file.transferTo(new java.io.File("image.jpg")) flash.message = 'Image uploaded' redirect(action: 'uploadImage') } } In this code if i upload some other files like text files it throws Exception.For that i want to check the file Extension and I want to use If loop that ensures the uploaded file is image file or not.But i dont know how to find the file extension in grails. Is there any other way to upload images in grails application.It has to accept only image files. can anyone provide help? thanks.
tagged with: groovy
favorite count: 0
has title: image uploading in grails
accepted answer: http://stackoverflow.com/a/366087
has answer: http://stackoverflow.com/a/9514496
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/22725423
has answer: http://stackoverflow.com/a/11363720
has answer: http://stackoverflow.com/a/366116
type: Question
tagged with: frameworks
downvote count: 0
has answer: http://stackoverflow.com/a/4426671
answer count: 6

http://stackoverflow.com/q/621633
type: Question
has answer: http://stackoverflow.com/a/621639
has body: I used log4j in a java program. I initialized it with : BasicConfigurator.configure(); // logger configuration try { logger.setLevel(Level.DEBUG); } catch (Exception e) { System.out.println("Logfile not found"); } But, during the execution of the program i get 3 log statements instead of one. For example, 3 lines 1047 [main] INFO ibis.Preproc.Ratings - Added AS TIMEZONE to tZones[0] = GMT-12:00 1047 [main] INFO ibis.Preproc.Ratings - Added AS TIMEZONE to tZones[0] = GMT-12:00 1047 [main] INFO ibis.Preproc.Ratings - Added AS TIMEZONE to tZones[0] = GMT-12:00 instead of one line 1047 [main] INFO ibis.Preproc.Ratings - Added AS TIMEZONE to tZones[0] = GMT-12:00 Are there any extra configurations to be done to log4j to avoid this?
accepted answer: http://stackoverflow.com/a/621652
tagged with: log4j
has answer: http://stackoverflow.com/a/621679
has answer: http://stackoverflow.com/a/11545873
answer count: 4
possible better answer: http://stackoverflow.com/a/621679
type: AnsweredQuestion
has title: repeated logging in log 4j in java
score: 0
tagged with: java
has answer: http://stackoverflow.com/a/621652

http://stackoverflow.com/a/522109
has comment: http://stackoverflow.com/comment/335731
has body: There could be dependencies in the code that expect the commit to be done rather than deferred (for example, if the isolation level is set to TRANSACTION_READ_COMMITTED). Consider fixing your transaction manager to do the nested transaction on a separate connection. UPDATE: It looks like the Spring framework uses SavePoints to provide nested transactions. My guess is that they just ignore the issue of isolation mode.
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/335697
upvote count: 2
answers question: http://stackoverflow.com/q/521669
has comment: http://stackoverflow.com/comment/339819
has comment: http://stackoverflow.com/comment/342284
score: 2

http://stackoverflow.com/q/380626
answer count: 3
has answer: http://stackoverflow.com/a/380633
tagged with: parsing
has comment: http://stackoverflow.com/comment/75253877
has answer: http://stackoverflow.com/a/380645
upvote count: 3
type: UnansweredQuestion
has title: How to convert ISO 8601 date (string) to Date?
downvote count: 1
has answer: http://stackoverflow.com/a/44117153
score: 2
has comment: http://stackoverflow.com/comment/9853904
tagged with: java
tagged with: date
type: Question
linked to: http://stackoverflow.com/q/38922754
tagged with: iso8601
has body: I am parsing XML file. In this file there is one tag containing date string "2008-11-10T05:51:33Z" and I want convert this string in to java.util.Date object. How can this be done?
favorite count: 0

http://stackoverflow.com/a/30192904
upvote count: 89
has comment: http://stackoverflow.com/comment/59958817
has comment: http://stackoverflow.com/comment/59958081
has body: Actually, It is not wise to compare Runnable and Thread with each other. This two have a dependency and relationship in multi-threading just like Wheel and Engine relationship of motor vehicle. I would say, there is only one way for multi-threading with two steps. Let me make my point. Runnable: When implementing interface Runnable it means you are creating something which is run able in a different thread. Now creating something which can run inside a thread (runnable inside a thread), doesn't mean to creating a Thread. So the class MyRunnable is nothing but a ordinary class with a void run method. And it's objects will be some ordinary objects with only a method run which will execute normally when called. (unless we pass the object in a thread). Thread: class Thread, I would say A very special class with the capability of starting a new Thread which actually enables multi-threading through its start() method. Why not wise to compare? Because we need both of them for multi-threading. For Multi-threading we need two things: Something that can run inside a Thread (Runnable). Something That can start a new Thread (Thread). So technically and theoretically both of them is necessary to start a thread, one will run and one will make it run (Like Wheel and Engine of motor vehicle). That's why you can not start a thread with MyRunnable you need to pass it to a instance of Thread. But it is possible to create and run a thread only using class Thread because Class Thread implements Runnable so we all know Thread also is a Runnable inside. Finally Thread and Runnable are complement to each other for multithreading not competitor or replacement.
type: Answer
score: 89
downvote count: 0
has comment: http://stackoverflow.com/comment/132695179
answers question: http://stackoverflow.com/q/541487

http://stackoverflow.com/comment/21478885
comment on: http://stackoverflow.com/q/485530
score: 0
has text: Also see [this](http://stackoverflow.com/questions/15219625/how-would-be-implements-autosugesion-in-jtextarea-swing/15220056#15220056) similar answer
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/11998688
comment on: http://stackoverflow.com/a/9479959
has text: hmm ... can't really believe that you can execute a java _source_ file. All that might happen - depending on your local setup - is that an editor/IDE associated with the file extension is fired up :-)
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/367105
answers question: http://stackoverflow.com/q/367104
has comment: http://stackoverflow.com/comment/196415
has comment: http://stackoverflow.com/comment/196410
has comment: http://stackoverflow.com/comment/196427
has body: Did you know you can import Orientation and say MyClass myClass = new MyClass(Orientation.VERTICAL); ?
score: 4
type: Answer
downvote count: 1
upvote count: 5

http://stackoverflow.com/a/638179
upvote count: 42
answers question: http://stackoverflow.com/q/638171
has body: Yes, just add a constructor to Truck. You will probably want to add a constructor to Car also, though not necessarily public: public class Car { protected Car(Car orig) { ... } public class Truck extends Car { public Truck(Car orig) { super(orig); } ... } As a rule it's generally best to make classes either leaf (and you might want to mark those final) or abstract. It looks as if you want a Car object, and then have the same instance turn into a Truck. A better way of doing this is to delegate behaviour to another object within Car (Vehicle). So: public final class Vehicle { private VehicleBehaviour behaviour = VehicleBehaviour.CAR; public void becomeTruck() { this.behaviour = VehicleBehaviour.TRUCK; } ... } If you implement Cloneable then you can "automatically" copy an object to a instance of the same class. However there are a number of problems with that, including having to copy each field of mutable objects which is error-prone and prohibits the use of final.
type: Answer
has comment: http://stackoverflow.com/comment/70239644
has comment: http://stackoverflow.com/comment/70183097
has comment: http://stackoverflow.com/comment/67370729
has comment: http://stackoverflow.com/comment/70311077
has comment: http://stackoverflow.com/comment/70246005
downvote count: 0
score: 42

http://stackoverflow.com/a/604434
upvote count: 1
downvote count: 0
type: Answer
has body: In Object Oriented Software Construction 2 Bertrand Meyer calls this the "Uniform Access Principle" and the general idea is that when a property goes from a simple one (i.e. just an integer) to a derived one (a function call), the people using it shouldn't have to know. You don't want everyone using your code to have to change from int x = foo.y; to int x = foo.y(); That breaks encapsulation because you haven't changed your "interface" just your "implementation".
answers question: http://stackoverflow.com/q/604188
score: 1

http://stackoverflow.com/comment/317423
score: 0
has text: What do you mean by "modify the object cookie"? Are you saying cookie = xxx, or are you actually changing the object itself e.g. cookie.setProperty(xxx)?
comment on: http://stackoverflow.com/q/502256
type: Comment
type: QuestionComment

http://stackoverflow.com/q/362424
favorite count: 0
has answer: http://stackoverflow.com/a/362738
tagged with: anonymous-types
has answer: http://stackoverflow.com/a/362463
has comment: http://stackoverflow.com/comment/87451627
has answer: http://stackoverflow.com/a/26912508
answer count: 10
has answer: http://stackoverflow.com/a/1099898
possible better answer: http://stackoverflow.com/a/362463
has title: Accessing constructor of an anonymous class
tagged with: constructor
has comment: http://stackoverflow.com/comment/41777445
upvote count: 238
accepted answer: http://stackoverflow.com/a/362443
has body: Lets say I have a concrete class Class1 and I am creating an anonymous class out of it. Object a = new Class1(){ void someNewMethod(){ } }; Now is there any way I could overload the constructor of this anonymous class. Like shown below Object a = new Class1(){ void someNewMethod(){ } public XXXXXXXX(int a){ super(); System.out.println(a); } }; With something at xxxxxxxx to name the constructor?
has answer: http://stackoverflow.com/a/2026058
linked to: http://stackoverflow.com/q/20807148
type: AnsweredQuestion
tagged with: overloading
tagged with: java
has answer: http://stackoverflow.com/a/32715815
type: Question
linked to: http://stackoverflow.com/q/5107158
has answer: http://stackoverflow.com/a/10465155
score: 238
downvote count: 0
has answer: http://stackoverflow.com/a/11697472
has answer: http://stackoverflow.com/a/14625945
has answer: http://stackoverflow.com/a/362443

http://stackoverflow.com/comment/102973856
has text: Check that you use the right import statement: `import org.xml.sax.InputSource;`
type: Comment
score: 2
comment on: http://stackoverflow.com/a/562207
type: AnswerComment

http://stackoverflow.com/a/398108
downvote count: 0
type: AcceptedAnswer
has body: I'm sorry, but what you are doing sounds like a big ball o' mud. Doesn't matter to me what path you take, but I'd simplify the architecture by reducing the number of technologies/frameworks that you are using. If you can find a way to do it in Ruby/Rails without reference to Java (although you may need to keep the C++ client-side), that would work. Obviously, working in .NET (my preferred platform) is another choice. Windows Communication Foundation makes it much easier to write web services that are lighter weight than the old ASP.NET web services -- including RESTful web services using JSON. If I were doing it today I'd use ASP.NET MVC for the web front-end, WCF (for web services), and either eliminate the C++ client or consider writing it in C# with .NET or Mono.
upvote count: 2
type: Answer
accepted answer of: http://stackoverflow.com/q/398089
score: 2
answers question: http://stackoverflow.com/q/398089

http://stackoverflow.com/q/467761
tagged with: seek
score: 0
tagged with: java
tagged with: stream
has answer: http://stackoverflow.com/a/467785
type: Question
answer count: 2
has title: Streaming files over the network with random access - java
type: UnansweredQuestion
tagged with: sockets
has answer: http://stackoverflow.com/a/467776
has body: So ive got a need to play music files from a server on the network, in a java client app. I was thinking Sockets - have the server open a music file as a stream, and have the client connect to that and read &amp; play it as an InputStream. Which would work - except AFAICS users wont be able to seek into the file(which they can currently for local Files), because I cant see how the Sockets stream can support that. Any better ideas? Or a way to use the Sockets to seek? JNI? I dont know enough about it to know if it would help. The (totally lame) last resort is to use mapped network drives.

http://stackoverflow.com/a/2457661
answers question: http://stackoverflow.com/q/507391
upvote count: 1
type: Answer
has body: HornetQ looks good. http://www.spec.org/jms2007/results/jms2007.html
downvote count: 0
score: 1

http://stackoverflow.com/q/547622
has comment: http://stackoverflow.com/comment/360191
tagged with: tree
tagged with: recursion
has answer: http://stackoverflow.com/a/548258
has answer: http://stackoverflow.com/a/547649
score: 21
has title: Counting nodes in a tree in Java
has answer: http://stackoverflow.com/a/547640
has comment: http://stackoverflow.com/comment/359482
has answer: http://stackoverflow.com/a/547906
downvote count: 0
has answer: http://stackoverflow.com/a/8442910
has answer: http://stackoverflow.com/a/547722
favorite count: 0
has answer: http://stackoverflow.com/a/547636
has answer: http://stackoverflow.com/a/44336555
has answer: http://stackoverflow.com/a/547637
has comment: http://stackoverflow.com/comment/360154
has comment: http://stackoverflow.com/comment/359753
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/8445377
has comment: http://stackoverflow.com/comment/359454
has answer: http://stackoverflow.com/a/547644
has comment: http://stackoverflow.com/comment/359528
answer count: 15
has answer: http://stackoverflow.com/a/547652
has answer: http://stackoverflow.com/a/36442365
tagged with: java
has body: First of all, I swear this is not homework, it's a question I was asked in an interview. I think I made a mess of it (though I did realise the solution requires recursion). Here is the question: Implement the count() method which returns the number of nodes in a tree. If a node doesn't have either a left or right child, the relevant getXXChild() method will return null class Tree { Tree getRightChild() { // Assume this is already implemented } Tree getLeftChild() { // Assume this is already implemented } int count() { // Implement me } } My reason for asking the question is simply curious to see the correct solution, and thereby measure how bad mine was. Cheers, Tony
upvote count: 21
has answer: http://stackoverflow.com/a/3418307
type: Question
has answer: http://stackoverflow.com/a/547639

http://stackoverflow.com/a/24550034
answers question: http://stackoverflow.com/q/361975
type: Answer
downvote count: 1
score: 7
upvote count: 8
has body: I have tried a lot of things, but the sample code here works perfect. Link The crux of the code is: String s = "एक गाव में एक किसान"; String out = new String(s.getBytes("UTF-8"), "ISO-8859-1");

http://stackoverflow.com/a/466006
type: Answer
answers question: http://stackoverflow.com/q/465953
upvote count: 9
has body: My only problem with the OP's code is that you're mixing paradigms -- doB shows an error by throwing an exception, while doSomething shows an error by returning a code. Ideally, you would pick one or the other. Of course, in legacy maintenance, you might not have that luxury. If you pick returning error codes, that's OK, but I dislike it because it encourages you to use side channels (like global variables) to communicate state on failure, rather than bundling that state into an exception and letting it bubble up the stack until you can do something about it.
downvote count: 0
score: 9

http://stackoverflow.com/comment/86119979
score: 2
has text: @Jack because Java 8 wasn't out yet when the other answer was accepted in 2009.
type: AnswerComment
comment on: http://stackoverflow.com/a/23183963
type: Comment

http://stackoverflow.com/q/405336
tagged with: methods
type: Question
has answer: http://stackoverflow.com/a/16581925
possible better answer: http://stackoverflow.com/a/405348
tagged with: oop
has comment: http://stackoverflow.com/comment/230503
has answer: http://stackoverflow.com/a/405367
has answer: http://stackoverflow.com/a/405348
tagged with: java
has body: Netbeans tells me it's bad to access a static method from a non static method. Why is this bad? "Accessing static method getInstance" is the warning: import java.util.Calendar; public class Clock { // Instance fields private Calendar time; /** * Constructor. Starts the clock at the current operating system time */ public Clock() { System.out.println(getSystemTime()); } private String getSystemTime() { return this.time.getInstance().get(Calendar.HOUR)+":"+ this.time.getInstance().get(Calendar.MINUTE); } }
accepted answer: http://stackoverflow.com/a/405366
answer count: 7
has title: Why is accessing a static method from a non-static method bad?
has answer: http://stackoverflow.com/a/3359663
score: 4
favorite count: 0
tagged with: static
has answer: http://stackoverflow.com/a/405366
has answer: http://stackoverflow.com/a/405465
upvote count: 4
has comment: http://stackoverflow.com/comment/230473
type: AnsweredQuestion
downvote count: 0
has comment: http://stackoverflow.com/comment/230463
has answer: http://stackoverflow.com/a/405349

http://stackoverflow.com/q/562273
answer count: 19
downvote count: 2
upvote count: 10
has comment: http://stackoverflow.com/comment/373706
has answer: http://stackoverflow.com/a/4197882
score: 8
favorite count: 0
has answer: http://stackoverflow.com/a/4376425
has comment: http://stackoverflow.com/comment/373460
has answer: http://stackoverflow.com/a/7974929
tagged with: javasound
possible better answer: http://stackoverflow.com/a/695562
has answer: http://stackoverflow.com/a/562434
has answer: http://stackoverflow.com/a/562393
accepted answer: http://stackoverflow.com/a/562393
has answer: http://stackoverflow.com/a/563343
tagged with: audio
has answer: http://stackoverflow.com/a/695562
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/563735
has title: What output and recording ports does the Java Sound API find on your computer?
has comment: http://stackoverflow.com/comment/375219
tagged with: java
has body: I'm working with the Java Sound API, and it turns out if I want to adjust recording volumes I need to model the hardware that the OS exposes to Java. Turns out there's a lot of variety in what's presented. Because of this I'm humbly asking that anyone able to help me run the following on their computer and post back the results so that I can get an idea of what's out there. A thanks in advance to anyone that can assist :-) import javax.sound.sampled.*; public class SoundAudit { public static void main(String[] args) { try { System.out.println("OS: "+System.getProperty("os.name")+" "+ System.getProperty("os.version")+"/"+ System.getProperty("os.arch")+"\nJava: "+ System.getProperty("java.version")+" ("+ System.getProperty("java.vendor")+")\n"); for (Mixer.Info thisMixerInfo : AudioSystem.getMixerInfo()) { System.out.println("Mixer: "+thisMixerInfo.getDescription()+ " ["+thisMixerInfo.getName()+"]"); Mixer thisMixer = AudioSystem.getMixer(thisMixerInfo); for (Line.Info thisLineInfo:thisMixer.getSourceLineInfo()) { if (thisLineInfo.getLineClass().getName().equals( "javax.sound.sampled.Port")) { Line thisLine = thisMixer.getLine(thisLineInfo); thisLine.open(); System.out.println(" Source Port: " +thisLineInfo.toString()); for (Control thisControl : thisLine.getControls()) { System.out.println(AnalyzeControl(thisControl));} thisLine.close();}} for (Line.Info thisLineInfo:thisMixer.getTargetLineInfo()) { if (thisLineInfo.getLineClass().getName().equals( "javax.sound.sampled.Port")) { Line thisLine = thisMixer.getLine(thisLineInfo); thisLine.open(); System.out.println(" Target Port: " +thisLineInfo.toString()); for (Control thisControl : thisLine.getControls()) { System.out.println(AnalyzeControl(thisControl));} thisLine.close();}}} } catch (Exception e) {e.printStackTrace();}} public static String AnalyzeControl(Control thisControl) { String type = thisControl.getType().toString(); if (thisControl instanceof BooleanControl) { return " Control: "+type+" (boolean)"; } if (t…
has answer: http://stackoverflow.com/a/1337032
has answer: http://stackoverflow.com/a/562402
type: Question
has answer: http://stackoverflow.com/a/1532171
has answer: http://stackoverflow.com/a/2604331
has answer: http://stackoverflow.com/a/1890792
has answer: http://stackoverflow.com/a/563752
has answer: http://stackoverflow.com/a/563330
has answer: http://stackoverflow.com/a/562400
has answer: http://stackoverflow.com/a/1881873
has answer: http://stackoverflow.com/a/4330167
has answer: http://stackoverflow.com/a/562441
has comment: http://stackoverflow.com/comment/374495

http://stackoverflow.com/q/462566
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/462718
downvote count: 0
tagged with: slf4j
possible better answer: http://stackoverflow.com/a/462718
accepted answer: http://stackoverflow.com/a/462671
tagged with: log4j
favorite count: 0
has body: I have some questions about logging, more specifically about setting it up and making sure it works. The project I'm doing will use Wicket, Spring and Hibernate. I know that Wicket and Hibernate uses Simple Logging Facade for Java (SL4J) and that Spring is using the logging component from Apache Commons. Will they co-exist happily? I thought I would use log4j together with both SL4J and the logging component from Apache commons, do you think that's a good idea? Can I set up them all to output logging data into a common file? Or should I use separate files? Or should I store the logging messages in the database? (I'd rather not, as I find grepping etc on text files quite convenient.) For Spring I guess I need some kind of configuration file for the Apache Commons logging component as well where I direct it to use log4j? When I've set these up I guess to see that everything works I set the logging level to INFO as it's fairly certain that all three of the frameworks output some information in that mode? Or is there an even better way to make sure? And my last question. In the project I'm starting, do you recommend that I use SL4J for my own logging purposes? (I thought I would use log4j directly, but that was before I learned a little bit more about logging and a lot of respectable libraries seem to choose the path of a bridge/facade for their logging needs. And if it gets us flexibility without added cost there's no reason not to do it that way.) I'm looking forward to hearing more from you about how you are doing your logging. It's a new area for me which I'm eager to improve myself in.
tagged with: logging
upvote count: 23
type: AnsweredQuestion
tagged with: apache-commons
tagged with: java
has title: Logging using SL4J, Jakarta Commons logging, log4j for third party libraries and my own code
score: 23
has answer: http://stackoverflow.com/a/462671

http://stackoverflow.com/comment/382188
type: AnswerComment
score: 0
type: Comment
has text: +1 for recommending this -- it just might save me on my next project. :)
comment on: http://stackoverflow.com/a/549129

http://stackoverflow.com/comment/138718470
type: Comment
comment on: http://stackoverflow.com/a/32828953
score: 0
type: AnswerComment
has text: I suspect, if your approach works correctly on Windows. As far as I know, the file separator in jar files is always '/', never '\', even on Windows, so `File.separator` would result in the wrong value on Windows.

http://stackoverflow.com/a/1010593
has comment: http://stackoverflow.com/comment/35992219
upvote count: 118
has comment: http://stackoverflow.com/comment/71996533
has body: Maven is a Framework, Ant is a Toolbox Maven is a pre-built road car, whereas Ant is a set of car parts. With Ant you have to build your own car, but at least if you need to do any off-road driving you can build the right type of car. To put it another way, Maven is a framework whereas Ant is a toolbox. If you're content with working within the bounds of the framework then Maven will do just fine. The problem for me was that I kept bumping into the bounds of the framework and it wouldn't let me out. XML Verbosity tobrien is a guy who knows a lot about Maven and I think he provided a very good, honest comparison of the two products. He compared a simple Maven pom.xml with a simple Ant build file and he made mention of how Maven projects can become more complex. I think that its worth taking a look at a comparison of a couple of files that you are more likely to see in a simple real-world project. The files below represent a single module in a multi-module build. First, the Maven file: com.mycompany app-parent 1.0 4.0.0 persist Persistence Layer com.mycompany common compile ${project.version} com.mycompany domain provided ${project.version} org.hibernate hibernate ${hibernate.version} provided commons-lang commons-lang ${commons-lang.version} provided org.springframework spring ${spring.version} provided org.dbunit dbunit 2.2.3 test org.testng testng ${testng.version} test jdk15 commons-dbcp commons-dbcp ${commons-dbcp.version} test com.oracle ojdbc ${oracle-jdbc.version} test org.easymock easymock ${easymock.version} test And the equivalent Ant file: <import file="../build/common-build.xml" /> <pathelement location="${common.jar}" /> <pathelement location="${domain.jar}" /> <pathelement location="${hibernate.jar}" /> <pathelement location="${commons-lang.jar}" /> <pathelement location="${spring.jar}" /> <pathelement location="${classes.dir.main}" /> <pathelement location="${testng.jar}" /> <pathelement location="${dbunit.jar}" /> <pathelement location="${easymock.jar…
type: Answer
score: 118
downvote count: 0
answers question: http://stackoverflow.com/q/603189

http://stackoverflow.com/q/633600
score: 27
has answer: http://stackoverflow.com/a/3289257
has answer: http://stackoverflow.com/a/4193666
answer count: 14
has answer: http://stackoverflow.com/a/5468500
tagged with: java
tagged with: selenium
has answer: http://stackoverflow.com/a/1202096
has title: Selenium click() event seems not to be always triggered => results in timeout?
has answer: http://stackoverflow.com/a/6251469
upvote count: 27
has answer: http://stackoverflow.com/a/646448
has body: Here's what I do: selenium.click("link=mylink"); selenium.waitForPageToLoad(60000); // do something, then navigate to a different page // (window focus is never changed in-between) selenium.click("link=mylink"); selenium.waitForPageToLoad(60000); The link "mylink" does exist, the first invocation of click() always works. But the second click() sometimes seems to work, sometimes not. It looks like the click() event is not triggered at all, because the page doesn't even start to load. Unfortunately this behaviour is underterministic. Here's what I already tried: Set longer time timeout => did not help Wait for an element present after loading one page => doesn't work either since the page does not even start to load For now I ended up invoking click() twice, so: selenium.click("link=mylink"); selenium.waitForPageToLoad(60000); // do something, then navigate to a different page // (window focus is never changed in-between) selenium.click("link=mylink"); selenium.click("link=mylink"); selenium.waitForPageToLoad(60000); That will work, but it's not a really nice solution. I've also seen in another forum where someone suggested to write something like a 'clickAndWaitWithRetry': try { super.click("link=mylink"); super.waitForPageToLoad(60000); } catch (SeleniumException e) { super.click("link=mylink"); super.waitForPageToLoad(60000); } But I think that is also not a proper solution.... Any ideas/explanations why the click() event is sometimes not triggered?
tagged with: timeout
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/648260
has answer: http://stackoverflow.com/a/5175217
has answer: http://stackoverflow.com/a/4866422
has answer: http://stackoverflow.com/a/646684
downvote count: 0
has answer: http://stackoverflow.com/a/5119813
favorite count: 0
has comment: http://stackoverflow.com/comment/18645782
has answer: http://stackoverflow.com/a/2683569
type: Question
has answer: http://stackoverflow.com/a/6534710
has answer: http://stackoverflow.com/a/2141490

http://stackoverflow.com/a/640373
has body: I think you'll like MyEclipse IDE. Ain't free but IMHO it's worth it.
downvote count: 1
answers question: http://stackoverflow.com/q/640161
type: Answer
upvote count: 0
has comment: http://stackoverflow.com/comment/137760269
score: -1

http://stackoverflow.com/comment/17718790
type: AnswerComment
type: Comment
score: 2
has text: +1, though I disagree on Network Failure: There are enough layers that are capable of detecting errors before the parser is involved, and even if they fail, the parser would only detect those few errors that destroy xml-well-formedness (basically: messing up a <, >, =, ', or a tag name).
comment on: http://stackoverflow.com/a/562945

http://stackoverflow.com/a/559525
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/42284184
has comment: http://stackoverflow.com/comment/42283564
type: Answer
has comment: http://stackoverflow.com/comment/373510
score: 24
upvote count: 24
downvote count: 0
accepted answer of: http://stackoverflow.com/q/559510
has comment: http://stackoverflow.com/comment/55155752
answers question: http://stackoverflow.com/q/559510
has body: You should check out Jazzy its used in some high profile Java applications. Two problems with it: It has not been updated since 2005. There is only English dictionary on their SourceForge page. There are some third party dictionaries floating around. I had one for French, last time I used jazzy.

http://stackoverflow.com/comment/3760381
score: 2
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/494507
has text: Note that this is not necessarily sufficient. For example even with this flag I get the following stack trace for a program which tries to use a JFrame: Exception in thread "main" java.awt.HeadlessException at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159) at java.awt.Window.<init>(Window.java:431) at java.awt.Frame.<init>(Frame.java:403) at javax.swing.JFrame.<init>(JFrame.java:207)

http://stackoverflow.com/q/606145
downvote count: 0
type: UnansweredQuestion
tagged with: java
type: Question
upvote count: 2
has title: JibX: how to output the fields from a particular class into different parts of the XML
favorite count: 0
has body: I've managed to get what I want when mapping with inheritance like this: ThisClassShouldntExist freeFlowMsg errorMsg BaseForm extends ThisClassShouldntExist function subFunction SpecificForm extends BaseForm address My binding.xml: <value name="free-flow-message" field="freeFlowMessage" /> <value name="error-msg" field="errorMessage" /> <value name="prog-name" field="function" /> <value name="sub-prog-name" field="subFunction" /> <value name="address" field="addressline1" usage="optional"/> A sample data: <?xml version="1.0" encoding="UTF-8"?> prog-name sub-prog-name address free-flow-message error-msg So, the bottom line is that I need to "split" the output of the class BaseForm into 2 different part of the XML output. First part goes into , second into , but also I want to avoid the inheritance just to comply with JibX. I tried doing something like this but didn't work: Also tried to define 2 in the same binding for the same class, but of course it wouldn't work.
tagged with: http://stackoverflow.com/tag/xml
tagged with: data-binding
score: 2
answer count: 0

http://stackoverflow.com/comment/190110
has text: Indeed it does if you set the ENABLEDELAYEDEXPANSION variable as described above (I forgot to add it initially, hence the edit) - just tested it seconds ago.
type: Comment
comment on: http://stackoverflow.com/a/359242
type: AnswerComment
score: 0

http://stackoverflow.com/q/480261
has answer: http://stackoverflow.com/a/4480209
accepted answer: http://stackoverflow.com/a/4480209
tagged with: swing
possible better answer: http://stackoverflow.com/a/7423782
type: Question
has title: Java Swing: Mouseover text on JComboBox items?
has answer: http://stackoverflow.com/a/480287
has answer: http://stackoverflow.com/a/480342
has body: In Swing, is there a way to define mouseover text (or tool tip text) for each item in a JComboBox?
score: 20
has answer: http://stackoverflow.com/a/7423782
favorite count: 0
answer count: 5
has answer: http://stackoverflow.com/a/480310
type: AnsweredQuestion
upvote count: 20
downvote count: 0
tagged with: java

http://stackoverflow.com/comment/21824216
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/480463
has text: And what if this external process hangs, process.destroy will never be able to kill it, in linux you can send a SIGINT but then it will kill the whole program not just this process, launching something which is not tested, might be on the safe side to launch in altogether a new process unless there is a way to kill this particular process. or if there is then tell me, i laucnh e.g nslookup and then there is no way to kill it, (except the quit) so how can you really kill the process if it hangs??
score: 0

http://stackoverflow.com/q/595130
tagged with: intellij-idea
possible better answer: http://stackoverflow.com/a/28385747
has answer: http://stackoverflow.com/a/595195
upvote count: 2
answer count: 2
has body: A friend is just starting to learn Java, using IntelliJ. He asks how can he set up some template so creating a new project will contain a default main class. Currently, when he creates a new project, it has no source files, and he has to add a Run/Debug application configuration manually, and then select the main class.
favorite count: 0
tagged with: projects-and-solutions
has answer: http://stackoverflow.com/a/28385747
score: 2
type: AnsweredQuestion
has title: Configuring IntelliJ IDEA to create main class for new projects
downvote count: 0
tagged with: java
accepted answer: http://stackoverflow.com/a/595195
type: Question

http://stackoverflow.com/a/664740
answers question: http://stackoverflow.com/q/457463
type: Answer
has body: You need to create a subclass of JTable to override the method TableCellEditor getCellEditor(int row, int column). This enables you to set arbitrary cell editors for any row and column combination. The default way is to set the cell editor for an entire column. (You can also set individual cell renderers by overriding getCellRenderer.)
score: 0

http://stackoverflow.com/comment/6353621
has text: I think Joda's pretty much standard nowadays :-)
score: 1
comment on: http://stackoverflow.com/a/453393
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/279144
comment on: http://stackoverflow.com/a/459507
score: 0
type: Comment
has text: I've never see that, but I have tried the no action thing in various browsers and they all behave the same way. It probably depends on how qualified the action parameter is...
type: AnswerComment

http://stackoverflow.com/comment/36581553
score: 1
has text: A thing that i've had noticed is that if I change the column type into the model, the same column on database is not changed with **update**
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/1689769

http://stackoverflow.com/comment/203164
score: 0
type: Comment
comment on: http://stackoverflow.com/a/371326
type: AnswerComment
has text: I like this answer, is there any advantage to extending CalendarType verses TimestampType?

http://stackoverflow.com/comment/3266670
type: Comment
has text: Sounds interesting, do you have already s.th. to have a look at / to try? Cheers, Martin
comment on: http://stackoverflow.com/a/2239227
type: AnswerComment
score: 0

http://stackoverflow.com/q/602749
accepted answer: http://stackoverflow.com/a/603324
tagged with: java
tagged with: hibernate
possible better answer: http://stackoverflow.com/a/602941
type: Question
answer count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/417132
has comment: http://stackoverflow.com/comment/418157
has answer: http://stackoverflow.com/a/602941
favorite count: 0
has comment: http://stackoverflow.com/comment/415136
upvote count: 1
has comment: http://stackoverflow.com/comment/415184
type: AnsweredQuestion
has title: Using a NamedQuery with a composite class
has body: I have the following class defined in my mapping XML file: <column name="COUNTRY_CODE" /> <column name="STATE" /> I am trying to define a NameQuery for this class. What I tried was: from com.data.StateRefData WHERE primaryKey = :primaryKey The Java code that I use to call this is: Query stateQuery = null; List<StateRefData> stateList = null; StateRefPkData primaryKey = new StateRefPkData(); StateRefData filter = new StateRefData(); primaryKey.setCountryCode(inCountryCode); primaryKey.setState(inStateProvince); filter.setPrimaryKey(primaryKey); stateQuery = session.getNamedQuery("findState"); stateQuery.setProperties(filter); However, I get these errors right at the "stateQuery.list()" part: [ERROR JDBCExceptionReporter:72] Line 1: Incorrect syntax near ','. org.hibernate.exception.SQLGrammarException: could not execute query at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.doList(Loader.java:1596) at org.hibernate.loader.Loader.list(Loader.java:1577) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74) Any idea on how to use a NamedQuery with a composite? Note: I have also tried doing: stateQuery.setParameter("primaryKey", primaryKey); and it still has the error. New (edited): Here is the HQL and SQL that happens when I execute the code: [DEBUG AST:223] --- HQL AST --- \-[QUERY] 'query' +-[SELECT_FROM] 'SELECT_FROM' | \-[FROM] 'from' | \-[RANGE] 'RANGE' | +-[DOT] '.' | | +-[DOT] '.' | | | +-[DOT] '.' | | | | +-[DOT] '.' | | | | | +-[IDENT] 'com' | | | \-[IDENT] 'data' | | \-[IDENT] 'StateRefData' | \-[ALIAS] 'd' \-[WHERE] 'WHERE' \-[EQ] '=' +-[DOT] '.' | +-[IDENT] 'd' | \-[IDENT] 'primaryKey' \-[COLON] ':' \-[IDENT]…
has answer: http://stackoverflow.com/a/603324
score: 1

http://stackoverflow.com/a/20476490
score: 3
upvote count: 3
has body: I just wrote a util class, it include test methods, you can have a check ~ IteratePackageUtil.java: package eric.j2se.reflect; import java.util.Set; import org.reflections.Reflections; import org.reflections.scanners.ResourcesScanner; import org.reflections.scanners.SubTypesScanner; import org.reflections.util.ClasspathHelper; import org.reflections.util.ConfigurationBuilder; import org.reflections.util.FilterBuilder; /** * an util to iterate class in a package, * * @author eric * @date Dec 10, 2013 12:36:46 AM */ public class IteratePackageUtil { /** * &lt;p&gt; * Get set of all class in a specified package recursively. this only support lib * &lt;/p&gt; * &lt;p&gt; * class of sub package will be included, inner class will be included, * &lt;/p&gt; * &lt;p&gt; * could load class that use the same classloader of current class, can't load system packages, * &lt;/p&gt; * * @param pkg * path of a package * @return */ public static Set&lt;Class&lt;? extends Object&gt;&gt; getClazzSet(String pkg) { // prepare reflection, include direct subclass of Object.class Reflections reflections = new Reflections(new ConfigurationBuilder().setScanners(new SubTypesScanner(false), new ResourcesScanner()) .setUrls(ClasspathHelper.forClassLoader(ClasspathHelper.classLoaders(new ClassLoader[0]))) .filterInputsBy(new FilterBuilder().includePackage(pkg))); return reflections.getSubTypesOf(Object.class); } public static void test() { String pkg = "org.apache.tomcat.util"; Set&lt;Class&lt;? extends Object&gt;&gt; clazzSet = getClazzSet(pkg); for (Class&lt;? extends Object&gt; clazz : clazzSet) { System.out.println(clazz.getName()); } } public static void main(String[] args) { test(); } }
answers question: http://stackoverflow.com/q/520328
downvote count: 0
type: Answer

http://stackoverflow.com/a/498073
upvote count: 3
downvote count: 0
type: Answer
score: 3
has body: Probably you can workaround Robot lack of ability to know the borders of the window, by allowing the user to select the area he wants to screen shot. You have two approaches, if the option is fullscreen you don't need to worry, follow the Robot approach described before. If the applicatin is for desired area: Start desired application. Take a full screen of the desktop. Create a full screen app using the screenshot as the background, ONLY to allow the user to select the area where to capture the image ( you start with an small square and let the user drag until he creates the desired screen capture ) Pass this information to Robot and take the screenshots from that area. Something like this: alt text http://img136.imageshack.us/img136/8622/screencapturebb3.png If you don't like the option to use a full screenshot as background, you can use a transparent window. And do the same : - ) Aaahhh second option is to try to identify borders analyzing the images, but honestly , I don't think it worth it. There's a third option, but is a secret.
has comment: http://stackoverflow.com/comment/28616004
has comment: http://stackoverflow.com/comment/28603582
answers question: http://stackoverflow.com/q/464593

http://stackoverflow.com/comment/12638858
type: Comment
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/6695906
has text: Thanks for catching this, mzjn. I was actually looking for both, and got them mixed up. I've removed the accepted answer flag from my own answer.

http://stackoverflow.com/q/366658
has answer: http://stackoverflow.com/a/373038
accepted answer: http://stackoverflow.com/a/467683
has answer: http://stackoverflow.com/a/366776
favorite count: 0
tagged with: memory-management
has comment: http://stackoverflow.com/comment/254086
has comment: http://stackoverflow.com/comment/201975
has comment: http://stackoverflow.com/comment/201584
type: AnsweredQuestion
score: 22
has comment: http://stackoverflow.com/comment/207668
tagged with: java
has comment: http://stackoverflow.com/comment/207263
has body: Does Java 6 consume more memory than you expect for largish applications? I have an application I have been developing for years, which has, until now taken about 30-40 MB in my particular test configuration; now with Java 6u10 and 11 it is taking several hundred while active. It bounces around a lot, anywhere between 50M and 200M, and when it idles, it does GC and drop the memory right down. In addition it generates millions of page faults. All of this is observed via Windows Task Manager. So, I ran it up under my profiler (jProfiler) and using jVisualVM, and both of them indicate the usual moderate heap and perm-gen usages of around 30M combined, even when fully active doing my load-test cycle. So I am mystified! And it not just requesting more memory from the Windows Virtual Memory pool - this is showing up as 200M "Mem Usage". CLARIFICATION: I want to be perfectly clear on this - observed over an 18 hour period with Java VisualVM the class heap and perm gen heap have been perfectly stable. The allocated volatile heap (eden and tenured) sits unmoved at 16MB (which it reaches in the first few minutes), and the use of this memory fluctuates in a perfect pattern of growing evenly from 8MB to 16MB, at which point GC kicks in an drops it back to 8MB. Over this 18 hour period, the system was under constant maximum load since I was running a stress test. This behavior is perfectly and consistently reproducible, seen over numerous runs. The only anomaly is that while this is going on the memory taken from Windows, observed via Task Manager, fluctuates all over the place from 64MB up to 900+MB. UPDATE 2008-12-18: I have run the program with -Xms16M -Xmx16M without any apparent adverse affect - performance is fine, total run time is about the same. But memory use in a short run still peaked at about 180M. Update 2009-01-21: It seems the answer may be in the number of threads - see my answer below. EDIT: And I mean millions of page faults literally - in the region of 30M+. …
type: Question
has answer: http://stackoverflow.com/a/467683
upvote count: 22
has comment: http://stackoverflow.com/comment/251278
has comment: http://stackoverflow.com/comment/206473
has answer: http://stackoverflow.com/a/367933
has answer: http://stackoverflow.com/a/467737
has title: Java 6 Excessive Memory Usage
has answer: http://stackoverflow.com/a/368582
has answer: http://stackoverflow.com/a/7331778
possible better answer: http://stackoverflow.com/a/367933
downvote count: 0
answer count: 7
has comment: http://stackoverflow.com/comment/205441

http://stackoverflow.com/comment/25192973
score: 0
type: Comment
has text: Which Eclipse version are you using?
comment on: http://stackoverflow.com/a/15273716
type: AnswerComment

http://stackoverflow.com/a/631170
has body: Since java does not preserve generic types at runtime, ideally both of them should behave the same. Probably, there is something else which is causing the problem.
score: 1
answers question: http://stackoverflow.com/q/631136
downvote count: 0
type: Answer
upvote count: 1

http://stackoverflow.com/a/504356
score: 2
downvote count: 0
has body: If you look at the API Set extends Collection. According, to the description the Set does not allow null values.
upvote count: 2
answers question: http://stackoverflow.com/q/504337
type: Answer

http://stackoverflow.com/a/377392
answers question: http://stackoverflow.com/q/377331
has comment: http://stackoverflow.com/comment/205374
has comment: http://stackoverflow.com/comment/213790
type: AcceptedAnswer
has body: I suggest to file a bug against IDEA along these lines: If a class has no debug information but has JavaDocs, IDEA should use the JavaDoc to determine the names of the parameters. Btw. Eclipse has the same problem. :)
downvote count: 0
type: Answer
score: 3
accepted answer of: http://stackoverflow.com/q/377331
upvote count: 3

http://stackoverflow.com/comment/451607
type: Comment
comment on: http://stackoverflow.com/a/638339
has text: No, that's actually the least of your worries. Worse is when your XML is encoded as UTF-8 (the standard default), and you wrap it with an InputStreamReader that assumes it's ISO-8859-1 (the platform default for US Linux installations) or Windows-1252 (the platform default for US Windows installs)
type: AnswerComment
score: 0

http://stackoverflow.com/comment/398163
type: QuestionComment
score: 0
has text: There are no obvious problems in the code snippet. There is not enough information to deduce the cause of the problem.
comment on: http://stackoverflow.com/q/586000
type: Comment

http://stackoverflow.com/a/50740662
answers question: http://stackoverflow.com/q/462534
type: Answer
has body: Old thread, but I've just faced the same problem and ended up with an utility function: private Set&lt;String&gt; getColumnNames(ResultSet cached) throws SQLException { ResultSetMetaData metaData = cached.getMetaData(); return IntStream.range(1, metaData.getColumnCount()) .mapToObj(i -&gt; { try { return metaData.getColumnName(i); } catch (SQLException e) { throw new RuntimeException(e); } }).collect(toSet()); } It'd be quite elegent if we wouldn't have to catch exceptions inside a lambda (without some ugly hacks)
score: 0

http://stackoverflow.com/comment/51578063
has text: +1 for being the only solution to me. I'm trying to use type substitution for subclassing (implClass) in JAXB 2.* in a xsd file and the classes unmarshaled are generated ones other than the one specified in implClass. vocaro's answer resolve the problem!
score: 0
type: Comment
comment on: http://stackoverflow.com/a/4321449
type: AnswerComment

http://stackoverflow.com/comment/425708
comment on: http://stackoverflow.com/a/609430
score: 0
type: Comment
has text: Update? I seem to be getting lots of updates on entities that are immutable.
type: AnswerComment

http://stackoverflow.com/a/435753
accepted answer of: http://stackoverflow.com/q/435740
upvote count: 31
answers question: http://stackoverflow.com/q/435740
downvote count: 1
has body: I've used the Apache Commons CLI library for command-line argument parsing. It's fairly easy to use and has reasonably good documentation. Which library you choose probably comes down to which style of options you prefer ("--gnu-style" or "-javac-style").
type: AcceptedAnswer
type: Answer
score: 30

http://stackoverflow.com/a/496956
has comment: http://stackoverflow.com/comment/314797
has comment: http://stackoverflow.com/comment/312903
has comment: http://stackoverflow.com/comment/312881
answers question: http://stackoverflow.com/q/496779
has body: Multiplying, adding, or xor-ing things will not make it more unique. Mathematically, you'd be applying constant functions to a single variable, which does not increase the number of possible values of the variable. That sort of technique is useful for combining multiple hashcodes and still keeping the risk of collisions relatively small; it has no bearing whatever on a single hashcode.
score: 4
downvote count: 0
has comment: http://stackoverflow.com/comment/314801
has comment: http://stackoverflow.com/comment/314183
type: Answer
upvote count: 4

space
tags question: http://stackoverflow.com/q/637907
tag name: space
type: Tag

http://stackoverflow.com/q/603283
type: Question
accepted answer: http://stackoverflow.com/a/617227
has comment: http://stackoverflow.com/comment/47533593
upvote count: 270
has answer: http://stackoverflow.com/a/643369
has answer: http://stackoverflow.com/a/603352
has answer: http://stackoverflow.com/a/17557883
favorite count: 0
has answer: http://stackoverflow.com/a/3477915
score: 269
has answer: http://stackoverflow.com/a/603358
has comment: http://stackoverflow.com/comment/10222671
has answer: http://stackoverflow.com/a/618331
has comment: http://stackoverflow.com/comment/93799324
has body: I am using both the JAI media apis and ImageMagick? ImageMagick has some scalability issues and the JNI based JMagick isn't attractive either. JAI has poor quality results when doing resizing operations compared to ImageMagick. Does anyone know of any excellent tools either open source or commercial that are native java and deliver high quality results?
tagged with: image-manipulation
has comment: http://stackoverflow.com/comment/3558561
has answer: http://stackoverflow.com/a/9418812
has answer: http://stackoverflow.com/a/5624876
has answer: http://stackoverflow.com/a/20785819
has answer: http://stackoverflow.com/a/617227
has title: What is the best java image processing library/approach?
downvote count: 1
possible better answer: http://stackoverflow.com/a/9418812
has comment: http://stackoverflow.com/comment/37481788
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/2407113
has answer: http://stackoverflow.com/a/2350120
tagged with: java
has comment: http://stackoverflow.com/comment/3545445
tagged with: image-processing
answer count: 11
has comment: http://stackoverflow.com/comment/55935565

http://stackoverflow.com/comment/15891082
comment on: http://stackoverflow.com/a/858165
type: Comment
has text: Yep, that was a typo, fixed now. It only took 3 years for someone to spot it, cheers!
score: 1
type: AnswerComment

http://stackoverflow.com/q/462373
tagged with: java
has answer: http://stackoverflow.com/a/20588836
has body: Can anyone tell me the difference between break and continue statements?
has answer: http://stackoverflow.com/a/462377
accepted answer: http://stackoverflow.com/a/462375
downvote count: 7
score: 308
type: Question
has answer: http://stackoverflow.com/a/42825600
has answer: http://stackoverflow.com/a/33928967
has answer: http://stackoverflow.com/a/462385
has answer: http://stackoverflow.com/a/462422
has answer: http://stackoverflow.com/a/46487133
tagged with: continue
has answer: http://stackoverflow.com/a/462414
upvote count: 315
has answer: http://stackoverflow.com/a/10693810
has answer: http://stackoverflow.com/a/29799393
has answer: http://stackoverflow.com/a/24910233
answer count: 21
has answer: http://stackoverflow.com/a/462428
favorite count: 0
has answer: http://stackoverflow.com/a/50136742
has answer: http://stackoverflow.com/a/462375
has answer: http://stackoverflow.com/a/27381033
has answer: http://stackoverflow.com/a/462380
has answer: http://stackoverflow.com/a/462418
possible better answer: http://stackoverflow.com/a/462396
has answer: http://stackoverflow.com/a/462376
tagged with: break
has answer: http://stackoverflow.com/a/462396
has title: Difference between break and continue statement
has answer: http://stackoverflow.com/a/462436
has answer: http://stackoverflow.com/a/462378
type: AnsweredQuestion

http://stackoverflow.com/a/506546
accepted answer of: http://stackoverflow.com/q/506317
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/506317
type: Answer
score: 2
upvote count: 2
has body: I usually use the flatpack library to parse CSVs into Java Models : Flatpack Project on sourceforge It is quite simple to use and use XML mappings to handle the CSV to Model projection (thus not inducing thight coupling between your csv and your java objects)

http://stackoverflow.com/q/377745
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/407312
type: Question
answer count: 2
tagged with: database
possible better answer: http://stackoverflow.com/a/377765
has answer: http://stackoverflow.com/a/407312
tagged with: oracle-database
upvote count: 1
tagged with: jdbc
favorite count: 0
has body: We have a problem with the Euro character when saving and retrieving it from a Oracle 10g using the Oracle 10.2.0.3 JDBC driver. The problem only occurs during a JUnit test running under Linux. The Euro characters returned from database after saving are total screwed up. Oracle has been configured to use character set "WE8MSWIN1252". Could it be that Linux cannot work with this character set?
downvote count: 0
has answer: http://stackoverflow.com/a/377765
has title: Oracle JDBC Euro character
type: AnsweredQuestion

http://stackoverflow.com/q/382886
has answer: http://stackoverflow.com/a/59567362
answer count: 3
has body: Is there a Java-based program (executable-jar) that can format java code (indenting/spacing)? If it would be configurable, that would be great.
tagged with: coding-style
type: UnansweredQuestion
upvote count: 1
tagged with: format
has answer: http://stackoverflow.com/a/382906
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/382890
has title: Standalone java base java formatter
type: Question
downvote count: 0
tagged with: executable-jar
favorite count: 0

http://stackoverflow.com/comment/103325826
score: 3
type: AnswerComment
comment on: http://stackoverflow.com/a/48588062
has text: There is *no* way to "escape ]]>" in CDATA.
type: Comment

http://stackoverflow.com/comment/78356808
type: Comment
has text: well that sucks!
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/464102

http://stackoverflow.com/a/581474
has body: Installing and managing the multiple Java runtime versions required on your PC was a bother that most users didn't want to go trough, either. If it doesn't work out of the box, forget it!
answers question: http://stackoverflow.com/q/580995
score: 3
downvote count: 0
type: Answer
upvote count: 3

http://stackoverflow.com/comment/30518587
has text: See also [Auto-generating toString Method](http://stackoverflow.com/questions/2653268/auto-generating-tostring-method)
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/443730

http://stackoverflow.com/q/550129
score: 9
has title: Export PDF pages to a series of images in Java
tagged with: export
has answer: http://stackoverflow.com/a/566943
linked to: http://stackoverflow.com/q/20656649
answer count: 6
has answer: http://stackoverflow.com/a/3803592
tagged with: http://stackoverflow.com/tag/pdf
has answer: http://stackoverflow.com/a/52974419
favorite count: 0
upvote count: 9
accepted answer: http://stackoverflow.com/a/550172
has body: I need to export the pages of an arbitrary PDF document into a series of individual images in jpeg/png/etc format. I need to do this in in Java. Although I do know about iText, PDFBox and various other java pdf libraries, I am hoping for a pointer to some working example, or some how-to. Thanks.
has answer: http://stackoverflow.com/a/13286249
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/9132149
has answer: http://stackoverflow.com/a/10637970
possible better answer: http://stackoverflow.com/a/566943
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/550172
tagged with: image
type: Question

http://stackoverflow.com/q/589486
has answer: http://stackoverflow.com/a/589566
favorite count: 0
upvote count: 3
has title: fo:data-cell overflow
tagged with: xsl-fo
tagged with: pdf-generation
downvote count: 0
type: UnansweredQuestion
tagged with: xslt
score: 3
tagged with: java
has body: I am using XSLT -> FO to generate the PDF. When the text in a column exceeds the size of the column and there are no spaces in the text - then the text runs over into the next cell or outside the table. I want the text to be occupied within the same cell. Thanx in Advance, Swetha
type: Question
has answer: http://stackoverflow.com/a/589610
answer count: 2

http://stackoverflow.com/comment/276230
type: Comment
has text: Thanks for the tip, it worked. It would be good if this was mentioned in the samples/examples/tutorials available online.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/455855

http://stackoverflow.com/q/419850
type: UnansweredQuestion
score: 11
has answer: http://stackoverflow.com/a/5890128
has answer: http://stackoverflow.com/a/425507
answer count: 4
upvote count: 11
tagged with: java
tagged with: http
type: Question
has body: I'm writing a Java client application to receive live M-JPEG video from an IP camera. The video is sent by the camera as an endless multipart HTTP message where each part is a single JPEG frame. I need to process each of these frames as they arrive, so I'm hoping there's a way to make an HTTP request that asynchronously triggers an event as each message part/video frame is received. Is anyone aware of any libraries that can do this? All the examples I can find on Google won't work because they use blocking calls that only parse the response and break it up into parts after the entire response has finished being received (which obviously won't work for an endless response). I realise I could manually break up the data into parts as it arrives by searching for the message boundary but it just feels like I would be reinventing the wheel.
has answer: http://stackoverflow.com/a/73532923
tagged with: multipart
downvote count: 0
has answer: http://stackoverflow.com/a/424722
favorite count: 0
has title: Java: Receive a multipart HTTP response
linked to: http://stackoverflow.com/q/42533237

http://stackoverflow.com/comment/41085793
has text: @BrainSlugs83 I think that's a different question.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/366689
type: Comment

http://stackoverflow.com/a/487602
score: 9
has body: I would treat this just as any other String constant you have scattered throughout your code and define a constant variable for it. Granted, in this case "java.io.tmpdir" is unlikely to change, but you never know. (I don't mean that Sun might change the meaning of "java.io.tmpdir", or what system property it points to, but that you might change your mind about what system property you need to read.) If you're only using a particular property within one class, then I'd define the constants right in that class. private final String TEMPDIR = "java.io.tmpdir"; If you're using the same properties in different classes, you may want to define an static class of your own to hold the constants you use most often. public final Class Prop { public static final String TEMPDIR = "java.io.tmpdir"; ... } Then, everywhere you need to use that constant just call it using System.getProperty(Prop.TEMPDIR);
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/487590
type: Answer
has comment: http://stackoverflow.com/comment/303821
answers question: http://stackoverflow.com/q/487590
has comment: http://stackoverflow.com/comment/303849
upvote count: 9

http://stackoverflow.com/q/369383
downvote count: 0
has comment: http://stackoverflow.com/comment/198370
has comment: http://stackoverflow.com/comment/198423
answer count: 3
has title: What is the best way to get min and max value from a list of Comparables that main contain null values?
has answer: http://stackoverflow.com/a/369395
has comment: http://stackoverflow.com/comment/7346725
linked to: http://stackoverflow.com/q/6259354
linked to: http://stackoverflow.com/q/481813
favorite count: 0
has comment: http://stackoverflow.com/comment/198393
has comment: http://stackoverflow.com/comment/198449
score: 6
tagged with: collections
upvote count: 6
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/369395
tagged with: java
has body: I am thinking about something like this: public static &lt;T extends Comparable&lt;T&gt;&gt; T minOf(T...ts){ SortedSet&lt;T&gt; set = new TreeSet&lt;T&gt;(Arrays.asList(ts)); return set.first(); } public static &lt;T extends Comparable&lt;T&gt;&gt; T maxOf(T...ts){ SortedSet&lt;T&gt; set = new TreeSet&lt;T&gt;(Arrays.asList(ts)); return set.last(); } But is not null safe, which is something I want too. Do you know a better way to solve this problem? EDIT: After the comments I have also tried min(): public static &lt;T extends Comparable&lt;T&gt;&gt; T minOf(T...ts){ return Collections.min(Arrays.asList(ts), new Comparator&lt;T&gt;(){ public int compare(T o1, T o2) { if(o1!=null &amp;&amp; o2!=null){ return o1.compareTo(o2); }else if(o1!=null){ return 1; }else{ return -1; } }}); } What do you think of that?
tagged with: comparable
type: Question
possible better answer: http://stackoverflow.com/a/369413
has answer: http://stackoverflow.com/a/30596059
has answer: http://stackoverflow.com/a/369413

http://stackoverflow.com/a/463162
answers question: http://stackoverflow.com/q/463155
has body: Boolean isValueBig; if(value &gt; 100) { isValueBig = true; } else { isValueBig = false; }
type: Answer
score: 5
upvote count: 5
downvote count: 0

http://stackoverflow.com/a/2469399
answers question: http://stackoverflow.com/q/615493
has body: a bit late, but this works for me (web appl in Glassfish) Properties prop = new Properties(); prop.load(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")); System.out.println("All attributes:" + prop.stringPropertyNames()); System.out.println(prop.getProperty("{whatever attribute you want}"));
type: Answer
score: 11
has comment: http://stackoverflow.com/comment/22716141
downvote count: 1
upvote count: 12

http://stackoverflow.com/comment/342446
comment on: http://stackoverflow.com/a/529488
has text: This works but I still need to wrap it with a NumberFormat object because of an additional constraint that I forgot to mention. Basically there is a MAP[Type => NumberFormatter] that this needs to play nicely with.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/473309
type: Answer
has comment: http://stackoverflow.com/comment/58745996
has comment: http://stackoverflow.com/comment/6448526
score: 1984
has body: Use java.lang.String.format(String,Object...) like this: String.format("%05d", yournumber); for zero-padding with a length of 5. For hexadecimal output replace the d with an x as in "%05x". The full formatting options are documented as part of java.util.Formatter.
has comment: http://stackoverflow.com/comment/23375992
has comment: http://stackoverflow.com/comment/39731497
has comment: http://stackoverflow.com/comment/51016124
has comment: http://stackoverflow.com/comment/65648560
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/473282
has comment: http://stackoverflow.com/comment/29983960
accepted answer of: http://stackoverflow.com/q/473282
has comment: http://stackoverflow.com/comment/46003114
has comment: http://stackoverflow.com/comment/126048835
upvote count: 1984

http://stackoverflow.com/q/484119
type: Question
has comment: http://stackoverflow.com/comment/8925180
accepted answer: http://stackoverflow.com/a/484255
score: 66
has body: I've discovered this idiom recently, and I am wondering if there is something I am missing. I've never seen it used. Nearly all Java code I've worked with in the wild favors slurping data into a string or buffer, rather than something like this example (using HttpClient and XML APIs for example): final LSOutput output; // XML stuff initialized elsewhere final LSSerializer serializer; final Document doc; // ... PostMethod post; // HttpClient post request final PipedOutputStream source = new PipedOutputStream(); PipedInputStream sink = new PipedInputStream(source); // ... executor.execute(new Runnable() { public void run() { output.setByteStream(source); serializer.write(doc, output); try { source.close(); } catch (IOException e) { throw new RuntimeException(e); } }}); post.setRequestEntity(new InputStreamRequestEntity(sink)); int status = httpClient.executeMethod(post); That code uses a Unix-piping style technique to prevent multiple copies of the XML data being kept in memory. It uses the HTTP Post output stream and the DOM Load/Save API to serialize an XML Document as the content of the HTTP request. As far as I can tell it minimizes the use of memory with very little extra code (just the few lines for Runnable, PipedInputStream, and PipedOutputStream). So, what's wrong with this idiom? If there's nothing wrong with this idiom, why haven't I seen it? EDIT: to clarify, PipedInputStream and PipedOutputStream replace the boilerplate buffer-by-buffer copy that shows up everywhere, and they also allow you to process incoming data concurrently with writing out the processed data. They don't use OS pipes.
has answer: http://stackoverflow.com/a/485087
linked to: http://stackoverflow.com/q/8243157
has comment: http://stackoverflow.com/comment/9014068
answer count: 10
upvote count: 67
favorite count: 0
has answer: http://stackoverflow.com/a/485183
has comment: http://stackoverflow.com/comment/115583926
has comment: http://stackoverflow.com/comment/8517063
has answer: http://stackoverflow.com/a/484987
has title: Why doesn't more Java code use PipedInputStream / PipedOutputStream?
has answer: http://stackoverflow.com/a/484180
tagged with: design-patterns
downvote count: 1
has answer: http://stackoverflow.com/a/484255
has answer: http://stackoverflow.com/a/35329172
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/484440
tagged with: pipe
possible better answer: http://stackoverflow.com/a/484180
tagged with: java
has answer: http://stackoverflow.com/a/61140309
tagged with: concurrency
has answer: http://stackoverflow.com/a/19466012
has comment: http://stackoverflow.com/comment/80141784
has answer: http://stackoverflow.com/a/78859006

http://stackoverflow.com/a/21569756
type: Answer
has body: My practice is following: if type of variable is simple (int, double, ...) I prefer variant b (inside). Reason: reducing scope of variable. if type of variable is not simple (some kind of class or struct) I prefer variant a (outside). Reason: reducing number of ctor-dtor calls.
upvote count: 3
answers question: http://stackoverflow.com/q/407255
score: 3
downvote count: 0

http://stackoverflow.com/comment/41738833
comment on: http://stackoverflow.com/a/370967
has text: @Pacerier Think through it. *How* do you call it? Three ways: (1) Using the subclass name directly, as Child.Method - but in this case it didn't need to be abstract because you're referring to a specific subclass name anyway; (2) through an object - but then it didn't need to be static; (3) through a Class<?> instance with reflection - but then the compiler can't guarantee that the Class instance has the method defined, and now you're subject to runtime exception if you call an abstract method when you were reflecting Parent. Bottom line: needing static abstract indicates a design flaw
type: Comment
score: 6
type: AnswerComment

http://stackoverflow.com/comment/376573
has text: It's a nice Idea but is it possible to get it to set the String's colour in the Jframe I have already created (Instead of in a new JFrame) as the class I am working on is a gui and I want to colour the text and print it to a JTextArea?
comment on: http://stackoverflow.com/a/565276
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/573715
downvote count: 1
has body: Supply the path relative to the classloader, not the class you're getting the loader from. For instance: resourcesloader.class.getClassLoader().getResource("package1/resources/repository/SSL-Key/cert.jks").toString();
accepted answer of: http://stackoverflow.com/q/573679
score: 50
upvote count: 51
answers question: http://stackoverflow.com/q/573679
type: AcceptedAnswer
type: Answer

http://stackoverflow.com/comment/413410
score: 0
type: Comment
type: QuestionComment
has text: it will depend both on location, and users will be able to customize it further.
comment on: http://stackoverflow.com/q/601036

http://stackoverflow.com/a/17321802
has body: import com.google.common.collect.ComparisonChain; /** * @author radler * Class Description ... */ public class Attribute implements Comparable&lt;Attribute&gt; { private String type; private String value; public String getType() { return type; } public void setType(String type) { this.type = type; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } @Override public String toString() { return "Attribute [type=" + type + ", value=" + value + "]"; } @Override public int compareTo(Attribute that) { return ComparisonChain.start() .compare(this.type, that.type) .compare(this.value, that.value) .result(); } }
answers question: http://stackoverflow.com/q/369512
downvote count: 0
type: Answer
score: 14
upvote count: 14

http://stackoverflow.com/q/564469
tagged with: java
has answer: http://stackoverflow.com/a/565814
has answer: http://stackoverflow.com/a/564483
upvote count: 10
downvote count: 1
has title: What is a good & free game engine?
type: Question
has comment: http://stackoverflow.com/comment/375725
has answer: http://stackoverflow.com/a/564491
possible better answer: http://stackoverflow.com/a/1949809
has answer: http://stackoverflow.com/a/1949809
answer count: 14
has answer: http://stackoverflow.com/a/564616
has answer: http://stackoverflow.com/a/568759
has answer: http://stackoverflow.com/a/1949983
has comment: http://stackoverflow.com/comment/1861234
favorite count: 0
has answer: http://stackoverflow.com/a/564479
score: 9
has answer: http://stackoverflow.com/a/564570
accepted answer: http://stackoverflow.com/a/564491
tagged with: python
has answer: http://stackoverflow.com/a/566012
has answer: http://stackoverflow.com/a/1949972
has answer: http://stackoverflow.com/a/565591
has body: For C++, Java, or Python, what are some good game + free game engines that are easy to pick up? Any type of game engine is okay. I just want to get started somewhere by looking into different game engines and their capabilities.
tagged with: c++
has answer: http://stackoverflow.com/a/564472
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/564524

http://stackoverflow.com/a/25490144
downvote count: 1
has body: IMO static import is quite a nice feature. It is absolutely true that heavy reliance on static import makes the code unreadable and difficult to understand which class a static method or attribute belongs to. However, in my experience it becomes a usable feature especially when designing Util classes which provide some static methods and attributes. The ambiguity arising whenever providing static import can be circumvented by establishing code standards. In my experience within a company this approach is acceptable and makes the code cleaner and easy to understand. Preferably I insert the _ character in front static methods and static attributes (somehow adopted from C). Apparently this approach violates the naming standards of Java but it provides clarity to code. For example, if we have a AngleUtils class: public class AngleUtils { public static final float _ZERO = 0.0f; public static final float _PI = 3.14f; public static float _angleDiff(float angle1, float angle2){ } public static float _addAngle(float target, float dest){ } } In this case the static import provides clarity and code structure looks more elegant to me: import static AngleUtils.*; public class TestClass{ public void testAngles(){ float initialAngle = _ZERO; float angle1, angle2; _addAngle(angle1, angle2); } } Right away someone can tell the which method or attribute comes from a static import and it hides the information of the class which it belongs to. I dont suggest using static import for classes that are integral part of a module and provide static and non-static methods as in these case it is important to know which class provides certain static functionality.
score: 0
answers question: http://stackoverflow.com/q/420791
type: Answer
has comment: http://stackoverflow.com/comment/50097433
upvote count: 1

http://stackoverflow.com/a/454211
has body: Never tried it. But I recently stumbled on a project named Jepp that may be of interest to you. Jepp embeds CPython in Java. It is safe to use in a heavily threaded environment, it is quite fast and its stability is a main feature and goal.
answers question: http://stackoverflow.com/q/454182
score: 4
upvote count: 4
downvote count: 0
type: Answer

http://stackoverflow.com/comment/492215
type: QuestionComment
comment on: http://stackoverflow.com/q/625433
has text: If they take more than an hour you can still print something like; 90 mins, 53 secs.
score: 5
type: Comment

http://stackoverflow.com/a/594918
score: 1
answers question: http://stackoverflow.com/q/594789
downvote count: 0
type: Answer
has body: I would urge caution whenever it seems like a good idea to create a non-private nested class. You are almost certainly better off going straight for an outer class. But if you are going to create a public nested class, it doesn't seem any more strange to put it in an interface than a class. The abstractness of the outer class is not necessarily related to the abstractness of a nested class.
upvote count: 1

http://stackoverflow.com/a/410922
has body: You may want to refer to this question about avoiding != null. Basically, if null is a valid response, you have to check for it. If not, assert it (if you can). But whatever you do, try and minimize the cases where null is a valid response for this amongst other reasons.
type: Answer
score: 1
answers question: http://stackoverflow.com/q/410890
downvote count: 1
upvote count: 2

http://stackoverflow.com/q/477750
tagged with: java
tagged with: primitive
type: Question
has answer: http://stackoverflow.com/a/477769
has answer: http://stackoverflow.com/a/477776
tagged with: casting
has comment: http://stackoverflow.com/comment/121879226
has answer: http://stackoverflow.com/a/495218
has answer: http://stackoverflow.com/a/2752272
answer count: 11
score: 79
has answer: http://stackoverflow.com/a/67721510
has title: Primitive type 'short' - casting in Java
has answer: http://stackoverflow.com/a/37306146
has answer: http://stackoverflow.com/a/26057437
favorite count: 0
has answer: http://stackoverflow.com/a/477765
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/477855
has answer: http://stackoverflow.com/a/477767
has body: I have a question about the primitive type short in Java. I am using JDK 1.6. If I have the following: short a = 2; short b = 3; short c = a + b; the compiler does not want to compile - it says that it "cannot convert from int to short" and suggests that I make a cast to short, so this: short c = (short) (a + b); really works. But my question is why do I need to cast? The values of a and b are in the range of short - the range of short values is {-32,768, 32767}. I also need to cast when I want to perform the operations -, *, / (I haven't checked for others). If I do the same for primitive type int, I do not need to cast aa+bb to int. The following works fine: int aa = 2; int bb = 3; int cc = aa +bb; I discovered this while designing a class where I needed to add two variables of type short, and the compiler wanted me to make a cast. If I do this with two variables of type int, I don't need to cast. A small remark: the same thing also happens with the primitive type byte. So, this works: byte a = 2; byte b = 3; byte c = (byte) (a + b); but this not: byte a = 2; byte b = 3; byte c = a + b; For long, float, double, and int, there is no need to cast. Only for short and byte values.
upvote count: 79
has answer: http://stackoverflow.com/a/41750719
downvote count: 0
tagged with: short

http://stackoverflow.com/comment/453439
score: 0
type: Comment
type: QuestionComment
has text: Any source code? If you do not write a OptimisticLockException should not be thrown. So it may be a error in the code.
comment on: http://stackoverflow.com/q/639908

http://stackoverflow.com/comment/196839
has text: A cast will just produce another warning, since the code is not type safe.
type: AnswerComment
score: 4
type: Comment
comment on: http://stackoverflow.com/a/367632

http://stackoverflow.com/comment/83739018
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/8726007
has text: Please add used libraries.
score: 0

http://stackoverflow.com/q/397867
tagged with: java
tagged with: http://stackoverflow.com/tag/c
answer count: 6
type: Question
has body: George Marsaglia has written an excellent random number generator that is extremely fast, simple, and has a much higher period than the Mersenne Twister. Here is the code with a description: good C random number generator I wanted to port the CMWC4096 code to Java, but it uses several unsigned datatypes so I am not sure how to do this properly. Here is the full C code: /* choose random initial c&lt;809430660 and */ /* 4096 random 32-bit integers for Q[] */ static unsigned long Q[4096],c=362436; unsigned long CMWC4096(void) { unsigned long long t, a=18782LL; static unsigned long i=4095; unsigned long x,r=0xfffffffe; i = (i+1) &amp; 4095; t = a*Q[i] + c; c = (t&gt;&gt;32); x = t + c; if (x &lt; c) { x++; c++; } return (Q[i] = r - x); } Can anyone port this to Java? How does this work when you only have signed numbers available? EDIT: Thanks everybody for the quick answers! For the first 100 million numbers this java code seems to produce the same result as the C code. It is 3 times faster than Java's java.util.Random. public class ComplimentaryMultiplyWithCarryRandom { /** * Choose 4096 random 32-bit integers */ private long[] Q; /** * choose random initial c&lt;809430660 */ private long c = 362436; private int i; public ComplimentaryMultiplyWithCarryRandom() { Random r = new Random(1); Q = new long[4096]; // TODO initialize with real random 32bit values for (int i = 0; i &lt; 4096; ++i) { long v = r.nextInt(); v -= Integer.MIN_VALUE; Q[i] = v; } i = 4095; } int next() { i = (i + 1) &amp; 4095; long t = 18782 * Q[i] + c; c = t &gt;&gt;&gt; 32; long x = (t + c) &amp; 0xffffffffL; if (x &lt; c) { ++x; ++c; } long v = 0xfffffffeL - x; Q[i] = v; return (int) v; } }
score: 20
has answer: http://stackoverflow.com/a/397946
upvote count: 20
possible better answer: http://stackoverflow.com/a/397997
has answer: http://stackoverflow.com/a/397885
downvote count: 0
has answer: http://stackoverflow.com/a/397960
accepted answer: http://stackoverflow.com/a/397960
has answer: http://stackoverflow.com/a/397886
favorite count: 0
has answer: http://stackoverflow.com/a/73439958
tagged with: random
has title: Port of Random generator from C to Java?
tagged with: porting
has answer: http://stackoverflow.com/a/397997
type: AnsweredQuestion

http://stackoverflow.com/a/34444188
downvote count: 0
score: 37
has body: java.time Using the java.time framework built into Java 8 and later. import java.time.LocalDateTime; import java.time.Instant; import java.time.ZoneId; long epoch = Long.parseLong("1081157732"); Instant instant = Instant.ofEpochSecond(epoch); ZonedDateTime.ofInstant(instant, ZoneOffset.UTC); # ZonedDateTime = 2004-04-05T09:35:32Z[UTC] In this case you should better use ZonedDateTime to mark it as date in UTC time zone because Epoch is defined in UTC in Unix time used by Java. ZoneOffset contains a handy constant for the UTC time zone, as seen in last line above. Its superclass, ZoneId can be used to adjust into other time zones. ZoneId zoneId = ZoneId.of( "America/Montreal" );
upvote count: 37
type: Answer
has comment: http://stackoverflow.com/comment/56636302
answers question: http://stackoverflow.com/q/535004

http://stackoverflow.com/comment/397802
type: AnswerComment
score: 0
type: Comment
has text: Only allows for a specific part unique for your application.
comment on: http://stackoverflow.com/a/585994

http://stackoverflow.com/a/418489
upvote count: 5
has body: It appears that the NetBeans 6.5 Java Webapp project manager does not have the "Enable Groovy" support that is present in the Java App and Java Class library projects. I can think of two ways you might get around this: First, you could put your Groovy code and tests in a separate project as a Java Class Library. Then make the Java webapp dependent on the Groovy project. NetBeans will build the dependent project automatically so you'll hardly notice they are in separate projects. Second, the "Enable Groovy" isn't magic. All it does is write a groovy-build.xml in /nbprojects and modify build-impl.xml to import it. The groovy-build.xml overrides the default "javac" macro to invoke "groovyc" instead. If you're at all handy with Ant, you could copy a groovy-build.xml from a Java Application project and copy it to your Java Web project and then import it from your build.xml (before build-impl.xml is imported). The groovy-build.xml would likely need a few tweaks as some of the properties between a webapp and class library are a little different.
answers question: http://stackoverflow.com/q/416116
downvote count: 0
type: Answer
score: 5

http://stackoverflow.com/comment/326135
comment on: http://stackoverflow.com/q/512266
score: 0
type: Comment
has text: Why do people want to close this? Seems like a legitimate question that might help other people. If it's an exact duplicate, please say so.
type: QuestionComment

http://stackoverflow.com/comment/265395
comment on: http://stackoverflow.com/a/443768
type: AnswerComment
type: Comment
score: 3
has text: Yeah I actually saw that right after I posted this question. I am still interested in the details. I am going to dig through their code and how they implement it.

http://stackoverflow.com/comment/430651
has text: If it actually does the operation, I suspect condition. But I also expect the assignment to be jit'd away, so you'll have to experiment/profile to know for sure. Either way, the code clarity is probably more important.
score: 0
comment on: http://stackoverflow.com/a/448347
type: AnswerComment
type: Comment

http://stackoverflow.com/a/599269
has comment: http://stackoverflow.com/comment/6127795
has comment: http://stackoverflow.com/comment/21624981
has comment: http://stackoverflow.com/comment/11527982
has comment: http://stackoverflow.com/comment/94144570
has comment: http://stackoverflow.com/comment/87970476
downvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/1021594
upvote count: 259
has comment: http://stackoverflow.com/comment/96938951
has comment: http://stackoverflow.com/comment/15821017
score: 258
has comment: http://stackoverflow.com/comment/11530479
has comment: http://stackoverflow.com/comment/100833652
answers question: http://stackoverflow.com/q/599161
has body: Download the Apache Commons Lang and use the method StringUtils.join(list) StringUtils.join(list, ", ") // 2nd param is the separator. You can implement it by yourself, of course, but their code is fully tested and is probably the best possible implementation. I am a big fan of the Apache Commons library and I also think it's a great addition to the Java Standard Library.
has comment: http://stackoverflow.com/comment/38796852

http://stackoverflow.com/q/582526
has answer: http://stackoverflow.com/a/604642
answer count: 5
has answer: http://stackoverflow.com/a/654875
accepted answer: http://stackoverflow.com/a/582592
type: AnsweredQuestion
tagged with: java
tagged with: hibernate
possible better answer: http://stackoverflow.com/a/606927
tagged with: mysql
has answer: http://stackoverflow.com/a/606927
type: Question
has comment: http://stackoverflow.com/comment/57179704
upvote count: 22
has comment: http://stackoverflow.com/comment/5524307
has comment: http://stackoverflow.com/comment/8860966
has answer: http://stackoverflow.com/a/602971
downvote count: 0
has answer: http://stackoverflow.com/a/582592
score: 22
has body: I am trying to learn how Hibernate works, and I am running into an almost unacceptable learning curve. I can't see how to get Hibernate to respect the auto_increment policy for my objects. Instead, it is overwriting entries in the database with existing IDs, beginning with 1. I have a simple Foo object, backed by a MySQL table defined like this: CREATE TABLE `Foo` ( `fooId` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`fooId`), ) I have confirmed that inserting multiple Foo objects by hand with SQL (insert into Foo values();) does the right thing. My Java class has the ID specified using annotations like this: @Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name="fooId") private Integer id; I then execute some test code that simply instantiates Foo objects and saves them to the database (using session.save(obj)). It seems that it uses its own primary key sequence, beginning with one, and does not look at the table's key policy. It overwrites whatever was there. I have tried variations on the @GeneratedValue bit (using all possible strategies, leaving off the parenthetic clause). Somebody even suggested leaving off the GeneratedValue entirely. Nothing seems to work. Am I leaving something out? What am I missing? Is Hibernate really this hard? (If anybody has an alternative Java database persistence option, please suggest one. I am making prototypes, not long-lasting mondo-engineered projects.)
has title: Hibernate not respecting MySQL auto_increment primary key field
favorite count: 0

http://stackoverflow.com/comment/362549
comment on: http://stackoverflow.com/q/550919
has text: Another abuse of the offensive tag. Anonymous person, what exactly do you find offensive about this question?
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/62549818
has text: Using this example, if you wanted to convert the name of a planet as a string to a Planet object, how would you do it? I would want to be able to do something like `var p = "Earth"; var enum = (Planet)p;`.
type: AnswerComment
comment on: http://stackoverflow.com/a/469315
type: Comment
score: 0

recursion
type: Tag
tags question: http://stackoverflow.com/q/426878
tags question: http://stackoverflow.com/q/560708
tag name: recursion
tags question: http://stackoverflow.com/q/478049
tags question: http://stackoverflow.com/q/376346
tags question: http://stackoverflow.com/q/634963
tags question: http://stackoverflow.com/q/547622
tags question: http://stackoverflow.com/q/591228

http://stackoverflow.com/comment/413590
comment on: http://stackoverflow.com/a/601223
has text: he could be doing more than what is shown in the code snippet ;)
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/416397
comment on: http://stackoverflow.com/a/592130
score: 0
type: AnswerComment
type: Comment
has text: I was talking about a circular buffer, which by nature is supposed to be overwritten. It holds the last N elements added. Can be used like an airplane's "black box" when problems arise. It records the last N...events, messages, whatever. Overwrite is part of the design.

http://stackoverflow.com/comment/101470385
type: Comment
has text: @JoachimSauer Your edit is inserted at the wrong line
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/380828

http://stackoverflow.com/comment/53593324
comment on: http://stackoverflow.com/a/32815763
type: AnswerComment
score: 0
type: Comment
has text: I disagree , please compare my answer to other , especially the top voted answer.

http://stackoverflow.com/comment/40167990
comment on: http://stackoverflow.com/a/1609263
type: Comment
has text: Should be the correct answer. I just set level for console handler but nothing work. Luckily I read your answer.
score: 1
type: AnswerComment

http://stackoverflow.com/a/3296084
upvote count: 11
has body: I had something like this happen when I had accidentally duplicated the activity tag for one of my activities in my manifest. I had something like this in my application section. <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> When I removed the second activity tag, things started working normally.
type: Answer
has comment: http://stackoverflow.com/comment/4914530
downvote count: 0
score: 11
answers question: http://stackoverflow.com/q/601294

http://stackoverflow.com/comment/316517
has text: What do you mean when you say 'reifiable'? 'reifiable' is not a word.
comment on: http://stackoverflow.com/a/501284
type: AnswerComment
type: Comment
score: 2

http://stackoverflow.com/a/5042831
score: 1
has body: You can get this message if there is any missing argument. For example: You write &lt;xsl:variable name="maxPos" select="Math:max(9)"/&gt; instead &lt;xsl:variable name="maxPos" select="Math:max(9, 15)"/&gt;
downvote count: 0
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/643659

http://stackoverflow.com/comment/385210
score: 0
type: Comment
has text: @TheTXI port scanning will tell you closed ports but just because the port is closed to you doesn't mean it is free.
type: AnswerComment
comment on: http://stackoverflow.com/a/573369

http://stackoverflow.com/comment/302463
type: AnswerComment
comment on: http://stackoverflow.com/a/483134
type: Comment
has text: Use the one that works best for your application. I would not expect either to work in 100% of situations.
score: 0

http://stackoverflow.com/a/489574
has comment: http://stackoverflow.com/comment/305538
has comment: http://stackoverflow.com/comment/305847
type: Answer
has comment: http://stackoverflow.com/comment/305525
accepted answer of: http://stackoverflow.com/q/489538
answers question: http://stackoverflow.com/q/489538
upvote count: 21
has comment: http://stackoverflow.com/comment/305548
has body: I don't see that Joda recognizes that as a valid date. Example: strict = org.joda.time.format.DateTimeFormat.forPattern("MM/dd/yyyy") try { strict.parseDateTime('40/40/4353') assert false } catch (org.joda.time.IllegalFieldValueException e) { assert 'Cannot parse "40/40/4353": Value 40 for monthOfYear must be in the range [1,12]' == e.message } As best as I can tell, neither does DateFormat with setLenient(false). Example: try { df = new java.text.SimpleDateFormat('MM/dd/yyyy') df.setLenient(false) df.parse('40/40/4353') assert false } catch (java.text.ParseException e) { assert e.message =~ 'Unparseable' } Hope this helps!
type: AcceptedAnswer
downvote count: 0
score: 21

http://stackoverflow.com/q/626812
possible better answer: http://stackoverflow.com/a/626948
answer count: 4
tagged with: geometry
upvote count: 3
type: Question
type: AnsweredQuestion
score: 3
accepted answer: http://stackoverflow.com/a/633644
tagged with: algorithm
tagged with: java
has answer: http://stackoverflow.com/a/626943
tagged with: clipping
downvote count: 0
has answer: http://stackoverflow.com/a/626820
has title: Most elegant way to clip a line?
has answer: http://stackoverflow.com/a/626948
favorite count: 0
has body: I have a Rectangle2D and a Line2D. I want to "clip" the line so that only the part of the line which is within the rectangle remains. If none of the line is within the rectangle I want the line to be set to (0,0,0,0). Basically something along the lines of a Rectangle2D.intersect(Line2D src, Line2D dest) or something similar. Is there a way to do this with the java.awt.geom API? Or an elegant way to code it "by hand"?
has answer: http://stackoverflow.com/a/633644

http://stackoverflow.com/q/579445
has answer: http://stackoverflow.com/a/579571
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/579493
has answer: http://stackoverflow.com/a/579508
tagged with: java
has answer: http://stackoverflow.com/a/579493
has answer: http://stackoverflow.com/a/579506
type: Question
has answer: http://stackoverflow.com/a/579490
has answer: http://stackoverflow.com/a/579516
has answer: http://stackoverflow.com/a/26715369
has answer: http://stackoverflow.com/a/579932
has title: Java Constructors
downvote count: 0
accepted answer: http://stackoverflow.com/a/579506
answer count: 10
score: 30
favorite count: 0
has answer: http://stackoverflow.com/a/579491
tagged with: constructor
upvote count: 30
has answer: http://stackoverflow.com/a/579573
has body: I am trying to learn how to specify class constructors in Java. I am starting to understand that they specify the types of instance variables of objects made from that class. They also can be used to set the instance variable initial values. The follow example is from the Java tutorial on Sun's website: public Bicycle(int startCadence, int startSpeed, int startGear) { gear = startGear; cadence = startCadence; speed = startSpeed; } Where in your classes source code should you put the constructor(s)? Are these arguments the names of the variables?: (int startCadence, int startSpeed, int startGear) or are gear, cadence and speed the names of the variables? What is the difference between (int startCadence, int startSpeed, int startGear) and gear, cadence and speed? In the unlikely event that my instructor or any administrator from Salt Lake Community College ever comes across this question, let me make my intentions clear. This question is posted in the greatest spirit of academic honesty. I ask this question to seek general advice and help in understanding the proper way to use the Java programming language. I in no way use the work of others and represent it as my own work. I use the answers provided here as a general aid in my understanding. I do all my own work and do not copy work provided by people answering my question.

http://stackoverflow.com/a/591158
score: -1
upvote count: 2
has comment: http://stackoverflow.com/comment/403072
downvote count: 3
type: Answer
has body: Why do you not want to allow null? Do you want to throw an exception if null is added to your set? If so, just do something like this: private Set&lt;Object&gt; mySet = new HashSet&lt;Object&gt;() { @Override public boolean add(Object e) { if (e == null) throw new IllegalArgumentException("null"); // or NPE // or, of course, you could just return false return super.add(e); } }; HashSet's addAll() calls add() repeatedly, so this is the only method you'd have to override.
has comment: http://stackoverflow.com/comment/404760
has comment: http://stackoverflow.com/comment/403078
has comment: http://stackoverflow.com/comment/403069
answers question: http://stackoverflow.com/q/591115

http://stackoverflow.com/comment/442484
has text: BHARATH, If your statistical program requires a normal distribution, why do you not want to use a normal distribution, i.e. why don't you want to let it have its natural range?
score: 4
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/629814

http://stackoverflow.com/a/664988
type: Answer
has body: I've actually spent some time working on a implementation similar to what you're suggesting. I had a complied Open Laszlo front end embedded in a web page with a Django (a python MVC library) REST interface on the backend and no Open Laszlo server. It works reasonably well, but there are a couple of things to watch out for. Open Laszlo only supports calls to GET and POST, so you won't be able to easily use the DELETE and PUT methods in your REST API. The other is the lack of community around Laszlo (as mentioned elsewhere). I can sometimes be frustratingly difficult to answer some basic questions when using Laszlo, particularly around the XML HTTP API and XML replication features in the framework. I personally never really looked at the Laszlo back end server seriously as I wanted an open API that could be consumed easily by other clients. All this being said, the implementation does work and can be effective if you're willing to work around the limitations mentioned above. Plus Open Laszlo is free, which can be a really big plus if your working on a budget.
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/16134090
answers question: http://stackoverflow.com/q/400243
downvote count: 0

http://stackoverflow.com/a/449481
upvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/449445
score: 2
downvote count: 0
has body: Static variables and methods belong to the class and not instance, although you can refer them from an instance reference. Usually, you use the Class name to access them. If a method is declared as static, you don't need the object's instance in which it is defined to invoke it. Now, you might want to know when could such a situation arise? Consider the main method of java public static void main(String[] args) Why is it declared static? It's because in order to start your program this method should begin execution. And, since the program hasn't initialized there is no way you could create an instance of the class in which it is declared. Therefore, you are required to declare the class as public. And, this static method gets called when the class is loaded in memory through java YourClassName Besides this, static methods are used to modify static variables. They cannot manipulate non-static instance variables. Also, be aware, that static holds a different meaning in another language like C.

http://stackoverflow.com/comment/421825
type: QuestionComment
comment on: http://stackoverflow.com/q/609293
score: 0
has text: @Rob Kennedy: Perhaps it's unnecessary, but I try to not edit questions that I respond to.
type: Comment

http://stackoverflow.com/q/427902
upvote count: 89
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/427919
has body: Building on what has been written in SO question Best Singleton Implementation In Java - namely about using an enum to create a singleton - what are the differences/pros/cons between (constructor omitted) public enum Elvis { INSTANCE; private int age; public int getAge() { return age; } } and then calling Elvis.INSTANCE.getAge() and public enum Elvis { INSTANCE; private int age; public static int getAge() { return INSTANCE.age; } } and then calling Elvis.getAge()
score: 89
type: Question
linked to: http://stackoverflow.com/q/29585510
has title: What is the best approach for using an Enum as a singleton in Java?
tagged with: java
has answer: http://stackoverflow.com/a/427919
downvote count: 0
has answer: http://stackoverflow.com/a/427967
favorite count: 0
tagged with: singleton
possible better answer: http://stackoverflow.com/a/428146
has answer: http://stackoverflow.com/a/1149681
has answer: http://stackoverflow.com/a/428146
answer count: 4

http://stackoverflow.com/comment/234071
comment on: http://stackoverflow.com/q/408989
type: Comment
type: QuestionComment
has text: Added some new info regarding the size of the ListModel.
score: 0

http://stackoverflow.com/a/400481
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/42818456
has comment: http://stackoverflow.com/comment/42870594
has comment: http://stackoverflow.com/comment/42879549
score: 86
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/42900876
accepted answer of: http://stackoverflow.com/q/400477
upvote count: 86
has comment: http://stackoverflow.com/comment/42900950
answers question: http://stackoverflow.com/q/400477
has body: 32 bits. It's one of the Java language features that the size of the integer does not vary with the underlying computer. See the relevant section of the spec.

http://stackoverflow.com/comment/5796116
score: 73
type: AnswerComment
comment on: http://stackoverflow.com/a/509230
type: Comment
has text: this stuff is confusing, but i think all you have done is traded ClassCastExceptions for AssertionErrors.

http://stackoverflow.com/comment/39273570
type: Comment
score: 0
type: AnswerComment
has text: Changed the title to include FileInputStream.
comment on: http://stackoverflow.com/a/568655

classloader
tags question: http://stackoverflow.com/q/519816
tags question: http://stackoverflow.com/q/372639
tags question: http://stackoverflow.com/q/533545
tags question: http://stackoverflow.com/q/628290
tags question: http://stackoverflow.com/q/540150
tags question: http://stackoverflow.com/q/626043
tags question: http://stackoverflow.com/q/546492
tags question: http://stackoverflow.com/q/585991
tags question: http://stackoverflow.com/q/554963
tags question: http://stackoverflow.com/q/421422
tags question: http://stackoverflow.com/q/482633
tags question: http://stackoverflow.com/q/430089
tags question: http://stackoverflow.com/q/515702
type: Tag
tag name: classloader

http://stackoverflow.com/a/498660
answers question: http://stackoverflow.com/q/498636
downvote count: 0
type: Answer
has body: Parsing the file as fixed-size blocks of bytes is not good --- what if some character has a byte representation that straddles across two blocks? Use an InputStreamReader with the appropriate character encoding instead: BufferedReader br = new BufferedReader( new InputStreamReader( new FileInputStream("myfile.csv"), "ISO-8859-1"); char[] buffer = new char[4096]; // character (not byte) buffer while (true) { int charCount = br.read(buffer, 0, buffer.length); if (charCount == -1) break; // reached end-of-stream String s = String.valueOf(buffer, 0, charCount); // alternatively, we can append to a StringBuilder System.out.println(s); } Btw, remember to check that the unicode character can indeed be displayed correctly. You could also redirect the program output to a file and then compare it with the original file. As Jon Skeet suggests, the problem may also be console-related. Try System.console().printf(s) to see if there is a difference.
score: 10
upvote count: 10

http://stackoverflow.com/comment/371001
type: AnswerComment
type: Comment
has text: This is where the choice of the "right" LayoutManager stands! Of couse you don't want to use hard-coded XYWH! Some LayoutManagers will have automatic alignment, some others won't.
comment on: http://stackoverflow.com/a/557457
score: 0

http://stackoverflow.com/a/375479
has comment: http://stackoverflow.com/comment/2819571
has comment: http://stackoverflow.com/comment/2566951
downvote count: 3
type: AcceptedAnswer
type: Answer
upvote count: 27
has comment: http://stackoverflow.com/comment/203649
score: 24
has body: IMPORTANT: As pointed out by Kip in the comments, this class has an infinite loop bug if the matching regex matches on the replacement string. I'll leave it as an exercise to readers to fix it, if necessary. I don't know of anything similar that's built into Java. You could roll your own without too much difficulty, using the Matcher class: import java.util.regex.*; public class CallbackMatcher { public static interface Callback { public String foundMatch(MatchResult matchResult); } private final Pattern pattern; public CallbackMatcher(String regex) { this.pattern = Pattern.compile(regex); } public String replaceMatches(String string, Callback callback) { final Matcher matcher = this.pattern.matcher(string); while(matcher.find()) { final MatchResult matchResult = matcher.toMatchResult(); final String replacement = callback.foundMatch(matchResult); string = string.substring(0, matchResult.start()) + replacement + string.substring(matchResult.end()); matcher.reset(string); } } } Then call: final CallbackMatcher.Callback callback = new CallbackMatcher.Callback() { public String foundMatch(MatchResult matchResult) { return "&lt;img src=\"thumbs/" + matchResults.group(1) + "\"/&gt;"; } }; final CallbackMatcher callbackMatcher = new CallbackMatcher("/\[thumb(\d+)\]/"); callbackMatcher.replaceMatches(articleText, callback); Note that you can get the entire matched string by calling matchResults.group() or matchResults.group(0), so it's not necessary to pass the callback the current string state. EDIT: Made it look more like the exact functionality of the PHP function. Here's the original, since the asker liked it: public class CallbackMatcher { public static interface Callback { public void foundMatch(MatchResult matchResult); } private final Pattern pattern; public CallbackMatcher(String regex) { this.pattern = Pattern.compile(regex); } public String findMatches(String string, Callback callback) { final Matcher matcher = this.pattern.matcher(string); while(matcher.find())…
accepted answer of: http://stackoverflow.com/q/375420
answers question: http://stackoverflow.com/q/375420
has comment: http://stackoverflow.com/comment/203627
has comment: http://stackoverflow.com/comment/203651

http://stackoverflow.com/comment/58410827
has text: @Jaberino: No, it's about a currently running Java process, in Windows, with no console associated with it.
type: AnswerComment
comment on: http://stackoverflow.com/a/407792
type: Comment
score: 3

http://stackoverflow.com/q/434581
tagged with: windows
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/434692
has comment: http://stackoverflow.com/comment/257504
has answer: http://stackoverflow.com/a/434606
downvote count: 0
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/434622
has comment: http://stackoverflow.com/comment/257692
has title: exit batch file using java code
type: Question
has comment: http://stackoverflow.com/comment/257813
has body: I am having the sample code like this. /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author padmaja */ import java.io.*; class Test{ public static void main(String arg[]){ try{ String command = "cmd /C start C:/excel.bat"; Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(command); }catch (IOException e) { e.printStackTrace(); } } } I am opening excel sheet by using the above code. The problem is if use a thread to open excel sheet every 15 minutes then multiple excel sheet will be dispalyed. I want to close the running of a batch file from the above code itself. Thanks in advance
answer count: 3
upvote count: 1

http://stackoverflow.com/a/744988
upvote count: 7
answers question: http://stackoverflow.com/q/570076
type: AcceptedAnswer
downvote count: 0
has body: I ended up setting some of the netbeans command line options in the launcher script to force anti aliasing and force subpixel font rendering. This fixed the issue. Update: Added Steps I set the netbeans_default_options under /etc/netbeans.conf to read: netbeans\_default\_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true -J-Dawt.useSystemAAFontSettings=lcd"
has comment: http://stackoverflow.com/comment/28620320
has comment: http://stackoverflow.com/comment/556687
accepted answer of: http://stackoverflow.com/q/570076
type: Answer
has comment: http://stackoverflow.com/comment/74132908
score: 7
has comment: http://stackoverflow.com/comment/13055250

http://stackoverflow.com/a/613914
has body: I just found this: Thrown when the "verifier" detects that a class file, though well formed, contains some sort of internal inconsistency or security problem. Java API Have you returned a boolean? Could you please provide more information, which environment is set? The security question is important, I think.
answers question: http://stackoverflow.com/q/613903
upvote count: 1
type: Answer
downvote count: 0
score: 1

http://stackoverflow.com/a/404802
has comment: http://stackoverflow.com/comment/230588
has comment: http://stackoverflow.com/comment/78155859
has comment: http://stackoverflow.com/comment/41696187
type: Answer
has comment: http://stackoverflow.com/comment/18133502
score: 8
has comment: http://stackoverflow.com/comment/19823184
answers question: http://stackoverflow.com/q/404795
accepted answer of: http://stackoverflow.com/q/404795
has comment: http://stackoverflow.com/comment/48422044
downvote count: 19
has comment: http://stackoverflow.com/comment/6683676
has body: Personally, and I think this is backed up by convention, EAFP is never a good way to go. You can look at it as an equivalent to the following: if (o != null) o.doSomething(); else // handle as opposed to: try { o.doSomething() } catch (NullPointerException npe) { // handle } Moreover, consider the following: if (a != null) if (b != null) if (c != null) a.getB().getC().doSomething(); else // handle c null else // handle b null else // handle a null This may look a lot less elegant (and yes this is a crude example - bear with me), but it gives you much greater granularity in handling the error, as opposed to wrapping it all in a try-catch to get that NullPointerException, and then try to figure out where and why you got it. The way I see it EAFP should never be used, except for rare situations. Also, since you raised the issue: yes, the try-catch block does incur some overhead even if the exception is not thrown.
upvote count: 27
has comment: http://stackoverflow.com/comment/107157874
has comment: http://stackoverflow.com/comment/25319722
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/20660093

http://stackoverflow.com/comment/89196907
type: Comment
score: 2
has text: JD is a good starting point but fail to decompile complex code. A good alternative is use https://github.com/JetBrains/intellij-community/tree/master/plugins/java-decompiler/engine
type: AnswerComment
comment on: http://stackoverflow.com/a/647140

http://stackoverflow.com/comment/53280929
type: Comment
comment on: http://stackoverflow.com/a/18785300
has text: Yes I agree. I asked on the concurrency-interest list if it was something that could eventually be included in the JDK. But the discussion focussed on other points and nobody gave an opinion on that one. I'd like to see it included personally as well.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/9950045
has text: cont. Also since you're asking.. no, no I really wouldn't feel any safer with a program that thought good error handling meant silently ignoring every exception and just continued silently corrupting state - and I'd take any bet that that's not how these things are implemented in airplane software.. I'd think catching all errors in some well defined points in the program and restarting from there would make much more sense than that.
type: Comment
comment on: http://stackoverflow.com/a/399074
score: 1
type: AnswerComment

http://stackoverflow.com/a/549819
downvote count: 0
type: Answer
has body: The contains() method uses equals() to determine whether an object is in the list. I suspect your class MyObject does not override the equals() method, and this will be why myList.contains(b) is returning false.
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/549808

http://stackoverflow.com/a/520839
answers question: http://stackoverflow.com/q/462898
score: 2
upvote count: 3
downvote count: 1
type: Answer
has body: In your case, you are generating the database from the classes. This would imply that you wont use the database for other purposes (as doing so would force you to have DDL scripts). That means that have this rule implemented in the database or in the java code is unimportant. We also know that Hibernate would raise a transient exception in the case where one would delete one or more statuses and try to reference it when committing without a cascade. Also, the database will be generated using a foreign key constraint. All that means that the constraint MUST be respected for the application to work. If your entities are in a jar by themselves, you could add a transient method to the alarm or the status interface to remove a status while respecting the rule. Also, the programmers, when using the entities will be forced to respect the rule or else the code wont work. But to make the task easier, you could make the relation bidirectional so that the task of tracking down the alarms from the statuses is made easier. If you can, use an ondelete interceptor/listener to set the alarm.status property to null.

http://stackoverflow.com/a/572941
answers question: http://stackoverflow.com/q/572572
has body: java.awt.Robot has a method createScreenCapture(Rectangle screenRect) to capture screenshots. http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Robot.html however, to get the current active window you would have to use OS specific extensions (mostly via JNI)
score: 0
type: Answer

http://stackoverflow.com/comment/254168
type: AnswerComment
comment on: http://stackoverflow.com/a/428989
type: Comment
score: 1
has text: Supposedly it waits for the process to exit. I'm not sure if you can read before that time or not. I ultimately did not need the shell output for what I was doing so I didn't explore it fully. I do know that running under windows trying to do the same thing I had timing issues

http://stackoverflow.com/a/671464
has comment: http://stackoverflow.com/comment/485644
downvote count: 0
type: Answer
has body: One important point when discussing Java EE productivity: you should be using Java EE 5 and EJB3.x since they provide for new level of productivity (and functionality) compared to previous releases. Staying within standard Java EE specs is absolutely important, e.g. using Hibernate instead of JPA is not beneficial to productivity. There is no limitation to fall back to Hibernate features when using JPA, but by using Hibernate instead of JPA you are locked in into single persistence provider with no cheap way out. The whole idea behind using standards is the same: conceptual flexibility (by plugging in different implementations) with available extensibility (by using proprietary extensions if absolutely necessary). Java EE 5 and EJB3 are huge steps in this direction. Of course, you want to minimize any proprietary features but if some seem absolutely necessary it's a good sign that they will be part of spec in next release... Main obstacles to Java EE productivity are in its enterprise focus (offers a lot more than than needed for majority of projects) and in its legacy (backward compatibility). There is also a lot more to be done in presentation tier with JSF and state management - watch for JSR-299 to address these among other improvements.
has comment: http://stackoverflow.com/comment/485861
answers question: http://stackoverflow.com/q/645746
score: 3
upvote count: 3

http://stackoverflow.com/q/450069
has title: Detect which monitor shows the Window
type: AnsweredQuestion
tagged with: java
has body: I do have main application JFrame window which can include different components. I open a self implemented OnScreenKeyboard when the user select a editable textfield. The OSK is also a JFrame window. When the user drag the main window to another monitor, the OSK should also be shown on the same monitor. For this i have to detect the monitor the main JFrame is shown. I try to find a method in Toolkit.getDefaultToolkit() but was not able to find someting. Do you know how i can detect the monitor where a JFrame is shown? Java-Version 1.4 Windows XP Thanks
accepted answer: http://stackoverflow.com/a/450511
type: Question
upvote count: 4
downvote count: 0
answer count: 1
tagged with: toolkit
score: 4
tagged with: multiple-monitors
tagged with: windows
favorite count: 0
has answer: http://stackoverflow.com/a/450511
tagged with: jframe

http://stackoverflow.com/a/1575566
type: Answer
accepted answer of: http://stackoverflow.com/q/431491
score: 2
answers question: http://stackoverflow.com/q/431491
downvote count: 0
has body: Also quite nice: http://code.google.com/p/gwtwiki/
upvote count: 2
type: AcceptedAnswer

http://stackoverflow.com/q/542383
tagged with: jsp
has title: java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext;
answer count: 3
favorite count: 0
downvote count: 0
possible better answer: http://stackoverflow.com/a/15231992
tagged with: jsp-tags
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/767719
has answer: http://stackoverflow.com/a/542454
accepted answer: http://stackoverflow.com/a/542454
score: 1
tagged with: java
has body: I am trying to set a variable that I will refer to in a custom JSP tag, so I have something like this in my JSP: &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt; &lt;c:set var="path" value="test"/&gt; However, I am getting this error when The JSP runs: java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext; at org.apache.taglibs.standard.tag.common.core.SetSupport.doEndTag(SetSupport.java:140) I am running Tomcat 5.5, and Java 1.5, with JSTL 1.2. Am I doing something wrong here? Thanks!
type: Question
tagged with: jstl
has answer: http://stackoverflow.com/a/15231992
upvote count: 1

http://stackoverflow.com/a/1086523
score: 3
answers question: http://stackoverflow.com/q/407624
has body: One thing I didn't see in your question is whether you need to play out these processed samples or if you're doing something else with them (encoding them into a file, for example). I'd be more worried about the state of Java's sound engine than in how fast the JVM can crunch samples. I pushed pretty hard on javax.sound.sampled a few years back and came away deeply unimpressed -- it doesn't compare with equivalent frameworks like OpenAL or Mac/iPhone's Core Audio (both of which I've used at a similar level of intensity). javax.sound.sampled requires you to push your samples into an opaque buffer of unknown duration, which makes synchronization nigh impossible. It's also poorly documented (very hard to find examples of streaming indeterminate-length audio over a Line as opposed to the trivial examples of in-memory Clips), has unimplemented methods (DataLine.getLevel()... whose non-implementation isn't even documented), and to top it off, I believe Sun laid off the last JavaSound engineer years ago. If I had to use a Java engine for sound mixing and output, I'd probably try to use the JOAL bindings to OpenAL as a first choice, since I'd at least know the engine was currently supported and capable of very low-latency. Though I suspect in the long run that Nils is correct and you'll end up using JNI to call the native sound API.
upvote count: 3
type: Answer
downvote count: 0

http://stackoverflow.com/a/433968
answers question: http://stackoverflow.com/q/433958
has body: You want java.text.DecimalFormat. DecimalFormat df = new DecimalFormat("0.00##"); String result = df.format(34.4959);
type: Answer
accepted answer of: http://stackoverflow.com/q/433958
has comment: http://stackoverflow.com/comment/257318
upvote count: 98
score: 98
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/472596
has answer: http://stackoverflow.com/a/475550
type: Question
has answer: http://stackoverflow.com/a/587719
has answer: http://stackoverflow.com/a/472664
tagged with: c#
tagged with: continuous-integration
has body: What is the best continuous integration setup for a Devleopment department that codes in multiple environments? At my company we write some code in C# and some in Java, I've previously used CC.Net but I've never done CInt with Java. I'm aware of Continuum and was recently told about Hudson, but I've never used either. Would it be better to use two CInt services one for each platform or to use a single one for both?
downvote count: 0
answer count: 6
has answer: http://stackoverflow.com/a/472631
score: 3
accepted answer: http://stackoverflow.com/a/472631
favorite count: 0
has answer: http://stackoverflow.com/a/472808
possible better answer: http://stackoverflow.com/a/472622
has answer: http://stackoverflow.com/a/472622
has title: Best continuous integration setup for multi-platform development
type: AnsweredQuestion
upvote count: 3
tagged with: java

http://stackoverflow.com/a/496465
score: 1
has body: See the package description for javax.xml.validation. It contains information about and examples for validating both XSDs and DTDs
type: Answer
upvote count: 2
downvote count: 1
answers question: http://stackoverflow.com/q/496369

http://stackoverflow.com/q/545779
tagged with: java
has answer: http://stackoverflow.com/a/545931
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/545927
tagged with: pmd
score: 4
has title: Detect changing value of object passed as parameter
has answer: http://stackoverflow.com/a/545819
answer count: 7
has body: I'm now working with code that looks like this public String getName(User user) { user.setSth(...); return user.getName(); } I think it's bad practice to change objects passed as parameters. Is there a tool that detects that kind of code? I looked at findbugs, pmd and checkstyle, but could not find any check for this. P.S. sorry for bad example.
tagged with: findbugs
favorite count: 0
has answer: http://stackoverflow.com/a/545943
accepted answer: http://stackoverflow.com/a/545943
has comment: http://stackoverflow.com/comment/360622
has answer: http://stackoverflow.com/a/545854
tagged with: parameter-passing
upvote count: 4
has comment: http://stackoverflow.com/comment/357761
has answer: http://stackoverflow.com/a/545859
tagged with: checkstyle
possible better answer: http://stackoverflow.com/a/545819
has answer: http://stackoverflow.com/a/545934
downvote count: 0

http://stackoverflow.com/q/638421
downvote count: 0
possible better answer: http://stackoverflow.com/a/638873
favorite count: 0
has answer: http://stackoverflow.com/a/638432
has answer: http://stackoverflow.com/a/638595
upvote count: 2
has answer: http://stackoverflow.com/a/638433
score: 2
type: AnsweredQuestion
tagged with: oop
has body: I'm soon going to be starting the development stage of my coursework and the current design is to have a single class that handles database connections and many classes that call it; the database class is supposed to open the connection and pass queries along blindly, other classes are responsible for the contents of those queries. What I want to know is what is the best way for these reference to know about the database class? My instinct would be to make the methods in the Database class static and call them as Database.method() but is there a better way? P.S. was reference the right word for this? If not what is the right word, it would help next time I have a similar quesiton.
tagged with: java
has title: Best way for many classes to reference a database connection class
accepted answer: http://stackoverflow.com/a/638595
type: Question
has answer: http://stackoverflow.com/a/638795
tagged with: database
answer count: 6
has answer: http://stackoverflow.com/a/638873
has answer: http://stackoverflow.com/a/638426

http://stackoverflow.com/a/430048
type: Answer
answers question: http://stackoverflow.com/q/429762
has body: Create a small bash script to monitor opened sockets for a certain app or pid, and let it run while testing your java app. I doubt anyway that there are any kind of leaks in this thing as sockets are very used in linux/unix world and this kind of problem would bubble up very quicky
score: 0

http://stackoverflow.com/q/374586
tagged with: java
has answer: http://stackoverflow.com/a/38216584
type: Question
score: 20
upvote count: 22
has answer: http://stackoverflow.com/a/374593
has answer: http://stackoverflow.com/a/2325989
answer count: 3
favorite count: 0
has body: How do I append the contents of one list at the end of another list?
type: UnansweredQuestion
downvote count: 2
has title: How to append the contents of a list at the end of the other list?
tagged with: collections
tagged with: list

http://stackoverflow.com/q/538999
has comment: http://stackoverflow.com/comment/351497
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/539045
accepted answer: http://stackoverflow.com/a/539045
type: Question
score: 0
possible better answer: http://stackoverflow.com/a/539023
has answer: http://stackoverflow.com/a/543813
has title: java.util.Scanner and Wikipedia
answer count: 5
has body: I'm trying to use java.util.Scanner to take Wikipedia contents and use it for word based searches. The fact is that it's all fine but when reading some words it give me errors. Looking at code and making some check it turned out that with some words it seems not to recognize the encoding, or so, and the content is no more readable. This is the code used to take the page: // -Start- try { connection = new URL("http://it.wikipedia.org wiki/"+word).openConnection(); Scanner scanner = new Scanner(connection.getInputStream()); scanner.useDelimiter("\\Z"); content = scanner.next(); // if(word.equals("pubblico")) // System.out.println(content); System.out.println("Doing: "+ word); //End The problem arises with words as "pubblico" for the italian wikipedia. the result of the println on word pubblico is like this (cutted): ï¿ï¿½]Ksr>ï¿½~E ï¿½1Aï¿½ï¿½ï¿½Eï¿½ER3tHZï¿½4vï¿½ï¿½&amp;PZjtcï¿½¿½ï¿½Dï¿½7_|ï¿½ï¿½ï¿½ï¿½=8ï¿½ï¿½Ø} Do you have any idea why? Yet looked at page source and headers are the same, with same encoding... Turned Out that content is gzipped, so can i tell wikipedia not to send me teir pages zipped or it's the only way? thank you
has answer: http://stackoverflow.com/a/542077
tagged with: java.util.scanner
has answer: http://stackoverflow.com/a/539049
has answer: http://stackoverflow.com/a/539023
tagged with: wikipedia

http://stackoverflow.com/a/499047
answers question: http://stackoverflow.com/q/499013
downvote count: 0
has body: Are you trying to run the script ON THE REMOTE machine or ON YOUR LOCAL machine? Your approach will read the file from the remote machine but run it on your local. The usual way to get something running on a remote machine is having a process on the remote machine to run permanently and listen for requests. If a request arrives this process will start your batch file you would like to have run.
type: Answer
upvote count: 1
score: 1

http://stackoverflow.com/a/483444
downvote count: 0
score: 6
has body: The basic idea behind Garbage Collection is that you don't have to care about memory management. What the Garbage Collectod does is to periodically check upon objects references and find the one that are no more used (not referenced anymore) to reclaim their memory and compact the other. Garbage Collector use various algorithms to perform their work and they differ for some details from a lenguage to another. Wikipedia gives you a good starting point. If you're looking for more in depth information about actual implementation of various Garbage Collectors (Java, .NET, ..) you can check here and here or search google for more.
upvote count: 6
answers question: http://stackoverflow.com/q/483427
type: Answer

http://stackoverflow.com/a/13158607
upvote count: 38
has body: No need to make it too complicated. DigestUtils works fine and makes you comfortable while working with md5 hashes. DigestUtils.md5Hex(_hash); or DigestUtils.md5(_hash); Either you can use any other encryption methods such as sha or md.
score: 37
answers question: http://stackoverflow.com/q/415953
downvote count: 1
type: Answer

http://stackoverflow.com/a/10026065
has comment: http://stackoverflow.com/comment/51664192
has comment: http://stackoverflow.com/comment/64089332
has comment: http://stackoverflow.com/comment/73572863
has comment: http://stackoverflow.com/comment/26132669
has comment: http://stackoverflow.com/comment/129238493
answers question: http://stackoverflow.com/q/481813
has comment: http://stackoverflow.com/comment/73374698
has body: You can simply use Apache Commons Lang: result = ObjectUtils.compare(firstComparable, secondComparable)
has comment: http://stackoverflow.com/comment/102775104
has comment: http://stackoverflow.com/comment/30950203
score: 248
downvote count: 1
upvote count: 249
has comment: http://stackoverflow.com/comment/92690416
type: Answer
has comment: http://stackoverflow.com/comment/73772713

http://stackoverflow.com/q/528891
tagged with: struts2
downvote count: 0
has body: I'm working on a webapp that uses struts 2, spring, URL Rewrite Filter and a couple of other dependencies that I'm not sure are relevant to this. One of the url's we construct is constructed as follows: &lt;s:url id="blah" includeParams="get"&gt; This works fine when deploying in jboss as a normal webapp dropped in deploy/. So then all urls are of the form http://localhost:8080/mywebapp/... and when using this tag all the get parameters get included as expected. However we wish to deploy this code in the root context (so everything ends up under http://localhost:8080/...), so we deployed it as ROOT.war. Suddenly, all the get parameters no longer show up in the URL. I've been looking for a while and can't seem to figure out what might cause this. First I thought it was to do with the URL rewriting but it seems to be working fine. Any tips, pointers, further questions for clarification are welcome. To add to the confusion, this all also works fine when deployed in jetty (where root context is the default). edit: I've also tried removing ROOT.war and using jboss-web.xml to deploy to root context, this exhibits the exact same problem though.
tagged with: url-rewriting
favorite count: 0
accepted answer: http://stackoverflow.com/a/532467
upvote count: 1
has title: Getting struts s:url includeparams to work on jboss when deploying as ROOT.war
type: AnsweredQuestion
score: 1
tagged with: java
tagged with: jboss
type: Question
tagged with: jakarta-ee
has answer: http://stackoverflow.com/a/532467
answer count: 1

http://stackoverflow.com/a/647267
answers question: http://stackoverflow.com/q/647252
type: Answer
score: 5
upvote count: 5
downvote count: 0
has body: Your root cause Exception is javax.sound.sampled.LineUnavailableException: line with format ALAW 8000.0 Hz, 8 bit, stereo, 2 bytes/frame, not supported This occurs because not all sound drivers support all bit rates or encodings, or because the machine just doesn't have a sound card. Sound can be encoded in A law or mu law (or others, such as MP3) and can be encoded at different bit rates and sample sizes. Java does not always support all possible sound formats, depending on what is supported by the base system. You probably want to do the following: Ensure that the computer on which you're running the program has a reasonable sound card. Most of the time when I see the above Exception, I'm running on server machine with no built-in sound card or with a really lame sound card or with no audio path. If you're using a remote terminal or something like this, ensure that the sound has a configured way to play. Try re-encoding your sound sample at a different rate, or perhaps as a WAV file, and then try playing it.

http://stackoverflow.com/comment/97195571
score: 1
comment on: http://stackoverflow.com/a/2692379
type: AnswerComment
type: Comment
has text: I said in another comment that blocking `super.super.` invites programmers to find new, convoluted and egregious ways to shoot themselves in the foot in the pursuit of a workaround, this is a perfect example of that, because your colleagues will probably hate you so much for writing something like this that they will personally and literally shoot you in the foot. +1

http://stackoverflow.com/a/8433926
downvote count: 0
has body: why this would have been bad idea? : abstract class ImmutableNumber extends Number implements Comparable { // do NOT implement compareTo method; allowed because class is abstract } class Integer extends ImmutableNumber { // implement compareTo here } class Long extends ImmutableNumber { // implement compareTo here } another option may have been to declare class Number implements Comparable, omit compareTo implementation, and implement it in some classes like Integer while throw UnsupportedException in others like AtomicInteger.
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/480632
score: 1

http://stackoverflow.com/q/448320
has answer: http://stackoverflow.com/a/47422203
favorite count: 0
possible better answer: http://stackoverflow.com/a/448347
linked to: http://stackoverflow.com/q/654054
has answer: http://stackoverflow.com/a/5984003
has answer: http://stackoverflow.com/a/448526
has answer: http://stackoverflow.com/a/448334
has answer: http://stackoverflow.com/a/473348
has answer: http://stackoverflow.com/a/448341
tagged with: foreach
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/27993769
has answer: http://stackoverflow.com/a/654252
linked to: http://stackoverflow.com/q/448122
tagged with: java
has answer: http://stackoverflow.com/a/450514
score: 33
type: Question
has answer: http://stackoverflow.com/a/57807613
upvote count: 33
has answer: http://stackoverflow.com/a/617199
tagged with: newline
has answer: http://stackoverflow.com/a/450548
has answer: http://stackoverflow.com/a/4272720
answer count: 16
has answer: http://stackoverflow.com/a/448333
has title: How do I append a newline character for all lines except the last one?
has body: I'm iterating through a HashMap (see my earlier question for more detail) and building a string consisting of the data contained in the Map. For each item, I will have a new line, but for the very last item, I don't want the new line. How can I achieve this? I was thinking I could so some kind of check to see if the entry is the last one or not, but I'm not sure how to actually do that. Thanks!
has answer: http://stackoverflow.com/a/448365
has answer: http://stackoverflow.com/a/448347
has comment: http://stackoverflow.com/comment/300903
has comment: http://stackoverflow.com/comment/269376
accepted answer: http://stackoverflow.com/a/448333
downvote count: 0

http://stackoverflow.com/a/485805
has body: If you build a shed and use a hammer 80-90% of the time, does it follow that you should use only hammers to build sheds? No, you use the most appropriate tools for each part of the job, just as you have done! Also the average skills/experience level of the IT work-force has increased in recent years. E.g. This SO Poll showed the medium SO programmer is in their 30's with over 10 years experience. You boss will have no problem recruiting programmers with a broad mix of skills and experience.
upvote count: 2
answers question: http://stackoverflow.com/q/484355
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/comment/76110683
type: AnswerComment
comment on: http://stackoverflow.com/a/517539
type: Comment
has text: @DonBranson nowadays, we have 64bits JVM. can i suppose that on 64bits JVM, long/double are atomic (i.e all 64bits are read in one step) ??
score: 0

http://stackoverflow.com/a/528533
score: 4
has comment: http://stackoverflow.com/comment/341555
upvote count: 4
has comment: http://stackoverflow.com/comment/342439
downvote count: 0
has body: Doesn't the first way of handling exceptions does exactly this (the try-throw-catch mechanism)? I mean, it throws an exception and catches it in the same method. That's not a "way of handling exceptions" - it's utter nonsense. The whole point of exceptions is to let another method up the call stack handle it. If you're going to handle the condition within the same method, there's no point in using an exception - that's what if() is for! If that makes the control flow of your method too complicated, you should probably refactor some of the logic into separate methods - and then it might make sense to have those throw exception that the remaining method body catches. That being said, I can imagine one special case where it could make sense to throw and catch an exception in the same method: when you're already calling a method that may throw an exception and have a catch block to handle it, then in some cases it could make sense to throw an exception to indicate a similar problem that the existing catch block can handle in the same way.
type: Answer
answers question: http://stackoverflow.com/q/528417

http://stackoverflow.com/comment/55168092
has text: @MarcGravell I would not put one that is least likely to be used correctly to be first in the post, but that is your call. (Comment will self-destruct sometime soon).
type: Comment
comment on: http://stackoverflow.com/a/541348
score: 0
type: AnswerComment

graphics
tag name: graphics
tags question: http://stackoverflow.com/q/638363
tags question: http://stackoverflow.com/q/591291
tags question: http://stackoverflow.com/q/372755
tags question: http://stackoverflow.com/q/465994
tags question: http://stackoverflow.com/q/563237
tags question: http://stackoverflow.com/q/602688
tags question: http://stackoverflow.com/q/645137
tags question: http://stackoverflow.com/q/576235
tags question: http://stackoverflow.com/q/395599
tags question: http://stackoverflow.com/q/639977
type: Tag
tags question: http://stackoverflow.com/q/541774
tags question: http://stackoverflow.com/q/566711
tags question: http://stackoverflow.com/q/602249
tags question: http://stackoverflow.com/q/609002
tags question: http://stackoverflow.com/q/567181
tags question: http://stackoverflow.com/q/438221
tags question: http://stackoverflow.com/q/481619
tags question: http://stackoverflow.com/q/575706
tags question: http://stackoverflow.com/q/548360
tags question: http://stackoverflow.com/q/400566
tags question: http://stackoverflow.com/q/563109
tags question: http://stackoverflow.com/q/424849
tags question: http://stackoverflow.com/q/639243
tags question: http://stackoverflow.com/q/640443
tags question: http://stackoverflow.com/q/506589
tags question: http://stackoverflow.com/q/537297

http://stackoverflow.com/a/484840
score: 41
has body: A RuntimeException should be used only when the client cannot recover from whatever the problem is. It is occasionally appropriate to do what you are talking about, but more often it is not appropriate. If you are using a JDK >= 1.4, then you can do something like: try { // Code that might throw an exception } catch (IOException e) { throw new RuntimeException(e); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } and the rethrown RuntimeException will have the original cause included inside it. This way, someone at the top of the thread catching the RuntimeException -- your threads do catch RuntimeException so they don't just silently die, right? -- can at least print out the FULL stack trace of the cause. But as others have said and will say, exceptions are checked for a reason. Only do this when you are positive that your clients cannot recover from the problem that you are rethrowing as an unchecked exception. NOTE: Better than just RuntimeException would be to use a more specific unchecked exception if one is available. For example, if the only reason your method could throw a ClassNotFoundException is because a configuration file is missing, you could rethrow a MissingResourceException, which is an unchecked exception but gives more information about why you are throwing it. Other good RuntimeExceptions to use if they describe the problem you are rethrowing are IllegalStateException, TypeNotPresentException and UnsupportedOperationException. Also note that it is ALWAYS a good idea for your threads to catch RuntimeException and at a minimum log it. At least this way you understand why your threads are going away.
has comment: http://stackoverflow.com/comment/301476
has comment: http://stackoverflow.com/comment/301451
has comment: http://stackoverflow.com/comment/301385
accepted answer of: http://stackoverflow.com/q/484794
has comment: http://stackoverflow.com/comment/71326386
has comment: http://stackoverflow.com/comment/301609
answers question: http://stackoverflow.com/q/484794
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/31748736
downvote count: 0
has comment: http://stackoverflow.com/comment/301650
has comment: http://stackoverflow.com/comment/301730
upvote count: 41
type: Answer
has comment: http://stackoverflow.com/comment/71308790

http://stackoverflow.com/comment/297583
comment on: http://stackoverflow.com/a/480584
type: AnswerComment
score: 0
type: Comment
has text: @Darron: Ok, at first it sounded like you were saying that the Thread didn't have to keep it around.

http://stackoverflow.com/comment/45509621
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2599980
has text: Make sure it's a security group, https://technet.microsoft.com/en-us/library/cc781446%28v=ws.10%29.aspx.
type: AnswerComment

http://stackoverflow.com/q/646940
tagged with: java
tagged with: inputstream
possible better answer: http://stackoverflow.com/a/646957
upvote count: 7
linked to: http://stackoverflow.com/q/3159913
has title: why does java's inputstream.close() block?
favorite count: 0
has body: My Java program uses ProcessBuilder (with redirectErrorStream set true) and has a loop that runs the processes's inputstream's read method, which is blocking. The external program I'm calling then comes to a stop waiting for input and stdin. I now want to kill the process. Is this not done by (in a seperate thread) calling the process's destroy method, and calling the inputstream's close method to stop the read method from blocking anymore, so that my initial thread can end its life? For some reason process.getInputStream().close() blocks. From the JavaDoc I don't see why this can happen. Furthermore, I don't understand why the javadoc says "The close method of InputStream does nothing." (link to javadoc) Could someone explain this? Thanks :-)
answer count: 4
has answer: http://stackoverflow.com/a/646957
downvote count: 0
has comment: http://stackoverflow.com/comment/460285
has answer: http://stackoverflow.com/a/647673
has answer: http://stackoverflow.com/a/646969
accepted answer: http://stackoverflow.com/a/646969
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/646986
score: 7

http://stackoverflow.com/q/613307
tagged with: httpurlconnection
tagged with: java
possible better answer: http://stackoverflow.com/a/31123016
has answer: http://stackoverflow.com/a/58047436
tagged with: http
has answer: http://stackoverflow.com/a/31123016
has answer: http://stackoverflow.com/a/2092749
has title: Read error response body in Java
has answer: http://stackoverflow.com/a/60755943
has answer: http://stackoverflow.com/a/37275327
upvote count: 101
has body: In Java, this code throws an exception when the HTTP result is 404 range: URL url = new URL("http://stackoverflow.com/asdf404notfound"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.getInputStream(); // throws! In my case, I happen to know that the content is 404, but I'd still like to read the body of the response anyway. (In my actual case the response code is 403, but the body of the response explains the reason for rejection, and I'd like to display that to the user.) How can I access the response body?
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/32343874
downvote count: 0
has answer: http://stackoverflow.com/a/613484
has answer: http://stackoverflow.com/a/613382
favorite count: 0
has comment: http://stackoverflow.com/comment/426136
type: Question
accepted answer: http://stackoverflow.com/a/613484
answer count: 8
has answer: http://stackoverflow.com/a/613354
score: 101

http://stackoverflow.com/comment/363170
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/551528
has text: @S.Lott - I've made the edits. Not sure they're actually relevant to the question I'm actually asking tho :-)

http://stackoverflow.com/a/37221449
score: 4
upvote count: 4
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/364114
has body: A quick&amp;dirty batch solution (based on Alex's answer): libs.bat @ECHO OFF FOR %%I IN (*.jar) DO ( echo ^&lt;dependency^&gt; echo ^&lt;groupId^&gt;local.dummy^&lt;/groupId^&gt; echo ^&lt;artifactId^&gt;%%I^&lt;/artifactId^&gt; echo ^&lt;version^&gt;0.0.1^&lt;/version^&gt; echo ^&lt;scope^&gt;system^&lt;/scope^&gt; echo ^&lt;systemPath^&gt;${project.basedir}/lib/%%I^&lt;/systemPath^&gt; echo ^&lt;/dependency^&gt; ) Execute it like this: libs.bat &gt; libs.txt. Then open libs.txt and copy its content as dependencies. In my case, I only needed the libraries to compile my code, and this solution was the best for that purpose.

http://stackoverflow.com/q/505928
has answer: http://stackoverflow.com/a/66405630
favorite count: 0
tagged with: arraylist
has answer: http://stackoverflow.com/a/600337
has answer: http://stackoverflow.com/a/505954
upvote count: 240
has answer: http://stackoverflow.com/a/54575586
has answer: http://stackoverflow.com/a/28203967
has answer: http://stackoverflow.com/a/35208694
has comment: http://stackoverflow.com/comment/323477
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/509117
has answer: http://stackoverflow.com/a/47283162
has answer: http://stackoverflow.com/a/505979
has body: I have an ArrayList, a Collection class of Java, as follows: ArrayList&lt;String&gt; animals = new ArrayList&lt;String&gt;(); animals.add("bat"); animals.add("owl"); animals.add("bat"); animals.add("bat"); As you can see, the animals ArrayList consists of 3 bat elements and one owl element. I was wondering if there is any API in the Collection framework that returns the number of bat occurrences or if there is another way to determine the number of occurrences. I found that Google's Collection Multiset does have an API that returns the total number of occurrences of an element. But that is compatible only with JDK 1.5. Our product is currently in JDK 1.6, so I cannot use it.
tagged with: collections
has answer: http://stackoverflow.com/a/2459753
has answer: http://stackoverflow.com/a/26253933
has answer: http://stackoverflow.com/a/36073434
has answer: http://stackoverflow.com/a/509307
has answer: http://stackoverflow.com/a/39254390
has answer: http://stackoverflow.com/a/505942
has answer: http://stackoverflow.com/a/505941
has answer: http://stackoverflow.com/a/28516715
tagged with: java
has answer: http://stackoverflow.com/a/56678675
has answer: http://stackoverflow.com/a/66610169
has answer: http://stackoverflow.com/a/35199234
has answer: http://stackoverflow.com/a/505935
has answer: http://stackoverflow.com/a/45845518
type: Question
answer count: 25
has answer: http://stackoverflow.com/a/27206052
has answer: http://stackoverflow.com/a/66321564
downvote count: 0
has answer: http://stackoverflow.com/a/505945
has title: How to count the number of occurrences of an element in a List
score: 240

http://stackoverflow.com/a/366269
score: 6
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/366232
answers question: http://stackoverflow.com/q/366232
type: Answer
upvote count: 6
downvote count: 0
has body: strictfp is a method or class modifier that forces the JVM to do floating point math a certain way that is guaranteed to be the same across different JVM implementations (stopping the JVM from cutting corners to improve performance and possibly lose some precision / accuracy). More information can be found on the wikipedia entry, but it's low on detail. Hardcore information (if you care) can be found in the JVM spec.

http://stackoverflow.com/a/623954
upvote count: 3
answers question: http://stackoverflow.com/q/623692
has body: If you are designing a business application with lots of entry forms and tabular data, writing code for your UI is both faster and more maintainable than using an UI designer. In those kinds of applications, there almost never need to precisely place one element at predefined place on screen, while on the other hand, there is a lots of repetition and design conventions that can simply be extracted into separate methods. Take for example an Eclipse or OpenOffice preferences dialog. There are a bunch of categories and a bunch of different options to set for each. If you have to make something of that size, hand designing each screen is a mundane task. Much better approach is to write code which will generate UI elements on-the-fly, from provided domain data, according to some conventions and defaults. I don't see how using a designer facilitates better separation, nor how that perceived separation would help with anything, given that you already keep your business logic out of the UI. And, finally, if you're using Java, be sure to check out MigLayout. It works with Swing and SWT, its' syntax is very concise and clear, and it has a debug mode that's unbelievably useful.
has comment: http://stackoverflow.com/comment/436912
downvote count: 0
type: Answer
score: 3
has comment: http://stackoverflow.com/comment/437247

http://stackoverflow.com/a/78973308
score: 0
type: Answer
has body: In JAVA, we can use a piece of executable code that can be called later, for example after a certain event or completion of a task(Callback Function). This is useful when we want to delay the execution or we need to handle asynchronous processes (as an example an async http-request, when the point is not blocking the main program flow because of waiting for one thread to finish running. In JAVA, usually Callback Functions are implemented by Interface. In the following code, you see a simple calculator. I have defined an interface called "ResultListener" that contains a method. This method(onResult) is then implemented by another class or passed as a lambda expression. The onResult method is like a placeholder for what should be done, when the result is available. The "Calculator" class handles the arithmetic operations (Add, Subtract, Multiply and Division) using an ExecutorService. These methods are called in a loop in Main function and for each call a task is submitted to the thread pool that is excecuted asynchronously. Once the operation is completed, the onResult method of corresponding "ResultListener" (here instantiated by name: listener) is invoked passing the type of operation, variables (operands) and the result. in the main function when we instantiate "ResultListener", the lambda expression is defining what should be done when the Callback is invoked. ResultListener listener = (operation, a, b, result) -> System.out.println(operation + " of " + a + ", " + b + " Result: " + result); here, it is just printing. import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class test { public interface ResultListener { void onResult(String operation ,int a, int b, int result); } public static class Calculator { private ResultListener listener; private ExecutorService executor = Executors.newFixedThreadPool(5); public Calculator(ResultListener listener) { this.listener = listener; } public void Add(int a, int b) { executor.execute…
answers question: http://stackoverflow.com/q/443708

http://stackoverflow.com/a/645404
downvote count: 2
score: 0
has body: It's difficult to answer this question without looking at the code (which I guess will be big enough to not be publishable here). However, using Occam's razor, you have two possibilies Server objects must be getting unregistered somehow Since breakpoints stop the errors, it's definitely a race condition. I would suggest you go over the code paths carefully keeping the two points above in mind.
type: Answer
answers question: http://stackoverflow.com/q/645208
upvote count: 2

http://stackoverflow.com/q/528664
tagged with: java
has answer: http://stackoverflow.com/a/1206861
has answer: http://stackoverflow.com/a/739287
has answer: http://stackoverflow.com/a/528711
accepted answer: http://stackoverflow.com/a/528745
type: Question
has answer: http://stackoverflow.com/a/528669
answer count: 11
has answer: http://stackoverflow.com/a/528745
upvote count: 28
linked to: http://stackoverflow.com/q/528312
downvote count: 0
has answer: http://stackoverflow.com/a/528714
favorite count: 0
has answer: http://stackoverflow.com/a/529166
score: 28
has answer: http://stackoverflow.com/a/529421
tagged with: serialization
has title: Simple way to do Xml in Java
has answer: http://stackoverflow.com/a/528686
possible better answer: http://stackoverflow.com/a/528669
has body: Is there is Simple way to read and write Xml in Java? I've used a SAX parser before but I remember it being unintuitive, I've looked at a couple of tutorials for JAXB and it just looks complicated. I don't know if I've been spoilt by C#'s XmlDocument class, but All I want to do is create an Xml Document that represents a a set of classes and their members (some are attributes some are elements). I would look into serialization but the XML has to have the same format as the output of a c# app which I am reverse engineering into Java.
tagged with: http://stackoverflow.com/tag/xml
has answer: http://stackoverflow.com/a/528829
has answer: http://stackoverflow.com/a/528699
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/831865

http://stackoverflow.com/q/574056
possible better answer: http://stackoverflow.com/a/574084
tagged with: applet
has title: Why does this applet have a destroy method?
has answer: http://stackoverflow.com/a/574384
has answer: http://stackoverflow.com/a/574122
has body: I've been trying to learn about applets by studying the code for the "Welcome to HotJava" applet. I decompiled the *.class file using the Windows version of Jad, and I see the following lines of code public void init() { // Skip some lines... addMouseListener(this); } public void destroy() { removeMouseListener(this); } Is the destroy method really necessary here? Why does the applet need to remove itself as a mouse listener if it's just about to end?
answer count: 4
favorite count: 0
score: 2
has answer: http://stackoverflow.com/a/574106
accepted answer: http://stackoverflow.com/a/574106
downvote count: 0
type: Question
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/574084
upvote count: 2

http://stackoverflow.com/q/610062
has answer: http://stackoverflow.com/a/610081
possible better answer: http://stackoverflow.com/a/673132
tagged with: velocity
has answer: http://stackoverflow.com/a/610103
score: 35
tagged with: java
has answer: http://stackoverflow.com/a/15984767
type: Question
answer count: 8
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/610103
has answer: http://stackoverflow.com/a/33385467
has answer: http://stackoverflow.com/a/4557076
has title: JSP vs Velocity what is better?
upvote count: 35
has answer: http://stackoverflow.com/a/1932642
has answer: http://stackoverflow.com/a/673132
has body: What is better between JSP and velocity in - Performance - Ease of use - Ease of creating reusable components - Availability of open source 3rd parties - IDE support
downvote count: 0
tagged with: jsp
has answer: http://stackoverflow.com/a/610098
favorite count: 0

http://stackoverflow.com/a/496909
score: 3
downvote count: 0
answers question: http://stackoverflow.com/q/496884
upvote count: 3
has body: Use the sourcefiles parameter instead of sourcepath:
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/80651481
type: Answer
accepted answer of: http://stackoverflow.com/q/496884

xslt
tags question: http://stackoverflow.com/q/424119
tags question: http://stackoverflow.com/q/601702
tags question: http://stackoverflow.com/q/460895
tags question: http://stackoverflow.com/q/539781
tags question: http://stackoverflow.com/q/450165
tags question: http://stackoverflow.com/q/618222
tags question: http://stackoverflow.com/q/529309
tags question: http://stackoverflow.com/q/643659
tags question: http://stackoverflow.com/q/473041
tags question: http://stackoverflow.com/q/547599
tag name: xslt
tags question: http://stackoverflow.com/q/430001
tags question: http://stackoverflow.com/q/544153
tags question: http://stackoverflow.com/q/369760
type: Tag
tags question: http://stackoverflow.com/q/581939
tags question: http://stackoverflow.com/q/589486
tags question: http://stackoverflow.com/q/562241

http://stackoverflow.com/comment/264604
comment on: http://stackoverflow.com/a/429284
has text: formatting got lost ... all the listed files are in the root of the ear file
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/439323
score: 2
upvote count: 2
has answer: http://stackoverflow.com/a/439516
tagged with: java
has answer: http://stackoverflow.com/a/439362
has title: C++ .NET equivalent to java public static void main()?
type: Question
tagged with: .net
has answer: http://stackoverflow.com/a/439363
tagged with: equivalent
has answer: http://stackoverflow.com/a/439391
has body: In java I can simply test classes directly with public static void main() I then just add quick code and under Eclipse "Run" the class. Is there anything similar in C++ .NET ? Right now I have to create an empty project, reference the correct headers then set that project as start up project.
downvote count: 0
favorite count: 0
type: UnansweredQuestion
answer count: 4
tagged with: c++

http://stackoverflow.com/comment/241784
has text: You shouldn't be suggesting solutions you've never used, it's poor advice (even if it is right).
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/417525
type: Comment

http://stackoverflow.com/a/620042
downvote count: 0
upvote count: 3
has body: My opinion is that since it is a programmer error you should either assert on it or throw a RuntimException (Java, or whatever the equivalent is for other languages). I have my own UnhandledEnumException that extends from RuntimeException that I use for this.
answers question: http://stackoverflow.com/q/619945
type: Answer
score: 3

http://stackoverflow.com/a/23698107
type: Answer
score: 2
downvote count: 0
has body: Pagination using Query Interface: There are two methods of the Query interface for pagination. 1. Query setFirstResult(int startPosition): This method takes an integer that represents the first row in your result set, starting with row 0. 2. Query setMaxResults(int maxResult): This method tells Hibernate to retrieve a fixed number maxResults of objects. Using above two methods together, we can construct a paging component in our web or Swing application. Example: Query query = session.createQuery("FROM Employee"); query.setFirstResult(5); query.setMaxResults(10); List&lt;Employee&gt; list = query.list(); for(Employee emp: list) { System.out.println(emp); } Pagination using Criteria Interface: There are two methods of the Criteria interface for pagination. 1. Criteria setFirstResult(int firstResult): Set the first result to be retrieved. 2. List item Criteria setMaxResults(int maxResults): Set a limit upon the number of objects to be retrieved. Example: Criteria criteria = session.createCriteria(Employee.class); criteria.setFirstResult(5); criteria.setMaxResults(10); List&lt;Employee&gt; list = criteria.list(); for(Employee emp: list) { System.out.println(emp); }
answers question: http://stackoverflow.com/q/489360
upvote count: 2

http://stackoverflow.com/q/564807
has answer: http://stackoverflow.com/a/564864
has title: Sortable table-like Java class
has answer: http://stackoverflow.com/a/564866
has answer: http://stackoverflow.com/a/565191
answer count: 7
favorite count: 0
accepted answer: http://stackoverflow.com/a/564864
has answer: http://stackoverflow.com/a/564859
has answer: http://stackoverflow.com/a/564964
has body: Does anyone know of a class in Java that has a list of elements, so that the elements are sortable by any of the elements members? The idea is basically to have some database table-like implementation, where you can just add fields to sort by. To illustrate: SomeTable table = new SomeTable(); table.addField("name", String); table.addField("age", int); table.addField("hair color", String); table.add(new Object[]{"Thomas", 32, "brown"}); table.add(new Object[]{"Jack", 34, "black"}); table.sort("age") would sort the table so that Thomas is the first element, while table.sort("name") would sort the table so that Jack is the first element. I can code something like this myself (actually I have done that once), but I'm just curious to see if there's a ready library to do such things (without a database). PS: I know that int is not a class, but that's not the point here. This example code is just here to show the kind of functionality I expect.
score: 2
has answer: http://stackoverflow.com/a/565221
possible better answer: http://stackoverflow.com/a/564851
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/564851
downvote count: 1
type: Question
type: AnsweredQuestion
tagged with: sorting

hibernate
tags question: http://stackoverflow.com/q/462898
tags question: http://stackoverflow.com/q/413131
tags question: http://stackoverflow.com/q/423924
tags question: http://stackoverflow.com/q/416432
tags question: http://stackoverflow.com/q/391989
tags question: http://stackoverflow.com/q/530215
tags question: http://stackoverflow.com/q/444932
tags question: http://stackoverflow.com/q/644814
tags question: http://stackoverflow.com/q/396391
tags question: http://stackoverflow.com/q/490354
tags question: http://stackoverflow.com/q/489360
tags question: http://stackoverflow.com/q/549961
tags question: http://stackoverflow.com/q/508019
tags question: http://stackoverflow.com/q/509950
tags question: http://stackoverflow.com/q/594597
tags question: http://stackoverflow.com/q/641388
tags question: http://stackoverflow.com/q/504337
tags question: http://stackoverflow.com/q/407492
tags question: http://stackoverflow.com/q/369460
tags question: http://stackoverflow.com/q/643055
tags question: http://stackoverflow.com/q/606489
tags question: http://stackoverflow.com/q/430899
tags question: http://stackoverflow.com/q/586077
tags question: http://stackoverflow.com/q/431635
tags question: http://stackoverflow.com/q/635906
tags question: http://stackoverflow.com/q/424312
tags question: http://stackoverflow.com/q/510000
tags question: http://stackoverflow.com/q/587538
tags question: http://stackoverflow.com/q/471799
tags question: http://stackoverflow.com/q/520902
tags question: http://stackoverflow.com/q/630054
tags question: http://stackoverflow.com/q/376093
tags question: http://stackoverflow.com/q/634342
tags question: http://stackoverflow.com/q/359287
tags question: http://stackoverflow.com/q/566264
tags question: http://stackoverflow.com/q/605986
tag name: hibernate
tags question: http://stackoverflow.com/q/425039
tags question: http://stackoverflow.com/q/531451
tags question: http://stackoverflow.com/q/484929
tags question: http://stackoverflow.com/q/447478
tags question: http://stackoverflow.com/q/631695
tags question: http://stackoverflow.com/q/531096
tags question: http://stackoverflow.com/q/586592
tags question: http://stackoverflow.com/q/432347
tags question: http://stackoverflow.com/q/452669
tags question: http://stackoverflow.com/q/492315
tags question: http://stackoverflow.com/q/529904
tags question: http://stackoverflow.com/q/582526
tags question: http://stackoverflow.com/q/518267
tags question: http://stackoverflow.com/q/556238
tags question: http://stackoverflow.com/q/520869
tags question: http://stackoverflow.com/q/467879
tags question: http://stackoverflow.com/q/628963
tags question: http://stackoverflow.com/q/578433
tags question: http://stackoverflow.com/q/609351
tags question: http://stackoverflow.com/q/635630
tags question: http://stackoverflow.com/q/554481
tags question: http://stackoverflow.com/q/498676
tags question: http://stackoverflow.com/q/602397
tags question: http://stackoverflow.com/q/517861
tags question: http://stackoverflow.com/q/602749
tags question: http://stackoverflow.com/q/576659
tags question: http://stackoverflow.com/q/418197
tags question: http://stackoverflow.com/q/364472
tags question: http://stackoverflow.com/q/486964
tags question: http://stackoverflow.com/q/634687
tags question: http://stackoverflow.com/q/605749
type: Tag
tags question: http://stackoverflow.com/q/570229
tags question: http://stackoverflow.com/q/417062
tags question: http://stackoverflow.com/q/448246
tags question: http://stackoverflow.com/q/645002
tags question: http://stackoverflow.com/q/608923
tags question: http://stackoverflow.com/q/399401
tags question: http://stackoverflow.com/q/438146
tags question: http://stackoverflow.com/q/434014
tags question: http://stackoverflow.com/q/398215
tags question: http://stackoverflow.com/q/477267
tags question: http://stackoverflow.com/q/378297

http://stackoverflow.com/q/605876
tagged with: connection-pooling
score: 0
accepted answer: http://stackoverflow.com/a/619142
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/914863
has title: Proxool maximum connection count
answer count: 3
has body: I'm using proxool java connection pool (version 0.9.1). Everything works fine till I reach the maximum connection count. If the maximum connection count is reached proxool immediately throws an SQLExcepion: java.sql.SQLException: Couldn't get connection because we are at maximum connection count (n/n) and there are none available Of course instead of n the maximum connection count is shown. Why is proxool throwing an SQLException immediately instead of waiting for an available connection? Not forever of course, but a configurable timeout would be great. I don't know if it important, but I'm using proxool in a Tomcat J2EE application. Parameters of proxool are defined in context.xml and I'm using Proxool DataSource Support.
tagged with: proxool
has answer: http://stackoverflow.com/a/619142
possible better answer: http://stackoverflow.com/a/612215
has answer: http://stackoverflow.com/a/612215
type: AnsweredQuestion

http://stackoverflow.com/a/550663
answers question: http://stackoverflow.com/q/398215
upvote count: 1
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/367241
score: 1
has body: We ran into this problem at work. I fixed it, as Robert suggests, by creating a connection provider (ie, an implementation of DataSource), called ""OracleSchemaRemappingDataSource" and using spring to do the plumbing. Basically, this datasource implements getConnection(). The implementation of that method works by getting a connection from some other data source by spring injection, which it assumes to be an oracle connection, and then executing ALTER SESSION SET CURRENT_SCHEMA = 'someotherschema' and them passing that connection back. All of the hibernate config is careful to use names without specifying schemas for them. Also: with this, you don't want to disable caching - allow hibernate to manage connections as normal, as we are not doing any magic within the app such as using different connections on a per-user basis.
has comment: http://stackoverflow.com/comment/362712

http://stackoverflow.com/comment/91775123
comment on: http://stackoverflow.com/a/448318
has text: Didn't feel like offering any profiler options?
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/458088
downvote count: 0
has comment: http://stackoverflow.com/comment/30683007
has comment: http://stackoverflow.com/comment/31272216
answers question: http://stackoverflow.com/q/456148
type: Answer
upvote count: 19
score: 19
has comment: http://stackoverflow.com/comment/35684462
has body: I ran into a similar problem about a year ago. In our case, our front end developers were all familiar with JSP, and I really did not want to throw another templating engine into the mix. I wanted something that relied on the servlet container's JSP processor to generate e-mail content for me. It's fairly straightforward: I had to have a JSP page in my application (you can put it in /WEB-INF if you don't want it externally accessible). I wrote a custom HttpServletResponse and ServletOutputStream that captures content written by the servlet container and turns it into a String, and relied on RequestDispatcher.include(...) to make a "request" to the template JSP (I also wrote a custom HttpServletRequest to isolate the original request from mutation). Because this is a bit of a hack, and not the way the servlet API was intended to be used, I encapsulated all this in a utility class, so that all the client code has to do is pass in the path to the JSP template, and get back the processed content.
has comment: http://stackoverflow.com/comment/30663223

http://stackoverflow.com/q/427482
has title: java.awt.Color error
possible better answer: http://stackoverflow.com/a/429700
has answer: http://stackoverflow.com/a/429700
accepted answer: http://stackoverflow.com/a/427540
score: 0
tagged with: resin
tagged with: jsp
has answer: http://stackoverflow.com/a/17693407
linked to: http://stackoverflow.com/q/34588
has answer: http://stackoverflow.com/a/427506
has answer: http://stackoverflow.com/a/427540
has body: I have this simple Jsp page: &lt;%@ page language="java" import="java.awt.Color"%&gt; &lt;% Color background = Color.white; %&gt; Which fails with following error: java.lang.NoClassDefFoundError at _text__jsp._jspService(/text.jsp:3) at com.caucho.jsp.JavaPage.service(JavaPage.java:75) at com.caucho.jsp.Page.subservice(Page.java:506) at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182) at com.caucho.server.http.Invocation.service(Invocation.java:315) at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135) at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:346) at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:274) at com.caucho.server.TcpConnection.run(TcpConnection.java:139) at java.lang.Thread.run(Thread.java:534) I'm running it on Resin 2.1.13. Any idea what's causing this?
answer count: 4
type: AnsweredQuestion
tagged with: java
type: Question

http://stackoverflow.com/a/10426838
upvote count: 25
answers question: http://stackoverflow.com/q/512692
type: Answer
has comment: http://stackoverflow.com/comment/16197117
score: 25
has body: public String listmap_to_json_string(List&lt;Map&lt;String, Object&gt;&gt; list) { JSONArray json_arr=new JSONArray(); for (Map&lt;String, Object&gt; map : list) { JSONObject json_obj=new JSONObject(); for (Map.Entry&lt;String, Object&gt; entry : map.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); try { json_obj.put(key,value); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } json_arr.put(json_obj); } return json_arr.toString(); } alright, try this~ This worked for me :D
downvote count: 0

http://stackoverflow.com/comment/10535411
type: Comment
type: AnswerComment
score: 4
has text: Yes, generating code is an additional step for developers, but it saves you a great deal of performance in the app. Both bootstrapping and parsing database results are significantly faster. Other tools rely on reflection, which is cruelly slow in Android.
comment on: http://stackoverflow.com/a/7873389

http://stackoverflow.com/a/530319
upvote count: 8
type: Answer
score: 8
answers question: http://stackoverflow.com/q/530203
has body: One of your Ant XML files should have a "junit" task in it; in your case, it sounds as if this task has the "haltonerror" attribute set to "on", which causes the build to halt if any of the JUnit tests fail. If you can't spot the junit directive immediately, it might be in an included file (look for "import" directives, usually near the top of the file). You can set this attribute to "off" to change this behaviour, but I'd strongly advise against it; you want your unit tests to tell you when the code is broken. If any of the tests are going to be known failures due to changes in the code, it's better to fix the test before continuing with your code changes than to turn it off.
downvote count: 0

http://stackoverflow.com/q/565252
score: 16
downvote count: 1
upvote count: 17
type: Question
has answer: http://stackoverflow.com/a/9963553
has answer: http://stackoverflow.com/a/22378884
has answer: http://stackoverflow.com/a/565261
has body: Does anyone know how I would set the color of a string that will be printed using System.out? This is the code I currently have: System.out.println("TEXT THAT NEEDS TO BE A DIFFERENT COLOR.");
has comment: http://stackoverflow.com/comment/37779196
has title: How to set a string's color
linked to: http://stackoverflow.com/q/5762491
has comment: http://stackoverflow.com/comment/376437
has comment: http://stackoverflow.com/comment/376781
has answer: http://stackoverflow.com/a/565291
has answer: http://stackoverflow.com/a/14925806
duplicate of: http://stackoverflow.com/q/5762491
favorite count: 0
has answer: http://stackoverflow.com/a/565276
answer count: 9
tagged with: colors
has comment: http://stackoverflow.com/comment/376804
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/565399
has answer: http://stackoverflow.com/a/565445
tagged with: system.out
tagged with: java
has comment: http://stackoverflow.com/comment/376450
has answer: http://stackoverflow.com/a/565257

http://stackoverflow.com/a/635668
has comment: http://stackoverflow.com/comment/448920
upvote count: 4
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/635629
score: 4
has comment: http://stackoverflow.com/comment/449237
has body: You mean like Class&lt;T&gt;.cast(Object obj)? Something like: Class.forName("YourClass").cast(obj); Should do pretty much what you want. Be aware that this is quite smelly though and is probably a sign of poor design.

http://stackoverflow.com/q/506105
has answer: http://stackoverflow.com/a/506110
has answer: http://stackoverflow.com/a/56866220
upvote count: 298
has comment: http://stackoverflow.com/comment/321613
possible better answer: http://stackoverflow.com/a/506109
has answer: http://stackoverflow.com/a/49514009
tagged with: validation
has title: How can I check if a single character appears in a string?
has answer: http://stackoverflow.com/a/506117
has answer: http://stackoverflow.com/a/506109
has comment: http://stackoverflow.com/comment/75765194
tagged with: string
answer count: 16
favorite count: 0
has answer: http://stackoverflow.com/a/6646758
tagged with: character
has body: In Java is there a way to check the condition: "Does this single character appear at all in string x" without using a loop?
has answer: http://stackoverflow.com/a/63323603
has comment: http://stackoverflow.com/comment/49749351
has answer: http://stackoverflow.com/a/11634692
score: 293
has comment: http://stackoverflow.com/comment/117256235
has answer: http://stackoverflow.com/a/10696096
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/48162284
has answer: http://stackoverflow.com/a/506107
has answer: http://stackoverflow.com/a/507137
type: Question
has answer: http://stackoverflow.com/a/49513868
has comment: http://stackoverflow.com/comment/110287145
has answer: http://stackoverflow.com/a/66324429
has answer: http://stackoverflow.com/a/73864206
accepted answer: http://stackoverflow.com/a/506107
has answer: http://stackoverflow.com/a/10481110
downvote count: 5

http://stackoverflow.com/q/574675
type: Question
has comment: http://stackoverflow.com/comment/386493
downvote count: 0
tagged with: applet
answer count: 3
favorite count: 0
has answer: http://stackoverflow.com/a/574684
upvote count: 1
has answer: http://stackoverflow.com/a/575255
has title: read file in an applet
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/574686
score: 1
has answer: http://stackoverflow.com/a/574686
tagged with: java
tagged with: file
accepted answer: http://stackoverflow.com/a/574684
has body: Hi there I want to read out a file that lies on the server. I get the path to the file by a parameter &lt;PARAM name=fileToRead value="http://someserver.de/file.txt"&gt; when I now start the applet following error occurs Caused by: java.lang.IllegalArgumentException: URI scheme is not "file" Can someone give me a hint? BufferedReader file; String strFile = new String(getParameter("fileToRead")); URL url = new URL(strFile); URI uri = url.toURI(); try { File theFile = new File(uri); file = new BufferedReader(new FileReader(new File(uri))); String input = ""; while ((input = file.readLine()) != null) { words.add(input); } } catch (IOException ex) { Logger.getLogger(Hedgeman.class.getName()).log(Level.SEVERE, null, ex); }

http://stackoverflow.com/comment/335356
score: 0
type: Comment
comment on: http://stackoverflow.com/a/519270
has text: Well, I mean obviously -- it's a conceptual question. You don't need to implement the state pattern for a trivial app; that seems to go without saying.
type: AnswerComment

http://stackoverflow.com/a/1526812
score: 0
answers question: http://stackoverflow.com/q/383783
type: Answer
has body: Richard Yee mentions that Oracle's latest drivers fix the problem. I can confirm that. Had the same problem here with 10.2 drivers, upgraded today to ojdbc5.jar (11.2.0.1.0), and the problem is gone now.

http://stackoverflow.com/a/446034
upvote count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/269670
has body: Have you tried java.sql.Types.OTHER? It might work. API says, it's for database specific types.
type: Answer
answers question: http://stackoverflow.com/q/445455
score: 1

http://stackoverflow.com/q/637440
has title: How to use Apache HWPF to extract text and images out of a DOC file
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/26792796
linked to: http://stackoverflow.com/q/1870328
answer count: 4
score: 3
has answer: http://stackoverflow.com/a/5856244
downvote count: 0
has comment: http://stackoverflow.com/comment/15700668
tagged with: java
has body: I downloaded the Apache HWPF. I want to use it to read a doc file and write its text into a plain text file. I don't know the HWPF so well. My very simple program is here: I have 3 problems now: Some of packages have errors (they can't find apache hdf). How I can fix them? How I can use the methods of HWDF to find and extract the images out? Some piece of my program is incomplete and incorrect. So please help me to complete it. I have to complete this program in 2 days. once again I repeat Please Please help me to complete this. Thanks you Guys a lot for your help!!! This is my elementary code : public class test { public void m1 (){ String filesname = "Hello.doc"; POIFSFileSystem fs = null; fs = new POIFSFileSystem(new FileInputStream(filesname ); HWPFDocument doc = new HWPFDocument(fs); WordExtractor we = new WordExtractor(doc); String str = we.getText() ; String[] paragraphs = we.getParagraphText(); Picture pic = new Picture(. . .) ; pic.writeImageContent( . . . ) ; PicturesTable picTable = new PicturesTable( . . . ) ; if ( picTable.hasPicture( . . . ) ){ picTable.extractPicture(..., ...); picTable.getAllPictures() ; } }
tagged with: hwpf
type: Question
has answer: http://stackoverflow.com/a/5846735
upvote count: 3
favorite count: 0
has answer: http://stackoverflow.com/a/637448
tagged with: apache-poi

http://stackoverflow.com/comment/259519
comment on: http://stackoverflow.com/a/436767
has text: for my next trick, I'll try to learn Spanish by writing an essay on "Why Unicorns are cooler than Griffons" in MS Word, and let clippy correct my spelling and grammar.
type: AnswerComment
type: Comment
score: 2

http://stackoverflow.com/a/483421
has body: Whilst it would be nice to be able to omit type generic definition in these cases, it does produce warnings. (There is a serious proposal to extend the language with a non-raw syntax for inferring type here.) You really should not get into the habbit of ignoring compiler warnings. As Pete Kirkham you can use the type inference that already exists (although I suggest using shorter names).
type: Answer
answers question: http://stackoverflow.com/q/482674
score: 0

http://stackoverflow.com/comment/231015
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/405868
has text: I think that's a rather narrow if not naive view. Creational patterns have their place and factories are often good. IoC may have its place but it will never replace new. *Nothing* will ever be as clear or simple as A a = new A(); so it's preposterous to call it obsolete.

http://stackoverflow.com/comment/259493
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/436767
type: Comment
has text: yes, bad example. I was trying to code a simplistic example to the "Eclipse compiler" -- get rid of all the icons in the trough and assume it's correct.

http://stackoverflow.com/a/564334
has comment: http://stackoverflow.com/comment/375580
has comment: http://stackoverflow.com/comment/125483209
type: AcceptedAnswer
score: 39
type: Answer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/564320
upvote count: 39
answers question: http://stackoverflow.com/q/564320
has body: This is the closest you can get: Bar bar; if(foo!=null &amp;&amp; (bar = foo.getBar())!=null){ System.out.println("Success: " + bar); } else { System.out.println("Failiure."); }

http://stackoverflow.com/comment/402217
type: Comment
score: 0
comment on: http://stackoverflow.com/a/589727
type: AnswerComment
has text: I downloaded the JPedal demo jar, but (1) the xml it exported did not have bounding box info; and (2) when I did plain text extraction it did not return the "searchable"/invisi- text (I assume it tried to do OCR?)

http://stackoverflow.com/comment/36855263
has text: This did not work for me on Linux. It types just the letter, no acute.
type: AnswerComment
comment on: http://stackoverflow.com/a/2588745
score: 0
type: Comment

http://stackoverflow.com/comment/366717
has text: Let's say this bug was detected before it caused production trouble ;-)
type: AnswerComment
comment on: http://stackoverflow.com/a/554977
score: 0
type: Comment

http://stackoverflow.com/comment/220742
type: AnswerComment
score: 0
type: Comment
has text: i dunno if that exists in Java or not, but surely there is something similar. perhaps object.GetType() ?
comment on: http://stackoverflow.com/a/393861

http://stackoverflow.com/q/565634
possible better answer: http://stackoverflow.com/a/565644
has answer: http://stackoverflow.com/a/565644
has answer: http://stackoverflow.com/a/565645
type: AnsweredQuestion
has title: Why are integer literals with leading zeroes interpreted strangely?
upvote count: 71
tagged with: java
has answer: http://stackoverflow.com/a/23579623
has answer: http://stackoverflow.com/a/567690
accepted answer: http://stackoverflow.com/a/565645
type: Question
answer count: 8
has answer: http://stackoverflow.com/a/565909
score: 69
has answer: http://stackoverflow.com/a/565660
linked to: http://stackoverflow.com/q/6935345
favorite count: 0
has answer: http://stackoverflow.com/a/43788285
has answer: http://stackoverflow.com/a/565655
downvote count: 2
has body: This prints 83 System.out.println(0123) However this prints 123 System.out.println(123) Why does it work that way?

http://stackoverflow.com/a/53429345
downvote count: 0
has body: As various answers have already pointed out, the compiler is allowed to generate various constructs (including classes) that do not directly correspond to something in source code. These have to be marked as synthetic: 13.1. The Form of a Binary A binary representation for a class or interface must also contain all of the following: [...] 11. A construct emitted by a Java compiler must be marked as synthetic if it does not correspond to a construct declared explicitly or implicitly in source code, unless the emitted construct is a class initialization method (JVMS §2.9). [...] As pointed out by @Holger in a comment to another question, relevant examples for such constructs are the Class objects representing method references and lambdas: System.out.println(((Runnable) System.out::println).getClass().isSynthetic()); System.out.println(((Runnable) () -&gt; {}).getClass().isSynthetic()); Output: true true While this is not explicitly mentioned, it follows from 15.27.4. Run-Time Evaluation of Lambda Expressions: The value of a lambda expression is a reference to an instance of a class with the following properties: [...] and the almost identical wording for method references (15.13.3. Run-Time Evaluation of Method References). As this class is not explicitly mentioned anywhere in source code, it has to be synthetic.
score: 6
type: Answer
upvote count: 6
answers question: http://stackoverflow.com/q/399546

http://stackoverflow.com/comment/441077
score: 0
type: AnswerComment
has text: heheheh ... At least take a look at the source control system ( you have one don't you ) The places that have more changes in the last months are the ones that deserve refactoring.
type: Comment
comment on: http://stackoverflow.com/a/628273

http://stackoverflow.com/q/465142
tagged with: jdbc
has comment: http://stackoverflow.com/comment/283514
type: UnansweredQuestion
has title: Weird JDBC executeQuery exception
tagged with: large-query
has comment: http://stackoverflow.com/comment/302658
has comment: http://stackoverflow.com/comment/283475
has answer: http://stackoverflow.com/a/465524
tagged with: java
tagged with: mysql
type: Question
has answer: http://stackoverflow.com/a/486177
score: 0
answer count: 3
has body: I have the following code: public Object RunQuery(String query) throws Exception{ System.out.println("Trying to run query"); Statement stmt = null; ResultSet rs = null; try { stmt = conn.createStatement(); System.out.println("Got Statement"); rs = stmt.executeQuery(query); System.out.println("Query executed"); ... } catch (SQLException ex) { // handle any errors System.out.println("SQLException: " + ex.getMessage()); System.out.println("SQLState: " + ex.getSQLState()); System.out.println("VendorError: " + ex.getErrorCode()); } catch (Exception ex) { System.out.println("Exception: " + ex.getMessage()); } finally { if (rs != null) { try { rs.close(); } catch (SQLException sqlEx) { } // ignore rs = null; } if (stmt != null) { try { stmt.close(); } catch (SQLException sqlEx) { } // ignore stmt = null; } return ret; } } Which works perfectly fine when running query = "SELECT * FROM smalltable" But fails on query = "SELECT * FROM bigtable" which has about 200K records. The debugger elegantly ignores the catch blocks and goes straight into the finally block; NetBeans gave me this stack frame when I added stmt.executeQuery(query) to the watch list: &gt;Exception occurred in target VM: Communications link failure Last packet sent to the server was 0 ms ago. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Last packet sent to the server was 0 ms ago. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3009) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2895) …
has answer: http://stackoverflow.com/a/465174

http://stackoverflow.com/a/1497838
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/638087
type: Answer
answers question: http://stackoverflow.com/q/638087
downvote count: 0
score: 6
upvote count: 6
has body: My final choice is JamVM + GNU Classpath. Works great! :)

http://stackoverflow.com/a/568241
has comment: http://stackoverflow.com/comment/88065032
answers question: http://stackoverflow.com/q/567996
type: Answer
accepted answer of: http://stackoverflow.com/q/567996
has comment: http://stackoverflow.com/comment/83591433
score: 87
has comment: http://stackoverflow.com/comment/83590511
upvote count: 87
has body: What you want to investigate is Maven's dependency plugin. Add something similar to the following to pom.xml: org.apache.maven.plugins maven-dependency-plugin ${project.build.directory} Then run mvn clean dependency:copy-dependencies to copy perform the copy. Combine this with the assembly plugin and you can package everything into a self contained archive for distribution.
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/3068275
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/572791
type: Comment
has text: Actually mainframes are cheaper than PC server clusters in most respects when doing a straight processing-over-cost calculation.

http://stackoverflow.com/q/559296
has answer: http://stackoverflow.com/a/559706
answer count: 9
has title: Java implementation of JSON to XML conversion
has answer: http://stackoverflow.com/a/559347
possible better answer: http://stackoverflow.com/a/5869811
has answer: http://stackoverflow.com/a/2588177
tagged with: http://stackoverflow.com/tag/xml
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/31299050
has answer: http://stackoverflow.com/a/10837252
tagged with: translation
accepted answer: http://stackoverflow.com/a/561337
upvote count: 21
has body: Are there existing JARs available to convert from JSON to XML?
type: Question
score: 21
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has answer: http://stackoverflow.com/a/583514
has comment: http://stackoverflow.com/comment/127284637
downvote count: 0
has answer: http://stackoverflow.com/a/6633337
has answer: http://stackoverflow.com/a/5869811
has answer: http://stackoverflow.com/a/561337
favorite count: 0

http://stackoverflow.com/a/581062
has body: Could you provide a working example and more information? For example, on what operating system are you testing on? Swing has some differences between some, e.g. JDialogs without a parent getting an entry in the gnome panel but not in the windows taskbar and things like that. Secondly, I would guess, that your JDialog is visible before you call setLocationRelativeTo, maybe through somewhat within the part you commented out as "boring". I would suggest, you punch a quick System.out.println(isVisible()); into your code, just before setLocationRelativeTo, just in case...
has comment: http://stackoverflow.com/comment/399736
score: 1
upvote count: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/574746
downvote count: 0
answers question: http://stackoverflow.com/q/574746
type: Answer

http://stackoverflow.com/a/741318
has body: This might be an overkill for you, but Project Akuma does what you want and more. I found it via this entry at Kohsuke's (one of Sun's rock start programmers) fabulously useful blog.
downvote count: 0
score: 5
has comment: http://stackoverflow.com/comment/24441504
upvote count: 5
type: Answer
answers question: http://stackoverflow.com/q/636367

http://stackoverflow.com/q/606835
answer count: 4
has comment: http://stackoverflow.com/comment/419073
type: AnsweredQuestion
has title: In Java, how should message producers identify themselves?
tagged with: java
has answer: http://stackoverflow.com/a/606920
has answer: http://stackoverflow.com/a/606848
has answer: http://stackoverflow.com/a/606856
type: Question
has comment: http://stackoverflow.com/comment/419113
score: 3
upvote count: 3
downvote count: 0
has body: I have a queue of uniform message objects with multiple producers and a single consumer. The consumer is publishing the information and needs to be able to grant access based on the data's origin, so I want the producer send a suitable identifier along with the message. The producers themselves can't be responsible for the far side access restrictions. The id should relate to the role of the producer in my application. I want to enforce that all producers have to define one and that a subclassed producer may choose to inherit or redefine it. The producer's class name would be a good approximation, but the property I want to identify is not really inherent in the class structure, it's rather something I define. I could use reflection to find out the class name or maybe an interface name, but this smells of too much overhead. Also, I'm unsure what the appropriate property would be to look for. As all producers subclass the same abstract parent class, I thought a good way would be to put a constant in there (or in an interface), but then I realised that in Java, a "constant" is really a "static final", which means I can't override it, so it doesn't work that way. How would a more experienced Java programmer do this?
possible better answer: http://stackoverflow.com/a/606856
favorite count: 0
has answer: http://stackoverflow.com/a/606896
accepted answer: http://stackoverflow.com/a/606848
tagged with: design-patterns

lazy-evaluation
tags question: http://stackoverflow.com/q/442589
type: Tag
tag name: lazy-evaluation

http://stackoverflow.com/comment/1716611
type: AnswerComment
type: Comment
has text: I believe keepGoing should be marked volatile (or its accesses be synchronized), otherwise some threads might not see the new value.
comment on: http://stackoverflow.com/a/546951
score: 1

http://stackoverflow.com/a/546198
has body: Your while loop is wrong. i never gets incremented so your window creation is in an endless loop and your CPU consumption should be at 100% until you abort the program. Also, the GUI should be completely non-responsive when you run your program.
type: Answer
score: 0
answers question: http://stackoverflow.com/q/546144
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/358074

http://stackoverflow.com/q/623692
has answer: http://stackoverflow.com/a/623718
tagged with: java
score: 15
answer count: 11
has answer: http://stackoverflow.com/a/623707
type: Question
tagged with: gui-designer
possible better answer: http://stackoverflow.com/a/623718
has answer: http://stackoverflow.com/a/623954
has answer: http://stackoverflow.com/a/623950
accepted answer: http://stackoverflow.com/a/623783
favorite count: 0
has answer: http://stackoverflow.com/a/623705
has answer: http://stackoverflow.com/a/623751
has answer: http://stackoverflow.com/a/623733
has answer: http://stackoverflow.com/a/623708
tagged with: c++
has body: I would like to hear some opinions on hand coding your GUIs as one typically do when using Java or Qt with C++, vs using a gui-designer tool? Examples of GUI designer tools would be MFC GUI-designer, Qt designer, Interface Builder (Apple). I used to be a fan of hand coding but from recent experience I have switched. The problem I have seen with hand coding is that it is fairly quick and flexible to write the GUIs but once you need to make a change to a GUI written a long time ago it can be very difficult. Finding the right element in big panel can be difficult. The second problem is that it makes it far too easy to add a lot of logic in the GUI creation and layout code. I have often had to take over maintenance of GUI code which is really hard to reuse because its behavior is mixed with its appearance and mixing layout and behavior often makes the class very large and difficult to understand. Using a GUI designer tool force a much clearer separation between appearance and logic in my view.
has title: Handcode GUI or use gui-designer tool
has answer: http://stackoverflow.com/a/623753
downvote count: 2
tagged with: windows-forms-designer
tagged with: swing
upvote count: 17
has answer: http://stackoverflow.com/a/623783
has answer: http://stackoverflow.com/a/623700
type: AnsweredQuestion

http://stackoverflow.com/a/372648
has comment: http://stackoverflow.com/comment/202990
answers question: http://stackoverflow.com/q/372639
upvote count: 4
downvote count: 0
score: 4
type: AcceptedAnswer
type: Answer
has body: Well, you could write your own classloader. That would probably do the trick - but it's really not a nice thing to do, and in particular your students would then get used to something which wouldn't work in the real world. Why not just use a short package name?
accepted answer of: http://stackoverflow.com/q/372639

coding-style
tags question: http://stackoverflow.com/q/406053
tags question: http://stackoverflow.com/q/382361
tags question: http://stackoverflow.com/q/398953
tags question: http://stackoverflow.com/q/402514
tags question: http://stackoverflow.com/q/387008
tags question: http://stackoverflow.com/q/359732
tags question: http://stackoverflow.com/q/382886
tags question: http://stackoverflow.com/q/463029
type: Tag
tags question: http://stackoverflow.com/q/382633
tag name: coding-style
tags question: http://stackoverflow.com/q/589855
tags question: http://stackoverflow.com/q/367104
tags question: http://stackoverflow.com/q/465627
tags question: http://stackoverflow.com/q/487126

http://stackoverflow.com/comment/440559
type: AnswerComment
has text: constructor injection++: Once you create an object it must be ready to use and in a consistent state.
type: Comment
comment on: http://stackoverflow.com/a/627831
score: 0

http://stackoverflow.com/comment/46601713
comment on: http://stackoverflow.com/a/499516
type: Comment
score: 0
type: AnswerComment
has text: The convention according to whom?

http://stackoverflow.com/q/460978
has body: In my helpset file, I'm declaring a favorites view, using Lesezeichen Lesezeichen javax.help.FavoritesView This automatically adds an appropriate button to the toolbar (in the swing application). Unfortunately, the tooltip of the button reads "Add to favorites". I would like to replace this by my own text, but didn't find anything about this in the documentation or using a google search. Any ideas or pointers? Disclaimer: I already posted this question to JavaRanch, didn't get an answer yet, though.
downvote count: 0
tagged with: javahelp
has answer: http://stackoverflow.com/a/461134
accepted answer: http://stackoverflow.com/a/461134
tagged with: swing
type: AnsweredQuestion
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/1143227
type: Question
answer count: 2
upvote count: 1
tagged with: tooltip
has title: Changing "Favorites" Tooltip in Java Help
favorite count: 0
has answer: http://stackoverflow.com/a/1143227

http://stackoverflow.com/a/425419
upvote count: 8
type: Answer
score: 8
has comment: http://stackoverflow.com/comment/615918
answers question: http://stackoverflow.com/q/425402
downvote count: 0
has body: Really, you don't need unix skills directly for writing java-based applications. However, if you want to develop java-based applications on unix boxes and deploy there, you want a good working understanding of how to operate and administer a unix box. But for the areas you mention (directory traversing, creating files), you'll be using Java APIs that only occasionally touch on Unix-specific ("\n" vs "\r\n", directories rooted at "/", etc.) information. When they do touch, it's not something you need to know in a programming sort of way, it's something you need to know in a user/administrator sort of way.

dtd
tags question: http://stackoverflow.com/q/582352
type: Tag
tag name: dtd
tags question: http://stackoverflow.com/q/496369

http://stackoverflow.com/a/2757551
downvote count: 0
answers question: http://stackoverflow.com/q/567659
has comment: http://stackoverflow.com/comment/72966543
has body: I've just discovered this quick Groovy-sourced solution: import groovy.time.TimeCategory import groovy.time.TimeDuration Date start = new Date() // do something here Date stop = new Date() TimeDuration td = TimeCategory.minus( stop, start ) println td
has comment: http://stackoverflow.com/comment/3017991
score: 116
has comment: http://stackoverflow.com/comment/91285972
upvote count: 116
has comment: http://stackoverflow.com/comment/25365954
type: Answer
has comment: http://stackoverflow.com/comment/44494571

http://stackoverflow.com/comment/18465783
type: AnswerComment
has text: I opened a separate thread about this, and there is a solution with Spring `@Profiles` and `@Configuration`: http://blog.springsource.org/2011/02/14/spring-3-1-m1-introducing-profile/ See also the other thread: http://stackoverflow.com/questions/13490393/annotation-driven-dependency-injection-which-handles-different-environments
type: Comment
comment on: http://stackoverflow.com/a/13471200
score: 0

http://stackoverflow.com/comment/60249277
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/459872
type: Comment
has text: Well, there is a very important difference: I have a C library (sqlite), and I want to integrate it into a java project without losing platform-independence (so SNI isn't ok). Speed is not so critical as generally for sqlite. So, what to do? Compile the library into java .class files, and integrate them. It is the solution, imho.

http://stackoverflow.com/comment/437439
type: AnswerComment
comment on: http://stackoverflow.com/a/624210
type: Comment
score: 0
has text: @Alnitak Sold! I just needed to be convinced! :-) Thanks

http://stackoverflow.com/a/392577
has body: I guess it could also be a break statement inside a switch, if the finally block is part of a switch case. Also, if the finally block calls a method implemented in some other languages, it might do whatever the compiler of that language pleases.
type: Answer
answers question: http://stackoverflow.com/q/392216
score: 0

http://stackoverflow.com/a/660990
type: Answer
has body: Just in case you might still be interested in an extra piece of info, are you aware that the most recent versions of Struts2 (that is, 2.1.?) do not impose the extension .action to your actions? In fact, you do not need any extension at all! If my recollection serves me right, the only requirement is that, in web.xml, you map your Struts2 filter (org.apache.struts2.dispatcher.FilterDispatcher) to url-pattern: /* action2 /* From then on, a <s:url> tag appearing on a page whose extension is empty will, in turn, generate a url with no extension...
score: 0
answers question: http://stackoverflow.com/q/536821
has comment: http://stackoverflow.com/comment/475050

http://stackoverflow.com/a/34307737
answers question: http://stackoverflow.com/q/567996
upvote count: 9
downvote count: 0
score: 9
has body: Take a look at maven's dependency plugin, specifically the copy-dependencies goal. The usage section describes how to do exactly what you want. To do it from the command line just do: $ mvn dependency:copy-dependencies -DoutputDirectory=OUTPUT_DIR
type: Answer

http://stackoverflow.com/a/614438
has comment: http://stackoverflow.com/comment/29533941
has comment: http://stackoverflow.com/comment/52318101
upvote count: 97
has comment: http://stackoverflow.com/comment/52311635
has comment: http://stackoverflow.com/comment/117959539
has comment: http://stackoverflow.com/comment/20232165
has comment: http://stackoverflow.com/comment/82237579
has comment: http://stackoverflow.com/comment/28029694
answers question: http://stackoverflow.com/q/613954
has comment: http://stackoverflow.com/comment/37778565
has comment: http://stackoverflow.com/comment/82803630
has comment: http://stackoverflow.com/comment/83883195
has comment: http://stackoverflow.com/comment/52313137
has comment: http://stackoverflow.com/comment/52316149
has comment: http://stackoverflow.com/comment/17857051
type: Answer
has comment: http://stackoverflow.com/comment/52316146
has comment: http://stackoverflow.com/comment/52310107
score: 90
has comment: http://stackoverflow.com/comment/52318034
has comment: http://stackoverflow.com/comment/52315393
has comment: http://stackoverflow.com/comment/8586963
has body: Rather than rehash all the (many) reasons against checked exceptions, I'll pick just one. I've lost count of the number of times I've written this block of code: try { // do stuff } catch (AnnoyingcheckedException e) { throw new RuntimeException(e); } 99% of the time I can't do anything about it. Finally blocks do any necessary cleanup (or at least they should). I've also lost count of the number of times I've seen this: try { // do stuff } catch (AnnoyingCheckedException e) { // do nothing } Why? Because someone had to deal with it and was lazy. Was it wrong? Sure. Does it happen? Absolutely. What if this were an unchecked exception instead? The app would've just died (which is preferable to swallowing an exception). And then we have infuriating code that uses exceptions as a form of flow control, like java.text.Format does. Bzzzt. Wrong. A user putting "abc" into a number field on a form is not an exception. Ok, i guess that was three reasons.
has comment: http://stackoverflow.com/comment/82176053
downvote count: 7

strong-typing
tags question: http://stackoverflow.com/q/387091
tag name: strong-typing
type: Tag

http://stackoverflow.com/a/484331
type: Answer
has body: Sparx Systems has a UML tutor here: http://www.sparxsystems.com/uml-tutorial.html They also have a trial version of their tools, if you are so inclined... EDIT: Be sure to check their navigation pane for additional resources as well.
score: 1
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/484301

http://stackoverflow.com/comment/674034
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/517502
has text: @mmyers A simple hello world uses 13mb in java on my machine which is significantly more than any other language I use. Ruby for example uses 1.4mb and common lisp is something like 3mb. I don't have mono on this machine, but it was only a couple of mb. I'm assuming that the jvm uses so much more memory for a reason and am asking what that reason is.
score: 0

http://stackoverflow.com/q/548415
tagged with: java
downvote count: 2
type: Question
has title: Is there a better Java application framework than Swing?
has answer: http://stackoverflow.com/a/548430
accepted answer: http://stackoverflow.com/a/548435
answer count: 6
score: 4
has answer: http://stackoverflow.com/a/550087
favorite count: 0
has answer: http://stackoverflow.com/a/548435
upvote count: 6
tagged with: saf
possible better answer: http://stackoverflow.com/a/548431
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/548920
has answer: http://stackoverflow.com/a/79494264
has body: I'm planning to work on some hobby Java projects. I've done some small-scale projects, so I'm familiar with the language itself and building a GUI with Swing. I'd like to make my work a little less ad-hoc and perhaps find some tools that might be useful out in the real world. NetBeans now comes bundled with the Swing Application Framework, which seems to be a very useful tool. It helps bridge the gulf between knowing how to create a JFrame and how to use one effectively in the context of a larger application. The problem being that there are large chunks of the API completely undocumented and there's virtually no documentation on how to use it. There are only two questions in the FAQ, the mailing lists are all but dead, and I can't even tell if the project is being actively developed or if it's been abandoned. I've managed to get up and running with it based largely on the two-year-old JavaOne presentation posted on the project's home page. Is there a better alternative? Is another tool/library/API out there that does the same sort of thing in a slightly more newbie-friendly way? Note that I'm planning to develop desktop applications at the moment, and am not looking for J2EE frameworks like Spring and Hibernate.
has answer: http://stackoverflow.com/a/548431

http://stackoverflow.com/comment/19119838
has text: In my case I also had to add this JComponent.setDefaultLocale(Locale.GERMAN);
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/5154408
type: Comment

http://stackoverflow.com/q/631645
type: UnansweredQuestion
tagged with: multithreading
score: 14
has title: Java StringBuilder and Thread Safety
tagged with: stringbuilder
has comment: http://stackoverflow.com/comment/444338
tagged with: java
linked to: http://stackoverflow.com/q/272535
tagged with: thread-safety
has comment: http://stackoverflow.com/comment/84731104
has answer: http://stackoverflow.com/a/633142
type: Question
has comment: http://stackoverflow.com/comment/444351
has comment: http://stackoverflow.com/comment/444367
has answer: http://stackoverflow.com/a/631655
upvote count: 14
has answer: http://stackoverflow.com/a/631669
has body: I am building up a String out of multiple pieces and want to use either StringBuffer or StringBuilder to do so. From the Java 5 docs, I see that StringBuilder is preferred when possible, with the caveat that Instances of StringBuilder are not safe for use by multiple threads. From this statement, I understand that I should not have a single StringBuilder instance shared by multiple threads. But what about this case: //Is this safe? //foo() is called simultaneously by multiple threads String foo(String a, String b) { return new StringBuilder(a).append(b).toString(); } Here there could be multiple threads in the function at the same time, using the StringBuilder class at the same time (eg, concurrent access of static variables, if there are any), but each thread would have its own separate instance of StringBuilder. From the documentation, I can not quite decide whether this counts as use by multiple threads or not.
downvote count: 0
linked to: http://stackoverflow.com/q/48558432
has answer: http://stackoverflow.com/a/631652
favorite count: 0
has answer: http://stackoverflow.com/a/631685
answer count: 5

http://stackoverflow.com/comment/289198
has text: Netbeans is my favorite also!!!
comment on: http://stackoverflow.com/a/471457
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/207649
type: Comment
has text: MVC provides a clean separation of concerns; look no further
comment on: http://stackoverflow.com/a/380054
score: 0
type: AnswerComment

http://stackoverflow.com/a/474293
downvote count: 0
score: 5
accepted answer of: http://stackoverflow.com/q/472896
answers question: http://stackoverflow.com/q/472896
type: AcceptedAnswer
upvote count: 5
type: Answer
has body: If your jar is in common then it's loaded globally in tomcat. Every webapp sees it. If you put it in your webapp only your webapp sees it. What I assume Boris is referring to is if some part of your global tomcat config loads something that needs a mysql connection (like a connection pool) then it's going to need the jdbc driver, so it'll need it in common. Otherwise, no. I believe there's a security configuration you can set up in the tomcat config that stores its config in a db. If you use this, it'll need a driver. Why would you want stuff in webapp/WEB-INF/lib? well, because it's modular, it's part of your webapp, if you move your webapp somewhere else it doesn't need an extra part of it that's part of your tomcat installation. Maintenance is much easier if you can drop your webapp directly in a stock tomcat installation. Another reason- if you have multiple webapps, they're all going to use the jars in common, which could cause library conflicts and version issues. In general, put as little in common as you can get away with. Even if you only have a single app.

http://stackoverflow.com/q/553390
has answer: http://stackoverflow.com/a/553412
possible better answer: http://stackoverflow.com/a/553398
has title: Most efficient collection for this kind of LILO?
has answer: http://stackoverflow.com/a/553775
has answer: http://stackoverflow.com/a/553403
has answer: http://stackoverflow.com/a/553401
accepted answer: http://stackoverflow.com/a/553401
score: 2
upvote count: 2
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/553409
answer count: 8
type: AnsweredQuestion
has body: I am programming a list of recent network messages communicated to/from a client. Basically I just want a list that stores up to X number of my message objects. Once the list reaches the desired size, the oldest (first) item in the list should be removed. The collection needs to maintain its order, and all I will need to do is iterate through it, add an item to the end, and remove an item from the beginning, if #2 makes it too long. What is the most efficient structure/array/collection/method for doing this? Thanks!
has answer: http://stackoverflow.com/a/553423
has answer: http://stackoverflow.com/a/553406
has answer: http://stackoverflow.com/a/553398
tagged with: data-structures
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/624640
upvote count: 1
answers question: http://stackoverflow.com/q/424341
has body: If you can get away with just storing the state of your in-memory objects, then something like Prevaylor might work for you. It uses a combination of journalling changes to business objects with a serialized snapshot to record the state of your objects, which you can then reload later. However, it doesn't store the full JVM state (call stack, GC status etc). If you really need that level of detail, then a specialized JVM might be needed.
type: Answer
downvote count: 0
score: 1

ms-office
tags question: http://stackoverflow.com/q/396448
tags question: http://stackoverflow.com/q/359970
tag name: ms-office
type: Tag

http://stackoverflow.com/a/425431
type: Answer
answers question: http://stackoverflow.com/q/425017
has body: I am still learning Apache ServiceMix myself. ESB's in generally are pretty complicated. The best book I found is "Open-Source ESBs in Action" published by Manning. It runs MVN/ANT to setup your environment and walks you through with some pretty basic examples. Let me know how you like it.
has comment: http://stackoverflow.com/comment/413259
upvote count: 10
score: 10
downvote count: 0
has comment: http://stackoverflow.com/comment/249676

http://stackoverflow.com/comment/221804
comment on: http://stackoverflow.com/a/395128
type: Comment
has text: Hmmm.. never thought of that.. ;)
score: 0
type: AnswerComment

http://stackoverflow.com/q/463397
downvote count: 0
score: 1
tagged with: java
type: Question
tagged with: open-source
possible better answer: http://stackoverflow.com/a/3454949
has body: I'm looking for a way to display a VNC viewer in a thick/rich java client (specifically, I'm using SWT, but if I can get it into AWT/Swing, I can integrate that specifically.) This is not an applet, but a real, live, thick java client. TightVNC is probably sufficient; however, its GPL license is too restrictive for my needs. Is anyone aware of a Java VNC library available under a less restrictive license?
has answer: http://stackoverflow.com/a/3454949
answer count: 3
has answer: http://stackoverflow.com/a/463997
upvote count: 1
has title: How can I display a VNC Viewer in a Java rich client (LGPL, Apache, MIT license)?
has answer: http://stackoverflow.com/a/509364
accepted answer: http://stackoverflow.com/a/509364
favorite count: 0
type: AnsweredQuestion

http://stackoverflow.com/a/494898
type: Answer
has body: You can start with http://blogs.oracle.com/lmalventosa/entry/jmx_authentication_authorization It is a very nice starting point for security in JMX. There are various use case scenarios discussed for different level of security in JMX.
upvote count: 3
score: 3
accepted answer of: http://stackoverflow.com/q/494891
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/310684
answers question: http://stackoverflow.com/q/494891

http://stackoverflow.com/comment/133741402
type: Comment
has text: If you need to hold an 8-bit integer value, you can use ```char``` datatype. Silly as it may sound, ```char``` lets you store numbers in the range 0 to 255. it might be a problem to print though. And you can also use ```byte``` to store 0 to 255 using some tricks. Since Java is OOP anyway, there's nothing wrong in using a bit of object magic there.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/75111844

http://stackoverflow.com/a/430357
has comment: http://stackoverflow.com/comment/47642081
has comment: http://stackoverflow.com/comment/54801740
has comment: http://stackoverflow.com/comment/4767897
has comment: http://stackoverflow.com/comment/45582210
has comment: http://stackoverflow.com/comment/253983
has comment: http://stackoverflow.com/comment/60643917
has comment: http://stackoverflow.com/comment/254130
has body: This is from an interview with Gosling and others, about simplicity: Gosling: For me as a language designer, which I don't really count myself as these days, what "simple" really ended up meaning was could I expect J. Random Developer to hold the spec in his head. That definition says that, for instance, Java isn't -- and in fact a lot of these languages end up with a lot of corner cases, things that nobody really understands. Quiz any C developer about unsigned, and pretty soon you discover that almost no C developers actually understand what goes on with unsigned, what unsigned arithmetic is. Things like that made C complex. The language part of Java is, I think, pretty simple. The libraries you have to look up.
type: Answer
has comment: http://stackoverflow.com/comment/1411281
has comment: http://stackoverflow.com/comment/60704767
has comment: http://stackoverflow.com/comment/35527702
has comment: http://stackoverflow.com/comment/16736506
has comment: http://stackoverflow.com/comment/2086663
has comment: http://stackoverflow.com/comment/27347182
has comment: http://stackoverflow.com/comment/254777
has comment: http://stackoverflow.com/comment/42251643
has comment: http://stackoverflow.com/comment/49233240
has comment: http://stackoverflow.com/comment/60581380
has comment: http://stackoverflow.com/comment/73798204
accepted answer of: http://stackoverflow.com/q/430346
has comment: http://stackoverflow.com/comment/254816
has comment: http://stackoverflow.com/comment/2086336
upvote count: 218
has comment: http://stackoverflow.com/comment/34337532
has comment: http://stackoverflow.com/comment/87751167
score: 214
has comment: http://stackoverflow.com/comment/2086684
downvote count: 4
has comment: http://stackoverflow.com/comment/47939786
answers question: http://stackoverflow.com/q/430346
has comment: http://stackoverflow.com/comment/254580
has comment: http://stackoverflow.com/comment/41455894
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/132259999

http://stackoverflow.com/comment/302997
score: 0
comment on: http://stackoverflow.com/a/486507
type: Comment
has text: I am looking at the "engine" is was started using LaunchAnywhere ( from zerog ) I don't know how does it start the new VM using SYSTEM :-/
type: AnswerComment

http://stackoverflow.com/q/513786
score: 0
has title: How do you configure JBOSS to use the xml lib in the web app?
type: Question
type: AnsweredQuestion
tagged with: java
tagged with: jboss
has body: JBOSS is throwing a: java.lang.NoSuchMethodError: org.w3c.dom.Document.getDocumentURI()Ljava/lang/String; Error when loading a wsdl. Can I configure it to prefer the library in my WAR instead of the system or app server lib?
accepted answer: http://stackoverflow.com/a/513947
answer count: 1
has answer: http://stackoverflow.com/a/513947

http://stackoverflow.com/q/528312
downvote count: 0
favorite count: 0
tagged with: http://stackoverflow.com/tag/xml
has title: Creating an XML document using namespaces in Java
tagged with: namespaces
tagged with: xmldocument
type: AnsweredQuestion
upvote count: 19
has body: I am looking for example Java code that can construct an XML document that uses namespaces. I cannot seem to find anything using my normal favourite tool so was hoping someone may be able to help me out.
possible better answer: http://stackoverflow.com/a/528512
tagged with: java
has answer: http://stackoverflow.com/a/528506
has answer: http://stackoverflow.com/a/528512
type: Question
score: 19
tagged with: xom
answer count: 2
accepted answer: http://stackoverflow.com/a/528506

http://stackoverflow.com/a/370966
score: 153
type: Answer
has comment: http://stackoverflow.com/comment/122986085
downvote count: 8
has comment: http://stackoverflow.com/comment/16161524
has comment: http://stackoverflow.com/comment/13279268
has body: You can't override a static method, so making it abstract would be meaningless. Moreover, a static method in an abstract class would belong to that class, and not the overriding class, so couldn't be used anyway.
has comment: http://stackoverflow.com/comment/199878
answers question: http://stackoverflow.com/q/370962
has comment: http://stackoverflow.com/comment/199821
has comment: http://stackoverflow.com/comment/139633177
has comment: http://stackoverflow.com/comment/282001
has comment: http://stackoverflow.com/comment/15813082
has comment: http://stackoverflow.com/comment/200479
upvote count: 161

http://stackoverflow.com/a/408035
answers question: http://stackoverflow.com/q/407990
has body: Why not just read the input stream a block (4096bytes or whatever convenient size) at a time, call update() for each block.
has comment: http://stackoverflow.com/comment/99645171
accepted answer of: http://stackoverflow.com/q/407990
upvote count: 2
has comment: http://stackoverflow.com/comment/232995
type: AcceptedAnswer
type: Answer
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/233024

http://stackoverflow.com/comment/64711169
has text: This causes `Error code 0, SQL state XJ001: Java exception: '8: java.lang.ArrayIndexOutOfBoundsException'.` when used as batch
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/430929

http://stackoverflow.com/a/393993
answers question: http://stackoverflow.com/q/393968
downvote count: 0
has body: @Milhous said: check out the sets api. if you use addAll you can get or. If you use retainAll you can get the and. I dont know about the Xor. It seems like if you had sets s1 and s2 you could do this to get XOR: copy the set s1 to s3 s1.removeAll(s2); (s1 now contains all elements not in s2) s2.removeAll(s3); (s2 now contains all elements not in s3 = the old s1) s1.addAll(s2); (s1 now contains the union of the above two sets)
score: 3
upvote count: 3
type: Answer

http://stackoverflow.com/comment/30919782
type: AnswerComment
type: Comment
has text: I took the liberty of linking to Cibyl on Google code. I hope the link is the right one.
comment on: http://stackoverflow.com/a/1460144
score: 0

http://stackoverflow.com/q/466599
possible better answer: http://stackoverflow.com/a/466729
downvote count: 0
has answer: http://stackoverflow.com/a/466729
accepted answer: http://stackoverflow.com/a/466677
favorite count: 0
answer count: 3
score: 3
tagged with: synchronization
upvote count: 3
tagged with: multithreading
has title: JTree gives ArrayIndexOutOfBoundsException?
tagged with: swing
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/466677
tagged with: java
has body: I try to dynamically add nodes to a Java Swing JTree, and the user should be able to browse and to collapse hierarchy while nodes are constantly added. When I add a Thread.sleep(10) in my loop, it works fine; but this is a dirty hack... Here is the stripped down code that triggers this problem. Whenever I run this and doubleclick on the root node to expand/collapse it (while nodes are added), I get an ArrayIndexOutOfBoundsException. When I add a Thread.sleep(10) this does not happen. I guess this is a threading issue, but I have no idea how to synchronize this? Any hints would be greatly appreciated! public static void main(String[] args) throws InterruptedException { final JFrame frame = new JFrame(); frame.setSize(600, 800); frame.setVisible(true); MutableTreeNode root = new DefaultMutableTreeNode("root"); final DefaultTreeModel model = new DefaultTreeModel(root); final JTree tree = new JTree(model); frame.add(new JScrollPane(tree)); while (true) { MutableTreeNode child = new DefaultMutableTreeNode("test"); model.insertNodeInto(child, root, root.getChildCount()); tree.expandRow(tree.getRowCount() - 1); // uncommenting this to make it work // Thread.sleep(10); } } I want to use this for a search-on-typing application, so giving (almost) instant results is essential for me. EDIT: Thanks for the quick answers! SwingUtilities.invokeLater() solves the problem. I now do this: Add 100 items within SwingUtilities.invokeLater(); After 100 items, I run this so that the GUI can get updated: // just wait so that all events in the queue can be processed SwingUtilities.invokeAndWait(new Runnable() { public void run() { }; }); This way I have a very responsive GUI and it works perfectly. Thanks!
has answer: http://stackoverflow.com/a/466634
type: Question
tagged with: jtree

http://stackoverflow.com/comment/138334691
score: 0
type: AnswerComment
has text: @toolforger Feel free to share your code; can’t quite envision what this “messy structure of helper objects” looks like.
comment on: http://stackoverflow.com/a/28408543
type: Comment

http://stackoverflow.com/q/582352
has body: I am working on a system that should be able to read any (or at least, any well-formed) XML file, manipulate a few nodes and write them back into that same file. I want my code to be as generic as possible and I don't want hardcoded references to Schema/Doctype information anywhere in my code. The doctype information is in the source document, I want to keep exactly that doctype information and not provide it again from within my code. If a document has no DocType, I won't add one. I do not care about the form or content of these files at all, except for my few nodes. custom EntityResolvers or StreamFilters to omit or otherwise manipulate the source information (It is already a pity that namespace information seems somehow inaccessible from the document file where it is declared, but I can manage by using uglier XPaths) DTD validation. I don't have the referenced DTDs, I don't want to include them and Node manipulation is perfectly possible without knowing about them. The aim is to have the source file entirely unchanged except for the changed Nodes, which are retrieved via XPath. I would like to get away with the standard javax.xml stuff. My progress so far: DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setAttribute("http://xml.org/sax/features/namespaces", true); factory.setAttribute("http://xml.org/sax/features/validation", false); factory.setAttribute("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); factory.setAttribute("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); factory.setNamespaceAware(true); factory.setIgnoringElementContentWhitespace(false); factory.setIgnoringComments(false); factory.setValidating(false); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(new InputSource(inStream)); This loads the XML source into a org.w3c.dom.Document successfully, ignoring DTD validation. I can do my replacements and then I use Source source = new…
has answer: http://stackoverflow.com/a/582451
has answer: http://stackoverflow.com/a/5154211
upvote count: 3
tagged with: java
answer count: 3
downvote count: 1
tagged with: dtd
has comment: http://stackoverflow.com/comment/121055291
tagged with: doctype
score: 2
type: UnansweredQuestion
has title: How can I ignore DTD validation but keep the Doctype when writing an XML file?
type: Question
has answer: http://stackoverflow.com/a/47337172
linked to: http://stackoverflow.com/q/6637076
favorite count: 0
tagged with: http://stackoverflow.com/tag/xml

http://stackoverflow.com/a/23326613
upvote count: 4
downvote count: 0
has comment: http://stackoverflow.com/comment/132157703
has body: Here is an implementation I've coded for my own use but that could be useful. The buffer contains a maximum fixed set of items. The set is circular, old items are automatically removed. The caller can get items tail by an absolute incremental index (a long), but items may have been lost between calls too distant in time. This class is fully thread-safe. public sealed class ConcurrentCircularBuffer&lt;T&gt; : ICollection&lt;T&gt; { private T[] _items; private int _index; private bool _full; public ConcurrentCircularBuffer(int capacity) { if (capacity &lt;= 1) // need at least two items throw new ArgumentException(null, "capacity"); Capacity = capacity; _items = new T[capacity]; } public int Capacity { get; private set; } public long TotalCount { get; private set; } public int Count { get { lock (SyncObject) // full &amp; _index need to be in sync { return _full ? Capacity : _index; } } } public void AddRange(IEnumerable&lt;T&gt; items) { if (items == null) return; lock (SyncObject) { foreach (var item in items) { AddWithLock(item); } } } private void AddWithLock(T item) { _items[_index] = item; _index++; if (_index == Capacity) { _full = true; _index = 0; } TotalCount++; } public void Add(T item) { lock (SyncObject) { AddWithLock(item); } } public void Clear() { lock (SyncObject) { _items = new T[Capacity]; _index = 0; _full = false; TotalCount = 0; } } // this gives raw access to the underlying buffer. not sure I should keep that public T this[int index] { get { return _items[index]; } } public T[] GetTail(long startIndex) { long lostCount; return GetTail(startIndex, out lostCount); } public T[] GetTail(long startIndex, out long lostCount) { if (startIndex &lt; 0 || startIndex &gt;= TotalCount) throw new ArgumentOutOfRangeException("startIndex"); T[] array = ToArray(); lostCount = (TotalCount - Count) - startIndex; if (lostCount &gt;= 0) return array; lostCount = 0; // this maybe could optimized to not allocate the initial array // but in multi-threading environment…
has comment: http://stackoverflow.com/comment/132155970
score: 4
answers question: http://stackoverflow.com/q/590069
has comment: http://stackoverflow.com/comment/132156475
type: Answer

http://stackoverflow.com/comment/443333
has text: Why all the negative voting? This seems like a non-experienced person either wants to learn about Spring or was tasked to do so. Asking for direction shouldn't mean you get slapped.
score: 11
comment on: http://stackoverflow.com/q/628963
type: Comment
type: QuestionComment

http://stackoverflow.com/q/626669
answer count: 8
has comment: http://stackoverflow.com/comment/439360
has comment: http://stackoverflow.com/comment/439434
has answer: http://stackoverflow.com/a/626711
has answer: http://stackoverflow.com/a/626699
accepted answer: http://stackoverflow.com/a/626702
tagged with: callback
has answer: http://stackoverflow.com/a/626761
has answer: http://stackoverflow.com/a/626738
possible better answer: http://stackoverflow.com/a/626761
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/626703
has answer: http://stackoverflow.com/a/626758
score: 0
tagged with: java
has title: W/o function pointers, what's a recommended way to implement Callback in Java - other than interfaces?
has body: I have a couple of classes that want to pass each other some information and be called back later, using that information (Callback pattern). Within my application, this mechanism serves two purposes: scheduled / delayed execution asynchronous execution involving messaging My objects basically say to each other "when you're finished doing X, call me back and tell me to do Y with Z (because I'll have forgotten about it by then)". Where X might just be waiting for the right time, but also communicating with a remote service or calling a local function. Now, were there function pointers (or equivalent) in Java, I would implement some "Job" class containing one plus the arguments it needs. For example, in PHP this structure would have to store a class name, a function name and an array of arguments. In C, it would be a pointer to the function and I'd have to make the arguments the same number and type for all calls. In Java, the usual approach is to have an interface that's implemented by all classes that want to be called back, like this: public interface ICallable { public void call_me(Object data); } Now this wouldn't work for me, because the objects to be called back might have a different set of methods to take the call the caller is not the one to decide what call should be made Maybe my problem is that I'm trying to have a common data structure and calling procedure for the various callbacks, but in principle, it seems to make sense to me. What's a good design pattern to approach this situation in Java?
has answer: http://stackoverflow.com/a/627111
tagged with: design-patterns
type: Question
has answer: http://stackoverflow.com/a/626702

http://stackoverflow.com/a/12736983
has comment: http://stackoverflow.com/comment/57165035
upvote count: 202
type: Answer
downvote count: 4
answers question: http://stackoverflow.com/q/433958
score: 198
has body: Yes you can do it with String.format: String result = String.format("%.2f", 10.0 / 3.0); // result: "3.33" result = String.format("%.3f", 2.5); // result: "2.500"

http://stackoverflow.com/a/614280
downvote count: 0
answers question: http://stackoverflow.com/q/613954
type: Answer
has comment: http://stackoverflow.com/comment/21313708
has comment: http://stackoverflow.com/comment/36961466
score: 20
upvote count: 20
has body: In short: Exceptions are an API design question. -- No more, no less. The argument for checked exceptions: To understand why checked exceptions might not be good thing, let's turn the question around and ask: When or why are checked exceptions attractive, i.e. why would you want the compiler to enforce declaration of exceptions? The answer is obvious: Sometimes you need to catch an exception, and that is only possible if the code being called offers a specific exception class for the error that you are interested in. Hence, the argument for checked exceptions is that the compiler forces programmers to declare which exceptions are thrown, and hopefully the programmer will then also document specific exception classes and the errors that cause them. In reality though, ever too often a package com.acme only throws an AcmeException rather than specific subclasses. Callers then need to handle, declare, or re-signal AcmeExceptions, but still cannot be certain whether an AcmeFileNotFoundError happened or an AcmePermissionDeniedError. So if you're only interested in an AcmeFileNotFoundError, the solution is to file a feature request with the ACME programmers and tell them to implement, declare, and document that subclass of AcmeException. So why bother? Hence, even with checked exceptions, the compiler cannot force programmers to throw useful exceptions. It is still just a question of the API's quality. As a result, languages without checked exceptions usually do not fare much worse. Programmers might be tempted to throw unspecific instances of a general Error class rather than an AcmeException, but if they care at all about their API quality, they will learn to introduce an AcmeFileNotFoundError after all. Overall, the specification and documentation of exceptions is not much different from the specification and documentation of, say, ordinary methods. Those, too, are an API design question, and if a programmer forgot to implement or export a useful feature, the API needs …

http://stackoverflow.com/comment/63111503
score: 0
type: Comment
has text: @Brian Does the fact you're using ASM mean that the classes do not actually get loaded but only the files them selves get scanned? As loading everything from the classpath to memory in order to scan it would be a huuuge overhead.
type: AnswerComment
comment on: http://stackoverflow.com/a/435930

http://stackoverflow.com/a/4314199
score: 15
answers question: http://stackoverflow.com/q/633158
type: Answer
has body: We are switching from @Autowire back to XML configuration in our big project. The problem is very low bootstrap performance. Autowiring scanner loads all classes from autowiring search classpath, so, lots of classes are loaded eagerly during Spring initialization.
has comment: http://stackoverflow.com/comment/27544320
downvote count: 1
upvote count: 16

http://stackoverflow.com/a/492233
answers question: http://stackoverflow.com/q/492207
has body: Are you sure you have to have the Java 1.4.2_12 apps run using that specific Java VM? Most apps should run fine on the newer VMs, so you might be able to simply have them all use 1.5. If you do need to use the specific VM versions then you can do what other posters have suggested.
downvote count: 0
has comment: http://stackoverflow.com/comment/308260
type: Answer
upvote count: 2
score: 2
has comment: http://stackoverflow.com/comment/309237

http://stackoverflow.com/a/435000
has comment: http://stackoverflow.com/comment/95646852
type: AcceptedAnswer
has body: Regarding the load factor, I'll simply quote from the HashMap javadoc: As a general rule, the default load factor (.75) offers a good tradeoff between time and space costs. Higher values decrease the space overhead but increase the lookup cost (reflected in most of the operations of the HashMap class, including get and put). The expected number of entries in the map and its load factor should be taken into account when setting its initial capacity, so as to minimize the number of rehash operations. If the initial capacity is greater than the maximum number of entries divided by the load factor, no rehash operations will ever occur. Meaning, the load factor should not be changed from .75 , unless you have some specific optimization you are going to do. Initial capacity is the only thing you want to change, and set it according to your N value - meaning (N / 0.75) + 1, or something in that area. This will ensure that the table will always be large enough and no rehashing will occur.
type: Answer
upvote count: 42
downvote count: 0
accepted answer of: http://stackoverflow.com/q/434989
answers question: http://stackoverflow.com/q/434989
score: 42

http://stackoverflow.com/a/510027
answers question: http://stackoverflow.com/q/510000
type: Answer
has body: I am not familiar with specific libraries you are using, but let me try. How stateless are your application code? Do you have any sort of global state like singleton with member fields? If the service is stateful and are using singleton, you could have such mixups.
score: 0

http://stackoverflow.com/comment/110373707
type: QuestionComment
comment on: http://stackoverflow.com/q/464098
has text: short-answer: yes, under normal conditions.
score: 0
type: Comment

http://stackoverflow.com/comment/55825076
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/15990375
has text: Is it possible to get this component with its declared name ? I mean component's variable name
score: 1

http://stackoverflow.com/comment/433607
has text: @mmyers: Probably it would be better to understand java's type system first. Although I write that my self too. :) Cheers
score: 0
type: Comment
comment on: http://stackoverflow.com/a/620523
type: AnswerComment

http://stackoverflow.com/comment/363277
comment on: http://stackoverflow.com/a/551024
type: Comment
score: 0
type: AnswerComment
has text: So instead of fixing the design, just create another unit of work around it. And then maybe later create something else to work around this script that I've created. And then change something and break all of these things that depend on it. I see the light now.

http://stackoverflow.com/a/442366
type: Answer
upvote count: 6
downvote count: 2
score: 4
answers question: http://stackoverflow.com/q/442322
has body: You can do this with hobby (Ruby), low implementation (Python) languages, but you can't imagine how many apps are written in Java around the world. Just check freshmeat or sourceforge. And that's only a portion. So no, it's not a good idea. Actually, it would be a pretty stupid idea. There are not two GUI frameworks. Swing depends and uses AWT as it's basis.

http://stackoverflow.com/a/542097
has comment: http://stackoverflow.com/comment/74801549
has comment: http://stackoverflow.com/comment/8876139
has comment: http://stackoverflow.com/comment/356662
has comment: http://stackoverflow.com/comment/67118561
downvote count: 5
has comment: http://stackoverflow.com/comment/55826135
type: Answer
has comment: http://stackoverflow.com/comment/68833571
has comment: http://stackoverflow.com/comment/28403541
has comment: http://stackoverflow.com/comment/67118549
upvote count: 50
has comment: http://stackoverflow.com/comment/354367
has comment: http://stackoverflow.com/comment/357174
has comment: http://stackoverflow.com/comment/354246
has comment: http://stackoverflow.com/comment/8876130
has body: Bob Lee said once in a presentation: whats the point of an interface if you have only one implementation. so, you start off with one implementation i.e. without an interface. later on you decide, well, there is a need for an interface here, so you convert your class to an interface. then it becomes obvious: your original class was called User. your interface is now called User. maybe you have a UserProdImpl and a UserTestImpl. if you designed your application well, every class (except the ones that instantiate User) will be unchanged and will not notice that suddenly they get passed an interface. so it gets clear -> Interface User implementation UserImpl.
answers question: http://stackoverflow.com/q/541912
score: 45

http://stackoverflow.com/a/1740798
answers question: http://stackoverflow.com/q/473566
type: Answer
has body: Here's an open source library, http://spnego.sourceforge.net/protected_soap_service.html, that has an example on connecting to a web service that is protected via integrated windows authentication. The library is implemented as a servlet filter.
score: 0

http://stackoverflow.com/a/642200
downvote count: 0
has body: This problem arises if you have a java classes in your source tree. Remove them and the error should disappear.
type: Answer
score: 2
answers question: http://stackoverflow.com/q/642198
upvote count: 2
accepted answer of: http://stackoverflow.com/q/642198
type: AcceptedAnswer

http://stackoverflow.com/q/639264
has answer: http://stackoverflow.com/a/781161
tagged with: regex
upvote count: 4
has comment: http://stackoverflow.com/comment/452688
has title: Regex for removing comma in a String when it is enclosed by quotes
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/452679
has answer: http://stackoverflow.com/a/781098
tagged with: java
possible better answer: http://stackoverflow.com/a/639311
has body: I need to remove commas within a String only when enclosed by quotes. example: String a = "123, \"Anders, Jr.\", John, john.anders@company.com,A" after replacement should be String a = "123, Anders Jr., John, john.anders@company.com,A" Can you please give me sample java code to do this? Thanks much, Lina
type: Question
accepted answer: http://stackoverflow.com/a/639389
has answer: http://stackoverflow.com/a/641415
has answer: http://stackoverflow.com/a/639388
has answer: http://stackoverflow.com/a/640582
score: 4
has answer: http://stackoverflow.com/a/639270
has answer: http://stackoverflow.com/a/32749877
has answer: http://stackoverflow.com/a/639389
has answer: http://stackoverflow.com/a/1033974
downvote count: 0
answer count: 10
has answer: http://stackoverflow.com/a/639311
favorite count: 0

http://stackoverflow.com/q/450789
type: Question
has title: batch not working if calling from a Java program
has body: I wrote a batch file that reads in a text file which contains a list of file name, and then delete and rename them one by one. I did this by using a for loop, and it works perfectly by double clicking it. But when I tried to call this batch from a Java program. It's no longer working for this part: for /f %%a in (ListFile.txt) do ( DEL %%a REN %%a_NEW %%~nxa ) If I only specify a certain file name. It's working by calling from Java. Say, DEL tag.jar REN tag.jar_NEW tag.jar The same thing happen for 'call' command. It's not working if calling from Java program, which makes me have to use 'start' command. Can someone tell me why is it like this? How can I make it also working if calling from Java program?
score: 0
tagged with: batch-file
has answer: http://stackoverflow.com/a/451566
has answer: http://stackoverflow.com/a/450809
has answer: http://stackoverflow.com/a/451248
has comment: http://stackoverflow.com/comment/271893
favorite count: 0
answer count: 5
has answer: http://stackoverflow.com/a/451611
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/450911
upvote count: 2
tagged with: java
downvote count: 2

http://stackoverflow.com/comment/136292501
comment on: http://stackoverflow.com/a/77295673
type: AnswerComment
has text: Please read [answer]. In particular, please make sure to address the question being asked. This looks like a comment.
type: Comment
score: 1

http://stackoverflow.com/a/40386211
has body: I have written a package for R called qualpalr that is designed specifically for this purpose. I recommend you look at the vignette to find out how it works, but I will try to summarize the main points. qualpalr takes a specification of colors in the HSL color space (which was described previously in this thread), projects it to the DIN99d color space (which is perceptually uniform) and find the n that maximize the minimum distance between any oif them. # Create a palette of 4 colors of hues from 0 to 360, saturations between # 0.1 and 0.5, and lightness from 0.6 to 0.85 pal &lt;- qualpal(n = 4, list(h = c(0, 360), s = c(0.1, 0.5), l = c(0.6, 0.85))) # Look at the colors in hex format pal$hex #&gt; [1] "#6F75CE" "#CC6B76" "#CAC16A" "#76D0D0" # Create a palette using one of the predefined color subspaces pal2 &lt;- qualpal(n = 4, colorspace = "pretty") # Distance matrix of the DIN99d color differences pal2$de_DIN99d #&gt; #69A3CC #6ECC6E #CA6BC4 #&gt; 6ECC6E 22 #&gt; CA6BC4 21 30 #&gt; CD976B 24 21 21 plot(pal2)
type: Answer
answers question: http://stackoverflow.com/q/470690
downvote count: 0
score: 1
upvote count: 1

http://stackoverflow.com/a/573556
has body: I broke away from Java 12 years ago. 12! At the time, I didn't agree with the approaching change that was J2EE. I like many concepts of the language, but it doesn't help to be backed by Sun (yuck) and needs to be majorly rebuilt from the ground up. Something new, "java like". And, in my (small) community, all of the Java developers are unfortunately referred to as "dinosaurs", in that they act like the COBOL developers used to act...absorbed in their own world, unaware that things have moved on, mostly without them.
answers question: http://stackoverflow.com/q/573543
downvote count: 4
upvote count: 0
score: -4
type: Answer
has comment: http://stackoverflow.com/comment/385379

http://stackoverflow.com/comment/75940866
type: Comment
has text: @jpganz18: If you simply call `request.getSession()` or `request.getSession(true)`, then you get either existing or new session. However if your code calls `request.getSession(false)`, then you get either existing session or null, if no session exists.
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/598923

http://stackoverflow.com/comment/456804
type: Comment
comment on: http://stackoverflow.com/a/642524
has text: I added to the text above as I ran out of comment space here.
score: 0
type: AnswerComment

http://stackoverflow.com/a/24008990
score: 4
answers question: http://stackoverflow.com/q/453388
has body: Use either Joda-Time or the new java.time package in Java 8. Both frameworks use the Half-Open approach where the beginning is inclusive while the ending is exclusive. Sometimes notated as [). This is generally the best approach for defining spans of time. java.time The java.time framework built into Java 8 and later has a Period class to represent a span of time as a number of years, a number of months, and a number of days. But this class is limited to whole days, no representation of hours, minutes, and seconds. Note that we specify a time zone, crucial for determining a date. For example, a new day dawns earlier in Paris than in Montréal. ZoneId zoneId = ZoneId.of( "America/Montreal" ); LocalDate now = LocalDate.now( zoneId ); LocalDate then = LocalDate.of( 2001, 1, 1 ); Period period = Period.between( then, now ); Then: 2001-01-01. Now: 2015-09-07. Period: P14Y8M6D. Days: 5362 For whole days, then Daylight Saving Time (DST) is irrelevant. If you want a count of total days, use the ChronoUnit enum which includes some calculation methods. Notice the calculations return a long. long days = ChronoUnit.DAYS.between( then, now ); // "5362" seen above. I have asked about doing a full period in java.time, including hours, minutes, seconds. Not possible as of Java 8. A surprising workaround using the bundled libraries was suggested by Meno Hochschild: Use a Duration class found in the javax.xml.datatype package. Joda-Time Here is some example code in Joda-Time 2.3. DateTimeZone timeZone = DateTimeZone.forID( "Europe/Paris" ); DateTime start = new DateTime( 2014, 1, 2, 3, 4, 5, timeZone ); DateTime stop = new DateTime( 2014, 5, 2, 3, 4, 5, timeZone ); Period period = new Period( start, stop ); Calling toString will get you a string representation in the form defined by the ISO 8601 standard, PnYnMnDTnHnMnS.
type: Answer
upvote count: 4
downvote count: 0

http://stackoverflow.com/a/553178
downvote count: 0
answers question: http://stackoverflow.com/q/553175
type: Answer
has comment: http://stackoverflow.com/comment/364892
score: 11
has body: If you want it to run under Scheduled tasks you have to make sure you don't have "only run when user logged in" checked, which usually means you need to supply a password. A windows service would be the normal way to do this: the Java service wrapper is 3rd party but loads of people use it. If you really wanted to not use a 3rd party method you could use svrany.exe (http://support.microsoft.com/kb/137890) on WIndows NT or later, but it is not designed specifically for Java.
upvote count: 11
has comment: http://stackoverflow.com/comment/364917
has comment: http://stackoverflow.com/comment/38048966

infrastructure
tags question: http://stackoverflow.com/q/429352
type: Tag
tag name: infrastructure

http://stackoverflow.com/a/467107
has comment: http://stackoverflow.com/comment/56634350
score: 53
answers question: http://stackoverflow.com/q/466841
has body: Here's one simple approach for checking if the files are exactly the same: assertEquals("The files differ!", FileUtils.readFileToString(file1, "utf-8"), FileUtils.readFileToString(file2, "utf-8")); Where file1 and file2 are File instances, and FileUtils is from Apache Commons IO. Not much own code for you to maintain, which is always a plus. :) And very easy if you already happen to use Apache Commons in your project. But no nice, detailed error messages like in mark's solution. Edit: Heh, looking closer at the FileUtils API, there's an even simpler way: assertTrue("The files differ!", FileUtils.contentEquals(file1, file2)); As a bonus, this version works for all files, not just text.
type: Answer
upvote count: 53
has comment: http://stackoverflow.com/comment/7983466
has comment: http://stackoverflow.com/comment/3079921
downvote count: 0

http://stackoverflow.com/a/571639
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/571193
has body: As MemoryCacheImageOutputStream implements ImageInputStream, you could just use it as an input stream for an ImageReader. So you would end up with something like this (very basic, not tested): public BufferedImage readImage(MemoryCacheImageOutputStream input) { ImageInputStream is = input; ImageReader decoder = ImageIO.getImageReadersByFormatName("JPEG").next(); decoder.setInput(is); BufferedImage bi = decoder.read(0); return bi; }
downvote count: 0

http://stackoverflow.com/q/482633
has answer: http://stackoverflow.com/a/482909
has answer: http://stackoverflow.com/a/482849
accepted answer: http://stackoverflow.com/a/482909
possible better answer: http://stackoverflow.com/a/482637
favorite count: 0
score: 51
has answer: http://stackoverflow.com/a/483134
tagged with: classloader
answer count: 5
has title: In Java, is it possible to know whether a class has already been loaded?
has answer: http://stackoverflow.com/a/12683214
has body: Is it possible to know whether a Java class has been loaded, without attempting to load it? Class.forName attempts to load the class, but I don't want this side effect. Is there another way? (I don't want to override the class loader. I'm looking for a relatively simple method.)
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/482637
tagged with: java
type: Question
upvote count: 51

http://stackoverflow.com/a/410902
downvote count: 0
answers question: http://stackoverflow.com/q/410890
score: 3
upvote count: 3
type: Answer
has body: I generally do not chain getters like this where there is more than one nullable getter. If you're running inside your ide you can just set a breakpoint and use the "evaluate expression" functionality of your ide on each element successively. But you're going to be scratching your head the moment you get this error message from your production server logs. So best keep max one nullable item per line. Meanwhile we can dream of groovy's safe navigation operator

http://stackoverflow.com/q/529474
upvote count: 1
has answer: http://stackoverflow.com/a/529499
linked to: http://stackoverflow.com/q/523107
score: 1
tagged with: java
has title: unable to run ksh script from java: java.io.IOException: .: not found
type: Question
downvote count: 0
has body: I tried to run a shell script from java code, but I am facing problem. The script is in batchstart.sh file - #!/bin/ksh export DISPLAY=:0.0 Now the script is run with a dot on the command line -- . batchstart.sh How do I run it from java? My java code is below. It throws the following exception - java.io.IOException: .: not found at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.&lt;init&gt;(UNIXProcess.java:102) at java.lang.ProcessImpl.start(ProcessImpl.java:65) at java.lang.ProcessBuilder.start(ProcessBuilder.java:451) at java.lang.Runtime.exec(Runtime.java:591) at java.lang.Runtime.exec(Runtime.java:429) at SetDisplay.main(SetDisplay.java:12) import java.io.*; public class SetDisplay { public static void main(String[] args) { File wd = new File("/myhomedir/"); System.out.println("Working Directory: " +wd); Process proc = null; try { proc = Runtime.getRuntime().exec(". batchstart.sh", null, wd); } catch (Exception e) { e.printStackTrace(); } } } How do I make the shell script run ? I tried the following code as well, but that too doesn't work. File wd = new File("/bin"); System.out.println(wd); Process proc = null; try { proc = Runtime.getRuntime().exec("/bin/bash", null, wd); } catch (IOException e) { e.printStackTrace(); } if (proc != null) { BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream())); PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(proc.getOutputStream())), true); out.println("cd /home/"); out.println(". batchstart.sh"); out.println("exit"); try { String line; while ((line = in.readLine()) != null) { System.out.println(line); } proc.waitFor(); in.close(); out.close(); proc.destroy(); } catch (Exception e) { e.printStackTrace(); } }
favorite count: 0
answer count: 3
tagged with: shell
has answer: http://stackoverflow.com/a/529497
tagged with: unix
has answer: http://stackoverflow.com/a/529495
type: UnansweredQuestion

http://stackoverflow.com/comment/95734476
type: Comment
comment on: http://stackoverflow.com/a/34508760
score: 5
type: AnswerComment
has text: The implementation cleanliness in the JDK shouldn't matter as long as it works and satisfies the contract. Like any black box, implementation details can always be fixed in future if really needed...

http://stackoverflow.com/a/571215
score: 3
downvote count: 0
type: Answer
upvote count: 3
answers question: http://stackoverflow.com/q/562018
has body: Try aiSee. It is used by all kinds of web-based applications for data mining, static program analysis, matrix visualization, network analysis, and whatnot. It is also used by some MediaWikis as their graph-layout backend. They have a huge database of sample graphs over at aiSee.com. Check it out. It supports edge labels, export to mapped SVG and HTML, and is not dependent on Swing.

http://stackoverflow.com/comment/250408
has text: Ah! It's "invoke". I was looking for "execute" in the javadocs and didn't see it. Thank you for the correction.
comment on: http://stackoverflow.com/a/426663
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/361368
downvote count: 0
type: Answer
score: 1
answers question: http://stackoverflow.com/q/359732
upvote count: 1
has body: I think it all boils down to preference and readability. Generally adding curly braces will make your code a lot more readable because of the extra space between the actual lines with code. Also, consider this example (not indented on purpose): if (condition1) if (condition2) doSomething(); else doSomethingElse(); When does doSomethingElse get called? When condition1 is true but condition2 is false, or when condition1 is false? Adding curly braces quickly solves this readability problem and avoids confusion.

http://stackoverflow.com/comment/41757210
type: Comment
comment on: http://stackoverflow.com/a/370967
has text: @ChadNB, Perhaps I should break the explanation up into steps. Consider this method `f(){ return "hello world"; }`. You have two choices. 1) Make it static. 2) Make it non-static. Which will you choose and which do you think is the default?
type: AnswerComment
score: 0

http://stackoverflow.com/q/444112
tagged with: rest
has comment: http://stackoverflow.com/comment/265633
type: Question
has comment: http://stackoverflow.com/comment/265673
has comment: http://stackoverflow.com/comment/265674
has comment: http://stackoverflow.com/comment/265680
has body: I want to send a URI as the value of a query/matrix parameter. Before I can append it to an existing URI, I need to encode it according to RFC 2396. For example, given the input: http://google.com/resource?key=value1 &amp; value2 I expect the output: http%3a%2f%2fgoogle.com%2fresource%3fkey%3dvalue1%2520%26%2520value2 Neither java.net.URLEncoder nor java.net.URI will generate the right output. URLEncoder is meant for HTML form encoding which is not the same as RFC 2396. URI has no mechanism for encoding a single value at a time so it has no way of knowing that value1 and value2 are part of the same key.
has answer: http://stackoverflow.com/a/1982782
tagged with: urlencode
linked to: http://stackoverflow.com/q/304806
has title: How do I encode URI parameter values?
has answer: http://stackoverflow.com/a/444568
tagged with: java
has comment: http://stackoverflow.com/comment/265642
tagged with: rfc2396
answer count: 7
accepted answer: http://stackoverflow.com/a/444568
has comment: http://stackoverflow.com/comment/265683
has comment: http://stackoverflow.com/comment/265754
score: 57
has answer: http://stackoverflow.com/a/4710475
possible better answer: http://stackoverflow.com/a/6715177
has comment: http://stackoverflow.com/comment/25796239
has comment: http://stackoverflow.com/comment/52039435
has answer: http://stackoverflow.com/a/6715177
linked to: http://stackoverflow.com/q/8135132
has answer: http://stackoverflow.com/a/444393
linked to: http://stackoverflow.com/q/724043
upvote count: 57
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/444335
downvote count: 0
tagged with: url
has answer: http://stackoverflow.com/a/444150
favorite count: 0
has comment: http://stackoverflow.com/comment/52049280

http://stackoverflow.com/comment/43166658
type: AnswerComment
comment on: http://stackoverflow.com/a/518874
type: Comment
has text: This is a good example of premature optimization (http://en.wikiquote.org/wiki/Donald_Knuth). There is no point in creating a long-lived object until there is a reason to do so (slow resource initialization, for example).
score: 3

http://stackoverflow.com/q/416998
has answer: http://stackoverflow.com/a/417018
accepted answer: http://stackoverflow.com/a/417093
upvote count: 6
has body: Iam a great fan of javascript frameworks especially jQuery .I have always wanted to design sites like "plurk.com" but i know that it needs very huge lines of javascript.so that shut me off.But since i came to know GWT , i really want to test it out and want to ask you if it makes our job easier to develop complex things than with the javascript or its frameworks .Which one would you prefer ?
favorite count: 0
has answer: http://stackoverflow.com/a/417075
score: 6
type: Question
tagged with: gwt
type: AnsweredQuestion
has title: Is Google Web Toolkit useful to develop complex javascripts?
tagged with: java
has answer: http://stackoverflow.com/a/417093
possible better answer: http://stackoverflow.com/a/418372
downvote count: 0
has answer: http://stackoverflow.com/a/417450
has answer: http://stackoverflow.com/a/418372
tagged with: javascript
answer count: 6
has answer: http://stackoverflow.com/a/417083

http://stackoverflow.com/comment/263887
has text: I agree. This difference in terminology really comes down to the end-user (developer, that is) experience. It has nothing to do with real technical differences, as the technical line is so incredibly blurred as to be damn-near nonexistent.
type: Comment
comment on: http://stackoverflow.com/a/441854
score: 4
type: AnswerComment

http://stackoverflow.com/a/360305
has body: How about just do it right? Here's my equals template which is knowledge applied from Effective Java by Josh Bloch. Read the book for more details: @Override public boolean equals(Object obj) { if(this == obj) { return true; } // only do this if you are a subclass and care about equals of parent if(!super.equals(obj)) { return false; } if(obj == null || getClass() != obj.getClass()) { return false; } final YourTypeHere other = (YourTypeHere) obj; if(!instanceMember1.equals(other.instanceMember1)) { return false; } ... rest of instanceMembers in same pattern as above.... return true; }
type: Answer
answers question: http://stackoverflow.com/q/360265
has comment: http://stackoverflow.com/comment/191017
downvote count: 1
score: 3
has comment: http://stackoverflow.com/comment/191052
upvote count: 4

http://stackoverflow.com/comment/404536
type: Comment
score: 1
has text: Darron, you have a citation for that? Since I worked for Sun for 10 years, and since the answer is basically "it depends on the workload and what kind of performance you care about measuring", I -- how to put this -- don't believe you.
type: AnswerComment
comment on: http://stackoverflow.com/a/589069

method-declaration
type: Tag
tag name: method-declaration
tags question: http://stackoverflow.com/q/519752

http://stackoverflow.com/q/522855
answer count: 10
has answer: http://stackoverflow.com/a/522857
has comment: http://stackoverflow.com/comment/336948
has body: Okay, here's my problem. Basically I have this problem. I have a number like .53999999. How do I round it up to 54 without using any of the Math functions? I'm guessing I have to multiply by 100 to scale it, then divide? Something like that? The issue is with money. let's say I have $50.5399999 I know how to get the $50, but I don't have how to get the cents. I can get the .539999 part, but I don't know how to get it to 54 cents.
type: Question
has answer: http://stackoverflow.com/a/523491
tagged with: rounding
tagged with: java
has title: How do I round up currency values in Java?
has answer: http://stackoverflow.com/a/522872
has answer: http://stackoverflow.com/a/522898
has answer: http://stackoverflow.com/a/522890
score: 12
has answer: http://stackoverflow.com/a/522875
upvote count: 12
downvote count: 0
has answer: http://stackoverflow.com/a/522859
favorite count: 0
tagged with: currency
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/523564
has answer: http://stackoverflow.com/a/567170
has answer: http://stackoverflow.com/a/522870

http://stackoverflow.com/a/20647811
answers question: http://stackoverflow.com/q/502494
downvote count: 0
score: 1
has body: Put ant lib in you classpath ( project lib ) and run this code : import org.apache.tools.ant.taskdefs.Execute; Execute exe = new Execute(); exe.setCommandline(new String[]{"java", "-version"}); exe.execute();
upvote count: 1
type: Answer

http://stackoverflow.com/comment/398099
type: Comment
comment on: http://stackoverflow.com/a/583464
has text: I think it is fine that everyone answered that the difference was negligible as I was not asking from an assembly code or ten-million-iterations-in-a-tight-loop angle.
type: AnswerComment
score: 0

http://stackoverflow.com/a/19020435
type: Answer
upvote count: 6
answers question: http://stackoverflow.com/q/541487
has body: if you use runnable you can save the space to extend to any of your other class.
downvote count: 0
score: 6

http://stackoverflow.com/q/439298
linked to: http://stackoverflow.com/q/157646
accepted answer: http://stackoverflow.com/a/439311
tagged with: http://stackoverflow.com/tag/xml
linked to: http://stackoverflow.com/q/59447599
has answer: http://stackoverflow.com/a/13088777
downvote count: 2
has answer: http://stackoverflow.com/a/8345820
type: Question
type: AnsweredQuestion
score: 106
has answer: http://stackoverflow.com/a/59877700
has answer: http://stackoverflow.com/a/51890452
tagged with: java
has body: Very similar to this question, except for Java. What is the recommended way of encoding strings for an XML output in Java. The strings might contain characters like "&amp;", "&lt;", etc.
has answer: http://stackoverflow.com/a/64746092
has title: Best way to encode text data for XML in Java?
has answer: http://stackoverflow.com/a/49148032
has answer: http://stackoverflow.com/a/439459
has answer: http://stackoverflow.com/a/7264268
has answer: http://stackoverflow.com/a/10035382
has answer: http://stackoverflow.com/a/48588062
linked to: http://stackoverflow.com/q/1527856
has answer: http://stackoverflow.com/a/2863461
tagged with: encoding
has answer: http://stackoverflow.com/a/20693473
upvote count: 108
has answer: http://stackoverflow.com/a/43047555
answer count: 21
has answer: http://stackoverflow.com/a/439596
has answer: http://stackoverflow.com/a/12207820
linked to: http://stackoverflow.com/q/22023460
favorite count: 0
has answer: http://stackoverflow.com/a/25865742
has answer: http://stackoverflow.com/a/439311
has answer: http://stackoverflow.com/a/439315
possible better answer: http://stackoverflow.com/a/439494
has answer: http://stackoverflow.com/a/22958900
has answer: http://stackoverflow.com/a/439494
has answer: http://stackoverflow.com/a/52364912

http://stackoverflow.com/comment/329983
type: AnswerComment
comment on: http://stackoverflow.com/a/500517
type: Comment
score: 19
has text: But to paraphrase Krusty with his danish, what have they done for us *LATELY*? =)

http://stackoverflow.com/q/459622
has answer: http://stackoverflow.com/a/459640
accepted answer: http://stackoverflow.com/a/459640
tagged with: permissions
favorite count: 0
tagged with: last-modified
has title: How to change the file's permission and last modified in Java?
type: AnsweredQuestion
score: 3
downvote count: 0
tagged with: java
has body: To my knowledge, Java's File class does not support to change the file's permission and last modified date. Is there any proper way to do this in a cross-platform style?
tagged with: file
tagged with: cross-platform
type: Question
answer count: 1
upvote count: 3

http://stackoverflow.com/q/538872
possible better answer: http://stackoverflow.com/a/3380035
has answer: http://stackoverflow.com/a/540903
has answer: http://stackoverflow.com/a/3380035
tagged with: java
tagged with: multithreading
has answer: http://stackoverflow.com/a/539533
type: Question
tagged with: gwt
score: 4
upvote count: 4
has body: I have a GWT application that displays some charts rendered by JFreeChart. Every few minutes, the page refreshes, which causes the app to generate new charts. (In other words, the entire chart generation process is bootstrapped by a client request.) The problem with this is that multiple clients hitting the same server would result in multiple requests to generate charts, but since the charts are the same for all users, there's really no reason to do this. I would like to prerender the charts in a background thread, which would be kicked off when the application starts, and then just serve the already-rendered charts to the client on request. I don't see any "sanctioned" way in GWT to execute your own code at server startup. The only way I can think of to accomplish this is to create a servlet that gets loaded at startup by the application container, and kick off the chart generation thread in the init() method. Is there a more preferred way to do this? Note: Assuming that it's true, "no" is a perfectly acceptable answer.
has title: Launching background threads on GWT startup
downvote count: 0
accepted answer: http://stackoverflow.com/a/539533
favorite count: 0
has answer: http://stackoverflow.com/a/541168
answer count: 4
type: AnsweredQuestion

http://stackoverflow.com/a/417028
type: Answer
answers question: http://stackoverflow.com/q/416970
score: 2
has comment: http://stackoverflow.com/comment/241313
has body: If I understand correctly, you load a bunch of data from the database to memory and then use them locally by looking for certain objects in that list. If this is the case, I see 2 options. Dont load all the data, but for each iteration access the database with a query returning only the specific record that you need. This will make more database queries, so it will probably bu slower, but with much less memory consumption. This solution could easily be improved by adding cache, so that most used values will be gotten fast. It will of course need some performance measurement, but I usually favor a naive solution with good caching, as the cache can implemented as a cross-concern and be very transparent to the programmer. If you really want to load all your data in memory (which is actually a form of caching), the time to transform your data from a list to a TreeMap (or any other efficient structure) will probably be small compared to the full processing. So you could do the data transformation yourself. As I said, in the general case, I would favor a solution with caching ...
downvote count: 0
upvote count: 2
has comment: http://stackoverflow.com/comment/241309

http://stackoverflow.com/a/2965252
answers question: http://stackoverflow.com/q/604424
type: Answer
has comment: http://stackoverflow.com/comment/11442702
downvote count: 9
has body: Another solution if the text is not the same as the enumeration value: public enum Blah { A("text1"), B("text2"), C("text3"), D("text4"); private String text; Blah(String text) { this.text = text; } public String getText() { return this.text; } public static Blah fromString(String text) { for (Blah b : Blah.values()) { if (b.text.equalsIgnoreCase(text)) { return b; } } return null; } }
score: 1068
upvote count: 1077
has comment: http://stackoverflow.com/comment/3510399
has comment: http://stackoverflow.com/comment/133766367

http://stackoverflow.com/comment/439917
comment on: http://stackoverflow.com/a/626687
type: AnswerComment
score: 0
type: Comment
has text: this is the way i do it now. I think that is also what starblue suggested.

http://stackoverflow.com/comment/417988
type: QuestionComment
has text: Can you please format the source code
score: 0
comment on: http://stackoverflow.com/q/605859
type: Comment

http://stackoverflow.com/a/512543
has body: I'd recommend to see if the customer is remotely happy or unhappy with one solution (e.g. check for deployment platform requirements) and - if there are no obstacles from this - go for the environment that the team (or qualified majority thereof) working on the solution has the most and best knowledge in. I've found it way more productive to work in the personal comfort zone than outside of it. Of course, sometimes you want to get out of the comfort zone in order to learn new stuff, but I wouldn't recommend doing so on paid customer projects (at least not if everybody is outside of their comfort zone). You need a way to estimate effort after all and you cannot do this if you don't know the environment.
answers question: http://stackoverflow.com/q/512503
score: 0
type: Answer

http://stackoverflow.com/a/438909
score: 1
upvote count: 1
has body: You should create a container class for the objects you want to store. I would not store the complete this object with all the logic inside. Store first field by field to find the element which is to big to store it that way. Than put a breakpoint in the methode and take a look at the field element. Does the element contains links which link to each other?
downvote count: 0
answers question: http://stackoverflow.com/q/438875
type: Answer

http://stackoverflow.com/comment/86577751
type: Comment
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/1829949
has text: @Martin that would be correct, but it would mean you have a different problem that needs to be fixed.

castor
tags question: http://stackoverflow.com/q/621903
tags question: http://stackoverflow.com/q/626648
tags question: http://stackoverflow.com/q/622997
type: Tag
tag name: castor
tags question: http://stackoverflow.com/q/644160

http://stackoverflow.com/comment/327169
has text: @DanM: Yes, you're probably right. If the matrix is so sparse anyway, then caching wouldn't be worth the trouble. As usual, the best way to compare these alternatives would be to perform a benchmark.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/512850

http://stackoverflow.com/a/476031
score: 7
accepted answer of: http://stackoverflow.com/q/475843
has comment: http://stackoverflow.com/comment/19794900
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/19812189
type: Answer
has body: Having separate interfaces doesn't mean you can't centralize the implementation. For example you could have one class implement both interfaces. Or each class could reference a common class which implements the protocol. So what I'd do is have separate interfaces, and at least to begin with, have one class implement both. So the implementation is shared, but user code sees the encoder and decoder as separate and independent concepts.
has comment: http://stackoverflow.com/comment/19779726
has comment: http://stackoverflow.com/comment/19820553
upvote count: 7
answers question: http://stackoverflow.com/q/475843

http://stackoverflow.com/q/605891
tagged with: sorting
has answer: http://stackoverflow.com/a/605902
has answer: http://stackoverflow.com/a/47530879
has answer: http://stackoverflow.com/a/55219554
has answer: http://stackoverflow.com/a/14908649
downvote count: 0
has answer: http://stackoverflow.com/a/605912
score: 179
tagged with: string
has answer: http://stackoverflow.com/a/65724970
has answer: http://stackoverflow.com/a/45034721
favorite count: 0
upvote count: 179
has body: Is there a native way to sort a String by its contents in java? E.g. String s = "edcba" -&gt; "abcde"
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/75965566
answer count: 15
has answer: http://stackoverflow.com/a/14908716
has title: Sort a single String in Java
has answer: http://stackoverflow.com/a/66413677
tagged with: java
has answer: http://stackoverflow.com/a/28820537
type: Question
has answer: http://stackoverflow.com/a/605901
linked to: http://stackoverflow.com/q/19468122
has answer: http://stackoverflow.com/a/69698513
has answer: http://stackoverflow.com/a/75592020
has answer: http://stackoverflow.com/a/43070910

http://stackoverflow.com/q/424067
has body: I'm developing an app for iPhone with a Java desktop companion that it synchs to over the network. I'd like to embed a scripting language into both apps so that end users can write scripts that add new behaviours and interact with the object model, and so that I can more rapidly develop some features. Any suggestions for this, or anyone done this before and got experiences to share? I'm thinking of something like tcl which I've used in the past, but not tcl itself as I'm not a big fan of the language. Main criteria are that it should be lightweight as poss (memory usage) easy to interface and extend with java and objective-c (nice to have) readable/approachable for people with limited programming experience My initial hunch is that I should be using one of python, ruby, or lua. My preference would be ruby, as I already have some experience with it and don't know much about the others. However my main unknown is which of these is easiest to get integrated with iPhone and Java. edit 2: per Jason Coco in the comments, the SDK terms prohibit embedded scripting languages. Checking into this it does indeed seem to, but I read it to preclude dynamic installation and extension only. I would still be interested in answers here, as the agreement doesn't seem to preclude having prepackaged scripts inside the application bundle itself - Apple would still get to vet that code. The agreement also seems to allow use of Apples "interpreters"...what are these? Javascript and what else? Any route to use those here?
tagged with: java
has comment: http://stackoverflow.com/comment/248020
has answer: http://stackoverflow.com/a/617677
type: Question
has comment: http://stackoverflow.com/comment/248033
score: 5
has comment: http://stackoverflow.com/comment/247931
upvote count: 5
has comment: http://stackoverflow.com/comment/247909
answer count: 3
has title: Suggestions for an embeddable scripting language for iPhone and Java app?
downvote count: 0
tagged with: cocoa-touch
has answer: http://stackoverflow.com/a/424399
favorite count: 0
has answer: http://stackoverflow.com/a/424267
type: UnansweredQuestion

http://stackoverflow.com/a/595319
answers question: http://stackoverflow.com/q/594722
has comment: http://stackoverflow.com/comment/468686
score: 0
has body: If you are into books, I would highly recommend reading Effective Java by Josh Bloch.
type: Answer

http://stackoverflow.com/comment/459320
score: 0
type: AnswerComment
has text: This sounds really interesting. A colleague of mine always speaks highly of Rails, so if this is anything like it I'm sure it will be good. Thanks for your answer.
type: Comment
comment on: http://stackoverflow.com/a/645860

http://stackoverflow.com/a/582560
has comment: http://stackoverflow.com/comment/394458
score: 0
answers question: http://stackoverflow.com/q/582493
type: Answer
has body: I work for a company that uses both Java and C#. I prefer C# because I think Visual Studio blows away Eclipse, and I just like the language better. However, I think you might do better learning Java in your case. You have more flexibility both for your project and career-wise. You can learn C# anytime.

http://stackoverflow.com/a/363811
type: Answer
has body: What your friend is suggesting is to keep things modular. It doesn't really matter what language you use, but if throw it together in one big project you might make it non modular.
answers question: http://stackoverflow.com/q/363792
upvote count: 1
score: 1
downvote count: 0

http://stackoverflow.com/a/616553
type: Answer
downvote count: 0
score: 10
answers question: http://stackoverflow.com/q/616532
has comment: http://stackoverflow.com/comment/429475
has body: JCI looks fine. This code snippet should be your base: JavaCompiler compiler = new JavaCompilerFactory().createCompiler("eclipse"); MemoryResourceReader mrr = new MemoryResourceReader(); mrr.add("resource name string", yourJavaSourceString.getBytes()); MemoryResourceStore mrs = new MemoryResourceStore(); CompilationResult result = compiler.compile(sources, mrr, mrs); // don't need the result, unless you care for errors/warnings // the class should have been compiled to your destination dir Any reason this should not work? Edit: added a MemoryResourceStore to send the compiled class output to memory, like requested. Also, setting javac settings, like classpath in your case, can be done via setCustomArguments(String[] pCustomArguments) in JavacJavaCompilerSettings class.
upvote count: 10

http://stackoverflow.com/a/549817
type: Answer
answers question: http://stackoverflow.com/q/549808
score: 2
has body: ( a == b ) == true Did you mean a.equals(b) and b.equals(a) return true? This is not the same as a check for reference equality, nor a check for a.compareTo(b) == 0. LinkedList.contains() uses equals(), so you have to make sure that the method has been implemented correctly. equals() should also be consistent with compareTo(), though this is not strictly necessary. If you're using a hash-based data structure (e.g. HashSet), you must ensure that hashCode() is implemented correctly.
upvote count: 2
downvote count: 0

http://stackoverflow.com/a/1060059
score: 10
type: AcceptedAnswer
type: Answer
upvote count: 10
accepted answer of: http://stackoverflow.com/q/579453
answers question: http://stackoverflow.com/q/579453
has comment: http://stackoverflow.com/comment/921276
has body: The JSOM open source OpenStreetMap Java editor project is using the Gettext library to handle all its translations and it is working out very well as people are able to use a variate of translation tools (like KBabel, poedit, launchpad...) to work with the po files so there is no platform constraint there. Also I don't quite see why you think the mentioned setup cannot be used on any platform - you can certainly use gettext in Windows see: here or here Given how popular gettext is I would certainly recommend it.
downvote count: 0

http://stackoverflow.com/comment/59380194
has text: Excellent answer, and very well put. More support for this point of view at: [Brainless Getters & Setters are a Waste](https://agiletribe.wordpress.com/2016/03/07/brainless-getters-setters-are-a-waste/)
type: Comment
score: 3
comment on: http://stackoverflow.com/a/565287
type: AnswerComment

http://stackoverflow.com/a/460312
answers question: http://stackoverflow.com/q/460293
upvote count: 80
type: Answer
downvote count: 0
score: 80
type: AcceptedAnswer
has body: From here: calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minute);
accepted answer of: http://stackoverflow.com/q/460293

http://stackoverflow.com/a/30611850
answers question: http://stackoverflow.com/q/529085
type: Answer
downvote count: 3
upvote count: 1
has comment: http://stackoverflow.com/comment/49290982
score: -2
has body: private E a[]; private int size; public GenSet(int elem) { size = elem; a = (E[]) new E[size]; }

http://stackoverflow.com/comment/295098
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/478010
has text: Thanks, it worked. However, the same ArrayList should not hold different data inside and outside the loop, right? Or is there a valid explanation for this?

http://stackoverflow.com/comment/7340731
score: 0
type: AnswerComment
type: Comment
has text: I see that it is nice to take an isolated piece of code and be able to reason about it, so i would be happy to have a concise syntax to generate properies and continue to access them with the traditional getX and setX. Haven't the Java maintainers noticed that we have to type the property name 6 (!) times when creating its getter an setter?
comment on: http://stackoverflow.com/a/508775

http://stackoverflow.com/comment/98288642
score: 0
comment on: http://stackoverflow.com/a/55805224
has text: Agreed. Put useful details into this answer, and I'll gladly upvote it.
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/62472724
type: AnswerComment
has text: @anshulkatta it should be noted that in OOP, getters and setters are an anti-pattern, they come from procedural programming, having a class with them breaks the encapsulation principle, and generates a lot of boilerplate code, that is, the same kind of code repeated over and over again. Objects should be immutable, if modification of its properties is required it should be done through method that do something more than just returning the value of the property.
type: Comment
score: 2
comment on: http://stackoverflow.com/a/594635

executable-jar
tags question: http://stackoverflow.com/q/574594
tags question: http://stackoverflow.com/q/382886
tags question: http://stackoverflow.com/q/548505
tag name: executable-jar
type: Tag
tags question: http://stackoverflow.com/q/597098
tags question: http://stackoverflow.com/q/456451
tags question: http://stackoverflow.com/q/394616

encryption
tags question: http://stackoverflow.com/q/537596
tags question: http://stackoverflow.com/q/382113
tag name: encryption
tags question: http://stackoverflow.com/q/612121
tags question: http://stackoverflow.com/q/372268
tags question: http://stackoverflow.com/q/521101
type: Tag

http://stackoverflow.com/comment/193853
type: Comment
has text: that link was perfect. I am going to send him that link and convince :) thanks a load
comment on: http://stackoverflow.com/a/363868
score: 0
type: AnswerComment

http://stackoverflow.com/a/563976
score: 2
has body: I have never seen a good reasoning for this. The best I have seen is that: It makes it clear what it is without having to see the parent It makes it easier to change what the class extends without having to figure out what interfaces it should implement I don't like either suggestion. I think the likely cause is that while the code was being written the interfaces were written before the abstract classes and the developers didn't bother to remove the duplicate implements. Never underestimate the laziness of a developer :-) In the end no harm is done except that at class load time it probably takes a non-noticeable fraction of time longer to load a class with duplicate interfaces.
downvote count: 0
type: Answer
upvote count: 2
answers question: http://stackoverflow.com/q/563952

http://stackoverflow.com/comment/329934
score: 3
type: Comment
comment on: http://stackoverflow.com/a/516014
type: AnswerComment
has text: I don't know either. For me it was helpful.

http://stackoverflow.com/q/634102
score: 14
type: AnsweredQuestion
upvote count: 14
has answer: http://stackoverflow.com/a/634147
tagged with: java
accepted answer: http://stackoverflow.com/a/634443
type: Question
possible better answer: http://stackoverflow.com/a/634147
answer count: 2
has comment: http://stackoverflow.com/comment/17878344
has comment: http://stackoverflow.com/comment/447093
has comment: http://stackoverflow.com/comment/8859961
downvote count: 0
tagged with: deadlock
has title: Log4j is hanging my application what am I doing wrong?
has comment: http://stackoverflow.com/comment/447122
has comment: http://stackoverflow.com/comment/14150963
tagged with: log4j
favorite count: 0
has answer: http://stackoverflow.com/a/634443
linked to: http://stackoverflow.com/q/3537870
tagged with: multithreading
has body: First some background on the application. I have an application processing many independent tasks in parallel via a thread pool. The thread pool is now hanging. The following is an snippet from my thread dumps, all my Threads in pool-2 are BLOCKED by "pool-2-thread-78". It seems to be locked trying to write to the console which I find extremely odd. Can anyone shed any light on the situation for me? EDIT: Platform details java version "1.6.0_07" Java(TM) SE Runtime Environment (build 1.6.0_07-b06) Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing) Ubuntu Linux server dual quad core machine. It seems to lock when writing to the printstream, I have considered just removing the console appender however I would rather know why it is blocking and remove it based on this knowledge. In the past the remove and see if it works has come back to bite me :) relevant section from my log4j log4j.rootLogger=DEBUG, STDOUT log4j.logger.com.blah=INFO, LOG log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender log4j.appender.LOG=org.apache.log4j.FileAppender Thread dump extract "pool-2-thread-79" Id=149 BLOCKED on org.apache.log4j.spi.RootLogger@6c3ba437 owned by "pool-2-thread-78" Id=148 at org.apache.log4j.Category.callAppenders(Category.java:201) at org.apache.log4j.Category.forcedLog(Category.java:388) at org.apache.log4j.Category.error(Category.java:302) at com.blah.MessageProcessTask.run(MessageProcessTask.java:103) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask/java:268) at java.util.concurrent.FutureTask.run(FutureTask/java:54) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:619) "pool-2-thread-78" Id=148 RUNNABLE at java.io.FileOutputStream.writeBytes(Native Method) at java.io.FileOutputStream.write(FileOutputStream.java…

http://stackoverflow.com/comment/246694
score: 0
type: AnswerComment
type: Comment
has text: Since it's a while loop with an interval of around 8 secs, the IO involved in reading the file will be quite a lot.
comment on: http://stackoverflow.com/a/390270

http://stackoverflow.com/a/421371
downvote count: 0
answers question: http://stackoverflow.com/q/421357
type: Answer
score: 1
upvote count: 1
has body: I don't know if this is applicable, but if you are running in a pure Vista/Windows Server 2008 solution, I would use TxF (transactional NTFS) and then make sure you open the file handle and perform the file operations by calling the appropriate file APIs through JNI. If that is not an option, then I think you need to have some sort of service that all clients access which is responsible to coordinate the reading/writing of the file.

http://stackoverflow.com/a/435930
type: Answer
answers question: http://stackoverflow.com/q/435890
score: 67
has comment: http://stackoverflow.com/comment/63111503
accepted answer of: http://stackoverflow.com/q/435890
has comment: http://stackoverflow.com/comment/68928454
upvote count: 68
has body: A while ago, I put together a package for doing what you want and more. (I needed it for a utility I was writing). It uses the ASM library. You can use reflection, but ASM turned out to perform better. I put my package in an open-source library I have on my website. The library is here: http://software.clapper.org/javautil/. You want to start with the ClassFinder class. The utility I wrote it for is an RSS reader that I still use every day, so the code does tend to get exercised. I use ClassFinder to support a plug-in API in the RSS reader; on startup, it looks in a couple of directory trees for jars and class files containing classes that implement a certain interface. It's a lot faster than you might expect. The library is BSD-licensed, so you can safely bundle it with your code. The source is available. If that's useful to you, help yourself. Update: If you're using Scala, you might find this library to be more Scala-friendly.
has comment: http://stackoverflow.com/comment/71904999
downvote count: 1
has comment: http://stackoverflow.com/comment/22149949
has comment: http://stackoverflow.com/comment/25626852
has comment: http://stackoverflow.com/comment/22149425
has comment: http://stackoverflow.com/comment/73025964
has comment: http://stackoverflow.com/comment/73023082
has comment: http://stackoverflow.com/comment/63174808
has comment: http://stackoverflow.com/comment/120365166
has comment: http://stackoverflow.com/comment/72990127
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/68724392
has comment: http://stackoverflow.com/comment/25411092

http://stackoverflow.com/comment/386376
type: Comment
comment on: http://stackoverflow.com/q/574529
has text: This isn't a question but I do think there is a place for sort of thing on SO. I know Jeff doesn't like the idea though so you might get flamed.
score: 0
type: QuestionComment

http://stackoverflow.com/a/74324304
answers question: http://stackoverflow.com/q/641172
has body: toFront () worked for me in a similar situation where I wanted a JFrame to create another JFrame but have the first JFrame get or retain focus. The new JFrame was always getting the focus. requestFocus () didn't work. requestFocusInWindow () didn't work. Various calls to one or the other above two methods didn't work, be it from a JFrame or a GlassPane or a getContentPane () or a JPanel(). setAlwaysOnTop (true) didn't work. Inside a JFrame subclass: public void configure () { if (glassPane == null) { return; } final boolean vis = ! glassPane.isVisible (); // Toggle glassPane.setVisible (vis); if (vis) { configFrame = new ConfigFrame ("Configuration", props, glassPane, this); configFrame.addWindowListener (new AdapterForClosingSubs (configureToggle)); toFront (); } else { configFrame.setVisible (false); configFrame.dispose (); configFrame = null; } if (getFocusOwner () != null) { System.out.println ("configure focus owner " + getFocusOwner ().getName ()); } } private final Runnable configureToggle = () -> { configure (); }; fwiw, Java 17.
type: Answer
score: 0

http://stackoverflow.com/q/641255
tagged with: macos
has answer: http://stackoverflow.com/a/981805
favorite count: 0
has answer: http://stackoverflow.com/a/5300105
has answer: http://stackoverflow.com/a/641897
type: UnansweredQuestion
has title: Glassfish hangs on OS X 10.5/Java 6
score: 2
has body: I want to play around with glassfish on a Mac, but I'm having trouble getting it to start. I've followed the installation instructions and created a default domain, which seemed to go fine, but when I try to start it (asadmin start-domain domain1) it just sits there: [kris@Macintosh-2:~/glassfish] ./bin/asadmin start-domain domain1 Starting Domain domain1, please wait. Default Log location is /Users/kris/glassfish/domains/domain1/logs/server.log. Redirecting output to /Users/kris/glassfish/domains/domain1/logs/server.log The log contains nothing but the command to launch the server: Mar 12, 2009 7:09:40 PM com.sun.enterprise.admin.servermgmt.launch.ASLauncher buildCommand INFO: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/java &lt;crapload of system properties&gt; -client -XX:+UnlockDiagnosticVMOptions -XX:MaxPermSize=192m -Xmx512m -XX:NewRatio=2 -XX:+LogVMOutput -XX:LogFile=/Users/kris/glassfish/domains/domain1/logs/jvm.log -cp /Users/kris/glassfish/lib/jhall.jar:/Users/kris/glassfish/lib/appserv-launch.jar com.sun.enterprise.server.PELaunch start Eventually, asadmin gives up waiting: Timeout waiting for domain domain1 to go to starting state. CLI156 Could not start the domain domain1. This is using glassfish v2.1, but I get similar behaviour on v3 prelude. I've also tried both java 5 and 6. I'm at a loss as to what sort of debugging to do as it doesn't seem to be even getting off the ground.
upvote count: 2
tagged with: java
has comment: http://stackoverflow.com/comment/679546
type: Question
tagged with: glassfish
has comment: http://stackoverflow.com/comment/786667
linked to: http://stackoverflow.com/q/5300034
answer count: 3
downvote count: 0

http://stackoverflow.com/comment/130719868
type: Comment
has text: That isn’t a string, that is just the contents of the byte array.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/71215417

http://stackoverflow.com/a/449538
answers question: http://stackoverflow.com/q/447700
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: You didn't specify the format.... Most likely, you want to send a POST request, the contents will be multipart/form-data MIME type. This emulates what a browser sends from an &lt;INPUT type="file" ...&gt; form element. This requires some pretty sophisticated parsing on the server side to extract the multiple parts from the body and correctly extract the file data from the other fields (if any). Fortunately, commons-fileupload does this perfectly. The first answer regarding FilePart is exactly right. Alternatively, you could simply post the raw contents of a file as the body of the request by using an InputStreamRequestEntity. This may be much simpler if you're writing your own server side to receive the data. The server side is as simple as streaming the request's InputStream to disk. I use this technique for uploads with Google Gears.
score: 3
upvote count: 3
accepted answer of: http://stackoverflow.com/q/447700

http://stackoverflow.com/comment/323092
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/508776
score: 1
has text: Besides, aren't there some folks (e.g., Allen Holub) who would say that getters and setters are signs of poor object-orientation and weak minds? http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html

http://stackoverflow.com/comment/460250
type: AnswerComment
type: Comment
has text: Ah I see now. So in my case when I have x selected and click y it prints y twice which you have covered here, strange that it works this way though. Anyway thanks for the answer :)
score: 0
comment on: http://stackoverflow.com/a/646302

http://stackoverflow.com/a/29943800
has body: Using @Rules on TestWatcher you can take note of count and many other things like method name etc. You can override these methods and use . @Override public Statement apply(Statement base, Description description){ return super.apply(base, description); } @Override protected void failed(Throwable e, Description description) { failed.add(description); LogUtil.error("[FAILED] "+description.getMethodName()+" [Test Failed]"+e.getMessage()); super.failed(e, description); } @Override protected void finished(Description description) { LogUtil.info("[FINISHED] "+description.getMethodName()); super.finished(description); } @Override protected void skipped(AssumptionViolatedException e,Description description) { LogUtil.error("[FAILED] Test Failed due to Assumption Voilation "+e.getMessage()); super.skipped(e,description); } @Override protected void starting(Description description) { LogUtil.info("-----------------------------------------------------------"); LogUtil.info("[STARTED] "+description.getMethodName()); super.starting(description); } @Override protected void succeeded(Description description) { passed.add(description); LogUtil.info("[PASSED] "+description.getMethodName()); super.succeeded(description); } In your Junit Testcase Use @Rule public TestRule watcher = new TestWatcherChild();
score: 0
type: Answer
answers question: http://stackoverflow.com/q/535929

http://stackoverflow.com/comment/346334
type: AnswerComment
comment on: http://stackoverflow.com/a/513787
type: Comment
has text: The StringBuilder test is invalid because it does not call toString() at the end to actually give you a String you can use. I added this and the result is that StringBuilder takes about the same amount of time as +. I'm sure as you increase the number of appends it will eventually become cheaper.
score: 4

http://stackoverflow.com/a/371256
type: AcceptedAnswer
downvote count: 0
upvote count: 8
type: Answer
score: 8
accepted answer of: http://stackoverflow.com/q/371019
answers question: http://stackoverflow.com/q/371019
has body: Probably used by javabeans introspection. For instance Netbeans beaninfo editor does not recognise the event if extends EventListener is missing from the Listener.

http://stackoverflow.com/a/371688
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/371495
type: Answer
has body: I've used the HeapAnalyzer tool from IBM's alphaWorks with good success. It takes output from Java's heap profile, hprof, and analyzes it to show you the most likely memory leaks.
score: 1

http://stackoverflow.com/a/531460
downvote count: 0
answers question: http://stackoverflow.com/q/531282
has body: My customary practice is that if all the constructor has to do is set some fields on an object, it can be arbitrarily long. If it gets too long, it means that the class design is broken anyway, or data need to be packaged in some more complex structures. If, on the other hand, the input data need some more complex processing before initializing the class fields, I tend to give the constructor the processed data and move the processing to a static factory method.
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/a/451173
downvote count: 0
answers question: http://stackoverflow.com/q/451004
type: Answer
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/271868
has body: It is difficult to make a suggestion based on the information given but possibly the use of TemporaryQueues e.g. dynamically created PTP destinations on a per client basis might fit the problem? Here is a reasonable overview.

http://stackoverflow.com/comment/281719
type: Comment
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/463047
has text: Thanks. DB4O looks good for such a small project, but I believe the ability to browse and edit data outside the application is very important. Also would it be easy to handle newer versions of classes? (e.g. added/removed fields)

http://stackoverflow.com/a/579058
downvote count: 0
has body: One reason why first scenario is better is that the find(Class,String) method now has knowledge of what its return value is being assigned to. Therefore, it is now capable of doing any relevant casts internally instead of simply hoping the correct type was returned. For example, suppose the find method locates a String object internally when called with "someId". The find method may have a strategy for casting a String to a MyObj instance.
type: Answer
score: 3
answers question: http://stackoverflow.com/q/579031
upvote count: 3

http://stackoverflow.com/q/380046
has title: How can I best apply OOP principles to games and other input-driven GUI apps?
answer count: 6
downvote count: 0
has answer: http://stackoverflow.com/a/380054
has answer: http://stackoverflow.com/a/380088
has answer: http://stackoverflow.com/a/380233
favorite count: 0
possible better answer: http://stackoverflow.com/a/380054
tagged with: language-agnostic
has answer: http://stackoverflow.com/a/380112
has answer: http://stackoverflow.com/a/380064
tagged with: model-view-controller
has answer: http://stackoverflow.com/a/381009
type: AnsweredQuestion
score: 2
tagged with: oop
upvote count: 2
accepted answer: http://stackoverflow.com/a/380112
tagged with: java
has body: Whenever I try to write graphical programs (whether a game or really any GUI app) I always wind up with one or two god classes with way too many methods (and long methods, too), and each class having far too many responsibilities. I have graphics being done at the same time as calculations and logic, and I feel like this is a really bad way to go about organizing my code. I want to get better at organizing my code and abstracting out responsibilities to different classes. Here's an example of where I'd like to start - I want to write a Minesweeper clone, just sort of as practice and to try to improve my software engineering skills. How would I go about making this nice and object-oriented? For the sake of discussion, let's just say I'm using Java (because I probably will, either that or C#). Here's some things I would think about: should each tile inherit from JButton or JComponent and handle drawing itself? or should the tiles just be stored as some non-graphical MinesweeperTile object and some other class handles drawing them? is the 8-segment display countdown timer (pre-Vista, at least) a separate class that handles drawing itself? when the user clicks, do the tiles have mouse event listeners or does some other collision detection method loop through the tiles and check each one to see if it's been hit? I realize that there's not just one way to write a GUI application, but what are some pretty basic things I can start doing to make my code more organized, manageable, object-oriented, and just over all write better programs? edit: I guess I should add that I'm familiar with MVC, and I was originally going to incorporate that into my question, but I guess I didn't want to shoehorn myself into MVC if that's not necessarily what I need. I did searched for topics on MVC with GUI apps but didn't really find anything that answers my specific question. edit2: Thanks to everyone who answered. I wish I could accept more than one answer..
type: Question

http://stackoverflow.com/comment/208083
type: Comment
type: QuestionComment
has text: Can you clarify why you did not see Test.class and Test$Inner.class? I assume there another SomeClass in the same package that generated the class files you did see?
score: 0
comment on: http://stackoverflow.com/q/380406

http://stackoverflow.com/a/10655576
answers question: http://stackoverflow.com/q/477886
score: 0
type: Answer
has body: POI or JExcel are good APIs. I personally like better POI, plus POI is constantly updated. Furthermore, there are more resources online about POI than JExcel in case you have any questions. However, either of the two does a great job.

http://stackoverflow.com/a/534366
upvote count: 2
answers question: http://stackoverflow.com/q/533467
type: Answer
has body: MATLAB does this with a contour plot: see the contour function -- it produces contour line data from a grid of f(x,y) data. I don't know much about the algorithm they use (they do have a page which discusses it) but maybe worth looking at the Octave equivalent. there's a thesis on contour plotting and a CodeProject page based on the thesis.
score: 2
downvote count: 0

http://stackoverflow.com/a/41964063
has body: Strategically, it helps to know several languages as demonstrated by a little research. Currently, PHP, Java, and ASP.NET (C#) are the most widely used server-side programming technologies (see https://w3techs.com/technologies/overview/programming_language/all). Therefore, knowing all three empowers your backend engineering potential.
type: Answer
answers question: http://stackoverflow.com/q/521305
has comment: http://stackoverflow.com/comment/71108363
downvote count: 1
score: -1
upvote count: 0

http://stackoverflow.com/comment/372457
comment on: http://stackoverflow.com/a/561289
type: AnswerComment
has text: The problem I have is not with the Heap Size, but with the amount of Virtual Memory that is assigned by Linux
type: Comment
score: 1

http://stackoverflow.com/comment/297476
type: Comment
has text: mmyers linked to the important part of the javadoc, which I quoted in my answer since it's so crucial. Software Monkey's answer is correct, but only implies it which is why it didn't get my vote.
comment on: http://stackoverflow.com/a/480611
type: AnswerComment
score: 0

http://stackoverflow.com/a/399335
upvote count: 7
answers question: http://stackoverflow.com/q/399286
type: Answer
has body: This might be different in different application servers. For tomcat, the favicon comes from the directory your root context is mapped to. So if your application is mapped to the root context [/], just place the favicon.ico file in the top level folder in your war file.
downvote count: 0
score: 7

http://stackoverflow.com/a/505941
type: Answer
has comment: http://stackoverflow.com/comment/324017
has comment: http://stackoverflow.com/comment/24702116
has comment: http://stackoverflow.com/comment/320542
has comment: http://stackoverflow.com/comment/320721
has comment: http://stackoverflow.com/comment/320629
score: 13
has body: Sorry there's no simple method call that can do it. All you'd need to do though is create a map and count frequency with it. HashMap&lt;String,int&gt; frequencymap = new HashMap&lt;String,int&gt;(); foreach(String a in animals) { if(frequencymap.containsKey(a)) { frequencymap.put(a, frequencymap.get(a)+1); } else{ frequencymap.put(a, 1); } }
has comment: http://stackoverflow.com/comment/99810743
has comment: http://stackoverflow.com/comment/320627
downvote count: 5
answers question: http://stackoverflow.com/q/505928
upvote count: 18
has comment: http://stackoverflow.com/comment/320554
has comment: http://stackoverflow.com/comment/320719

http://stackoverflow.com/comment/388131
score: 0
type: Comment
type: QuestionComment
has text: @Simucal, you seem to be correct. It's strange, I've never ran into this problem before though, ha ha. Thank you for correcting me before I made some huge mistake some time later. :)
comment on: http://stackoverflow.com/q/576162

http://stackoverflow.com/comment/75359342
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/614122
has text: You could add a method like `hasCause(Class<? extends Exception>... causeClasses)` (searching the whole chain) to your `AppSpecificException` and use it as easily as multiple catch clauses.

http://stackoverflow.com/comment/384637
score: 0
type: Comment
has text: You might find Ivy worth incorporating into your build system. It basically takes the dependency-resolution mechanisms of maven while jettisoning the rest - http://ant.apache.org/ivy/
comment on: http://stackoverflow.com/a/572840
type: AnswerComment

http://stackoverflow.com/q/513832
has answer: http://stackoverflow.com/a/515000
has comment: http://stackoverflow.com/comment/29762356
has answer: http://stackoverflow.com/a/16293384
has comment: http://stackoverflow.com/comment/29455790
has answer: http://stackoverflow.com/a/513871
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/10117865
has answer: http://stackoverflow.com/a/20666721
score: 723
has answer: http://stackoverflow.com/a/513852
has answer: http://stackoverflow.com/a/17849465
linked to: http://stackoverflow.com/q/8881291
tagged with: java
tagged with: equality
linked to: http://stackoverflow.com/q/3801343
has answer: http://stackoverflow.com/a/513846
accepted answer: http://stackoverflow.com/a/513839
has answer: http://stackoverflow.com/a/17040504
has answer: http://stackoverflow.com/a/15599387
has answer: http://stackoverflow.com/a/513935
downvote count: 10
type: Question
has comment: http://stackoverflow.com/comment/29723884
has comment: http://stackoverflow.com/comment/31072763
upvote count: 733
has answer: http://stackoverflow.com/a/14208295
possible better answer: http://stackoverflow.com/a/513935
has answer: http://stackoverflow.com/a/12242166
answer count: 23
linked to: http://stackoverflow.com/q/44238749
has title: How do I compare strings in Java?
has answer: http://stackoverflow.com/a/15681710
has answer: http://stackoverflow.com/a/513844
linked to: http://stackoverflow.com/q/11271554
linked to: http://stackoverflow.com/q/19965895
has answer: http://stackoverflow.com/a/16804712
tagged with: string
has body: I've been using the == operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals() instead, and it fixed the bug. Is == bad? When should it and should it not be used? What's the difference?
favorite count: 0
has answer: http://stackoverflow.com/a/513839
has answer: http://stackoverflow.com/a/21112002
linked to: http://stackoverflow.com/q/3052442
has answer: http://stackoverflow.com/a/515412
has answer: http://stackoverflow.com/a/14123474
has answer: http://stackoverflow.com/a/513855
has answer: http://stackoverflow.com/a/513840
has answer: http://stackoverflow.com/a/15760319

http://stackoverflow.com/q/602537
downvote count: 0
tagged with: jar
has answer: http://stackoverflow.com/a/38407087
has comment: http://stackoverflow.com/comment/414799
tagged with: manifest
has comment: http://stackoverflow.com/comment/414892
has answer: http://stackoverflow.com/a/602552
has answer: http://stackoverflow.com/a/1457276
has answer: http://stackoverflow.com/a/1607827
has answer: http://stackoverflow.com/a/1491611
has answer: http://stackoverflow.com/a/14532989
has answer: http://stackoverflow.com/a/603370
has answer: http://stackoverflow.com/a/3958210
has comment: http://stackoverflow.com/comment/414792
answer count: 17
favorite count: 0
tagged with: netbeans
has answer: http://stackoverflow.com/a/1174497
has answer: http://stackoverflow.com/a/638919
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/29660713
has comment: http://stackoverflow.com/comment/414804
has answer: http://stackoverflow.com/a/1559988
has answer: http://stackoverflow.com/a/635529
has body: I'm using NetBeans 6.5 and for some reason it won't produce executable jar "out of the box". I set my project to be the main project, defined main class in the project properties "run" menu and it works flawlessly when I press F6 to run it. I looked at the manifest file and it indeed didn't define the main class there, and also omitted the library dependencies. Am I missing something? Is there a way (other than manually altering the manifest file) to produce executable jar files? EDIT: yes, I tried clean and rebuild and it produced the jar in the dist folder, still with the same manifest.mf Manifest-Version: 1.0 Ant-Version: Apache Ant 1.7.1 Created-By: 10.0-b23 (Sun Microsystems Inc.)
has answer: http://stackoverflow.com/a/16115632
has answer: http://stackoverflow.com/a/14323608
tagged with: executable
tagged with: java
has title: Producing executable jar in NetBeans
has answer: http://stackoverflow.com/a/1491630
has comment: http://stackoverflow.com/comment/414779
type: Question
score: 20
upvote count: 20
has answer: http://stackoverflow.com/a/615382

http://stackoverflow.com/q/616598
downvote count: 2
has body: I am reading books on middleware, Spring, Hibernate, etc., and am wondering myself why the developer invented a new name, i.e. "enterprise edition" for Java "web" or "internet" libraries? As I have a quite individual mindset, "enterprise" edition sounds almost like "socialist" edition... what do I need to know to differentiate better?
tagged with: enterprise
has answer: http://stackoverflow.com/a/616617
favorite count: 0
answer count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/616663
has answer: http://stackoverflow.com/a/616693
score: 1
has title: Correct: Java "enterprise" edition = Java "internet" edition?
has answer: http://stackoverflow.com/a/616692
type: Question
tagged with: jakarta-ee
tagged with: naming-conventions
tagged with: java
has answer: http://stackoverflow.com/a/616643
upvote count: 3

http://stackoverflow.com/a/1191390
type: Answer
has comment: http://stackoverflow.com/comment/79586839
has comment: http://stackoverflow.com/comment/78282467
has body: Just to clarify the situation for Java, doubles and longs are not read or written to atomically unless they're declared volatile JLS - Nonatomic Treatment of double and long
upvote count: 28
has comment: http://stackoverflow.com/comment/83033244
has comment: http://stackoverflow.com/comment/76110726
has comment: http://stackoverflow.com/comment/57125331
downvote count: 0
has comment: http://stackoverflow.com/comment/99254275
score: 28
has comment: http://stackoverflow.com/comment/68432608
answers question: http://stackoverflow.com/q/517532

http://stackoverflow.com/a/573838
has body: Egwor suggest using a CountDownLatch instead. Definitely looks like it would simplify the situation. This is a job for condition variables. Basically, in run(), Lock the lock, construct some new window and signal the condition (and unlock the lock). "Meanwhile", in the other thread, do your other "bs", lock the lock; if the window is null, wait() on the condition variable; unlock the lock; window.doStuff();
has comment: http://stackoverflow.com/comment/385678
score: 0
upvote count: 1
has comment: http://stackoverflow.com/comment/385674
downvote count: 1
answers question: http://stackoverflow.com/q/573826
type: Answer

http://stackoverflow.com/q/374302
has answer: http://stackoverflow.com/a/374358
tagged with: java
has answer: http://stackoverflow.com/a/6051297
has body: In our project we have to map one nested structures of beans onto another. (These are actually JAXB mapped Java-Representations of XML documents that, say, represent an incoming order document.) This has to be mapped onto the quite different order document structure of another system. What are the options to do this? I would prefer something that fulfills the following requirements: The mapping should alert me when the mapping of one field was not defined The mapping should have some defaults, like mapping fields of equal names onto one another and providing standard mappings for, say, int to String and vice versa. The mapping should be bidirectional. One should be able to use code completion when defining the mapping. A promising framework for this is Dozer, but it does not fulfill 1 and 4. Same with JBeanMapper. Just programming it in Java does 4 but not the other requirements; using XSLT fulfills perhaps 2 but nothing else. Do you have better ideas?
type: UnansweredQuestion
score: 6
has answer: http://stackoverflow.com/a/4614421
has answer: http://stackoverflow.com/a/18013122
has answer: http://stackoverflow.com/a/16991212
downvote count: 0
tagged with: javabeans
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/374332
has title: How to map different Java-Bean structures onto one another
upvote count: 6
answer count: 6
tagged with: mapping

http://stackoverflow.com/a/475849
has body: Only thing is that you usually have one code part that will use the decoder and a separate using the encoder. So a change to the encoding part of the interface will force an unnecessary recompile of the decoding part and vice versa. True for c/c++ etc. with header file include. Search for solid principles and see Interface Segregation Principle.
type: Answer
score: 3
upvote count: 3
downvote count: 0
answers question: http://stackoverflow.com/q/475843

http://stackoverflow.com/q/542979
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/20496376
downvote count: 0
has answer: http://stackoverflow.com/a/68302971
type: Question
has comment: http://stackoverflow.com/comment/56155810
has answer: http://stackoverflow.com/a/46428835
tagged with: java
tagged with: jboss
has answer: http://stackoverflow.com/a/33357365
score: 214
has title: Where dump is dumped, using HeapDumpOnOutOfMemoryError parameter for JBoss
possible better answer: http://stackoverflow.com/a/20496376
has answer: http://stackoverflow.com/a/543037
accepted answer: http://stackoverflow.com/a/543037
favorite count: 0
tagged with: heap-memory
answer count: 5
tagged with: memory-leaks
has body: I was told I can add the -XX:+HeapDumpOnOutOfMemoryError parameter to my JVM start up options to my JBoss start up script to get a heap dump when we get an out of memory error in our application. I was wondering where this data gets dumped? Is it just to the console, or to some log file? If it's just to the console, what if I'm not logged into the Unix server through the console?
upvote count: 214

http://stackoverflow.com/comment/121198206
type: AnswerComment
type: Comment
has text: P.S. - "C# wouldn't allow that" is not the case anymore, C# 9.0 supports covariant return types :)
comment on: http://stackoverflow.com/a/573628
score: 0

http://stackoverflow.com/q/581006
has answer: http://stackoverflow.com/a/582030
has answer: http://stackoverflow.com/a/581040
has title: tinting sprites in Java2D on the fly?
score: 2
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/581408
downvote count: 0
has body: I am creating a game with an ascii-like map using Java2D on Linux (like a roguelike). By rendering BufferedImages via Graphics2D.drawImage the terrain is rendered. I would like to change the hue of each drawn image on the fly, without hurting performance too much. How can I achieve this? I suspect setComposite is part of the puzzle. Currently I do not need to keep the background intact (so transparency is not an issue). I want to use a wide variety of colors, so pre-generating tinted sprites is not a solution for me.
type: Question
favorite count: 0
tagged with: java-2d
upvote count: 2
answer count: 3
has answer: http://stackoverflow.com/a/581408
tagged with: java
possible better answer: http://stackoverflow.com/a/581040

http://stackoverflow.com/comment/1535695
type: AnswerComment
comment on: http://stackoverflow.com/a/1202096
type: Comment
has text: Hi, I could not make it work, it still says it have worked, but it does nothing!. The click command works but keeps waiting for the page to load (when it shouldn't). Any suggestion?
score: 0

http://stackoverflow.com/comment/77025197
type: Comment
has text: ... So, in this case I'd actually claim that the checked exceptions in fact helped you write more responsible code. The `InvocationTargetException` is nothing but unfortunate. It should clearly have been a `RuntimeException`. It's from the early days of Java, and no one had experienced the annoyance checked exceptions had brought us today. I would however like to emphasize that this is an API design issue, rather than an issue with checked exceptions as a language feature. Is it hard to get right? Sure, sometimes. But not so hard that a good feature like this should be tossed out the window.
comment on: http://stackoverflow.com/a/703944
score: 0
type: AnswerComment

http://stackoverflow.com/q/623892
score: 82
has answer: http://stackoverflow.com/a/623998
has answer: http://stackoverflow.com/a/23373796
has answer: http://stackoverflow.com/a/18366452
has answer: http://stackoverflow.com/a/33957727
has answer: http://stackoverflow.com/a/623916
upvote count: 82
type: AnsweredQuestion
downvote count: 0
tagged with: algorithm
has answer: http://stackoverflow.com/a/33386653
has answer: http://stackoverflow.com/a/623986
tagged with: java
has answer: http://stackoverflow.com/a/23868326
favorite count: 0
has comment: http://stackoverflow.com/comment/437271
has answer: http://stackoverflow.com/a/10178411
type: Question
has answer: http://stackoverflow.com/a/40437845
tagged with: trie
has answer: http://stackoverflow.com/a/10682132
has title: Where do I find a standard Trie based map implementation in Java?
accepted answer: http://stackoverflow.com/a/623998
has body: I have a Java program that stores a lot of mappings from Strings to various objects. Right now, my options are either to rely on hashing (via HashMap) or on binary searches (via TreeMap). I am wondering if there is an efficient and standard trie-based map implementation in a popular and quality collections library? I've written my own in the past, but I'd rather go with something standard, if available. Quick clarification: While my question is general, in the current project I am dealing with a lot of data that is indexed by fully-qualified class name or method signature. Thus, there are many shared prefixes.
has answer: http://stackoverflow.com/a/17810863
possible better answer: http://stackoverflow.com/a/26465078
tagged with: optimization
has answer: http://stackoverflow.com/a/27378976
has answer: http://stackoverflow.com/a/26465078
answer count: 14

http://stackoverflow.com/q/572572
has body: I am developing a screen capturing utility in Java &amp; I want to capture any background window, when I click on that particular window. But I am not getting how to add mouseClicked event to background window. Can somebody please help me?
has answer: http://stackoverflow.com/a/572672
has comment: http://stackoverflow.com/comment/384364
downvote count: 0
score: 1
favorite count: 0
has answer: http://stackoverflow.com/a/572580
type: UnansweredQuestion
answer count: 4
has title: Mouse Listener Question
tagged with: java
upvote count: 1
has answer: http://stackoverflow.com/a/572941
type: Question
has answer: http://stackoverflow.com/a/572582

http://stackoverflow.com/a/628743
type: Answer
score: 1
answers question: http://stackoverflow.com/q/628730
upvote count: 1
has comment: http://stackoverflow.com/comment/441452
downvote count: 0
has body: YOu're off to a good start. Refinements you could make: Generics. Your linked list could be LinkedList &lt; DependencyDataCollection > lList; This gives you type checking. You've seen here that your linked list is inconvenient to search - you have to check each value, which is slow and unwieldy. This is why people use hashmaps. Look up the builder pattern to find a way around the long list of constructor args.

http://stackoverflow.com/a/17776425
has comment: http://stackoverflow.com/comment/105118532
type: Answer
has body: ╔═══════════════╦═══════════════════╦═══════════════════╦═════════════════════╗ ║ Property ║ HashMap ║ Hashtable ║ ConcurrentHashMap ║ ╠═══════════════╬═══════════════════╬═══════════════════╩═════════════════════╣ ║ Null ║ allowed ║ not allowed ║ ║ values/keys ║ ║ ║ ╠═══════════════╬═══════════════════╬═════════════════════════════════════════╣ ║ Thread-safety ║ ║ ║ ║ features ║ no ║ yes ║ ╠═══════════════╬═══════════════════╬═══════════════════╦═════════════════════╣ ║ Lock ║ not ║ locks the whole ║ locks the portion ║ ║ mechanism ║ applicable ║ map ║ ║ ╠═══════════════╬═══════════════════╩═══════════════════╬═════════════════════╣ ║ Iterator ║ fail-fast ║ weakly consistent ║ ╚═══════════════╩═══════════════════════════════════════╩═════════════════════╝ Regarding locking mechanism: Hashtable locks the object, while ConcurrentHashMap locks only the bucket.
has comment: http://stackoverflow.com/comment/72624292
downvote count: 3
answers question: http://stackoverflow.com/q/510632
has comment: http://stackoverflow.com/comment/53395286
score: 258
has comment: http://stackoverflow.com/comment/51189130
upvote count: 261
has comment: http://stackoverflow.com/comment/44161494

http://stackoverflow.com/comment/363556
comment on: http://stackoverflow.com/a/551849
score: 0
type: Comment
has text: @Fabian: Hmm, strange, it does work. I'm wondering why it let me pull that off. I've never used a non-public main
type: AnswerComment

http://stackoverflow.com/comment/224468
score: 0
has text: Yeah, perhaps I should. I thought perhaps I was just using it wrong. If that is the case, they may want to update the documentation.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/398179

http://stackoverflow.com/a/382695
type: Answer
upvote count: 6
score: 6
has body: I believe it is making an exception because, though formatted strangely, what you have is an "else if". It shouldn't force you to put braces around the "if" in this case because you would end up with "... else { if { ... } } Your code should be formatted: if (true) { System.out.println("20"); } else if (true) { System.out.println("30"); }
answers question: http://stackoverflow.com/q/382633
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/382633
has comment: http://stackoverflow.com/comment/214519

http://stackoverflow.com/a/425062
score: 0
answers question: http://stackoverflow.com/q/424849
type: Answer
has body: Canvas is inappropriate for adding to Swing components. Use JComponent instead (and setOpaque(true)). Swing components should always be manipulated on the AWT Event Dispatch Thread (EDT). Use java.awt.EventQueue.invokeLater (invokeAndWait for applets). You shouldn't do any blocking operations from the EDT, so start your own threads for that. By default you are running in the main thread (or applet thread for applets), which is quite separate from the EDT. I suggest removing any dependence from your MyCanvas to JFrame. I also suggest keeping code for applications using frame separate from that using applets. Adding a component to a JApplet is the same as for JFrame (in both cases there is shenanigans where actually what happens is that add actually calls getContentPane().add which can cause some unnecessary confusion). The main difference is that you can't pack an applet.
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/3090347

http://stackoverflow.com/a/467768
score: 2
downvote count: 1
answers question: http://stackoverflow.com/q/467762
has comment: http://stackoverflow.com/comment/285868
has body: I'd vote for C#. Even with the learning curve of moving away from C++ your developers should be more productive and the tooling and libraries are great. The only place I see C# adding to the complexity of your project will be interfacing to your USB device, but it's fairly easy to get up to speed with P/Invoke and / C++/CLI to expose your C/C++ driver to .NET.
upvote count: 3
has comment: http://stackoverflow.com/comment/285717
type: Answer

http://stackoverflow.com/q/510061
has answer: http://stackoverflow.com/a/510344
has answer: http://stackoverflow.com/a/510087
type: Question
has answer: http://stackoverflow.com/a/510116
tagged with: optimization
upvote count: 1
has answer: http://stackoverflow.com/a/510114
has title: Is it possible to write a decent java optimizer if information is lost in the translation to bytecode?
favorite count: 0
type: UnansweredQuestion
answer count: 4
has body: It occurred to me that when you write a C program, the compiler knows the source and destination platform (for lack of a better term) and can optimize to the machine it is building code for. But in java the best the compiler can do is optimize to the bytecode, which may be great, but there's still a layer in the jvm that has to interpret the bytecode, and the farther the bytecode is away translation-wise from the final machine architecture, the more work has to be done to make it go. It seems to me that a bytecode optimizer wouldn't be nearly as good because it has lost all the semantic information available from the original source code (which may already have been butchered by the java compiler's optimizer.) So is it even possible to ever approach the efficiency of C with a java compiler?
downvote count: 0
score: 1
tagged with: java

http://stackoverflow.com/comment/16357539
type: Comment
comment on: http://stackoverflow.com/a/578709
has text: Don't use open session in view if you expect load on your server. This answer could use a warning in that direction.
type: AnswerComment
score: 0

http://stackoverflow.com/a/4257978
answers question: http://stackoverflow.com/q/611760
has comment: http://stackoverflow.com/comment/9870414
downvote count: 7
upvote count: 0
score: -7
type: Answer
has body: I think You can receive the entire data stream if you use thread.sleep()

http://stackoverflow.com/q/512555
favorite count: 0
has answer: http://stackoverflow.com/a/77160964
possible better answer: http://stackoverflow.com/a/512622
tagged with: windows
answer count: 4
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/512622
tagged with: shutdown-hook
tagged with: java
has title: Detect windows logout event in Java application
type: Question
has answer: http://stackoverflow.com/a/1890960
has body: Is there a library that I can use with Java to listen for user logout and possibly other Windows events? (Even better if it supports multiple platforms!) I remember reading about a library of this sort a number of years ago, but can't seem to find it now. I've seen other threads to do essentially the same thing using Python with win32ts. Also better if it's free and/or open source. Thanks. Note: The candidate solution of using Runtime.getRuntime().addShutdownHook(Thread) does not work correctly with javaw. I am still looking for a solution that will work with javaw. See java bug ids 4486580 and 4302814. Thanks --cam
upvote count: 2
linked to: http://stackoverflow.com/q/61692
has answer: http://stackoverflow.com/a/512660
accepted answer: http://stackoverflow.com/a/512660
tagged with: events
downvote count: 0

http://stackoverflow.com/q/525212
has answer: http://stackoverflow.com/a/40687370
has answer: http://stackoverflow.com/a/21793314
has answer: http://stackoverflow.com/a/38675063
has answer: http://stackoverflow.com/a/526287
has answer: http://stackoverflow.com/a/11410652
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/525359
has answer: http://stackoverflow.com/a/52984637
has answer: http://stackoverflow.com/a/525218
tagged with: unix
has answer: http://stackoverflow.com/a/55412953
linked to: http://stackoverflow.com/q/6295866
has comment: http://stackoverflow.com/comment/35402782
tagged with: java
has answer: http://stackoverflow.com/a/40047871
has answer: http://stackoverflow.com/a/17020905
has answer: http://stackoverflow.com/a/38604984
score: 180
type: Question
has answer: http://stackoverflow.com/a/37327025
has comment: http://stackoverflow.com/comment/62173009
has answer: http://stackoverflow.com/a/1546727
has answer: http://stackoverflow.com/a/50680287
has answer: http://stackoverflow.com/a/525222
has title: How to run Unix shell script from Java code?
has answer: http://stackoverflow.com/a/15203793
has body: It is quite simple to run a Unix command from Java. Runtime.getRuntime().exec(myCommand); But is it possible to run a Unix shell script from Java code? If yes, would it be a good practice to run a shell script from within Java code?
linked to: http://stackoverflow.com/q/25647806
downvote count: 0
tagged with: shell
answer count: 17
favorite count: 0
upvote count: 180

http://stackoverflow.com/comment/97137175
type: Comment
comment on: http://stackoverflow.com/a/574650
score: 7
type: AnswerComment
has text: @user10201743 Just to give a little context: _Everything_ in Maven is a plugin. The compiler? `maven-compiler-plugin`. Tests? `maven-surefire-plugin`. These two, including the assembly, are official maven plugins, so they might as well be considered as part of maven (esp. cause, at least now, all three of them are in your effective POM by default).

http://stackoverflow.com/comment/222366
type: AnswerComment
comment on: http://stackoverflow.com/a/362738
type: Comment
score: 1
has text: couldn't it just say to declare the constructor like if it were the base class constructor? i don't see problems with that

http://stackoverflow.com/comment/79509840
comment on: http://stackoverflow.com/a/500517
type: Comment
has text: @Jon Skeet: Suppose I have a method argument declared as final, and an inner class inside the method, but I don't use that final argument inside my inner class, will my final reference be eligible for garbage collection?
type: AnswerComment
score: 0

http://stackoverflow.com/q/616532
has answer: http://stackoverflow.com/a/20573091
accepted answer: http://stackoverflow.com/a/616630
upvote count: 18
has answer: http://stackoverflow.com/a/616712
type: Question
downvote count: 0
tagged with: runtime
score: 18
answer count: 6
possible better answer: http://stackoverflow.com/a/616553
has answer: http://stackoverflow.com/a/616553
has body: How can I compile java code from an arbitrary string (in memory) in Java 5 and Java 6, load it and run a specific method on it (predefined)? Before you flame this, I looked over existing implementations: Most rely on Java 6 Compiler API. Those that don't, rely on tricks. Yes, I checked out commons-jci. Either I'm too dense to understand how it works, or it just doesn't. I could not find how to feed the compiler my current class path (which is quite huge). On the implementation that worked (in Java 6), I could not find how to correctly load inner classes (or inner anonymous classes). I'd quite like it if the entire thing was in-memory, as the thing runs on multiple environments. I'm sure this has been solved before, but I can't find anything that looks even half-production quality on google (except jci, which, as I've said before, I haven't managed to use). Edit: I looked over JavaAssist - I need inner classes, Java 5.0 language level support and compiling with the entire classpath. Also, I'd like to create new classes on the fly. I might be mistaken, but I couldn't find how to do this with JavaAssit. I'm willing to use a file-system based solution (calling javac) but I don't know how to divine the classpath, nor how to later load the files (which are not in my classpath) with a special classloader that can be recycled for multiple invocations. While I do know how to research it, I'd prefer a ready solution. Edit2: For now, I'm content with BeanShell "evaluate". Apparently it does everything I need it to (get a string, evaluate it in the context of the 'current' classpath. It does miss some of Java 5 features, but it can use enums (not define) and compiled 'generic' (erased) classes, so it should be enough for what I want. I don't want to mark the answer as accepted yet since I do hope for a better solution to come up. Edit3: Accepted the beanshell suggestion - it really works wonderfully.
has answer: http://stackoverflow.com/a/616546
has answer: http://stackoverflow.com/a/616742
has answer: http://stackoverflow.com/a/616630
favorite count: 0
has title: On-the-fly, in-memory java code compilation for Java 5 and Java 6
type: AnsweredQuestion
tagged with: runtime-compilation
tagged with: java
tagged with: compilation

http://stackoverflow.com/a/623269
has comment: http://stackoverflow.com/comment/450293
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/600945
upvote count: 3
score: 3
has body: Could you try this (always worked for me): &lt;h:outputText value="#{listing.staffMember.name}" rendered="#{not empty listing.staffMember}"/&gt; Not sure what the difference is with comparing to null.

http://stackoverflow.com/a/16597636
score: 19
has comment: http://stackoverflow.com/comment/80142422
answers question: http://stackoverflow.com/q/397488
has body: Old question, but there is a better answer now (May 2013) - java-REPL! It's available on github and also available live at the java-repl website for quick one-off testing. If you grab the git hub code and run ant to generate the artifacts, you can make it easy to use with a small script like: #!/bin/sh java -jar /home/rdahlgren/scripts/javarepl-dev.build.jar Since finding this project I probably use it 5 times a day. Enjoy!
upvote count: 19
type: Answer
downvote count: 0

http://stackoverflow.com/comment/222045
has text: And how does eclipse format those classes w/ hard-wired formatting? That's what I'm looking for.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/395406

http://stackoverflow.com/a/6697897
has body: boolean canWrite(File file) { if (file.exists()) { return file.canWrite(); } else { try { file.createNewFile(); file.delete(); return true; } catch (Exception e) { return false; } } }
downvote count: 2
upvote count: 3
answers question: http://stackoverflow.com/q/468789
type: Answer
has comment: http://stackoverflow.com/comment/7927198
score: 1

http://stackoverflow.com/comment/274770
type: QuestionComment
comment on: http://stackoverflow.com/q/454498
has text: @PolyThinker: True, I'll drop that specific qualifier for the question.
score: 0
type: Comment

http://stackoverflow.com/q/606582
type: Question
answer count: 2
score: 4
favorite count: 0
has title: Is there a way to make a JComboBox act like an HTML Select?
upvote count: 4
tagged with: jcombobox
downvote count: 0
has body: What I am trying to do mimic an HTML Select tag. I want to display text as an option but when selected, I would use its value. For example, I would have a list of country names. However, when a user selects Japan, I want to get the Locale Code for that country. So the user sees that they selected Japan, but my code will get "ja_JP" or something. I am trying to avoid storing the Country Name and Locale Code in a HashMap or something.
tagged with: swing
has answer: http://stackoverflow.com/a/606614
accepted answer: http://stackoverflow.com/a/606614
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/606617
tagged with: java
has answer: http://stackoverflow.com/a/606617

http://stackoverflow.com/comment/370668
comment on: http://stackoverflow.com/a/559278
type: Comment
has text: I don't know regular expressions, but you deserve +1 for the effort!
score: 0
type: AnswerComment

http://stackoverflow.com/a/585659
upvote count: 90
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/585654
answers question: http://stackoverflow.com/q/585654
has body: Assuming K is your key type and V is your value type: for (Map.Entry&lt;K,V&gt; entry : map.entrySet()) { K key = entry.getKey(); V value = entry.getValue(); // do stuff } This version works with every Java version that supports generic (i.e. Java 5 and up). Java 10 simplified that by letting variable types be inferred using var: for (var entry : map.entrySet()) { var key = entry.getKey(); var value = entry.getValue(); // do stuff } While the previous two options are basically equivalent at the bytecode level, Java 8 also introduced forEach which uses lambdas* and works slightly difference. It invokes the lambda for each entry, which might add some overhead of those calls, if it's not optimized away: map.forEach((k, v) -&gt; { // do stuff }); * technically the BiConsumer can also be implemented using a normal class, but it's intended for and mostly used with lambdas.
type: Answer
score: 90

http://stackoverflow.com/comment/430731
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/617614
has text: There's no point at all in whitespace collapsing your HTML if you are applying HTTP compression - the end result will be so close as to not matter for the size of data across the wire. WS collapsing just adds another pre-deployment step.
score: 0

http://stackoverflow.com/a/1483387
has comment: http://stackoverflow.com/comment/139472829
has body: None, because having an ORM takes too much control away with small benefits. The time savings gained are easily blown away when you have to debug abnormalities resulting from the use of the ORM. Furthermore, ORMs discourage developers from learning SQL and how relational databases work and using this for their benefit.
has comment: http://stackoverflow.com/comment/70794822
has comment: http://stackoverflow.com/comment/130535325
has comment: http://stackoverflow.com/comment/36381678
type: Answer
has comment: http://stackoverflow.com/comment/35846853
has comment: http://stackoverflow.com/comment/1687006
answers question: http://stackoverflow.com/q/452385
has comment: http://stackoverflow.com/comment/2061717
downvote count: 14
score: 113
has comment: http://stackoverflow.com/comment/36229921
upvote count: 127

http://stackoverflow.com/a/75929090
score: 1
upvote count: 1
has body: In Kotlin, you can use format() function. val minutes = 5 val strMinutes = "%02d".format(minutes) where, 2 is the total number of digits you want to display(including zero). Output: 05
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/473282

http://stackoverflow.com/a/987403
answers question: http://stackoverflow.com/q/518527
type: Answer
upvote count: 3
has body: FWIW I'm using olap4j as the Java client against a MSAS server fronted up by msmdpump.dll. Seems so far to work OK.
score: 3
accepted answer of: http://stackoverflow.com/q/518527
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/598440
type: Answer
answers question: http://stackoverflow.com/q/596696
score: 0
has body: I'm not quite sure what you mean, but you probably should remove the priorities you don't want to see from the data model altogether, then they won't be painted at all.

http://stackoverflow.com/comment/53757515
comment on: http://stackoverflow.com/a/624590
has text: It also consider something like `mgarin@.com` as a valid email (tried with version 1.4.1). Or is it actually valid one?
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/381546
score: 10
answer count: 6
has comment: http://stackoverflow.com/comment/108990067
has answer: http://stackoverflow.com/a/71215417
has title: How can I display a byte array as a String in java's debug detail formatter?
accepted answer: http://stackoverflow.com/a/381934
has answer: http://stackoverflow.com/a/381869
downvote count: 0
has comment: http://stackoverflow.com/comment/209231
favorite count: 0
has body: I'd like to write a simple detail formatter that displays byte[] data in the form of a String (using String.&lt;init&gt;([B) to do the dirty work). However, I'm not sure how to find the class name for [B to use when creating the formatter. Is this even possible? Or, alternatively, is there another way to view byte arrays as strings in the debugger?
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/209411
tagged with: java
tagged with: eclipse
upvote count: 10
possible better answer: http://stackoverflow.com/a/381818
type: Question
tagged with: debugging
has answer: http://stackoverflow.com/a/381818
has answer: http://stackoverflow.com/a/381560
has answer: http://stackoverflow.com/a/381934
has answer: http://stackoverflow.com/a/1728559

http://stackoverflow.com/a/560438
upvote count: 1
accepted answer of: http://stackoverflow.com/q/560063
score: 1
type: AcceptedAnswer
downvote count: 0
has body: If your code cannot find the class, then that's always going to be an issue with your classpath (and this isn't specific to JDBC in any way). Make sure you have the MySQL JDBC JAR on your classpath at runtime (it's probably called mysql-connector-java-3.0.17-ga.jar; if you have an IDE, it can probably tell you where the class in question lives).
type: Answer
answers question: http://stackoverflow.com/q/560063

http://stackoverflow.com/comment/419146
type: AnswerComment
comment on: http://stackoverflow.com/a/606852
score: 0
type: Comment
has text: @Lee Theobald: There may be a setting you can pass to the schema factory to tell it where to find imports.

http://stackoverflow.com/a/529421
answers question: http://stackoverflow.com/q/528664
type: Answer
downvote count: 0
has body: Dom4j is a simple api for creating xml documents in java. Document document = DocumentHelper.createDocument(); Element root = document.addElement( "root" ); Element author2 = root.addElement( "author" ) .addAttribute( "name", "Toby" ) .addAttribute( "location", "Germany" ) .addText( "Tobias Rademacher" );
has comment: http://stackoverflow.com/comment/2601325
score: 3
upvote count: 3

http://stackoverflow.com/comment/96443139
has text: @JohnRPerry as the list changes frequently and the ones I like might not suit your needs, it's safe to just google for Java profilers and figure this out on your own. Personally I like working with YourKit for heavy weight profiling and Java Microbenchmark Harness (JMH) for micro-tests.
comment on: http://stackoverflow.com/a/448318
score: 1
type: AnswerComment
type: Comment

http://stackoverflow.com/a/453579
upvote count: 14
score: 14
answers question: http://stackoverflow.com/q/453538
has comment: http://stackoverflow.com/comment/273978
downvote count: 0
has body: Few from UI area: Incorrect ordering of buttons like OK/Cancel Using absolute layouts Different accelerator keys Different sizes/rendering of fonts Expecing certain keys to be present (Windows key, Meta key) (These are not Java specific though)
type: Answer

http://stackoverflow.com/a/593535
upvote count: 3
score: 3
accepted answer of: http://stackoverflow.com/q/593478
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: This is originally specified in Section 15.12.2.7 of the Java Language Specification, as a result of the Java Specification Requests #14. You may also find various discussions on the subject, such as Generics - type inference from context or Type Argument Inference at the Generics FAQ, etc.
answers question: http://stackoverflow.com/q/593478

http://stackoverflow.com/q/377640
accepted answer: http://stackoverflow.com/a/377648
has title: MVC framework for huge Java EE application
tagged with: java-ee-5
has body: Which MVC-framework is the best option (performance/ease of development) for a web application, that will have + 2 million visits per week. Basically the site is a search engine,but also there will be large amounts of XML parsing, and high db traffic. We are using Java, over Jboss 4.2.3x, with PG as DB, and Solr for the searches. We were thinking on code JSPs with taglibs, and Servlets, but we were feeling like there would be a better alternative, which don't know yet, as we are starting on the Java Web applications world. Any opinions, and shares of your experience will be appreciated! Thanks in advance!
favorite count: 0
has answer: http://stackoverflow.com/a/377648
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/634912
score: 3
has answer: http://stackoverflow.com/a/634912
upvote count: 3
tagged with: java
type: Question
answer count: 2
downvote count: 0

http://stackoverflow.com/comment/372093
comment on: http://stackoverflow.com/a/560986
type: AnswerComment
type: Comment
has text: i get 01100101 0x65 below the line (last operation is |, not &)
score: 0

http://stackoverflow.com/comment/214355
score: 0
type: Comment
type: QuestionComment
has text: I second the question from Milhous. Some more details about what you're trying to accomplish would allow people to give you more thorough answers.
comment on: http://stackoverflow.com/q/386695

http://stackoverflow.com/comment/90158115
score: 4
has text: I saying that many will "work" but only one is "right". And you don't need to test for ISO-8859-1 because it will always "work".
type: Comment
comment on: http://stackoverflow.com/a/51573443
type: AnswerComment

http://stackoverflow.com/a/1880450
has body: I had exactly the same thing on an IBM box with 3.24 G of memory: All swing apps would display - but the text (on menus, forms, buttons - everywhere it seems) were blank. The same swing program running on Sun JDK worked no problem. I reduced the Hardware Acceleration from 'Full' to 'None' ( on the Plug and Play Monitor settings off 'advanced' in display) - using an Intel(r) 82865G graphics card. Now swing apps work just fine it seems. Good spot...
type: Answer
answers question: http://stackoverflow.com/q/591291
downvote count: 0
score: 1
upvote count: 1

http://stackoverflow.com/a/574650
score: 2837
has comment: http://stackoverflow.com/comment/122839548
has comment: http://stackoverflow.com/comment/29000111
has comment: http://stackoverflow.com/comment/117162741
accepted answer of: http://stackoverflow.com/q/574594
has comment: http://stackoverflow.com/comment/130017710
has comment: http://stackoverflow.com/comment/38438171
has comment: http://stackoverflow.com/comment/120474848
has comment: http://stackoverflow.com/comment/72519363
has comment: http://stackoverflow.com/comment/89852026
type: Answer
has comment: http://stackoverflow.com/comment/81801298
has comment: http://stackoverflow.com/comment/115218092
has comment: http://stackoverflow.com/comment/125006432
has comment: http://stackoverflow.com/comment/137925977
has comment: http://stackoverflow.com/comment/99213871
has comment: http://stackoverflow.com/comment/84142668
downvote count: 17
has comment: http://stackoverflow.com/comment/92854128
has body: maven-assembly-plugin fully.qualified.MainClass jar-with-dependencies and you run it with mvn clean compile assembly:single Compile goal should be added before assembly:single or otherwise the code on your own project is not included. See more details in comments. Commonly this goal is tied to a build phase to execute automatically. This ensures the JAR is built when executing mvn install or performing a deployment/release. maven-assembly-plugin fully.qualified.MainClass jar-with-dependencies make-assembly package single
has comment: http://stackoverflow.com/comment/135741372
has comment: http://stackoverflow.com/comment/40570999
has comment: http://stackoverflow.com/comment/138519478
answers question: http://stackoverflow.com/q/574594
has comment: http://stackoverflow.com/comment/7204090
has comment: http://stackoverflow.com/comment/97137175
has comment: http://stackoverflow.com/comment/47151842
has comment: http://stackoverflow.com/comment/107827405
has comment: http://stackoverflow.com/comment/93679858
has comment: http://stackoverflow.com/comment/48284596
upvote count: 2854
type: AcceptedAnswer

http://stackoverflow.com/comment/79510370
comment on: http://stackoverflow.com/a/10380512
has text: @LawrenceDol At a theoretical level, I hate saying "never" because there are always exceptions where a banned approach is really best for the situation. However, at a practical level, I really love it because it enforces rules and reduces the amount of decision making many programmers need to make when collaborating on the shared codebase, it makes the overall design consistent, with just the right amount (minimal amount) of exceptions. Thus, it might be more accurate to say: "Always prefer A and only do B if A cannot solve the problem".
score: 4
type: AnswerComment
type: Comment

http://stackoverflow.com/a/397266
upvote count: 1
answers question: http://stackoverflow.com/q/397263
downvote count: 0
has body: Both are OK under different conditions. For example, if you know how to construct b when an object of class Foo is constructed, the first is OK. But if you don't, the only choice is to use the second.
type: Answer
score: 1

http://stackoverflow.com/comment/325641
score: 0
type: Comment
comment on: http://stackoverflow.com/a/511614
has text: Switching to junit has become ever so much easier with junit4 ;)
type: AnswerComment

http://stackoverflow.com/q/364936
has answer: http://stackoverflow.com/a/19465966
downvote count: 2
has answer: http://stackoverflow.com/a/364995
answer count: 7
accepted answer: http://stackoverflow.com/a/365926
tagged with: multiple-inheritance
has answer: http://stackoverflow.com/a/65030776
has answer: http://stackoverflow.com/a/364939
favorite count: 0
has answer: http://stackoverflow.com/a/365034
has answer: http://stackoverflow.com/a/365926
tagged with: input
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/364995
has title: Input and Output Stream Pipe in Java
has body: Does anyone have any good suggestions for creating a Pipe object in Java which is both an InputStream and and OutputStream since Java does not have multiple inheritance and both of the streams are abstract classes instead of interfaces? The underlying need is to have a single object that can be passed to things which need either an InputStream or an OutputStream to pipe output from one thread to input for another.
type: Question
tagged with: java
upvote count: 11
score: 9
has answer: http://stackoverflow.com/a/870625

http://stackoverflow.com/comment/296137
score: 0
has text: I agree with Yann Semet. Sure, it's an interesting piece of trivia, but it tells you nothing about the programmer. Here's a hint: if it appears in Java Puzzlers, it's probably not going to be helpful in the 80% case.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/479120

datetime
tags question: http://stackoverflow.com/q/489538
tags question: http://stackoverflow.com/q/530012
tags question: http://stackoverflow.com/q/453388
tags question: http://stackoverflow.com/q/363930
tags question: http://stackoverflow.com/q/477842
tag name: datetime
tags question: http://stackoverflow.com/q/508019
type: Tag
tags question: http://stackoverflow.com/q/439903
tags question: http://stackoverflow.com/q/386191

http://stackoverflow.com/comment/235860
has text: "Low-church C++" would be a more accurate way of describing it.
comment on: http://stackoverflow.com/a/410968
type: Comment
score: 6
type: AnswerComment

http://stackoverflow.com/comment/363527
comment on: http://stackoverflow.com/a/551849
score: 0
type: AnswerComment
type: Comment
has text: I tried the example and running the class with the main method works fine (in Eclipse).

http://stackoverflow.com/comment/376437
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/565252
has text: Strings do not have color information. Please specify what you are trying to do. Is it a Swing application? Or do you need ANSI-color on a terminal screen?
score: 0

http://stackoverflow.com/a/621230
upvote count: 47
has body: Read the tutorial on Java Web applications. Basically Web applications are a part of the Java EE standard. A lot of people only use the Web (servlets) part with additional frameworks thrown in, most notably Spring but also Struts, Seam and others. All you need is an IDE like IntelliJ, Eclipse or Netbeans, the JDK, the Java EE download and a servlet container like Tomcat (or a full-blown application server like Glassfish or JBoss). Here is a Tomcat tutorial.
accepted answer of: http://stackoverflow.com/q/621228
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/621228
score: 47
has comment: http://stackoverflow.com/comment/434455
has comment: http://stackoverflow.com/comment/434541
type: Answer
has comment: http://stackoverflow.com/comment/434173

http://stackoverflow.com/a/4795955
upvote count: 13
has comment: http://stackoverflow.com/comment/107924267
answers question: http://stackoverflow.com/q/496928
has comment: http://stackoverflow.com/comment/5313770
downvote count: 0
has body: There is yet another difference. If the type (Class) to test against is dynamic, e.g. passed as a method parameter, then instanceof won't cut it for you. boolean test(Class clazz) { return (this instanceof clazz); // clazz cannot be resolved to a type. } but you can do: boolean test(Class clazz) { return (clazz.isAssignableFrom(this.getClass())); // okidoki } Oops, I see this answer is already covered. Maybe this example is helpful to someone.
score: 13
type: Answer

http://stackoverflow.com/q/600733
has answer: http://stackoverflow.com/a/600747
tagged with: string
favorite count: 0
has answer: http://stackoverflow.com/a/600740
has answer: http://stackoverflow.com/a/601948
tagged with: regex
has answer: http://stackoverflow.com/a/601926
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/600745
has answer: http://stackoverflow.com/a/600749
has answer: http://stackoverflow.com/a/600745
accepted answer: http://stackoverflow.com/a/600740
type: Question
tagged with: java
has body: If I have a string like this: FOO[BAR] I need a generic way to get the "BAR" string out of the string so that no matter what string is between the square brackets it would be able to get the string. e.g. FOO[DOG] = DOG FOO[CAT] = CAT
has answer: http://stackoverflow.com/a/8515213
score: 164
answer count: 11
upvote count: 164
has answer: http://stackoverflow.com/a/10202809
has answer: http://stackoverflow.com/a/19640671
has title: Using Java to find substring of a bigger string using Regular Expression
has answer: http://stackoverflow.com/a/57677741
downvote count: 0
has answer: http://stackoverflow.com/a/600746

http://stackoverflow.com/comment/4030513
type: AnswerComment
has text: but it doesn't let you run tests from different packages
type: Comment
comment on: http://stackoverflow.com/a/413289
score: 17

http://stackoverflow.com/q/435640
tagged with: activemq-classic
score: 7
tagged with: java
has answer: http://stackoverflow.com/a/436833
possible better answer: http://stackoverflow.com/a/437115
accepted answer: http://stackoverflow.com/a/436833
upvote count: 7
type: Question
has body: I've set up a queue by configuring it in activemq.xml (ActiveMQ version 5.2.0) as described in the documentation. &lt;destinations&gt; &lt;queue physicalName="FOO.BAR" /&gt; &lt;queue physicalName="DUMMY" /&gt; &lt;/destinations&gt; I'm trying to access it from java (on the same host) with the following code: Hashtable properties = new Hashtable(); properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); properties.put(Context.PROVIDER_URL, "tcp://localhost:61616"); context = new InitialContext(properties); factory = (ConnectionFactory) context.lookup("ConnectionFactory"); connection = factory.createConnection(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); queueName = "DUMMY"; // which can be either FOO.BAR or DUMMY dest = (Destination) context.lookup(queueName); I'm receveing the following error, although the queue is visible in jconsole (Tree / org.apache.activemq / Queue): javax.naming.NameNotFoundException: DUMMY Please tell me what I'm doing wrong. Many, many thanks!
has title: ActiveMQ: Issue with queue lookup
answer count: 2
has answer: http://stackoverflow.com/a/437115
downvote count: 0
tagged with: jms
favorite count: 0
type: AnsweredQuestion

http://stackoverflow.com/comment/459325
comment on: http://stackoverflow.com/a/645886
has text: Yes I had heard that PHP has some of this functionality in it. I also agree that you can quickly knock pages together with PHP - I'm doing this as we speak to make a little prototype. Grails has also been recommended by another poster, I will have to look into it. Thanks alot for your answer :)
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/394279
type: QuestionComment
has text: So do you have a solution that you're going to post if no one gets it?
score: 0
type: Comment
comment on: http://stackoverflow.com/q/582278

yahoo
type: Tag
tag name: yahoo
tags question: http://stackoverflow.com/q/397933

http://stackoverflow.com/q/633964
favorite count: 0
tagged with: dozer
tagged with: http://stackoverflow.com/tag/xml
score: 2
upvote count: 2
type: UnansweredQuestion
has title: Dozer : primitive int -1 value to null object mapping
tagged with: java
type: Question
answer count: 1
downvote count: 0
has answer: http://stackoverflow.com/a/1009631
has body: Is there a way to configure dozer via its xml mapping file to convert a primitive int field value of -1 to a null object reference? The legacy object model defaults the value to -1, so that zero can be a valid selection. The newer object model we are mapping to, assumes that non-selected values will be null, and that any initialized object value is valid. I'm hoping to avoid the need to write a custom converter for this case.

http://stackoverflow.com/a/13548613
answers question: http://stackoverflow.com/q/383551
score: 6
upvote count: 7
downvote count: 1
has comment: http://stackoverflow.com/comment/82433251
has body: I read that Java reserves one byte for a boolean datatype, but it uses only one bit. However, the documentation says that "its "size" isn't something that's precisely defined". See here.
type: Answer

http://stackoverflow.com/a/5601673
downvote count: 0
has comment: http://stackoverflow.com/comment/63428911
score: 3
type: Answer
has body: I refresh the formulas with another tab for this I use the next sentence HSSFSheet worksheetse = workbook.getSheetAt(0); worksheetse.setForceFormulaRecalculation(true); but it's necesary that you apply the method setForceFormulaRecalculation for all the tabs that have the formulas. Sorry for my English
upvote count: 3
has comment: http://stackoverflow.com/comment/18122941
answers question: http://stackoverflow.com/q/521274

http://stackoverflow.com/a/401642
upvote count: 2
answers question: http://stackoverflow.com/q/377593
type: Answer
score: 2
downvote count: 0
has body: 1 - Will this mean that Java Applets that hail from 1990's are dead and not worth going back to? With the update to the Java plug-in - all applets, not just JavaFX-based applets get the improved user experience and performance. That being said - I don't think there are many (if any) killer applets out there. If there were - JavaFX would never have been needed. 2 - Same with Java Desktop: What will be compelling for us Java Developers to use it rather than JavaFX? If you are building GUI applications and want to run it in Java - in particular across multiple platforms (e.g. desktop, applets and mobile) as well as make it easier to work with someone who has actual Photoshop/GIMP skills - JavaFX is your best choice because it was designed explicitly for that type of process. However, remember JavaFX can call Java code and it can also make remote calls (either getting back XML or JSON). I think the most likely integration point will be to use JavaFX for UI and caching of results but all of the heavy coding logic will be on the server. Where it can be written in Java or .NET or assembler if you can get your assembler to emit XML or JSON :).

http://stackoverflow.com/a/55805224
type: Answer
score: 1
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/408042
has comment: http://stackoverflow.com/comment/98288642
has body: The new version of iText is supporting SVG files also. Please refer to this page.

http://stackoverflow.com/a/469368
upvote count: 8
has body: Something like this I think: public class Planets { public static readonly Planet MERCURY = new Planet(3.303e+23, 2.4397e6); public static readonly Planet VENUS = new Planet(4.869e+24, 6.0518e6); public static readonly Planet EARTH = new Planet(5.976e+24, 6.37814e6); public static readonly Planet MARS = new Planet(6.421e+23, 3.3972e6); public static readonly Planet JUPITER = new Planet(1.9e+27, 7.1492e7); public static readonly Planet SATURN = new Planet(5.688e+26, 6.0268e7); public static readonly Planet URANUS = new Planet(8.686e+25, 2.5559e7); public static readonly Planet NEPTUNE = new Planet(1.024e+26, 2.4746e7); public static readonly Planet PLUTO = new Planet(1.27e+22, 1.137e6); } public class Planet { public double Mass {get;private set;} public double Radius {get;private set;} Planet(double mass, double radius) { Mass = mass; Radius = radius; } // universal gravitational constant (m3 kg-1 s-2) private static readonly double G = 6.67300E-11; public double SurfaceGravity() { return G * Mass / (Radius * Radius); } public double SurfaceWeight(double otherMass) { return otherMass * SurfaceGravity(); } } Or combine the constants into the Planet class as above
type: Answer
downvote count: 3
has comment: http://stackoverflow.com/comment/23581867
answers question: http://stackoverflow.com/q/469287
score: 5
has comment: http://stackoverflow.com/comment/287154

http://stackoverflow.com/a/25278401
upvote count: 20
has body: With java 8 streams and collectors it can be done easily: String format(Collection&lt;?&gt; c) { String s = c.stream().map(Object::toString).collect(Collectors.joining(",")); return String.format("[%s]", s); } first we use map with Object::toString to create Collection&lt;String&gt; and then use joining collector to join every item in collection with , as delimiter.
answers question: http://stackoverflow.com/q/395401
type: Answer
has comment: http://stackoverflow.com/comment/41409895
has comment: http://stackoverflow.com/comment/76036560
score: 19
downvote count: 1

http://stackoverflow.com/comment/45414240
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/8753704
has text: Wow, I was so missing this feature in IDEA, but here it is. And they are not even ashamed to name it "Eclipse compiler", hats off :)

http://stackoverflow.com/a/551437
score: 2
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/550024
has body: Perhaps the compression Tomcat is referring to isn't gzip? It's a stab in the dark, but it might relate to white-space compression, or line trimming. I would imagine Tomcat would be a bit more explicit in this regard (here's hoping). We have the gzip filter mentioned by duffmo running in our application, the web.xml looks something like this: <?xml version="1.0" encoding="UTF-8"?> App-Web GZIPFilter weblogicx.servlet.gzip.filter.GZIPFilter [snip]
upvote count: 2
has comment: http://stackoverflow.com/comment/2978813

http://stackoverflow.com/comment/393144
comment on: http://stackoverflow.com/a/581290
has text: Yeah sorry no one was answering the old one :)
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/496875
possible better answer: http://stackoverflow.com/a/496886
accepted answer: http://stackoverflow.com/a/496933
has answer: http://stackoverflow.com/a/496886
type: Question
has answer: http://stackoverflow.com/a/496912
downvote count: 0
has body: I am looking to take a PDF and extract any text from it. I then want to make it available using ColdFusion's available Verity search to search the contents. Are there any libraries out there that do this quite well already? I am including Java or .NET (Java prefered) libraries in the scope since they can be called from CF. Any insights or experiences would be greatly appreciated... thanks! Edit: Indexing PDF files works when the text is embedded in the PDF as far as I know with CF. The PDFs I'm having to deal with have the text scanned as an image.
has title: Performing Optical Character Recognition on PDF's from ColdFusion using a Java or .NET Library?
tagged with: http://stackoverflow.com/tag/pdf
tagged with: ocr
answer count: 4
favorite count: 0
upvote count: 1
has answer: http://stackoverflow.com/a/496993
tagged with: coldfusion
has answer: http://stackoverflow.com/a/496933
type: AnsweredQuestion
score: 1
tagged with: java

http://stackoverflow.com/a/529495
upvote count: 1
has comment: http://stackoverflow.com/comment/342685
answers question: http://stackoverflow.com/q/529474
downvote count: 0
has comment: http://stackoverflow.com/comment/342688
has comment: http://stackoverflow.com/comment/342634
score: 1
has comment: http://stackoverflow.com/comment/342696
has body: The source command (".") is a shell built-in. You have to explicitly run /bin/ksh, passing your script name as the argument (followed by any script arguments). You have a larger problem if you need to source the script. That usually means that environment changes happen in the context of the current shell, not a subshell. This won't work with Java since Java's not a shell. You'll need to figure out how to change the environment with Java. Of course, if I'm wrong and there's more to that script that just setting DISPLAY, it may work as suggested. The method you're going to have to use depends on what you're trying to achieve(as in "Are you running other programs using exec() that rely on DISPLAY being set?" or "Does your Java program need DISPLAY to be set?"). If, as you state in your comment, it's only your Java program that needs DISPLAY set, just set it outside before your program runs. Create a cmd (or bash) file which sets the DISPLAY variable then calls the JRE to run your program. #/bin/ksh export DISPLAY-:0.0 /usr/bin/jre/java your_program blah.blah.blah I would also modify your main() to check that it's set to something and exit gracefully if not: if (System.getenv ("DISPLAY") == null) // doesn't exist, exit gracefully.
type: Answer
has comment: http://stackoverflow.com/comment/342870
has comment: http://stackoverflow.com/comment/342680
has comment: http://stackoverflow.com/comment/342690
has comment: http://stackoverflow.com/comment/342710
has comment: http://stackoverflow.com/comment/342743

http://stackoverflow.com/a/563563
has comment: http://stackoverflow.com/comment/374903
answers question: http://stackoverflow.com/q/563544
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/374888
score: 3
upvote count: 3
has body: I'm not sure about this. But, my guess is that x &gt;&gt;&gt; 1 gets promoted to a int from byte, because the literal "1" is an int. Then what you are observing makes sense.

trace
tag name: trace
type: Tag
tags question: http://stackoverflow.com/q/446023

http://stackoverflow.com/a/369212
type: Answer
upvote count: 25
has comment: http://stackoverflow.com/comment/25841939
downvote count: 1
has comment: http://stackoverflow.com/comment/122486740
answers question: http://stackoverflow.com/q/367706
score: 24
has body: Someone pointed me to args4j lately which is annotation based. I really like it!
has comment: http://stackoverflow.com/comment/71370771
has comment: http://stackoverflow.com/comment/82104760

string
tags question: http://stackoverflow.com/q/492091
tags question: http://stackoverflow.com/q/599161
tags question: http://stackoverflow.com/q/504402
tags question: http://stackoverflow.com/q/542770
tags question: http://stackoverflow.com/q/513832
tags question: http://stackoverflow.com/q/560605
tags question: http://stackoverflow.com/q/390703
tags question: http://stackoverflow.com/q/462348
tags question: http://stackoverflow.com/q/514721
tags question: http://stackoverflow.com/q/379176
tags question: http://stackoverflow.com/q/635807
tags question: http://stackoverflow.com/q/484392
tags question: http://stackoverflow.com/q/537174
tags question: http://stackoverflow.com/q/483348
tags question: http://stackoverflow.com/q/499504
tag name: string
tags question: http://stackoverflow.com/q/531779
tags question: http://stackoverflow.com/q/482925
tags question: http://stackoverflow.com/q/562160
tags question: http://stackoverflow.com/q/513600
tags question: http://stackoverflow.com/q/463950
type: Tag
tags question: http://stackoverflow.com/q/359625
tags question: http://stackoverflow.com/q/388461
tags question: http://stackoverflow.com/q/542226
tags question: http://stackoverflow.com/q/479654
tags question: http://stackoverflow.com/q/465627
tags question: http://stackoverflow.com/q/370004
tags question: http://stackoverflow.com/q/501588
tags question: http://stackoverflow.com/q/520907
tags question: http://stackoverflow.com/q/416500
tags question: http://stackoverflow.com/q/593671
tags question: http://stackoverflow.com/q/601804
tags question: http://stackoverflow.com/q/523871
tags question: http://stackoverflow.com/q/479825
tags question: http://stackoverflow.com/q/600733
tags question: http://stackoverflow.com/q/605891
tags question: http://stackoverflow.com/q/624207
tags question: http://stackoverflow.com/q/370818
tags question: http://stackoverflow.com/q/415996
tags question: http://stackoverflow.com/q/536478
tags question: http://stackoverflow.com/q/463460
tags question: http://stackoverflow.com/q/374405
tags question: http://stackoverflow.com/q/506105
tags question: http://stackoverflow.com/q/637907
tags question: http://stackoverflow.com/q/594604
tags question: http://stackoverflow.com/q/535227

http://stackoverflow.com/a/447857
type: Answer
score: 3
upvote count: 3
downvote count: 0
answers question: http://stackoverflow.com/q/446694
has body: I am developing JSF application with eclipse and maven.It automatically reloaded when a change is made on the program and you save that change.You have to restart when you change any configuration file.

http://stackoverflow.com/comment/270053
type: AnswerComment
has text: I'm making Thing generic because of another method (not listed in my example).
type: Comment
score: 0
comment on: http://stackoverflow.com/a/449115

http://stackoverflow.com/a/422385
answers question: http://stackoverflow.com/q/422181
upvote count: 27
score: 27
downvote count: 0
has body: LinkedHashMap does exactly that, see javadoc for the removeEldestEntry method. Something like this should do the trick, this will remove the oldest inserted entry: Map map = new LinkedHashMap() { @Override protected boolean removeEldestEntry(Entry eldest) { return size() &gt; N; } }; You can also remove oldest accessed entry by specifying it in the constructor: Map map = new LinkedHashMap(16, 0.75f, true) { @Override protected boolean removeEldestEntry(Entry eldest) { return size() &gt; N; } };
type: Answer

http://stackoverflow.com/comment/79729734
has text: No matter what type of app your using (experiment or not), it's just as simple as creating a single Base64.java file in your utils package using the code here: http://migbase64.sourceforge.net/ Look at the performance charts and notice the difference: 4-5 times as fast.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/469695
score: 1

http://stackoverflow.com/a/43724763
has comment: http://stackoverflow.com/comment/98231160
upvote count: 3
has comment: http://stackoverflow.com/comment/98191993
downvote count: 1
has comment: http://stackoverflow.com/comment/98243629
answers question: http://stackoverflow.com/q/381226
type: Answer
score: 2
has body: It is totally possible to monkeypatch in Java, using Unsafe.putObject and a class finder. Wrote a blog post here: https://tersesystems.com/blog/2014/03/02/monkeypatching-java-classes/
has comment: http://stackoverflow.com/comment/98231084

http://stackoverflow.com/comment/397478
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/585650
has text: Do you want to be able to edit the cells, or are you talking about popping up a dialog or making a previously hidden JPanel visible?
score: 0

http://stackoverflow.com/a/609180
type: Answer
answers question: http://stackoverflow.com/q/608915
score: 2
has body: How are you handling the suits of the deck? If you're representing the cards as simple ints, then I assume that the valid values of the cards are 0 - 51. If that's the case, then I guess cards 0 - 12 are all one suit, 13 - 25 are another, etc. Assignment of the suits can be arbitrary until you need to score hands that take it into account. With this arrangement you can detect a pair just as samoz wrote, with a modification to your comparison operation. You'll need to make sure the cards are congruent modulo 13. Just change the line if(hand[i] == hand[j]) to if( (hand[i] % 13) == (hand[j] % 13) ) The modulus operator (%) returns the remainder after division, so 0 % 13 = 0 1 % 13 = 1 2 % 13 = 2 ... 12 % 13 = 12 13 % 13 = 0 14 % 14 = 1 and so on... It allows you to tell when a sequence wraps around a certain value, the modulus, in this case 13, since there are 13 different cards in each of four suits. Let's say, for example, that in your deck of 52 cards numbered 0 - 51 that the cards 0 - 12 represent the Ace through King of clubs, cards 13 - 25 represent the hearts, 26 - 38 represent spades, and 39 - 51 represent diamonds. Now you're dealt the hand: 0, 12, 32, 21, 47 By taking the remainder modulus 13 of each card you're left with 0, 12, 6, 8, 8 You can see that the last two cards are a pair, the 9 of hearts and the 9 of diamonds (remember the numbering starts at 0, so it's off by one).
downvote count: 0
upvote count: 2

http://stackoverflow.com/comment/320544
has text: Refer to my answer below - the correct answer is to use a structure that supports the counting idea from the begining rather than counting entries from start to end each time a query is made.
score: 1
comment on: http://stackoverflow.com/a/505935
type: AnswerComment
type: Comment

directory
tags question: http://stackoverflow.com/q/516798
tag name: directory
type: Tag
tags question: http://stackoverflow.com/q/617414

http://stackoverflow.com/comment/266206
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/444501
has text: Ha, noted. :-) Clover seemed like a good idea as it could contain the license file. We have lots of plugins in the master pom that run all the time (surefire, etc). As we've never needed an easy way to conditionally turn them off, or configure them abnormally, I haven't put them in separate profiles

http://stackoverflow.com/comment/227671
type: Comment
comment on: http://stackoverflow.com/a/402396
has text: For databases, I usually go for wrappers. Yes, because of well-known null.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/269891
type: AnswerComment
comment on: http://stackoverflow.com/a/448904
score: 0
type: Comment
has text: Dude, that worked, can you in a few words explain what i did wrong? Thank you so much :)

http://stackoverflow.com/q/544514
has answer: http://stackoverflow.com/a/544521
accepted answer: http://stackoverflow.com/a/544521
type: Question
has title: Libraries Conflict for Quartz
tagged with: java
has body: have a weird situation. I'm using Glassfish server for my Enterprise application. In that application i'm using JSF, Richfaces, Quartz, Jasper Reports, and Commons Email. When I build and deploy application to my dev. computer, dev and test servers, everything works fine. But when I deploy app to Production server with same glassfish I can't run Quartz scheduler. It's giving me that there is some problem with commons-collections. I know there is a conflict somewhere but I can't find where. Can you give me some pointers where to look. By the way I'm using NetBeans 6.5. Here is the log: [#|2009-02-13T02:00:03.055+0000|WARNING|sun-appserver9.1|javax.enterprise.resource.webcontainer.jsf.lifecycle|_ThreadID=22;_ThreadName=httpSSLWorkerThread-80-4;_RequestID=97d21f45-2489-486c-b8d9-68625776c546;|#{SchedulerController.play}: java.lang.NoSuchMethodError: org.apache.commons.collections.SetUtils.orderedSet(Ljava/util/Set;)Ljava/util/Set; javax.faces.FacesException: #{SchedulerController.play}: java.lang.NoSuchMethodError: org.apache.commons.collections.SetUtils.orderedSet(Ljava/util/Set;)Ljava/util/Set; at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:107) at javax.faces.component.UICommand.broadcast(UICommand.java:383) at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321) at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296) at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253) at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97) at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244) at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411) at org.apache.catalina.c…
tagged with: conflicting-libraries
possible better answer: http://stackoverflow.com/a/1236292
answer count: 3
upvote count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/16938792
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/1236292
downvote count: 0
score: 1
tagged with: quartz-scheduler

http://stackoverflow.com/q/442758
accepted answer: http://stackoverflow.com/a/443351
tagged with: computation
favorite count: 0
tagged with: statistics
possible better answer: http://stackoverflow.com/a/442791
answer count: 5
has answer: http://stackoverflow.com/a/13445467
upvote count: 11
tagged with: probability
score: 11
has answer: http://stackoverflow.com/a/8377936
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/442791
has title: Which java-library computes the cumulative standard normal distribution function?
tagged with: java
type: Question
has body: For a project I have a specification with formulas, I have to implement. In these formulas a cumulative standard normal distribution function exists, that takes a float and outputs a probability. The function is symbolized by a Φ. Exists a Java-library, that computes this function?
has answer: http://stackoverflow.com/a/3112168
has answer: http://stackoverflow.com/a/443351
downvote count: 0

http://stackoverflow.com/a/461284
downvote count: 0
type: Answer
has body: I think a 32 bit JVM has a maximum of 2GB memory.This might be out of date though. If I understood correctly, you set the -Xmx on Eclipse launcher. If you want to increase the memory for the program you run from Eclipse, you should define -Xmx in the "Run->Run configurations..."(select your class and open the Arguments tab put it in the VM arguments area) menu, and NOT on Eclipse startup Edit: details you asked for. in Eclipse 3.4 Run->Run Configurations... if your class is not listed in the list on the left in the "Java Application" subtree, click on "New Launch configuration" in the upper left corner on the right, "Main" tab make sure the project and the class are the right ones select the "Arguments" tab on the right. this one has two text areas. one is for the program arguments that get in to the args[] array supplied to your main method. the other one is for the VM arguments. put into the one with the VM arguments(lower one iirc) the following: -Xmx2048m I think that 1024m should more than enough for what you need though! Click Apply, then Click Run Should work :)
score: 5
answers question: http://stackoverflow.com/q/461260
upvote count: 5

http://stackoverflow.com/a/627822
type: Answer
downvote count: 1
upvote count: 5
has body: The first loop is better. Because the variable something will be clear faster (theoretical) the program is better to read. But from point of memory this is irrelevant. If you have memory problems then you should profile where it is consumed.
has comment: http://stackoverflow.com/comment/74776352
has comment: http://stackoverflow.com/comment/74897803
answers question: http://stackoverflow.com/q/627784
score: 4

http://stackoverflow.com/a/625444
has comment: http://stackoverflow.com/comment/438182
upvote count: 34
has comment: http://stackoverflow.com/comment/438329
has comment: http://stackoverflow.com/comment/438186
has comment: http://stackoverflow.com/comment/438184
score: 29
answers question: http://stackoverflow.com/q/625433
downvote count: 5
has comment: http://stackoverflow.com/comment/438204
has comment: http://stackoverflow.com/comment/438573
has body: Either hand divisions, or use the SimpleDateFormat API. long start = System.currentTimeMillis(); // do your work... long elapsed = System.currentTimeMillis() - start; DateFormat df = new SimpleDateFormat("HH 'hours', mm 'mins,' ss 'seconds'"); df.setTimeZone(TimeZone.getTimeZone("GMT+0")); System.out.println(df.format(new Date(elapsed))); Edit by Bombe: It has been shown in the comments that this approach only works for smaller durations (i.e. less than a day).
type: Answer

http://stackoverflow.com/comment/29147020
type: Comment
type: QuestionComment
has text: To clarify some comments… While Joda-Time continues, its successor [JSR 310: Date and Time API](http://jcp.org/en/jsr/detail?id=310) is indeed scheduled to be part of Java 8 under the [java.time](http://download.java.net/jdk8/docs/api/java/time/package-summary.html) package. Oracle has a draft of a [tutorial](http://docs.oracle.com/javase/tutorial/datetime/index.html). JDBC 4.2 [will handle](http://openjdk.java.net/jeps/170) the new data types.
score: 5
comment on: http://stackoverflow.com/q/589870

http://stackoverflow.com/a/421507
score: 0
type: Answer
upvote count: 1
has body: I think you need a Java thread dump. This should list all threads with what they are doing at the moment. I had a similar problem myself, which a thread dump helped solve (Quartz scheduler threads, which did not exit when Tomcat finished).
downvote count: 1
answers question: http://stackoverflow.com/q/421422

http://stackoverflow.com/a/40079805
upvote count: 6
has comment: http://stackoverflow.com/comment/84295857
has comment: http://stackoverflow.com/comment/84541679
has comment: http://stackoverflow.com/comment/84302017
has comment: http://stackoverflow.com/comment/84546639
has comment: http://stackoverflow.com/comment/84541781
has comment: http://stackoverflow.com/comment/84606569
type: Answer
has comment: http://stackoverflow.com/comment/84547052
downvote count: 0
has comment: http://stackoverflow.com/comment/84525174
has body: The IPAddress Java library supports both IPv4 and IPv6 in a polymorphic manner including subnets. The javadoc is available at the link. Disclaimer: I am the project manager. All the use cases you listed are supported for both IPv4 and Ipv6 transparently. In other words, it differs from most other utilities in the sense that the code below works identically with either IPv4 or IPv6 as the input strings. Verify if an address is valid String str = "::1"; IPAddressString addrString = new IPAddressString(str); try { IPAddress addr = addrString.toAddress(); ... } catch(AddressStringException e) { //e.getMessage provides validation issue } Return if address is contained within a subnet String str = "1::1"; String subnetStr = "1::/64"; IPAddressString addrString = new IPAddressString(str); IPAddressString subnetString = new IPAddressString(subnetStr); try { IPAddress addr = addrString.toAddress(); IPAddress subnet = subnetString.toAddress(); boolean isContained = subnet.contains(addr); //true in this case ... } catch(AddressStringException e) { //e.getMessage provides validation issue } Return the broadcast address for a given subnet String subnetStr = "127.0.0.0/28"; IPAddressString subnetString = new IPAddressString(subnetStr); try { IPAddress subnet = subnetString.toAddress(); IPAddress broadcastAddr = subnet.getUpper(); ... } catch(AddressStringException e) { //e.getMessage provides validation issue } Return a list of addresses for a subnet in order String subnetStr = "127.0.0.0/28"; IPAddressString subnetString = new IPAddressString(subnetStr); try { IPAddress subnet = subnetString.toAddress(); for(IPAddress addr : subnet.getIterable()) { ... } } catch(AddressStringException e) { //e.getMessage provides validation issue } Sort a list of addresses List<IPAddressString> addrs; Collections.sort(addrs); //IPAddressString implements Comparable Get set of subnetted networks and list of addresses (response to AhmedRana): IPAddress subnet = new IPAddressString("192.168.0.0/28"…
score: 6
has comment: http://stackoverflow.com/comment/84642946
has comment: http://stackoverflow.com/comment/84546855
answers question: http://stackoverflow.com/q/558038

http://stackoverflow.com/comment/43280084
comment on: http://stackoverflow.com/a/11327916
has text: This is a very problematic approach! The file may not originate from the system running the code. I strongly discourage these kinds of "system independent" designs that actually depends on a specific system, the runtime system.
score: 24
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/244784
has text: I don't care about the foreign words. However intellectual you want to try to make it, this question has *one* answer per language. Even my mother knows that. It's that one I'm looking for.
comment on: http://stackoverflow.com/a/420419
type: AnswerComment
type: Comment
score: 0

http://stackoverflow.com/q/512877
has answer: http://stackoverflow.com/a/513182
has answer: http://stackoverflow.com/a/512918
has answer: http://stackoverflow.com/a/30358421
has answer: http://stackoverflow.com/a/512884
has answer: http://stackoverflow.com/a/513207
type: Question
has comment: http://stackoverflow.com/comment/326814
has answer: http://stackoverflow.com/a/513390
tagged with: java
has comment: http://stackoverflow.com/comment/50858119
downvote count: 5
has answer: http://stackoverflow.com/a/546494
has answer: http://stackoverflow.com/a/18328276
has answer: http://stackoverflow.com/a/512912
has answer: http://stackoverflow.com/a/547793
has comment: http://stackoverflow.com/comment/326833
has comment: http://stackoverflow.com/comment/9369271
has title: Why can't I define a static method in a Java interface?
has comment: http://stackoverflow.com/comment/326652
has answer: http://stackoverflow.com/a/513001
has answer: http://stackoverflow.com/a/31162902
has comment: http://stackoverflow.com/comment/326539
has answer: http://stackoverflow.com/a/513013
has comment: http://stackoverflow.com/comment/106917701
answer count: 24
has answer: http://stackoverflow.com/a/15809423
favorite count: 0
linked to: http://stackoverflow.com/q/21817
tagged with: static-methods
has comment: http://stackoverflow.com/comment/32999404
has comment: http://stackoverflow.com/comment/114565804
tagged with: java-6
tagged with: interface
has body: NOTE: This question predates Java 8. As of Java 8, static methods are allowed in interfaces. However, they cannot be declared abstract (required to be overridden) in the manner requested by this question. Why can't I define a static method in a Java interface? Here's the example: public interface IXMLizable<T> { static T newInstanceFromXML(Element e); Element toXMLElement(); } This won't work. But why not? One of the possible issues would be, what happens when you call: IXMLizable.newInstanceFromXML(e); In this case, I think it should just call an empty method (i.e. {}). All subclasses would be forced to implement the static method, so they'd all be fine when calling the static method. So why isn't this possible? I guess I'm looking for answer that's deeper than "because that's the way Java is". Is there a particular technological reason why static methods can't be overwritten? That is, why did the designers of Java decide to make instance methods overrideable but not static methods? The problem with my design is I'm trying to use interfaces to enforce a coding convention. That is, the goal of the interface is twofold: I want the IXMLizable interface to allow me to convert classes that implement it to XML elements (using polymorphism works fine). If someone wants to make a new instance of a class that implements the IXMLizable interface, they will always know that there will be a newInstanceFromXML(Element e) static factory method. Is there any other way to ensure this, other than just putting a comment in the interface?
has comment: http://stackoverflow.com/comment/98998748
linked to: http://stackoverflow.com/q/129267
has answer: http://stackoverflow.com/a/32669019
accepted answer: http://stackoverflow.com/a/513001
has answer: http://stackoverflow.com/a/19162187
upvote count: 578
has answer: http://stackoverflow.com/a/512942
score: 573
has answer: http://stackoverflow.com/a/512886
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/37832835
has answer: http://stackoverflow.com/a/6589752
possible better answer: http://stackoverflow.com/a/512987
has answer: http://stackoverflow.com/a/46998522
has answer: http://stackoverflow.com/a/4992095
has answer: http://stackoverflow.com/a/27155104
has answer: http://stackoverflow.com/a/512987

http://stackoverflow.com/a/5854411
type: Answer
upvote count: 1
has body: From Qt Designer docs: The form's top level layout can be set by clearing the selection (click the left mouse button on the form itself) and applying a layout. A top level layout is necessary to ensure that your widgets will re-size correctly when its window is re-sized.
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/541802

http://stackoverflow.com/q/635629
upvote count: 6
has answer: http://stackoverflow.com/a/635694
has answer: http://stackoverflow.com/a/635713
tagged with: generics
favorite count: 0
has comment: http://stackoverflow.com/comment/448852
has answer: http://stackoverflow.com/a/635633
answer count: 5
score: 6
has answer: http://stackoverflow.com/a/635652
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/635668
tagged with: java
accepted answer: http://stackoverflow.com/a/635694
has body: I'd like to implement a method that takes an Object as argument, casts it to an arbitrary type, and if that fails returns null. Here's what I have so far: public static void main(String[] args) { MyClass a, b; a = Main.&lt;MyClass&gt;staticCast(new String("B")); } public static class MyClass { } public static &lt;T&gt; T staticCast(Object arg) { try { if (arg == null) return null; T result = (T) arg; return result; } catch (Throwable e) { return null; } } Unfortunately the class cast exception is never thrown/caught in the body of the staticCast() function. It seems Java compiler generates the function String staticCast(Object arg) in which you have a line String result = (String) arg; even though I explicitly say that the template type should be MyClass. Any help? Thanks.
type: Question
has title: Java generics
possible better answer: http://stackoverflow.com/a/635633
tagged with: casting

http://stackoverflow.com/a/503820
downvote count: 0
upvote count: 3
type: Answer
score: 3
has body: I'm not completely sure I understand the problem, but it sounds like the root issue is that you have many projects, some of which are dependent on others. Some of the projects that are closer to the "leaf" of the dependency tree need to be able to use "stable" (or previously "released") versions of the more "core" projects. I solve exactly this problem using Hudson, ant, and ivy. I follow a pattern demonstrated by Clark in Pragmatic Project Automation (he doesn't demonstrate the dependency problems and solutions, and he uses CruiseControl rather than hudson.) I have a hand-written ant build file (we call it "cc-build.xml", because of our CruiseControl roots.) This file is responsible for refreshing the working space for the project from the CM repository and labeling the contents for future reference. It then hands off control to another hand-written ant build file (build.xml) that is provided by each project's developers. This project is responsible for the traditional build steps (compile, packaging, etc.) It is required to spit out the installable artifacts, unit test reports, etc, to the Hudson artifacts directory. It is my experience that automatically generated build files (by Eclipse or other similar IDE's) will never get close to getting this sufficiently robust for use in a CI scenario. Additionally, it uses ivy to resolve its own dependencies. Ivy supports precisely-specified dependency versions (e.g. "use version 1.1") and it supports "fuzzy versions" (e.g. "use version 1.1+" or "use the latest version in integration status.") Our projects typically start out specifying a very "fuzzy" version for internal projects under ongoing development, and as they get close to a release point, they "freeze" the dependency version so that stuff stops moving underneath them. The non-leaf projects (projects that are dependents for other projects) also use ivy to publish their artifacts to our internal ivy repository. That repository keeps all past builds of the dependen…
answers question: http://stackoverflow.com/q/502776

http://stackoverflow.com/comment/205702
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/377893
has text: Oh and what doc are you looking at! I should know that too!

http://stackoverflow.com/comment/198561
has text: why is this a cw? It's a perfectly valid programming question.
type: Comment
type: QuestionComment
score: 5
comment on: http://stackoverflow.com/q/369512

http://stackoverflow.com/a/438805
type: Answer
accepted answer of: http://stackoverflow.com/q/438508
has body: Short answer: you can't without signing the applet. Long answer: If you could without permissions, you could queue all kind of interesting messages. Your example, paste, or in long form: have access to something the client has copied before, is an action the client needs to know about and authorize. Think about a rouge applet monitoring the clipboard, "pasting" everything and sending it over the wire to a remote server. Your PIN for example. The solution is to sign your applet, thereby telling the client "It is in (your name here) responsibility that this applet is not evil." and asking the user if he/she believes you. If yes, the security manager will no longer block you. If not - well, the user distrusts you, why should the JVM do otherwise? See http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html
score: 0
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/438508

http://stackoverflow.com/comment/404913
comment on: http://stackoverflow.com/a/589069
has text: Okay, I see how you got there, but it still comes down to the 64-bit will perform better on *some* workloads, *worse* on others, and it's a wash on yet others. In other words, "dependent first and foremost on the workload".
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/a/463344
has comment: http://stackoverflow.com/comment/286882
score: 0
has comment: http://stackoverflow.com/comment/6401836
upvote count: 1
has comment: http://stackoverflow.com/comment/6299002
downvote count: 1
has comment: http://stackoverflow.com/comment/299614
has comment: http://stackoverflow.com/comment/281934
type: Answer
answers question: http://stackoverflow.com/q/462696
has body: I assume you have a large file which you are continously appending to. Crashes of the VM do not happen very often. But if they occur, you need a way to roll back the failed changes. You just need a way to know how far to roll back. For example by writing the last file length to a new file: WRITER: lock file write file position to pos-file write file remove pos-file unlock file If the writer crashes one of your readers will get the read lock. They have to check for the pos-file. If they find one a crash occurred. If they look inside the file they know how far to roll back the changes the get a consistent file again. Of course the roll back procedure has to happen in a similar way like the write procedure. When you are not appending but replacing the file, you can use the same method: WRITER: lock file write writing-in-progress-file write file remove writing-in-progress-file unlock file Same rules as previously apply for the reader. When the writing-in-progress-file exists but the reader already acquired the read lock the written file is in a inconsistent state.
has comment: http://stackoverflow.com/comment/284614
has comment: http://stackoverflow.com/comment/298705

http://stackoverflow.com/q/622471
has body: So I'm building the pacman game in Java to teach myself game programming. I have the basic game window with the pacman sprite and the ghost sprites drawn, the pacman moves with the arrow keys, doesn't move beyond the walls of the window, etc. Now I'm trying to build the maze, as in this picture: Without giving me the direct/complete solution to this, can someone guide me as to how this can be built? I'm talking only about the boundaries and the pipes('T' marks) here which you can't go through and you have to go around. Not the dots which the pacman eats yet. Here are my questions: 1) What's the most efficient algorithm/method for creating this maze? Will it have to be drawn each time the paint() method is called or is there a way to draw it only at the start of the game and never again? 2) How will this actually be drawn to the screen? I assume the fillRect() will be used? 3) Any hints on collision detection (so the pacman/ghosts can't go through the walls) would be helpful. 4) Any hints on how the vacant space between the pipes will be calculated so the dots can be filled between them will also be very helpful. Thanks
possible better answer: http://stackoverflow.com/a/622501
tagged with: algorithm
tagged with: java
has title: Pacman maze in Java
has answer: http://stackoverflow.com/a/622500
answer count: 3
favorite count: 0
score: 8
tagged with: maze
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/622501
has answer: http://stackoverflow.com/a/622529
accepted answer: http://stackoverflow.com/a/622500
upvote count: 8
type: Question
tagged with: 2d

http://stackoverflow.com/comment/51656816
comment on: http://stackoverflow.com/a/2154226
type: AnswerComment
score: 0
type: Comment
has text: The filename does not support chinese , I use a static filename ="下载物品", but the downloaded file name comes the mapping url, say xxx.do in springmvc, or mapping path on servlet. How to support chinese file name?

http://stackoverflow.com/a/51616749
upvote count: 11
accepted answer of: http://stackoverflow.com/q/545047
answers question: http://stackoverflow.com/q/545047
has body: Found the answer on https://xebia.com/blog/mapping-multimaps-with-hibernate/ This is a long blog post from 11 years ago. The key code is: public class MultiMapType implements UserCollectionType { public boolean contains(Object collection, Object entity) { return ((MultiMap) collection).containsValue(entity); } public Iterator getElementsIterator(Object collection) { return ((MultiMap) collection).values().iterator(); } public Object indexOf(Object collection, Object entity) { for (Iterator i = ((MultiMap) collection).entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); Collection value = (Collection) entry.getValue(); if (value.contains(entity)) { return entry.getKey(); } } return null; } public Object instantiate() { return new MultiHashMap(); } public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) throws HibernateException { return new PersistentMultiMap(session); } public PersistentCollection wrap(SessionImplementor session, Object collection) { return new PersistentMultiMap(session, (MultiMap) collection); } public Object replaceElements(Object original, Object target, CollectionPersister persister, Object owner, Map copyCache, SessionImplementor session) throws HibernateException { MultiMap result = (MultiMap) target; result.clear(); Iterator iter = ( (java.util.Map) original ).entrySet().iterator(); while ( iter.hasNext() ) { java.util.Map.Entry me = (java.util.Map.Entry) iter.next(); Object key = persister.getIndexType().replace( me.getKey(), null, session, owner, copyCache ); Collection collection = (Collection) me.getValue(); for (Iterator iterator = collection.iterator(); iterator.hasNext();) { Object value = persister.getElementType().replace( iterator.next(), null, session, owner, copyCache ); result.put(key, value); } } return result; } } There was also some talk over here: Multimap in Hibernate
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/96925736
downvote count: 0
type: Answer
score: 11

http://stackoverflow.com/a/588617
downvote count: 0
accepted answer of: http://stackoverflow.com/q/588593
type: Answer
answers question: http://stackoverflow.com/q/588593
has comment: http://stackoverflow.com/comment/400597
has comment: http://stackoverflow.com/comment/400895
score: 9
upvote count: 9
has body: What you want to do for both apps is create a jar file with a Main-class definition in the var manifest. There's a good bit of information on this in the Java Tutorials, but the gist of it is just that you'll create a jar file with the jar tool, and then make a little wrapper to run it as java -jar myfile.jar
type: AcceptedAnswer

http://stackoverflow.com/comment/224163
type: QuestionComment
comment on: http://stackoverflow.com/q/398089
has text: Implementation of JAX-WS for Java, like Axis or XFire somewhat https://metro.dev.java.net/.
score: 0
type: Comment

http://stackoverflow.com/comment/2848746
score: 0
type: Comment
comment on: http://stackoverflow.com/a/537886
type: AnswerComment
has text: +1 for "No shame or offense in admitting that."

http://stackoverflow.com/a/564946
upvote count: 1
answers question: http://stackoverflow.com/q/359683
has body: I suggest you to look at dotFX. It can be useful for you. It has a netbeans plugin,too. Read first here for get more information.
type: Answer
score: 1
downvote count: 0

http://stackoverflow.com/comment/385302
has text: @krisp - That's the point - there's no standard way of doing this. Make a program on the server that listens on port 8080, and whenever someone (a client) connects to 8080, the server finds a free port and sends the information to the client over port 8080.
type: Comment
comment on: http://stackoverflow.com/a/573369
score: 0
type: AnswerComment

http://stackoverflow.com/a/577106
type: AcceptedAnswer
downvote count: 0
upvote count: 30
type: Answer
has comment: http://stackoverflow.com/comment/45224981
has body: As you note, you cannot use JDK dynamic proxies (no interface), but using Spring and CGLIB (JAR included with Spring), you can do the following: public class Foo { public void setBar() { throw new UnsupportedOperationException("should not go here"); } public void redirected() { System.out.println("Yiha"); } } Foo foo = new Foo(); ProxyFactory pf = new ProxyFactory(foo); pf.addAdvice(new MethodInterceptor() { public Object invoke(MethodInvocation mi) throws Throwable { if (mi.getMethod().getName().startsWith("set")) { Method redirect = mi.getThis().getClass().getMethod("redirected"); redirect.invoke(mi.getThis()); } return null; } }); Foo proxy = (Foo) pf.getProxy(); proxy.setBar(); // prints "Yiha"
has comment: http://stackoverflow.com/comment/19430013
score: 30
answers question: http://stackoverflow.com/q/576918
accepted answer of: http://stackoverflow.com/q/576918

http://stackoverflow.com/a/1385610
score: 9
accepted answer of: http://stackoverflow.com/q/369301
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/369301
has comment: http://stackoverflow.com/comment/1235527
type: Answer
upvote count: 9
has comment: http://stackoverflow.com/comment/1236153
has body: The MT4j project has everything you need to develop multitouch applications in java. All the well known multitouch gestures are already built in and can be accessed as simple as listening to mouse events (for example: component.addGestureListener(..)). It also features a hardware accelerated scene graph, similar to JavaFX. You can even simulate multitouch input by connecting one ore more mice to your machine. Check it out at http://www.mt4j.org
has comment: http://stackoverflow.com/comment/26066243

binding
tags question: http://stackoverflow.com/q/460819
tags question: http://stackoverflow.com/q/554816
tags question: http://stackoverflow.com/q/396448
tags question: http://stackoverflow.com/q/593995
tags question: http://stackoverflow.com/q/609833
type: Tag
tags question: http://stackoverflow.com/q/634798
tags question: http://stackoverflow.com/q/501533
tag name: binding
tags question: http://stackoverflow.com/q/510655

http://stackoverflow.com/q/541487
linked to: http://stackoverflow.com/q/107823
has answer: http://stackoverflow.com/a/22190019
has answer: http://stackoverflow.com/a/20136329
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/46513687
has answer: http://stackoverflow.com/a/15474258
accepted answer: http://stackoverflow.com/a/541506
linked to: http://stackoverflow.com/q/1913098
tagged with: java
has answer: http://stackoverflow.com/a/21264101
has comment: http://stackoverflow.com/comment/100781135
has answer: http://stackoverflow.com/a/55971598
has answer: http://stackoverflow.com/a/35378242
has title: "implements Runnable" vs "extends Thread" in Java
has comment: http://stackoverflow.com/comment/6328916
has answer: http://stackoverflow.com/a/19020435
has answer: http://stackoverflow.com/a/12020863
type: Question
has answer: http://stackoverflow.com/a/11364937
has comment: http://stackoverflow.com/comment/52692827
has answer: http://stackoverflow.com/a/541500
has comment: http://stackoverflow.com/comment/6666220
has answer: http://stackoverflow.com/a/541507
linked to: http://stackoverflow.com/q/125333
has answer: http://stackoverflow.com/a/4019116
has answer: http://stackoverflow.com/a/2426408
has answer: http://stackoverflow.com/a/2786210
has answer: http://stackoverflow.com/a/21749501
has answer: http://stackoverflow.com/a/541551
has comment: http://stackoverflow.com/comment/6666348
has answer: http://stackoverflow.com/a/32005221
has answer: http://stackoverflow.com/a/10963798
has answer: http://stackoverflow.com/a/36822629
linked to: http://stackoverflow.com/q/141284
has answer: http://stackoverflow.com/a/46871451
has answer: http://stackoverflow.com/a/24279390
tagged with: java-threads
has comment: http://stackoverflow.com/comment/38848289
has answer: http://stackoverflow.com/a/71092974
has answer: http://stackoverflow.com/a/52135893
has answer: http://stackoverflow.com/a/50030727
has answer: http://stackoverflow.com/a/53624971
has comment: http://stackoverflow.com/comment/5563008
has answer: http://stackoverflow.com/a/9043937
has answer: http://stackoverflow.com/a/541506
has comment: http://stackoverflow.com/comment/65228919
has comment: http://stackoverflow.com/comment/92689361
has answer: http://stackoverflow.com/a/2399784
has comment: http://stackoverflow.com/comment/32236461
tagged with: runnable
has comment: http://stackoverflow.com/comment/650053
has answer: http://stackoverflow.com/a/27750341
upvote count: 2385
has answer: http://stackoverflow.com/a/28599310
favorite count: 0
linked to: http://stackoverflow.com/q/26938210
has answer: http://stackoverflow.com/a/10963921
has answer: http://stackoverflow.com/a/31640214
has answer: http://stackoverflow.com/a/541527
score: 2378
has answer: http://stackoverflow.com/a/25014151
has answer: http://stackoverflow.com/a/16495477
has answer: http://stackoverflow.com/a/43567639
tagged with: implements
linked to: http://stackoverflow.com/q/5562720
tagged with: multithreading
has answer: http://stackoverflow.com/a/11110781
has comment: http://stackoverflow.com/comment/6621713
has answer: http://stackoverflow.com/a/40521742
has body: From what time I've spent with threads in Java, I've found these two ways to write threads: With implements Runnable: public class MyRunnable implements Runnable { public void run() { //Code } } //Started with a "new Thread(new MyRunnable()).start()" call Or, with extends Thread: public class MyThread extends Thread { public MyThread() { super("MyThread"); } public void run() { //Code } } //Started with a "new MyThread().start()" call Is there any significant difference in these two blocks of code?
has answer: http://stackoverflow.com/a/541583
has answer: http://stackoverflow.com/a/17864833
downvote count: 7
answer count: 42
has answer: http://stackoverflow.com/a/30192904
possible better answer: http://stackoverflow.com/a/541527

http://stackoverflow.com/comment/435279
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/622369
has text: Do you want to turn rendered HTML into an image, or the raw HTML code?

http://stackoverflow.com/comment/450247
has text: return fileA.fileID - fileB.fileID;
comment on: http://stackoverflow.com/a/603822
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/61970998
has text: @BeniCherniavsky-Paskin the risk you describe is only because of the similarity between `message` and `msg`. But if he would call it something like `processedMsg` or something else that provides additional context - the chance of a mistake is much lower. Focus on what he says *not* on "how" he says it. ;)
type: AnswerComment
score: 10
comment on: http://stackoverflow.com/a/10380512
type: Comment

http://stackoverflow.com/q/630095
favorite count: 0
upvote count: 8
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2680888
possible better answer: http://stackoverflow.com/a/630125
downvote count: 1
type: Question
tagged with: bugzilla
score: 7
tagged with: java
has answer: http://stackoverflow.com/a/3633273
has answer: http://stackoverflow.com/a/12717163
accepted answer: http://stackoverflow.com/a/12717163
has answer: http://stackoverflow.com/a/5224786
tagged with: xml-rpc
has answer: http://stackoverflow.com/a/630123
has title: Is there a java api to access bugzilla?
has body: Is there a (standalone!) java api which wraps the XML-RPC interface to bugzilla? I don't want to program my own api for it, and I can't actually find a library which does this (and only this). Update: I'm looking for something like this http://oss.dbc.dk/bugzproxy/ only written in Java
tagged with: api
has answer: http://stackoverflow.com/a/630125
answer count: 7
has answer: http://stackoverflow.com/a/14701166

http://stackoverflow.com/comment/227775
score: 4
type: Comment
has text: Here's an academic paper about it: Jeffrey Stylos and Steven Clarke. "Usability Implications of Requiring Parameters in Objects' Constructors". International Conference on Software Engineering (ICSE 2007). http://www.cs.cmu.edu/~NatProg/papers/Stylos2007CreateSetCall.pdf
comment on: http://stackoverflow.com/a/402527
type: AnswerComment

http://stackoverflow.com/comment/456448
has text: consider rembering the actual color that was overwriten in #highlightHyperlink and use the remembered color in #removeHyperlinkHighlight.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/635444

http://stackoverflow.com/a/646905
has comment: http://stackoverflow.com/comment/460215
downvote count: 0
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/646899
has comment: http://stackoverflow.com/comment/460230
has body: What happens if you try: if (((Timerange) Timerange.longest(breaks)).durationInHours() &gt;= MIN_FREE_HOURS) return true; e.g., cast it?

http://stackoverflow.com/a/593872
has body: Go with the repository code you've already got. Do a few performance tests and see if it meets the perf. requirements. If there is a significant perf. issue that can be nailed down to too much DB IO then go for the sproc or implement a bulk export repository.
type: Answer
score: 0
answers question: http://stackoverflow.com/q/581821

http://stackoverflow.com/a/417559
score: 2
answers question: http://stackoverflow.com/q/417517
downvote count: 0
has body: Java can save its program settings in a Preferences, which in turn is stored in a per user location, based upon what settings are used to store and retrieve the values. On windows boxes these preferences are stored in the registry under HKEY_CURRENT_USER/Software/JavaSoft/Prefs There may be a large directory tree under this using the class paths of objects to distinguish the values.
upvote count: 2
type: Answer

http://stackoverflow.com/a/606427
answers question: http://stackoverflow.com/q/606352
type: AcceptedAnswer
type: Answer
has comment: http://stackoverflow.com/comment/26965914
score: 13
has comment: http://stackoverflow.com/comment/64120486
downvote count: 1
has body: Try Simple(Maven) its very easy to embed in a unit test. Take the RoundTripTest and examples such as the PostTest written with Simple. Provides an example of how to embed the server into your test case. Also Simple is much lighter and faster than Jetty, with no dependencies. So you won't have to add several jar files onto your classpath. Nor will you have to be concerned with WEB-INF/web.xml or any other artifacts.
upvote count: 14
accepted answer of: http://stackoverflow.com/q/606352

http://stackoverflow.com/comment/413692
type: Comment
has text: zach's answer doesn't wait for 15 minutes either!
comment on: http://stackoverflow.com/a/601326
type: AnswerComment
score: 0

http://stackoverflow.com/q/410890
has answer: http://stackoverflow.com/a/411171
upvote count: 28
tagged with: nullpointerexception
possible better answer: http://stackoverflow.com/a/412423
has answer: http://stackoverflow.com/a/411073
has answer: http://stackoverflow.com/a/412423
favorite count: 0
has answer: http://stackoverflow.com/a/411598
downvote count: 1
has answer: http://stackoverflow.com/a/411282
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/410902
has comment: http://stackoverflow.com/comment/236063
has answer: http://stackoverflow.com/a/410922
tagged with: java
has answer: http://stackoverflow.com/a/411328
has answer: http://stackoverflow.com/a/410926
has body: If I get a NullPointerException in a call like this: someObject.getSomething().getSomethingElse(). getAnotherThing().getYetAnotherObject().getValue(); I get a rather useless exception text like: Exception in thread "main" java.lang.NullPointerException at package.SomeClass.someMethod(SomeClass.java:12) I find it rather hard to find out which call actually returned null, often finding myself refactoring the code to something like this: Foo ret1 = someObject.getSomething(); Bar ret2 = ret1.getSomethingElse(); Baz ret3 = ret2.getAnotherThing(); Bam ret4 = ret3.getYetAnotherOject(); int ret5 = ret4.getValue(); and then waiting for a more descriptive NullPointerException that tells me which line to look for. Some of you might argue that concatenating getters is bad style and should be avoided anyway, but my Question is: Can I find the bug without changing the code? Hint: I'm using eclipse and I know what a debugger is, but I can't figuer out how to apply it to the problem. My conclusion on the answers: Some answers told me that I should not chain getters one after another, some answers showed my how to debug my code if I disobeyed that advice. I've accepted an answer that taught me exactly when to chain getters: If they cannot return null, chain them as long as you like. No need for checking != null, no need to worry about NullPointerExceptions (be warned that chaining still violates the Law of Demeter, but I can live with that) If they may return null, don't ever, never ever chain them, and perform a check for null values on each one that may return null This makes any good advice on actual debugging useless.
has answer: http://stackoverflow.com/a/410923
type: Question
tagged with: debugging
has title: How to trace a NullPointerException in a chain of getters
accepted answer: http://stackoverflow.com/a/410923
tagged with: getter
score: 27
answer count: 11
has answer: http://stackoverflow.com/a/410925

http://stackoverflow.com/q/440430
has answer: http://stackoverflow.com/a/441162
type: Question
answer count: 8
has body: I have an array of filenames and need to sort that array by the extensions of the filename. Is there an easy way to do this?
score: 5
possible better answer: http://stackoverflow.com/a/440447
has title: Java sort String array of file names by their extension
tagged with: arrays
downvote count: 0
tagged with: sorting
has answer: http://stackoverflow.com/a/440824
favorite count: 0
has answer: http://stackoverflow.com/a/440453
has answer: http://stackoverflow.com/a/440447
has answer: http://stackoverflow.com/a/440455
accepted answer: http://stackoverflow.com/a/440472
tagged with: file
has answer: http://stackoverflow.com/a/440449
has answer: http://stackoverflow.com/a/46800662
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/440472
tagged with: filenames
upvote count: 5
tagged with: java

http://stackoverflow.com/a/471318
score: 13
has body: double i = Double.NaN; NaN is not equal to anything, including itself.
downvote count: 1
answers question: http://stackoverflow.com/q/471296
type: Answer
upvote count: 14

http://stackoverflow.com/q/530441
has answer: http://stackoverflow.com/a/530505
favorite count: 0
has comment: http://stackoverflow.com/comment/343399
has answer: http://stackoverflow.com/a/530479
tagged with: regex
answer count: 4
has answer: http://stackoverflow.com/a/530576
score: 4
type: AnsweredQuestion
tagged with: java
tagged with: regex-negation
has comment: http://stackoverflow.com/comment/343474
possible better answer: http://stackoverflow.com/a/530576
type: Question
has title: How would you use a regular expression to ignore strings that contain a specific substring?
has body: How would I go about using a negative lookbehind(or any other method) regular expression to ignore strings that contains a specific substring? I've read two previous stackoverflow questions: java-regexp-for-file-filtering regex-to-match-against-something-that-is-not-a-specific-substring They are nearly what I want... my problem is the string doesn't end with what I want to ignore. If it did this would not be a problem. I have a feeling this has to do with the fact that lookarounds are zero-width and something is matching on the second pass through the string... but, I'm none too sure of the internals. Anyway, if anyone is willing to take the time and explain it I will greatly appreciate it. Here is an example of an input string that I want to ignore: 192.168.1.10 - - [08/Feb/2009:16:33:54 -0800] "GET /FOO/BAR/ HTTP/1.1" 200 2246 Here is an example of an input string that I want to keep for further evaluation: 192.168.1.10 - - [08/Feb/2009:16:33:54 -0800] "GET /FOO/BAR/content.js HTTP/1.1" 200 2246 The key for me is that I want to ignore any HTTP GET that is going after a document root default page. Following is my little test harness and the best RegEx I've come up with so far. public static void main(String[] args){ String inString = "192.168.1.10 - - [08/Feb/2009:16:33:54 -0800] \"GET /FOO/BAR/ HTTP/1.1\" 200 2246"; //String inString = "192.168.1.10 - - [08/Feb/2009:16:33:54 -0800] \"GET /FOO/BAR/content.js HTTP/1.1\" 200 2246"; //String inString = "192.168.1.10 - - [08/Feb/2009:16:33:54 -0800] \"GET /FOO/BAR/content.js HTTP/"; // This works //String inString = "192.168.1.10 - - [08/Feb/2009:16:33:54 -0800] \"GET /FOO/BAR/ HTTP/"; // This works String inRegEx = "^.*(?:GET).*$(?&lt;!.?/ HTTP/)"; try { Pattern pattern = Pattern.compile(inRegEx); Matcher matcher = pattern.matcher(inString); if (matcher.find()) { System.out.printf("I found the text \"%s\" starting at " + "index %d and ending at index %d.%n", matcher.group(), matcher.start(), matcher.end()); } else { S…
has answer: http://stackoverflow.com/a/530468
upvote count: 4
accepted answer: http://stackoverflow.com/a/530468
downvote count: 0

http://stackoverflow.com/q/542844
tagged with: java
answer count: 2
tagged with: taskbar
tagged with: user-interface
upvote count: 19
favorite count: 0
possible better answer: http://stackoverflow.com/a/7783200
has body: Edit: The question follows the horizontal rule; my own answer precedes it. Based on help from Oscar Reyes, I crafted this solution: import javax.swing.JOptionPane; import javax.swing.JFrame; public class MyApp extends JFrame { public static void main(String [] args) { new MyApp(); } public MyApp() { super("MyApp"); setUndecorated(true); setVisible(true); setLocationRelativeTo(null); String i = JOptionPane.showInputDialog(this, "Enter your name:", getTitle(), JOptionPane.QUESTION_MESSAGE); if(null != i) { JOptionPane.showInputDialog(this, "Your name is:", getTitle(), JOptionPane.INFORMATION_MESSAGE, null, null, i.concat(i)); } dispose(); } } Notice I display my output in a JOptionPane.showInputDialog also. This way the output is highlighted in a text field so I can simply press CTRL+C to copy the output to the system clipboard and them press ESC to dismiss the application. I've created a trivial GUI for my trivial application. My application prompts for a single input with a JOptionPane.showInputDialog, performs a calculation, and then displays a single output with a JOptionPane.showMessageDialog. I sometimes switch to a maximized browser window or something else to copy from, and then want to switch back to my JOptionPane dialog to paste into. I want to have my JOptionPane dialog show up as a task on the taskbar so I could switch to it like nearly any other running program. I prefer JOptionPane's simplicity, rather than having to create a JFrame, a FlowLayout, an Icon, a JTextField, a JButton, an ActionListener, and so on, and so on. Can JOptionPane show up as a task on the taskbar? If so, how do I get it to show up? If not, is there anything else that's a one-liner like JOptionPane.show[whatever]dialog()?
accepted answer: http://stackoverflow.com/a/543012
has comment: http://stackoverflow.com/comment/47729875
tagged with: joptionpane
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/543012
tagged with: swing
score: 19
type: Question
has answer: http://stackoverflow.com/a/7783200
has title: How can I make JOptionPane dialogs show up as a task on the taskbar?

http://stackoverflow.com/comment/83801912
comment on: http://stackoverflow.com/a/589885
score: 0
type: AnswerComment
has text: But someFlag is not static in the initial example.
type: Comment

http://stackoverflow.com/a/958211
type: Answer
answers question: http://stackoverflow.com/q/607863
has body: java.util.logging (jul) was unnecessary from the beginning. Just ignore it. jul in itself has the following downsides: At the time that jul was introduced in Java 1.4 there was already a well established logging framework in wide use: LOG4J the predefined log levels are: SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST. I won't tell you what I personally think about those predefined levels to keep this answer semi-objective. Additional levels can be defined. jul supports up to 4G different log levels which is slightly overkill, IMHO. Less is sometimes more. The most important point: if you dare to define your own log level you are likely to run into a memory leak issue! Feel free to read about this effect here: Classloader leaks: the dreaded "java.lang.OutOfMemoryError: PermGen space" exception How to fix the dreaded "java.lang.OutOfMemoryError: PermGen space" exception (classloader leaks) It's a pretty interesting read even if you are not planning to use custom levels, btw, since the problem is a wide-spread one that doesn't just apply to jul at all. it resides in the java.* namespace so the implementation can't be exchanged at runtime. This effectively prevents bridging it to SLF4J the same way its possible in case of commons.logging and LOG4J. The way bridging is done for jul has a performance impact. This makes jul the most inflexible logging framework out there. By introducing jul, Sun implicitly defined it to be the "standard java logging framework". This led to the common misconception that a "good Java citizen" should use jul in their libraries or applications. The opposite is the case. If you use either commons.logging or LOG4j you'll be able to exchange the actually used logging framework, if you ever need to, by bridging to SLF4J. This means that libraries using either commons.logging, LOG4J or SLF4J can all log to the same logging target, e.g. file. I'd personally suggest to use the SLF4J+Logback combo for all logging purposes. Both projects are coordi…
has comment: http://stackoverflow.com/comment/21129417
upvote count: 48
has comment: http://stackoverflow.com/comment/1649472
has comment: http://stackoverflow.com/comment/1650628
downvote count: 1
score: 47

http://stackoverflow.com/comment/311622
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/486071
score: 1
has text: The 2 apress books you mention have a lot of good code that give examples of using SQLFunction, SQLUpdate, MappingSqlQuery, etc. This is more or less what I was looking for. Cheers.

http://stackoverflow.com/comment/330027
type: AnswerComment
comment on: http://stackoverflow.com/a/515817
score: 0
type: Comment
has text: thanks! I answered from my phone, so iphone so I couldn't copy&paste.

http://stackoverflow.com/q/567525
has answer: http://stackoverflow.com/a/567587
tagged with: java
tagged with: https
type: Question
answer count: 2
downvote count: 0
score: 1
has body: I am connecting to a simple XML over HTTPS web service and getting a security exception. My question is whether you think the cause of this is the cert on the web server, so I should talk to the server admin or if my client code should be handling this. I would love to hear if anyone has encountered and solved this issue. Is the solution found on client side or server side? Below is the exception. Caused by: sun.security.validator.ValidatorException: Violated path length constraints at sun.security.validator.SimpleValidator.checkBasicConstraints(SimpleValidator.java:243) at sun.security.validator.SimpleValidator.checkExtensions(SimpleValidator.java:158) at sun.security.validator.SimpleValidator.engineValidate(SimpleValidator.java:143) at sun.security.validator.Validator.validate(Validator.java:202) at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(DashoA12275) at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(DashoA12275) Thanks for any advice.
has title: Simple Java Web Service client over HTTPS
favorite count: 0
tagged with: http://stackoverflow.com/tag/xml
type: UnansweredQuestion
upvote count: 1
tagged with: web-services
has answer: http://stackoverflow.com/a/567727

http://stackoverflow.com/comment/138718867
type: AnswerComment
has text: A still better approach – mainly if you want to scan recursively all subpackages – is: `final String name = javaFileObject.getName().replace(File.separatorChar, '.'); return Class.forName(name.substring(name.indexOf(pack), name.lastIndexOf(".class")));` Or as slower regex one liner: `return Class.forName(javaFileObject.getName().replace(File.separatorChar, '.').replaceAll(".*("+pack+".*)\\.class.*", "$1"));`
type: Comment
score: 1
comment on: http://stackoverflow.com/a/32828953

http://stackoverflow.com/q/634580
type: Question
has answer: http://stackoverflow.com/a/648861
has answer: http://stackoverflow.com/a/634613
has answer: http://stackoverflow.com/a/11818920
has body: Is there a way to get the current cpu load under Java without using the JNI?
answer count: 6
has title: CPU load from Java
possible better answer: http://stackoverflow.com/a/11818920
tagged with: profiling
accepted answer: http://stackoverflow.com/a/634631
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/634599
type: AnsweredQuestion
upvote count: 19
tagged with: java
has answer: http://stackoverflow.com/a/634631
score: 19
has answer: http://stackoverflow.com/a/634793

http://stackoverflow.com/comment/316288
type: Comment
has text: You don't have to add a try-catch. If a caller isn't able to handle the exception, it should simply declare it and do nothing.
comment on: http://stackoverflow.com/a/499457
type: AnswerComment
score: 0

http://stackoverflow.com/a/578566
answers question: http://stackoverflow.com/q/578537
score: 9
has body: Use Process.waitFor() to have your thread wait for the completion of the batch file's execution. java.lang.Runtime rt = java.lang.Runtime.getRuntime(); Process pr = rt.exec("MyBatch.bat"); pr.waitFor(); You may also want to look at using ProcessBuilder instead of Runtime.getRuntime().exec() if you need access to the console's output and/or input.
type: Answer
upvote count: 9
downvote count: 0

jar
tags question: http://stackoverflow.com/q/618616
tags question: http://stackoverflow.com/q/601088
tags question: http://stackoverflow.com/q/555100
tags question: http://stackoverflow.com/q/419314
tags question: http://stackoverflow.com/q/647116
tags question: http://stackoverflow.com/q/602537
tags question: http://stackoverflow.com/q/542127
tags question: http://stackoverflow.com/q/531353
tags question: http://stackoverflow.com/q/460364
tags question: http://stackoverflow.com/q/458518
tags question: http://stackoverflow.com/q/532459
tags question: http://stackoverflow.com/q/470592
tags question: http://stackoverflow.com/q/615493
tags question: http://stackoverflow.com/q/502960
tags question: http://stackoverflow.com/q/480474
tags question: http://stackoverflow.com/q/592663
type: Tag
tags question: http://stackoverflow.com/q/597098
tags question: http://stackoverflow.com/q/571616
tags question: http://stackoverflow.com/q/600146
tags question: http://stackoverflow.com/q/537596
tags question: http://stackoverflow.com/q/482345
tags question: http://stackoverflow.com/q/463972
tags question: http://stackoverflow.com/q/614790
tag name: jar
tags question: http://stackoverflow.com/q/600907
tags question: http://stackoverflow.com/q/419833
tags question: http://stackoverflow.com/q/634500
tags question: http://stackoverflow.com/q/554654
tags question: http://stackoverflow.com/q/528007
tags question: http://stackoverflow.com/q/403256
tags question: http://stackoverflow.com/q/574351
tags question: http://stackoverflow.com/q/624181
tags question: http://stackoverflow.com/q/603247
tags question: http://stackoverflow.com/q/394616
tags question: http://stackoverflow.com/q/574809
tags question: http://stackoverflow.com/q/475516
tags question: http://stackoverflow.com/q/478788
tags question: http://stackoverflow.com/q/402683
tags question: http://stackoverflow.com/q/380411
tags question: http://stackoverflow.com/q/515428
tags question: http://stackoverflow.com/q/482560
tags question: http://stackoverflow.com/q/625302

http://stackoverflow.com/comment/13311695
comment on: http://stackoverflow.com/a/10326251
type: Comment
has text: The question is how to display an image as Background, not how to load an image from file.
score: 1
type: AnswerComment

http://stackoverflow.com/a/1761472
type: Answer
upvote count: 1
has body: This example shows how you can layer SSL on top of an existing socket, obtaining the client cert from a PKCS#12 file. It is appropriate when you need to connect to an upstream server via a proxy, and you want to handle the full protocol by yourself. Essentially, however, once you have the SSL Context, you can apply it to an HttpsURLConnection, etc, etc. KeyStore ks = KeyStore.getInstance("PKCS12"); InputStream is = ...; char[] ksp = storePassword.toCharArray(); ks.load(is, ksp); KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); char[] kp = keyPassword.toCharArray(); kmf.init(ks, kp); sslContext = SSLContext.getInstance("SSLv3"); sslContext.init(kmf.getKeyManagers(), null, null); SSLSocketFactory factory = sslContext.getSocketFactory(); SSLSocket sslsocket = (SSLSocket) factory.createSocket(socket, socket .getInetAddress().getHostName(), socket.getPort(), true); sslsocket.setUseClientMode(true); sslsocket.setSoTimeout(soTimeout); sslsocket.startHandshake();
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/537040

http://stackoverflow.com/comment/201663
has text: I don't user (or like) Eclipse or Maven, so this isn't a problem. This is a tool problem anyway, so I'd be inclined to fix the tool if I did run into something like this. Useful tip though.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/369389
type: Comment

http://stackoverflow.com/comment/379866
type: Comment
has text: I've written commercially available software for Windows, Mac, Unix (but not Linux), AWT, Swing, etc... You might build applications which run equally well to each other with Java, but IMO they would not run equally well to "real" Windows or Mac or Unix applications (I'm talking about GUI apps).
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/568018

http://stackoverflow.com/a/595331
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/554641
score: 2
upvote count: 2
accepted answer of: http://stackoverflow.com/q/554641
has comment: http://stackoverflow.com/comment/411854
has comment: http://stackoverflow.com/comment/407247
has body: PowerMock is a bit slower at startup since it uses it's own classloader but the time needed also depends on how you write the tests using PowerMock. For instance if you are using the PrepareForTest annotation at the class or method level of your test. If you're using it at the method-level a new classloader is created for each test-method. The time may also depend on the junit fork mode.

http://stackoverflow.com/comment/240245
score: 0
has text: +1 I agree with Bombe. I nearly always use the textbox part as the buttons are usually so small they're difficult to hit, and if I want to enter 20 (or more), I don't want to have to click 19 times! Sometimes the answer is to rethink the approach.. :o)
type: Comment
comment on: http://stackoverflow.com/a/415675
type: AnswerComment

http://stackoverflow.com/comment/110440869
type: AnswerComment
has text: This is probably the smartest answer here. You will always encode and decode EXACTLY as in the front-end, since you're using the same engine. On the other hand performance might suffer slightly since you need to initialize the js engine, but that could be done at startup
type: Comment
score: 1
comment on: http://stackoverflow.com/a/607281

http://stackoverflow.com/q/416947
tagged with: awt
favorite count: 0
upvote count: 5
has answer: http://stackoverflow.com/a/416961
type: AnsweredQuestion
downvote count: 0
tagged with: java
accepted answer: http://stackoverflow.com/a/417012
tagged with: swing
type: Question
has answer: http://stackoverflow.com/a/417012
has body: Whenever I read about Swing they say they are light weight components. So I just googled Swing and found that it means Swing does not depend on native peers. Is that why they are called "light weight"? I mean by light weight I thought maybe the Swing components occupy less memory than the AWT components. Isn't that so?
possible better answer: http://stackoverflow.com/a/416961
has answer: http://stackoverflow.com/a/37895355
answer count: 3
score: 5
has title: Swing components are light-weight?

http://stackoverflow.com/comment/316616
comment on: http://stackoverflow.com/a/501450
type: AnswerComment
score: 0
has text: @litb, yes apparently so. But I wonder why they are not trying to "perform the least possible number of boxing/unboxing conversions".
type: Comment

http://stackoverflow.com/a/401419
answers question: http://stackoverflow.com/q/401415
type: Answer
downvote count: 0
score: 6
upvote count: 6
has body: The cast is effectively trying to do this: ChildN copy = (ChildN) orig.copy(); (It's working out the cast to perform at execution time, but that's what it will be because orig.getClass() will be ChildN.class) However, orig.copy() doesn't return an instance of ChildN, it returns an instance of just Parent, so it can't be cast to ChildN.

http://stackoverflow.com/a/488045
upvote count: 1
has comment: http://stackoverflow.com/comment/304257
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/487932
score: 1
has body: I wouldn't say that I'm an expert in any language but I'm competent in a few. Most of the code I've written recently has been "enterprise"-type stuff. Assuming you're comfortable learning a new API and language, the biggest difference I found is how constrained the iPhone is in terms of CPU performance and available memory. I'm very used to trading off a bit of memory for better performance -- almost unconsciously -- or being a little wasteful because I've got eight cores at my disposal. That's a really bad idea on the iPhone! The other hard thing is making sure that it's iPhone-y. Making a good app is not just a matter of shrinking the GUI down, you really need to think about presenting the data effectively. The technical aspects are all pretty much sorted. The unit test side is less advanced than on the Java side. On the other hand I find that I can be much more productive and less error-prone in Objective C than Java, and this is probably due to the object model which is quite different (you tend to delegate rather than inherit).

http://stackoverflow.com/a/6495000
downvote count: 0
has body: I agree with codehippo; I think that the best way to solve problems with constraints is to use algorithms which are specifically designed to deal with them. The L-BFGS-B algorithm should probably be a good solution in this case. However, if using python's scipy.optimize.fmin_l_bfgs_b module is not a viable option in your case (because you are using Java), you can try using a library I have written: a Java wrapper for the original Fortran code of the L-BFGS-B algorithm. You can download it from http://www.mini.pw.edu.pl/~mkobos/programs/lbfgsb_wrapper and see if it matches your needs.
upvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/540414
score: 2

http://stackoverflow.com/a/403983
answers question: http://stackoverflow.com/q/382361
downvote count: 0
type: Answer
upvote count: 1
has body: I second the iBatis recommendation. At the least, you can pull the SQL out from Java code that most likely uses StringBuffer and appending or String concat into XML where it is just easier to maintain. I did this for a legacy web app and I turned on debugging and ran unit tests for the DAOs and just copied the generated sql for each statement into the iBatis xml. Worked pretty smooth.
score: 1

http://stackoverflow.com/a/4784005
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/627784
has body: "Am I incorrect to say that the bottom loop is better?", the answer is NO, not only is better, in same case is necessary... The variable definition (not the content), is made in Memory heap, and is limited, in the first example, each loop create an instance in this memory, and if the size of "arrayOfStuff" is big, can occur "Out of memory error:java heap space"....
type: Answer
score: 0

http://stackoverflow.com/a/560906
has comment: http://stackoverflow.com/comment/372288
score: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/375681
answers question: http://stackoverflow.com/q/557663
type: Answer
has body: This kinda does what you are after, but it's still not right. For instance, it doesn't handle the case where Foo&lt;T&gt; implements Bar&lt;Map&lt;T&gt;&gt; . What you really need is some way to ask the jvm "ok, here is a list of types. What actual type do I get back if I apply these to this generic type?" But, this code kinda does what you are after. import java.lang.reflect.GenericDeclaration; import java.lang.reflect.ParameterizedType; import java.util.*; interface BaseInterface&lt;T&gt; {} interface FirstArg&lt;T1,T2&gt; extends BaseInterface&lt;T1&gt;{} interface SecondArg&lt;T1,T2&gt; extends BaseInterface&lt;T2&gt;{} class First implements FirstArg&lt;Number, String&gt; {} class Second implements SecondArg&lt;Number, String&gt; {} public class Example { public static void main(String[] av) { new Example().go(); } void go() { test(First.class); test(Second.class); } void test(Class&lt;?&gt; c1) { ParameterizedType t2 = (ParameterizedType) c1.getGenericInterfaces()[0]; System.out.println(c1 + " implements " + t2 ); Class&lt;?&gt; c2 = (Class&lt;?&gt;)t2.getRawType(); GenericDeclaration g2 = (GenericDeclaration) c2; System.out.println(t2 + " params are " + Arrays.asList(g2.getTypeParameters())); System.out.println("So that means"); for(int i = 0; i&lt;t2.getActualTypeArguments().length; i++) { System.out.println("Parameter " + c2.getTypeParameters()[i] + " is " + t2.getActualTypeArguments()[i]); } ParameterizedType t3 = (ParameterizedType) c2.getGenericInterfaces()[0]; System.out.println(t2 + " implements " + t3); System.out.println("and so that means we are talking about\n" + t3.getRawType().toString() + " &lt;"); for(int i = 0 ; i&lt; t3.getActualTypeArguments().length; i++) { System.out.println("\t" + t3.getActualTypeArguments()[i] + " -&gt; " + Arrays.asList(g2.getTypeParameters()).indexOf(t3.getActualTypeArguments()[i]) + " -&gt; " + t2.getActualTypeArguments()[Arrays.asList(g2.getTypeParameters()).indexOf(t3.getActualTypeArguments()[i])] ); } System.out.pr…
upvote count: 1

http://stackoverflow.com/q/448258
has answer: http://stackoverflow.com/a/448763
favorite count: 0
accepted answer: http://stackoverflow.com/a/448272
answer count: 9
tagged with: constructor
has answer: http://stackoverflow.com/a/448809
has answer: http://stackoverflow.com/a/448297
score: 32
upvote count: 32
has comment: http://stackoverflow.com/comment/270640
tagged with: c++
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/271163
has answer: http://stackoverflow.com/a/450060
linked to: http://stackoverflow.com/q/375141
has body: I know that calling a virtual method from a base class constructor can be dangerous since the child class might not be in a valid state. (at least in C#) My question is what if the virtual method is the one who initializes the state of the object ? Is it good practice or should it be a two step process, first to create the object and then to load the state ? First option: (using the constructor to initialize the state) public class BaseObject { public BaseObject(XElement definition) { this.LoadState(definition); } protected abstract LoadState(XElement definition); } Second option: (using a two step process) public class BaseObject { public void LoadState(XElement definition) { this.LoadStateCore(definition); } protected abstract LoadStateCore(XElement definition); } In the first method the consumer of the code can create and initialize the object with one statement: // The base class will call the virtual method to load the state. ChildObject o = new ChildObject(definition) In the second method the consumer will have to create the object and then load the state: ChildObject o = new ChildObject(); o.LoadState(definition);
has answer: http://stackoverflow.com/a/448351
has answer: http://stackoverflow.com/a/448819
tagged with: java
has title: Calling virtual method in base class constructor
type: Question
tagged with: c#
has comment: http://stackoverflow.com/comment/270729
has answer: http://stackoverflow.com/a/448354
has answer: http://stackoverflow.com/a/448272
has comment: http://stackoverflow.com/comment/16450725
has comment: http://stackoverflow.com/comment/270698
possible better answer: http://stackoverflow.com/a/448295
downvote count: 0
has answer: http://stackoverflow.com/a/448295

http://stackoverflow.com/comment/365058
comment on: http://stackoverflow.com/a/552321
type: AnswerComment
score: 0
type: Comment
has text: I guess the teacher wanted a deep copy. What's the best way to make a deep copy in Java?

http://stackoverflow.com/q/609862
has body: Using SWT, what is the common way to indicate that a menu item (from a taskbar menu) is the currently active selection? Checkmark? Bold? How is this done with code?
favorite count: 0
answer count: 3
has answer: http://stackoverflow.com/a/609950
tagged with: menu
possible better answer: http://stackoverflow.com/a/609954
has title: Java SWT: How to indicate a menu item is selected
tagged with: swt
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/609885
score: 4
type: Question
upvote count: 4
has answer: http://stackoverflow.com/a/609954
accepted answer: http://stackoverflow.com/a/609950
downvote count: 0

http://stackoverflow.com/a/29599529
upvote count: 1
answers question: http://stackoverflow.com/q/402247
has body: I have used shorts and bytes in Java apps communicating to custom usb or serial micro-controllers to receive 10bit values wrapped in 2 bytes as shorts.
downvote count: 0
type: Answer
score: 1

http://stackoverflow.com/a/374788
has body: if (myObject != null &amp;&amp; myObject.Id != pId) { myObject.Id = pId; myObject.Order = pOrder; }
answers question: http://stackoverflow.com/q/374770
type: Answer
score: 1
upvote count: 1
downvote count: 0

http://stackoverflow.com/a/6482689
type: Answer
answers question: http://stackoverflow.com/q/369406
score: 0
has body: You might find fast code plug-in pretty useful sometimes.

http://stackoverflow.com/a/490930
downvote count: 0
answers question: http://stackoverflow.com/q/490897
has body: If you make the Folder containing the batch file as a Public Share and then use that address of the batch file like "\ComputerName\ShareName\BatchFile", you can access the batch file. Hope this helps.
type: Answer
upvote count: 1
score: 1

http://stackoverflow.com/comment/196094
has text: Have you tried running the original unadulterated 1.4.2 compiled code on Java 6? You might want to select a particular garbage collector. Also possibly use -d32 to make sure you aren't using too much memory for pointers.
score: 0
type: Comment
comment on: http://stackoverflow.com/q/362500
type: QuestionComment

http://stackoverflow.com/q/454182
has body: I have a Python interface of a graph library written in C - igraph (the name of library). My need is to invoke the python modules pertaining to this graph library from Java code. It goes like this, the core of library is in c. This core has been imported into Python and interfaces to the functions embedded in core are available in Python. My project's rest of the code is in Java and hence I would like to call the graph functions by Java as well. Jython - which lets you invoke python modules with in Java was an option.I went on trying Jython to discover that it will not work in my case as the core code is in C and Jython wont support anything that is imported as a c dll in python code.I also thought of opting for the approach of calling graph routines directly in c. That is without passing through Python code. I am assuming there must be something which lets you call c code from Java, how ever I am not good in C hence I did not go for it. My last resort seems to execute Python interpreter from command line using Java. But that is a dirty and shameless. Also to deal with the results produced by Python code I will have to write the results in a file and read it back in java. Again dirty way. Is there something that any one can suggest me? Thanks to every one giving time. Thanks Igal for answering. I had a look at it. At first glance it appears as if it is simply calling the python script. Jep jep = new Jep(false, SCRIPT_PATH, cl); jep.set("query", query); jep.runScript(SCRIPT_PATH + file); jep.close(); Isnt it very similar to what we would do if called the python interpreter from command line through a Java code. Runtime runtime = Runtime.getRuntime(); Process proc = runtime.exec("python test.py"); Concern is how do I use the results generated by Python script. The naive way is to write them to file and read it back in Java. I am searching for a smarter approach.Thanks for suggestion anyway.
has answer: http://stackoverflow.com/a/2512480
answer count: 3
upvote count: 7
has title: Invoke Python modules from Java
tagged with: java
type: UnansweredQuestion
tagged with: ipc
has answer: http://stackoverflow.com/a/454211
downvote count: 0
score: 7
has answer: http://stackoverflow.com/a/12167871
favorite count: 0
type: Question
tagged with: python

http://stackoverflow.com/q/440786
has title: junit & java : testing non-public methods
has answer: http://stackoverflow.com/a/440902
has answer: http://stackoverflow.com/a/440796
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/441057
has answer: http://stackoverflow.com/a/44222874
has answer: http://stackoverflow.com/a/441076
has answer: http://stackoverflow.com/a/32219256
has answer: http://stackoverflow.com/a/440907
has answer: http://stackoverflow.com/a/3639276
has answer: http://stackoverflow.com/a/440865
tagged with: unit-testing
type: Question
tagged with: testing
has answer: http://stackoverflow.com/a/440792
has answer: http://stackoverflow.com/a/440802
tagged with: java
has answer: http://stackoverflow.com/a/10102174
score: 109
upvote count: 109
has answer: http://stackoverflow.com/a/442066
tagged with: junit
downvote count: 0
has answer: http://stackoverflow.com/a/440803
has answer: http://stackoverflow.com/a/440818
has body: JUnit will only test those methods in my class that are public. How do I do junit testing on the ones that are not (i.e., private, protected)? I can test them by not using junit, but I was wondering what the junit standard method was.
has comment: http://stackoverflow.com/comment/97118429
duplicate of: http://stackoverflow.com/q/34571
answer count: 17
favorite count: 0
has answer: http://stackoverflow.com/a/441043
has answer: http://stackoverflow.com/a/3513268

http://stackoverflow.com/a/606543
answers question: http://stackoverflow.com/q/606325
score: 0
type: Answer
has body: If you're doing this in order to insert some data into an XML packet, you would be much better off using an actual XML API, which will encode these for you.

http://stackoverflow.com/a/440915
has comment: http://stackoverflow.com/comment/63218736
answers question: http://stackoverflow.com/q/436752
downvote count: 0
accepted answer of: http://stackoverflow.com/q/436752
score: 22
upvote count: 22
has body: The complete answer to this question is a combination of all your responses, so I'm going to summarize: There is no need to set cookies="false" in the context.xml file. The ideal functionality is for tomcat to use it's url-based session identification, which will be used by default if cookies are not supported by the user. When a user doesn't have cookies enabled, tomcat will identify the session by the "JSESSIONID" parameter from the url of the request. A couple sample urls are as follows http://www.myurl.com;jsessionid=123456AFGT3 http://www.myurl.com;jsessionid=123456AFGT3?param1=value&amp;param2=value2 Notice how the session id is not part of the url query string (this is a j2ee standard) In order to ensure the jsessionid parameter gets appended to all your request URLs, you can't have plain url references. For example, in JSTL, you have to use &lt; c:url>. The servlet engine will then automatically append the jsessionid to the url if it is necessary. Here's an example: &lt;%--this is bad:--%> &lt; a href="page.html">link&lt; / a> &lt;%--this is good:--%> &lt; a href="&lt; c:url value='page.html'/>">link&lt; / a>
type: AcceptedAnswer
type: Answer

http://stackoverflow.com/a/458301
upvote count: 2
has comment: http://stackoverflow.com/comment/278439
type: Answer
has body: Odd.. you're trying to run an applet (I assume you are talking about a subclass of java.awt.Applet) inside tomcat? Generally this won't work because there's no display on which to display the applet. Assuming you don't want the applet to display anywhere and you just want to execute some portion of it programmatically, you may be able to get by using a virtual X server such as Xvfb or Xvnc. Once you have Xvfb or Xvnc running on your host running tomcat, you might try to set the DISPLAY inside the tomcat startup scripts to use the display of the virtual X server.
score: 2
answers question: http://stackoverflow.com/q/445049
downvote count: 0

http://stackoverflow.com/a/566405
upvote count: 5
downvote count: 0
has body: Invoking javac programatically: http://www.juixe.com/techknow/index.php/2006/12/12/invoke-javac-at-runtime/ com.sun.tools.javac.Main javac = new com.sun.tools.javac.Main(); String[] options = new String[] { "-classpath", classpath, "-d", outputDir, filename }; javac.compile(options);
has comment: http://stackoverflow.com/comment/379852
score: 5
has comment: http://stackoverflow.com/comment/379359
answers question: http://stackoverflow.com/q/566239
type: Answer

http://stackoverflow.com/a/13802864
answers question: http://stackoverflow.com/q/574240
upvote count: 7
downvote count: 1
has body: Synchronized methods can be checked using reflection API. This can be useful for testing some contracts, such as all methods in model are synchronized. The following snippet prints all the synchronized methods of Hashtable: for (Method m : Hashtable.class.getMethods()) { if (Modifier.isSynchronized(m.getModifiers())) { System.out.println(m); } }
type: Answer
score: 6

http://stackoverflow.com/comment/3139621
type: Comment
comment on: http://stackoverflow.com/q/529457
type: QuestionComment
has text: Yes, O(n^log2(7)) is at least possible. It is shown by Strassen and is quite simple to implement. There are better asymptotic times though but they can have unpractical big constants.
score: 0

http://stackoverflow.com/a/2879534
has comment: http://stackoverflow.com/comment/9893359
has comment: http://stackoverflow.com/comment/2943210
score: -18
has comment: http://stackoverflow.com/comment/7891114
answers question: http://stackoverflow.com/q/573621
has comment: http://stackoverflow.com/comment/18008560
has comment: http://stackoverflow.com/comment/2926174
has comment: http://stackoverflow.com/comment/7891884
upvote count: 1
downvote count: 19
has body: No and it should never be present in Java. It's just another bone to throw at people who can't be bothered with good design. Explicit implementation of an interface should never be needed or used. There are better ways to solver the problem that this tries to solve.
has comment: http://stackoverflow.com/comment/10968055
type: Answer
has comment: http://stackoverflow.com/comment/7884651
has comment: http://stackoverflow.com/comment/10968114

http://stackoverflow.com/comment/419448
comment on: http://stackoverflow.com/a/607056
type: AnswerComment
has text: I am offended by your constant, senseless use of smilies.
score: 0
type: Comment

http://stackoverflow.com/comment/132953878
has text: Well, thank you, I'll take your comments into consideration, comparing it to " If you want to try the answer with the most votes above, you can simply use this code:" which is *literally* the initial answer.
comment on: http://stackoverflow.com/a/18554758
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/483980
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/484967
has body: I'd like to be able to call "getProgram" on objects which have that method, without knowing which class they belong to. I know I should use an interface here, but I'm working with someone else's code and can't redesign the classes I'm working with. I thought BeanUtils.getProperty might help me, but it seems it only returns strings. Is there something like Beanutils.getProperty that will return a cast-able object? Or another, smarter way to work with two similar classes that don't share an interface? thanks, -Morgan
has answer: http://stackoverflow.com/a/484024
has answer: http://stackoverflow.com/a/484061
has title: getting a property of a java bean of unknown class
downvote count: 0
answer count: 7
tagged with: javabeans
favorite count: 0
possible better answer: http://stackoverflow.com/a/484108
has answer: http://stackoverflow.com/a/484232
has answer: http://stackoverflow.com/a/484005
has answer: http://stackoverflow.com/a/484138
has answer: http://stackoverflow.com/a/484108
accepted answer: http://stackoverflow.com/a/484138

http://stackoverflow.com/q/446418
tagged with: struts
has body: Here is my problem, I'm bulding a modular aplication, and I'm using the SwitchAction in the struts-config.xml to change to another config file, eht problem is that when I change to the other module, and get back to the default config xml, I'm getting a error, because my page use a AJAX request to get some data from the DB, and I've found out that the prefix that I first send to change the module is getting back and its return the wrong url. following is a example to better undestanding: Page modulos.vm, accessing the new's link, new's link have the prefix "new" so its acessing the page in the "new" module with this URL "/new/new.do", accessing the new.vm without a problem, accessing modulos.vm again, the AJAX function should be "/admin/modulos.do?somedata", but the URL that is returning is "/new/admin/modulos.do", and I dont know what to do, accordling withe the struts documentation "prefix - The module prefix (beginning with "/") of the module to which control should be switched. Use a zero-length string for the default module. The appropriate ModuleConfig object will be stored as a request attribute, so any subsequent logic will assume the new module." So anyone have any idea why AJAX is including the "new" in the URL? or anyone have any idea on how to clear up the relative path or something that may help me? Almost forget to mention I'm using JQuery to call the AJAX function.
score: 0
answer count: 1
has title: Problems with Struts and AJAX
tagged with: ajax
has answer: http://stackoverflow.com/a/446427
type: UnansweredQuestion
tagged with: java
type: Question

http://stackoverflow.com/comment/14631763
has text: This might be useful too: http://stackoverflow.com/questions/4522958/font-rendering-with-glyph-information
comment on: http://stackoverflow.com/q/639243
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/30276810
score: 0
type: AnswerComment
has text: Named capture groups are allowed in Java since 1.7: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html#group(java.lang.String)
type: Comment
comment on: http://stackoverflow.com/a/545348

http://stackoverflow.com/a/440227
answers question: http://stackoverflow.com/q/440160
score: 12
has comment: http://stackoverflow.com/comment/16503016
has comment: http://stackoverflow.com/comment/12756742
upvote count: 12
type: AcceptedAnswer
downvote count: 0
has body: Check out the code in the Java Deployment Toolkit.
has comment: http://stackoverflow.com/comment/1651409
type: Answer
accepted answer of: http://stackoverflow.com/q/440160

http://stackoverflow.com/a/496275
has body: In my opinion, consistency is important for this sort of thing. Properties files and MessageFormat already have lots of limitations. If you find these troubling you could "compile" your properties files to generate properly-formed ones. But I'd say go with using MessageFormat everywhere. This way, as you maintain the code you don't need to worry about which strings are formatted and which aren't. It becomes simpler to deal with, since you can hand off message processing to a library and not worry about the details at a high level.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/495776

http://stackoverflow.com/q/519099
has comment: http://stackoverflow.com/comment/332537
answer count: 6
tagged with: concurrency
has answer: http://stackoverflow.com/a/520026
has title: Unexpected multithreaded result
possible better answer: http://stackoverflow.com/a/519128
type: Question
has answer: http://stackoverflow.com/a/519128
downvote count: 0
accepted answer: http://stackoverflow.com/a/519187
has comment: http://stackoverflow.com/comment/332527
has answer: http://stackoverflow.com/a/519718
favorite count: 0
has answer: http://stackoverflow.com/a/519116
upvote count: 8
score: 8
has comment: http://stackoverflow.com/comment/332589
tagged with: multithreading
has body: I wrote a couple of Java classes—SingleThreadedCompute and MultithreadedCompute—to demonstrate the fact (or what I always thought was a fact!) that if you parallelize a compute-centric (no I/O) task on a single core machine, you don't get a speedup. Indeed my understanding is that parallelizing such tasks actually slows things down because now you have to deal with context-switching overhead. Well, I ran the classes and the parallel version unexpectedly runs faster: the single-threaded version is consistently running at just over 7 seconds on my machine, and the multithreaded version is consistently running at just over 6 seconds on my machine. Can anybody explain how this is possible? Here are the classes if anybody wants to look or try it for themselves. public final class SingleThreadedCompute { private static final long _1B = 1000000000L; // one billion public static void main(String[] args) { long startMs = System.currentTimeMillis(); long total = 0; for (long i = 0; i < _1B; i++) { total += i; } System.out.println("total=" + total); long elapsedMs = System.currentTimeMillis() - startMs; System.out.println("Elapsed time: " + elapsedMs + " ms"); } } Here's the multithreaded version: public final class MultithreadedCompute { private static final long _1B = 1000000000L; // one billion private static final long _100M = _1B / 10L; public static void main(String[] args) { long startMs = System.currentTimeMillis(); System.out.println("Creating workers"); Worker[] workers = new Worker[10]; for (int i = 0; i < 10; i++) { workers[i] = new Worker(i * _100M, (i+1) * _100M); } System.out.println("Starting workers"); for (int i = 0; i < 10; i++) { workers[i].start(); } for (int i = 0; i < 10; i++) { try { workers[i].join(); System.out.println("Joined with thread " + i); } catch (InterruptedException e) { /* can't happen */ } } System.out.println("Summing worker totals"); long total = 0; for (int i = 0; i < 10; i++) { total += workers[i].getTotal(); } System.out.println("tota…
has comment: http://stackoverflow.com/comment/332558
has answer: http://stackoverflow.com/a/519198
has answer: http://stackoverflow.com/a/519187
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/a/614357
answers question: http://stackoverflow.com/q/614227
score: 5
type: Answer
has comment: http://stackoverflow.com/comment/11165556
has body: Not easy to do have a look at OperatingSystemMXBean method getSystemLoadAverage() only available since java 6 you could keep a track of it and if it is the same for a while determine the pc is idle. This assumes idle in terms of idle CPU OperatingSystemMXBean operatingSystemMxBean = ManagementFactory.getOperatingSystemMXBean();
has comment: http://stackoverflow.com/comment/11166293
upvote count: 5
has comment: http://stackoverflow.com/comment/139549226
downvote count: 0

http://stackoverflow.com/q/598796
answer count: 2
upvote count: 1
tagged with: outofrangeexception
accepted answer: http://stackoverflow.com/a/598810
favorite count: 0
has answer: http://stackoverflow.com/a/598810
has answer: http://stackoverflow.com/a/598805
downvote count: 0
possible better answer: http://stackoverflow.com/a/598805
type: Question
type: AnsweredQuestion
has title: Java List with blank allowed
tagged with: list
score: 1
tagged with: java
has body: This is probably really simple but I really could not word it properly on Google. I have an ArrayList that keeps the info for each thread. Each thread has its own ID. So, at the beginning: myList.add(theIdOfTheThread, new InfoForTheThread()); //Add new thread info at index theIdOfTheThread And when I want info: myList.get(myId); //The info for the thread But, I always get OutOfRangeExceptions whenever a lower thread finishes and removes its entry, etc. So, I am sure there must be a better class to use for this, where I can just put entries in at any index I want, and pull them out at any index I want and they stay.

http://stackoverflow.com/comment/5938594
has text: Lucene is not relevant to this problem
comment on: http://stackoverflow.com/a/403221
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/396678
has text: make sure you get/compile a binary with LAME support, as FLV typically uses MP3 for its audio stream
comment on: http://stackoverflow.com/a/502784
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/a/28411462
has comment: http://stackoverflow.com/comment/45186723
has body: If you want to add a single unit of time and you expect that other fields to be incremented as well, you can safely use add method. See example below: SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd"); Calendar cal = Calendar.getInstance(); cal.set(1970,Calendar.DECEMBER,31); System.out.println(simpleDateFormat1.format(cal.getTime())); cal.add(Calendar.DATE, 1); System.out.println(simpleDateFormat1.format(cal.getTime())); cal.add(Calendar.DATE, -1); System.out.println(simpleDateFormat1.format(cal.getTime())); Will Print: 1970-12-31 1971-01-01 1970-12-31
answers question: http://stackoverflow.com/q/428918
downvote count: 0
type: Answer
score: 7
upvote count: 7

http://stackoverflow.com/a/2692261
answers question: http://stackoverflow.com/q/521110
downvote count: 0
score: 7
upvote count: 7
type: Answer
has body: Visual VM - Monitoring and performance analysis tool. (source: java.net) I love the charts it produces

http://stackoverflow.com/comment/359460
type: AnswerComment
score: 0
type: Comment
has text: I wouldn't write this as a one-liner in practice but the fact that you can makes a point about the simplicity... +1
comment on: http://stackoverflow.com/a/547644

http://stackoverflow.com/a/6633680
type: Answer
answers question: http://stackoverflow.com/q/397228
upvote count: 2
score: 0
downvote count: 2
has body: If your expertise is in Java as you say. You should have a look at Play Framework - it's a web framework inspired by Ruby on Rails with a very short development cycle - just save your Java source file and update your web browser. And if you want to try another language, Play Framework has a module that let you use Scala instead. I like Play Framework since it's easy to understand and has good performance. You can also use JPA and Hibernate for the ORM-layer if you want.

http://stackoverflow.com/a/842748
score: 0
has body: XMLEncoder only encodes bean properties, whereas equals can, obviously, work on non-beans and and any internal fields. Part of the problem is that you don't know what equals is actually looking at. An object could have many diffrent fields and still claim it was equal to some other object, it may even be a diffrent type. (for example, a custom URL class might return true for a string that equals it's external form). So I don't think it's possible without bytecode instrumentation where you can actually modify the classes equals() function to see what fields it accesses. Even then, it would still be extreemly difficult to 'truly' know why a function returned false. But hopefully it would be a simple issue of comparing the fields that are actually accessed in equals()
answers question: http://stackoverflow.com/q/636360
type: Answer

http://stackoverflow.com/q/497890
has answer: http://stackoverflow.com/a/535402
possible better answer: http://stackoverflow.com/a/741351
tagged with: java
score: 17
upvote count: 21
has answer: http://stackoverflow.com/a/498700
type: Question
tagged with: lisp
answer count: 6
downvote count: 4
has answer: http://stackoverflow.com/a/499046
has title: Learning Clojure without Java Knowledge
has answer: http://stackoverflow.com/a/497922
has answer: http://stackoverflow.com/a/497906
favorite count: 0
has answer: http://stackoverflow.com/a/741351
tagged with: clojure
has body: Ok, so I'm psyched about another list. I got myself a copy of the beta Clojure programming book... And the one thing I'm noticing most is that it's assumed I know... like all the major java classes. Except, generally, I don't really care about Java. I just want enough knowledge of it for Clojure to be an option for me. Any suggestion as to how to learn just what I need of it all?
accepted answer: http://stackoverflow.com/a/499046
type: AnsweredQuestion

http://stackoverflow.com/comment/234933
has text: (The problem of an_obj being null could have been tackled *then* - but there's no need to conflate the two issues.)
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/409941
type: Comment

http://stackoverflow.com/comment/71662139
has text: Showing test results without documenting the setup, is worthless. That’s especially true in this case, where both code fragments produce identical bytecode, so any measured difference is just a sign of insufficient test conditions.
score: 5
type: AnswerComment
comment on: http://stackoverflow.com/a/407323
type: Comment

http://stackoverflow.com/comment/6754154
comment on: http://stackoverflow.com/a/562400
score: 0
type: AnswerComment
has text: Please add a link, e.g. to a blog post explaining what is missing
type: Comment

http://stackoverflow.com/a/443933
has body: I still think you should consider paying for db4o. If you want something else, add "with an MIT-style license" to the title.
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/265543
downvote count: 0
answers question: http://stackoverflow.com/q/443558
score: 1

http://stackoverflow.com/comment/195818
type: AnswerComment
comment on: http://stackoverflow.com/a/366229
has text: @Zach - you're right, it does...updated it to fix that just in case
score: 0
type: Comment

http://stackoverflow.com/a/463660
answers question: http://stackoverflow.com/q/463240
type: Answer
has body: Although an answer has been accepted, a key problem here is the semantic mismatch between the two languages: assuming you have some sort of stream connection going on, how do you efficiently interchange data? One solution I might recommend is Google Protocol Buffers. It doesn't solve the subprocess/JNI/socket issue, but what it does do is allow you a pretty efficient way to have a complex object structure transit over a stream protocol. Remember: JNI is complicated, particularly for complex object references, but it's efficient. The most important thing is to pass data over that efficient context switch properly. GPB+JNI/Sub-Process Socket allows a single context switch to pull data over, combined with efficient codec support on both sides.
score: 4
upvote count: 4
downvote count: 0

http://stackoverflow.com/a/40805995
upvote count: 3
answers question: http://stackoverflow.com/q/423994
score: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/85168286
type: Answer
has body: I know it's old question still, might help someone. It's possible by using GSON's Field Naming Support eg. @SerializedName("new") private String New; public String getNew () { return New; } public void setNew (String aNew) { New = aNew; }

http://stackoverflow.com/comment/355815
type: AnswerComment
has text: I think SpringLayout is even more verbose. ;) I've used the GroupLayout that comes with LWUIT and it was not too bad, but not easy either. I liked JGoodies FormLayout, and since MiG Layout is its successor, I warmly recommend MiG. Anyways, it's good to know also the basic layouts.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/543793

http://stackoverflow.com/a/17503759
answers question: http://stackoverflow.com/q/549451
has body: LinearLayout row = new LinearLayout(this); //get the size of the screen Display display = getWindowManager().getDefaultDisplay(); this.screenWidth = display.getWidth(); // deprecated for(int i=0; i&lt;this.users.length; i++) { row.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); this.tag_button = new Button(this); this.tag_button.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, 70)); //get the size of the button text Paint mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setTextSize(tag_button.getTextSize()); mPaint.setTypeface(Typeface.create(Typeface.SERIF, Typeface.NORMAL)); float size = mPaint.measureText(tag_button.getText().toString(), 0, tag_button.getText().toString().length()); size = size+28; this.totalTextWidth += size; if(totalTextWidth &lt; screenWidth) { row.addView(tag_button); } else { this.tags.addView(row); row = new LinearLayout(this); row.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); row.addView(tag_button); this.totalTextWidth = size; } }
type: Answer
score: 1
upvote count: 1
downvote count: 0

c#
tags question: http://stackoverflow.com/q/448258
tags question: http://stackoverflow.com/q/469287
tags question: http://stackoverflow.com/q/513028
tags question: http://stackoverflow.com/q/478594
tags question: http://stackoverflow.com/q/483427
tags question: http://stackoverflow.com/q/579729
tags question: http://stackoverflow.com/q/497063
tags question: http://stackoverflow.com/q/439302
tags question: http://stackoverflow.com/q/645533
tags question: http://stackoverflow.com/q/364535
tags question: http://stackoverflow.com/q/563676
tags question: http://stackoverflow.com/q/472596
tags question: http://stackoverflow.com/q/457696
tags question: http://stackoverflow.com/q/521407
tags question: http://stackoverflow.com/q/596043
tags question: http://stackoverflow.com/q/581502
tags question: http://stackoverflow.com/q/370258
tag name: c#
tags question: http://stackoverflow.com/q/607587
tags question: http://stackoverflow.com/q/409563
tags question: http://stackoverflow.com/q/492091
tags question: http://stackoverflow.com/q/592307
tags question: http://stackoverflow.com/q/463155
tags question: http://stackoverflow.com/q/359732
tags question: http://stackoverflow.com/q/616487
tags question: http://stackoverflow.com/q/521305
tags question: http://stackoverflow.com/q/619945
tags question: http://stackoverflow.com/q/623845
tags question: http://stackoverflow.com/q/494389
tags question: http://stackoverflow.com/q/596684
tags question: http://stackoverflow.com/q/541194
tags question: http://stackoverflow.com/q/582493
tags question: http://stackoverflow.com/q/573621
tags question: http://stackoverflow.com/q/571565
tags question: http://stackoverflow.com/q/589169
tags question: http://stackoverflow.com/q/441275
tags question: http://stackoverflow.com/q/574171
tags question: http://stackoverflow.com/q/458537
tags question: http://stackoverflow.com/q/495273
tags question: http://stackoverflow.com/q/626328
tags question: http://stackoverflow.com/q/467762
tags question: http://stackoverflow.com/q/547934
tags question: http://stackoverflow.com/q/492703
tags question: http://stackoverflow.com/q/468198
tags question: http://stackoverflow.com/q/635807
tags question: http://stackoverflow.com/q/463562
tags question: http://stackoverflow.com/q/512124
tags question: http://stackoverflow.com/q/402969
tags question: http://stackoverflow.com/q/491199
tags question: http://stackoverflow.com/q/486815
tags question: http://stackoverflow.com/q/471448
tags question: http://stackoverflow.com/q/555129
tags question: http://stackoverflow.com/q/579833
tags question: http://stackoverflow.com/q/463029
tags question: http://stackoverflow.com/q/374770
tags question: http://stackoverflow.com/q/564699
tags question: http://stackoverflow.com/q/585071
tags question: http://stackoverflow.com/q/536267
tags question: http://stackoverflow.com/q/610962
tags question: http://stackoverflow.com/q/417648
tags question: http://stackoverflow.com/q/553857
tags question: http://stackoverflow.com/q/482955
tags question: http://stackoverflow.com/q/366562
tags question: http://stackoverflow.com/q/363792
tags question: http://stackoverflow.com/q/418056
tags question: http://stackoverflow.com/q/535720
tags question: http://stackoverflow.com/q/525711
tags question: http://stackoverflow.com/q/533076
type: Tag
tags question: http://stackoverflow.com/q/578230
tags question: http://stackoverflow.com/q/466808
tags question: http://stackoverflow.com/q/392324
tags question: http://stackoverflow.com/q/477954
tags question: http://stackoverflow.com/q/460446
tags question: http://stackoverflow.com/q/512651
tags question: http://stackoverflow.com/q/359436
tags question: http://stackoverflow.com/q/392624
tags question: http://stackoverflow.com/q/637291
tags question: http://stackoverflow.com/q/601152
tags question: http://stackoverflow.com/q/533330

http://stackoverflow.com/comment/358859
has text: I would edit the question/title to something like, "What are your experiences with development frameworks and tools for building web applications?" You aren't going to get any firm proof that one is more productive than another - at best you are going to get anecdotal experiences of individuals.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/546874

http://stackoverflow.com/a/525563
has comment: http://stackoverflow.com/comment/338781
downvote count: 0
answers question: http://stackoverflow.com/q/525548
type: Answer
score: 3
upvote count: 3
has comment: http://stackoverflow.com/comment/338854
has body: If you provide a constructor then Java will not generate you a default empty constructor. So your derived class will only be able to call your constructor. The default constructor doesn't initialize your private variables to default values. The proof is that it's possible to write a class that doesn't have a default constructor and has its private members initialized to default values. Here's an example: public class Test { public String s; public int i; public Test(String s, int i) { this.s = s; this.i = i; } public Test(boolean b) { // Empty on purpose! } public String toString() { return "Test (s = " + this.s + ", i = " + this.i + ")"; } public static void main (String [] args) { Test test_empty = new Test(true); Test test_full = new Test("string", 42); System.out.println("Test empty:" + test_empty); System.out.println("Test full:" + test_full); } }
has comment: http://stackoverflow.com/comment/339268

http://stackoverflow.com/a/359768
type: Answer
answers question: http://stackoverflow.com/q/359732
has body: It is a tradeof, shorter code (better readable) versus more secure code (less error prone). My 2 cents: There is a reason for this rule. It has been developed by countless programmers through long working hours, stretching into the night or next morning, trying to fix a bug that was caused by a little oversight. You have t decide for yourself if the tradeof is worth it. In my experience it is, I am one of those countless programmers who was working into the night to find the cause for a nasty bug. The cause was me being lazy.
score: 0
has comment: http://stackoverflow.com/comment/190617
has comment: http://stackoverflow.com/comment/190667

http://stackoverflow.com/comment/50244849
has text: It costs $5,000 per CPU on Tomcat and $15,000 per CPU on WebSphere Application Server, plus $6,000 per developer seat.... $11000 ^#$(@^$@&$$@%# NO THANK YOU.
comment on: http://stackoverflow.com/a/494878
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/431612
has text: "My advice, for your Java coding learn to program like a Java developer rather than a PHP developer." - +1 for this. Sounds like the focus is too much on functions and parameters passed in rather than objects and internal state.
type: AnswerComment
comment on: http://stackoverflow.com/a/618394
score: 0
type: Comment

http://stackoverflow.com/a/367911
answers question: http://stackoverflow.com/q/367905
has comment: http://stackoverflow.com/comment/197090
type: Answer
downvote count: 1
has comment: http://stackoverflow.com/comment/197071
score: -1
has comment: http://stackoverflow.com/comment/197085
has body: The __equalsCal behave as a Cache for the last call to Equals. So, if two calls in the same instance to equals method are invoked with the same parameter the method will be faster EDIT: Sorry this would be true if the __equalsCalc = null; would not be there, but rechecking your code, probably my answer is not valid.
upvote count: 0

http://stackoverflow.com/a/519962
downvote count: 0
score: 3
upvote count: 3
has body: The reason components resize is so stuff looks nice whatever size the window is, so Swing discourages straight X-Y position. You might want to have a look at GroupLayout http://java.sun.com/docs/books/tutorial/uiswing/layout/group.html which is designed for GUI builders, and the page mentioned above describes using invisible components to absorb the stretches. eg:layout.setAutoCreateGaps(true); SpringLayout might also be useful - see the visual guide If you really want X and Y then set the layout manager to null, and use setLocation() or setBounds(). I REALLY REALLY wouldn't recommend this, but it does work. Have a read of this tutorial
type: Answer
answers question: http://stackoverflow.com/q/519918

http://stackoverflow.com/q/512778
tagged with: junit
answer count: 7
has answer: http://stackoverflow.com/a/4946594
score: 44
favorite count: 0
has answer: http://stackoverflow.com/a/512813
upvote count: 44
has body: The JUnit view in Eclipse seems to order the tests randomly. How can I order them by class name?
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/19026843
has answer: http://stackoverflow.com/a/63629082
tagged with: eclipse
has title: Ordering unit tests in Eclipse's JUnit view
type: Question
has answer: http://stackoverflow.com/a/524067
possible better answer: http://stackoverflow.com/a/19026843
downvote count: 0
accepted answer: http://stackoverflow.com/a/524067
has answer: http://stackoverflow.com/a/27891022
has comment: http://stackoverflow.com/comment/402595
has answer: http://stackoverflow.com/a/513392

http://stackoverflow.com/a/620112
answers question: http://stackoverflow.com/q/620041
upvote count: 2
has body: I don't know about hibernate. But I do know that Oracle does treat empty strings as Null values. And there isn't any workaround for it.
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/a/454922
score: 3
answers question: http://stackoverflow.com/q/454908
downvote count: 1
upvote count: 4
has comment: http://stackoverflow.com/comment/275494
has body: The above code doesnt actually do anything visible - it just calcualtes then dumps the calculation. Is it the code you used, or just an example for this question? try doing textAreaDoc.insertString(int, String, AttributeSet) at the end?
type: Answer

http://stackoverflow.com/comment/451298
type: Comment
has text: That depends on the model of your JTree. You can construct a TreePath by specifying the single components that make up the path. Check the documentation.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/637978

http://stackoverflow.com/comment/5094087
comment on: http://stackoverflow.com/a/453554
has text: Yep, you're right, corrected it. Missed the mask in the end. Anyway, there is still useful info there - it is completely not obvious what's the period seed = (seed * multiplier + add) - and the underlying math is completely unexpected. PS: This is my blog, I tend to believe what I write :)
type: AnswerComment
score: 4
type: Comment

http://stackoverflow.com/q/627130
tagged with: java
has answer: http://stackoverflow.com/a/627146
has answer: http://stackoverflow.com/a/627249
has answer: http://stackoverflow.com/a/627161
answer count: 7
tagged with: compareto
downvote count: 0
has title: In Java what should I use for a PriorityQueue that returns the greatest element first?
has body: Java's PriorityQueue places the least element at the head of the list, however I need it to place the greatest element at the head. What what's the neatest way to get a priority queue that behaves like that. Since I wrote the class stored in this queue I could simply reverse the results of compareTo, its not used outside this queue. However I like to make the code an accurate representation of what I'm modeling, what I'm trying to do is get the greatest first so the code should say that rather than least first with an unusual definition of least. [edit]just a quick thank you everyone, Comparator sounds like what I need just as soon as I teach myself how to write one.
score: 2
type: AnsweredQuestion
tagged with: compare
favorite count: 0
has answer: http://stackoverflow.com/a/627148
type: Question
has answer: http://stackoverflow.com/a/627142
upvote count: 2
accepted answer: http://stackoverflow.com/a/627142
has answer: http://stackoverflow.com/a/627151
has answer: http://stackoverflow.com/a/627149
possible better answer: http://stackoverflow.com/a/627151

http://stackoverflow.com/q/588242
has comment: http://stackoverflow.com/comment/400192
has answer: http://stackoverflow.com/a/588260
has answer: http://stackoverflow.com/a/589155
has comment: http://stackoverflow.com/comment/400199
upvote count: 3
score: 1
tagged with: java
has body: How could I write Java code that is executed like javascript code used together with the eval function? What I would like to achieve would be something like this: System.execute ("String str = \"test\"; System.out.println(str);"); which would print the word 'test'. (10x dehmann ) A code sample would help a lot.
has comment: http://stackoverflow.com/comment/43248438
type: Question
has title: How could I call Java code dynamically?
tagged with: eval
has comment: http://stackoverflow.com/comment/400395
has answer: http://stackoverflow.com/a/589190
answer count: 4
linked to: http://stackoverflow.com/q/2605032
favorite count: 0
tagged with: dynamic
has answer: http://stackoverflow.com/a/590255
type: UnansweredQuestion
downvote count: 2

http://stackoverflow.com/comment/266134
score: 0
type: Comment
comment on: http://stackoverflow.com/a/444335
has text: OK. Didn't know about accepting own answer, I thought it's possible.
type: AnswerComment

http://stackoverflow.com/comment/539104
type: Comment
has text: Tried Jalopy per your suggestion. Fantastic product with excellent support from Trimex.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/611524

http://stackoverflow.com/a/371744
score: 3
downvote count: 0
accepted answer of: http://stackoverflow.com/q/371321
upvote count: 3
has body: There's not currently a distinction in the STOMP transport between IP ranges or internal v external IP addresses. Could you use user roles though; having special users &amp; roles for internal connections? Then use the normal access control lists so that external connections can only consume from topics and not publish? See the ActiveMQ Security Support
type: AcceptedAnswer
type: Answer
answers question: http://stackoverflow.com/q/371321

http://stackoverflow.com/a/640204
type: Answer
answers question: http://stackoverflow.com/q/640130
has body: Pagination It's kind of your service design how your pageing ist implemented! PDF is an standalone output format for printing issues. It can't read more data from the server (without Web-Services and Reader Extensions). So you can define, that JasperReports should only a subset of your data for paging. If you define datasets in JasperReports, you can reuse them without allocating unrequired memory. Images If you want images in your reports and keep your memory footprint low, write a balancing algorithm which generates the images when the server load is under a specified value (may be a dynamic value from the avg of the last day load). Do you need real time creation of the images? If the images were created by a servlet, they'll be load to Memory. A Java App. can pass the images to the ReportGenerator. images can be loaded from memory, from disk, or from a URL see; Jasper Reports Book P:170 The images should never be saved in the HTTP_SESSION! This is a total antipattern which causes memory bloating.
score: 3
has comment: http://stackoverflow.com/comment/11141891
downvote count: 0
upvote count: 3

http://stackoverflow.com/a/559720
has body: First off, is your application ending or are you forcibly ending it? If you are forcibly ending it (via the stop button), this Eclipse bug report has details about why this might not be working. Failing that, you may be correct about this being Windows-specific behavior. I'm on a Mac so I can't confirm, sorry. However, I can tell you that the following test program does execute the shutdown hooks as expected. public class MyShutdownHook { public static void main( String[] args ) { System.out.println( "Entering main." ); Runtime.getRuntime().addShutdownHook( new Thread( new Runnable() { public void run() { System.out.println( "Shutdown hook ran." ); } } ) ); System.out.println( "Exiting main." ); } } The Javadocs for Runtime#addShutdownHook do mention that shutdown hooks do not run when the JVM is aborted, not exited normally, so again, you are probably correct in your assumptions. That being said, here are some things to try. Again, sorry I can't confirm these ahead of time -- no Windows here. (Blessedly!) Make sure the JVM does not include the -Xrs option. This has a side-effect on shutdown hooks. Try launching the JVM using either the -server or -client option. It's been my experience that edge-case behavior can be effected by the choice of VM mode. (Especially with regard to threading -- at least on Mac.) Are you launching your app under a profiler or the like? Loading any native libraries? Are you getting some fatal error and missing it? E.g., OutOfMemoryError or the like? Try checking/unchecking the Launch in background option from your application's Run Configuration dialog in Eclipse. Last but not least: Invoke System.exit() manually if you have the opportunity. :)
answers question: http://stackoverflow.com/q/547169
score: 12
downvote count: 0
has comment: http://stackoverflow.com/comment/38571841
type: Answer
upvote count: 12

http://stackoverflow.com/comment/46141383
has text: And not to be confused with Java 8 default interface methods: http://java.dzone.com/articles/interface-default-methods-java
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/588056
score: 2

http://stackoverflow.com/a/387398
downvote count: 0
has body: Most definitely check out their forums, and ask questions. They've been very helpful to me in the past.
answers question: http://stackoverflow.com/q/372755
score: 1
upvote count: 1
type: Answer

http://stackoverflow.com/q/419021
score: 8
favorite count: 0
has title: How does Java's PreparedStatement work?
answer count: 5
has answer: http://stackoverflow.com/a/424745
tagged with: jdbc
has body: I am planning to replace repeatedly executed Statement objects with PreparedStatement objects to improve performance. I am using arguments like the MySQL function now(), and string variables. Most of the PreparedStatement queries I have seen contained constant values (like 10, and strings like "New York") as arguments used for the ? in the queries. How would I go about using functions like now(), and variables as arguments? Is it necessary to use the ?s in the queries instead of actual values? I am quite confounded.
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/243211
accepted answer: http://stackoverflow.com/a/419051
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/20489439
has answer: http://stackoverflow.com/a/419091
tagged with: prepared-statement
upvote count: 8
type: Question
has answer: http://stackoverflow.com/a/419051
possible better answer: http://stackoverflow.com/a/419091
has answer: http://stackoverflow.com/a/432252

http://stackoverflow.com/comment/15955600
score: 0
has text: Do you know that "Picked up..." statement would be printed in Tomcat logs?
type: Comment
comment on: http://stackoverflow.com/a/623036
type: AnswerComment

http://stackoverflow.com/a/584617
type: AcceptedAnswer
has body: I know of none, except few work around, unlike MySQL where we have that facility of IF EXIST. What you do is, try to connect to the database, if couldn't its likely its not there. And after a successful connection, you can do a simple select, like SELECT count(*) FROM TABLE_NAME, to know whether the table exist or not. You would be depending on the exception. Even in an official example from Sun, I have seen the similar work around. In Oracle we have dictionary tables to know about the database objects. I doubt if we have anything like that in Derby. [Edited] Well, I found that there is a way to know if the table exist. Try, SELECT tablename FROM SYSTABLES. It is for checking the existence of a table, for checking database you may need to do similar thing, I explained above.
accepted answer of: http://stackoverflow.com/q/584497
upvote count: 10
type: Answer
answers question: http://stackoverflow.com/q/584497
downvote count: 0
score: 10

http://stackoverflow.com/comment/7739919
comment on: http://stackoverflow.com/a/6565597
has text: You should specify the encoding to be used in `getBytes()`, otherwise your code will get different results on different platforms/user settings.
score: 17
type: AnswerComment
type: Comment

sql
tags question: http://stackoverflow.com/q/642241
tags question: http://stackoverflow.com/q/407688
tags question: http://stackoverflow.com/q/606062
tags question: http://stackoverflow.com/q/448036
tags question: http://stackoverflow.com/q/456532
tags question: http://stackoverflow.com/q/412615
tags question: http://stackoverflow.com/q/458879
tag name: sql
tags question: http://stackoverflow.com/q/387417
type: Tag
tags question: http://stackoverflow.com/q/400881
tags question: http://stackoverflow.com/q/422369
tags question: http://stackoverflow.com/q/644577
tags question: http://stackoverflow.com/q/515278
tags question: http://stackoverflow.com/q/467361
tags question: http://stackoverflow.com/q/497893
tags question: http://stackoverflow.com/q/398992
tags question: http://stackoverflow.com/q/516798
tags question: http://stackoverflow.com/q/382361
tags question: http://stackoverflow.com/q/635630
tags question: http://stackoverflow.com/q/370818
tags question: http://stackoverflow.com/q/554481
tags question: http://stackoverflow.com/q/535135
tags question: http://stackoverflow.com/q/512595
tags question: http://stackoverflow.com/q/370852
tags question: http://stackoverflow.com/q/530012
tags question: http://stackoverflow.com/q/460920
tags question: http://stackoverflow.com/q/521278
tags question: http://stackoverflow.com/q/530972
tags question: http://stackoverflow.com/q/404275
tags question: http://stackoverflow.com/q/643280

http://stackoverflow.com/a/403506
score: 1
has body: Ah fantastic, that was the one Suppressingfire, thanks. I was compiling via command line. I still need to learn about ant. Am used to php, its a lot simpler to start off with!
downvote count: 0
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/403378

http://stackoverflow.com/a/511177
score: 4
has body: How about using swig: http://www.swig.org/Doc1.3/Java.html ?
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/476968
type: Answer

http://stackoverflow.com/q/486964
tagged with: db2
favorite count: 0
tagged with: exception
has answer: http://stackoverflow.com/a/801119
upvote count: 4
has body: Ours is a J2EE app, using Struts-EJB-Hibernate on Websphere 6.1 over Mainframe/DB2 backend, that was recently moved to production. We are getting stale connection exception when the user login to the application first time or some times this exception occurs intermittently. on the second try the user able to log in to the application. The exact error message i am getting is empcom.ibm.websphere.ce.cm.StaleConnectionException: Execution failed due to a distribution protocol error that caused deallocation of the conversation. The command requested could not be completed because of a permanent error condition detected at the target system. DB2ConnectionCorrelator: AC100B80.A260.090107181206 I enabled PRETEST option in webshere settings and gave the interval as 60 sec, but still i am getting this issue.. kindly share your views and help me i can give you more details if you need.
type: UnansweredQuestion
tagged with: web-applications
tagged with: java
tagged with: hibernate
score: 4
has answer: http://stackoverflow.com/a/906553
has title: How to handle stale connections?
type: Question
answer count: 2
downvote count: 0

http://stackoverflow.com/comment/41967347
comment on: http://stackoverflow.com/a/399074
type: AnswerComment
score: 0
type: Comment
has text: @ChrisJester-Young, You stated that "people should find assertions by looking for `AssertionError` as well as `assert`". Where did you get that from? Is there a citation/source or is it merely an assumption? Because the inverse assumption that people/parsers should find assertions by looking for **only** `assert` is an equally-if-not-more valid default stand.

http://stackoverflow.com/comment/63250675
has text: @Alpaslan I hate people following rules of thumb without using their intelligence. Why anyone would imagine that `""` is likely to be any thing other than an empty String, but somehow believes `isEmpty` could not be broken. A developer who is afraid to write any code is afraid of their own shadow and will find one day when they have to write code have no idea what to do.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/531829
type: Comment

http://stackoverflow.com/a/484443
upvote count: 1
has body: It's likely that the connected device doesn't use a text protocol. Many devices use a binary message format that may have text embedded in it, but represents other information with more compact codes. Please edit your question and provide more information, such as the device that you're communicating with through the serial port, and the output that you get from the code you have running. Another helpful output to add would be something that prints a hexadecimal representation of the data you've read. A quick-and-dirty method for that is the following: import java.math.BigInteger; ... System.out.println(new BigInteger(1, readBuffer).toString(16)); I haven't worked with Holux GPS, but I have written a Garmin interface with javax.comm. In that case, the unit uses a proprietary (binary) Garmin protocol by default, but the (text-based) NMEA 0183 protocol can be enabled on the device. Is it possible that you are receiving a proprietary Holux message format, and need to use some command on the GPS unit to switch protocols?
answers question: http://stackoverflow.com/q/484392
downvote count: 0
type: Answer
score: 1

http://stackoverflow.com/q/565535
score: 32
has answer: http://stackoverflow.com/a/75771288
has answer: http://stackoverflow.com/a/565602
has answer: http://stackoverflow.com/a/565656
downvote count: 1
has answer: http://stackoverflow.com/a/73954908
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/14997027
has answer: http://stackoverflow.com/a/565594
linked to: http://stackoverflow.com/q/39031175
has body: We have a URL object in one of our Java classes that we want to mock, but it's a final class so we cannot. We do not want to go a level above, and mock the InputStream because that will still leave us with untested code (we have draconian test coverage standards). I've tried jMockIt's reflective powers but we work on Macs and there are problems with the Java agent handler that I haven't been able to resolve. So are there any solutions that do not involve using real URLs in the junit test?
tagged with: java
has comment: http://stackoverflow.com/comment/377275
has answer: http://stackoverflow.com/a/40073597
has answer: http://stackoverflow.com/a/14388215
possible better answer: http://stackoverflow.com/a/6189871
has answer: http://stackoverflow.com/a/40737274
type: Question
upvote count: 33
tagged with: mocking
has answer: http://stackoverflow.com/a/992781
tagged with: url
has answer: http://stackoverflow.com/a/69456830
has answer: http://stackoverflow.com/a/6189871
answer count: 13
has answer: http://stackoverflow.com/a/565555
accepted answer: http://stackoverflow.com/a/565555
has comment: http://stackoverflow.com/comment/377213
favorite count: 0
has title: Mocking a URL in Java

http://stackoverflow.com/comment/225210
type: Comment
comment on: http://stackoverflow.com/a/399440
score: 5
type: AnswerComment
has text: Unfortunately, the US Treasury is increasing the risk of having long overflow.

http://stackoverflow.com/q/562762
has title: How do I use interact with MySQL using Java?
score: 0
has answer: http://stackoverflow.com/a/562777
possible better answer: http://stackoverflow.com/a/562791
answer count: 4
has answer: http://stackoverflow.com/a/562791
has answer: http://stackoverflow.com/a/562814
has body: I'm assuming I need to use Connector\J and JDBC to achieve this, but I can't seem to 'install' Connector\J using the CLASSPATH thing. How do I do that ? I use the IntelliJ IDE if thats relevant. I'm looking for a way to talk to a mysql database and execute and print out a few basic queries but I'm not getting anywhere because I can't even talk to the database. Any help is appreciated.
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/562888
accepted answer: http://stackoverflow.com/a/562777
tagged with: java
tagged with: mysql
type: Question

http://stackoverflow.com/comment/770634
type: AnswerComment
has text: If you use Ant, consider Ivy.
comment on: http://stackoverflow.com/a/603260
type: Comment
score: 0

http://stackoverflow.com/a/520792
has body: You can also look at DatagramSocket and DatagramPacket. The advantage is lower over-head, the disadvantage is the over-head that regular Socket provides.
has comment: http://stackoverflow.com/comment/334331
answers question: http://stackoverflow.com/q/519850
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/28701888

http://stackoverflow.com/comment/332913
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/519375
has text: As long as you initialize the list at startup, finalize it and dont change it afterward, an ArrayList is fine for multiple threads.
score: 0

http://stackoverflow.com/comment/257615
has text: That was my first thought! WHEN do you know, it's the right time to close a sheet? Does a VBA macro works on it? Then this macro should close the file. Never ever speculate about time a process will take.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/434622
type: AnswerComment

http://stackoverflow.com/a/511948
answers question: http://stackoverflow.com/q/511921
upvote count: 22
has comment: http://stackoverflow.com/comment/325758
has comment: http://stackoverflow.com/comment/328905
score: 22
has body: It's for precision. The double data-type has a 53 bit mantissa. Among other things that means that a double can represent all whole up to 2^53 without precision loss. If you store such a large number in an integer you will get an overflow. Integers only have 32 bits. Returning the integer as a double is the right thing to do here because it offers a much wider usefull number-range than a integer could.
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/325710

cewolf
tag name: cewolf
tags question: http://stackoverflow.com/q/583118
type: Tag

http://stackoverflow.com/q/609762
type: UnansweredQuestion
score: -4
has comment: http://stackoverflow.com/comment/422176
has title: Need sample Java code to run a shellscript
has comment: http://stackoverflow.com/comment/422178
tagged with: java
type: Question
answer count: 2
downvote count: 4
upvote count: 0
tagged with: shell
has body: I tried with many different examples, but it is not working. I would really appreciate some sample Java code to run a shell script.
favorite count: 0
has answer: http://stackoverflow.com/a/14769951
has answer: http://stackoverflow.com/a/609783

http://stackoverflow.com/a/488184
has comment: http://stackoverflow.com/comment/307394
score: 0
has body: "I'm unsure where to draw the line between the business/service layer class and the DAO." Aren't we all? I suggest using an ORM (iBatis, Hibernate, Toplink, etc.). Don't implement your own DAO's.
type: Answer
answers question: http://stackoverflow.com/q/487857
has comment: http://stackoverflow.com/comment/306020
has comment: http://stackoverflow.com/comment/304358

localization
tags question: http://stackoverflow.com/q/617663
type: Tag
tag name: localization
tags question: http://stackoverflow.com/q/495776

http://stackoverflow.com/comment/139394729
score: 0
has text: The real problem is the misnaming. *Index* traditionally indicates zero-based counting, while the word [*ordinal*](https://en.wiktionary.org/wiki/ordinal#English) means 1-based counting. The [`PreparedStatement`](https://docs.oracle.com/en/java/javase/23/docs/api/java.sql/java/sql/PreparedStatement.html) documentation should have used `parameterOrdinal` or `parameterPosition` rather than `parameterIndex`.
comment on: http://stackoverflow.com/q/616135
type: Comment
type: QuestionComment

http://stackoverflow.com/a/457645
score: 3
upvote count: 5
type: Answer
has comment: http://stackoverflow.com/comment/277187
downvote count: 2
has comment: http://stackoverflow.com/comment/277156
has body: All possible solutions will be a kludge (like container objects, your HashMap idea, “multiple return values” as realized via arrays). I recommend regenerating the comma-separated list from the returned List. The code will end up being a lot cleaner.
answers question: http://stackoverflow.com/q/457629
has comment: http://stackoverflow.com/comment/277164

http://stackoverflow.com/comment/309436
type: Comment
comment on: http://stackoverflow.com/a/493385
type: AnswerComment
has text: Thanks rmeador. A lot of our developers do run Linux, and it does help. Its file system cache seems to be much better than Windows'. There's also some suspicion that Microsoft has deliberately hobbled performance of kernel calls by non-M$ code. ;) However, even Linux builds are too slow.
score: 0

http://stackoverflow.com/a/60448158
type: Answer
answers question: http://stackoverflow.com/q/610458
has body: It's pretty old topic but still up-to-date and surprisingly bringing higher impact nowadays. As Jon mentioned, it might be just a mistake Java's designers made at the very beginning. But I wouldn't imagine before it can have impact on security. Many coders know Apache Velocity, flexible and powerful template engine. It's so powerful that it allows to feed template with a set of named objects - stricly considered as objects from programming language (Java originally). Those objects can be accessed from within template like in programming language so for example Java's String instance can be used with all its public fields, properties and methods $input.isEmpty() where input is a String, runs directly through JVM and returns true or false to Velocity parser's output). So far so good. But in Java all objects inherit from Object so our end-users can also put this to the template $input.getClass() to get an instance of String Class. And with this reference they can also call a static method forName(String) on this $input.getClass().forName("java.io.FileDescriptor") use any class name and use it to whatever web server's account can do (deface, steal DB content, inspect config files, ...) This exploit is somehow (in specific context) described here: https://github.com/veracode-research/solr-injection#7-cve-2019-17558-rce-via-velocity-template-by-_s00py It wouldn't be possible if calling static methods from reference to the instance of class was prohibited. I'm not saying that a particular programming framework is better than the other one or so but I just want to put a comparison. There's a port of Apache Velocity for .NET. In C# it's not possible to call static methods just from instance's reference what makes exploit like this useless: $input.GetType().GetType("System.IO.FileStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
score: 0

http://stackoverflow.com/comment/58581571
type: Comment
comment on: http://stackoverflow.com/a/523625
type: AnswerComment
has text: I think this is the new URL for that page http://ant.apache.org/manual/Tasks/parallel.html
score: 0

http://stackoverflow.com/comment/372073
score: 0
comment on: http://stackoverflow.com/a/560965
type: Comment
has text: Both are arrays os bytes I tried the suggestion from Timbo, and its fubared when changed :-/
type: AnswerComment

http://stackoverflow.com/comment/445933
score: 2
comment on: http://stackoverflow.com/a/632917
type: AnswerComment
has text: Calendar actually has a getTimeInMillis() method that is a little more direct than getTime().getTime(). +1 anyway.
type: Comment

http://stackoverflow.com/comment/317983
comment on: http://stackoverflow.com/q/497552
type: Comment
type: QuestionComment
score: 0
has text: Thanks for your responses. As soon as I can test the different answers you have given me I'll close the answer with the one that resolves the issue. One week, tops

http://stackoverflow.com/q/616796
tagged with: factory-pattern
possible better answer: http://stackoverflow.com/a/616877
has answer: http://stackoverflow.com/a/70052918
has title: What is the difference between Factory and Strategy patterns?
has answer: http://stackoverflow.com/a/616893
favorite count: 0
has answer: http://stackoverflow.com/a/616877
has answer: http://stackoverflow.com/a/616975
has answer: http://stackoverflow.com/a/70601164
has answer: http://stackoverflow.com/a/71857961
has answer: http://stackoverflow.com/a/35309666
has answer: http://stackoverflow.com/a/9237839
tagged with: design-patterns
has comment: http://stackoverflow.com/comment/115031290
upvote count: 240
has answer: http://stackoverflow.com/a/19641411
answer count: 15
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/13029261
accepted answer: http://stackoverflow.com/a/616836
tagged with: abstract-factory
tagged with: java
has answer: http://stackoverflow.com/a/8057816
score: 239
tagged with: strategy-pattern
has body: Can any one explain the difference between factory and strategy patterns? For me both are looking same other than an extra factory class (which create an object of product in factory patterns)
downvote count: 1
has answer: http://stackoverflow.com/a/14553724
type: Question
has answer: http://stackoverflow.com/a/14557672
linked to: http://stackoverflow.com/q/370258
has answer: http://stackoverflow.com/a/616836
has answer: http://stackoverflow.com/a/27011057
has answer: http://stackoverflow.com/a/861100

http://stackoverflow.com/a/1319890
answers question: http://stackoverflow.com/q/515397
has body: Have you seen these? http://en.wikipedia.org/wiki/.NET%5FFramework#.NET%5Fvs.%5FJava%5Fand%5FJava%5FEE http://en.wikipedia.org/wiki/Comparison%5Fof%5Fthe%5FJava%5Fand%5F.NET%5Fplatforms http://en.wikipedia.org/wiki/Comparison%5Fof%5FC%5FSharp%5Fand%5FJava
type: Answer
score: 0

http://stackoverflow.com/a/47771708
has comment: http://stackoverflow.com/comment/83437560
answers question: http://stackoverflow.com/q/599634
has body: You can use the class org.apache.commons.lang.StringEscapeUtils: String s = StringEscapeUtils.unescapeHtml("Happy &amp;amp; Sad") It is working.
upvote count: 4
downvote count: 0
score: 4
type: Answer

http://stackoverflow.com/comment/7724440
comment on: http://stackoverflow.com/a/3730797
type: Comment
has text: @mike: reflection might help: http://comments.gmane.org/gmane.comp.video.mplayer.user/58067 @Jared you might be able to compile it in windows, just then never run that particular code in other OS's and it might work.
score: 0
type: AnswerComment

http://stackoverflow.com/q/619567
tagged with: jvm
favorite count: 0
has comment: http://stackoverflow.com/comment/31774002
type: Question
score: 5
tagged with: java
answer count: 3
tagged with: eclipse
has comment: http://stackoverflow.com/comment/52291812
has comment: http://stackoverflow.com/comment/717573
upvote count: 5
downvote count: 0
has answer: http://stackoverflow.com/a/619931
has answer: http://stackoverflow.com/a/30382935
type: UnansweredQuestion
tagged with: proxy
has answer: http://stackoverflow.com/a/619916
has title: Zombie http.proxyHost settings for JVM on OSX
has body: I recently changed network and removed all my HTTP proxy settings from the System Preferences / Networking panel on OSX (Leopard). However, now whenever I use Eclipse the Java HTTP proxy system properties seem to be 'automagically' set to use my now defunct HTTP proxy. I can find no direct reference to this proxy anywhere on my system, have deleted and reinstalled Eclipse, have monitored the network traffic to rule out any proxy auto configuration, and yet this proxy configuration persists on the Mac OSX JVM. This is what I see in the Eclipse configuration details: http.proxyHost=zombie http.proxyPort=8080 https.proxyHost=zombie https.proxyPort=8080 I can work around this by manually configuring a proxy with no host name or port in the Eclipse preferences, but this doesn't seem to stick and the zombie system proxy eventually rises from the dead. Personally I think that this is some kind of Apple JVM bug - but can anyone tell me how I can kill these zombie HTTP proxy settings for good without reinstalling my operating system?
tagged with: macos

http://stackoverflow.com/comment/241336
type: Comment
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/417015
has text: You need to use the Swing Timer to read or update a visualized Swing component. Even reading the current state or a value from a component should be done on the EDT for deterministic results.

http://stackoverflow.com/a/513964
has comment: http://stackoverflow.com/comment/50180554
has body: To expand/correct on the first answer above, it's not translation that String.format would help with, actually. What String.format will help with is when you're printing a date/time (or a numeric format, etc), where there are localization(l10n) differences (ie, some countries will print 04Feb2009 and others will print Feb042009). With translation, you're just talking about moving any externalizable strings (like error messages and what-not) into a property bundle so that you can use the right bundle for the right language, using ResourceBundle and MessageFormat. Looking at all the above, I'd say that performance-wise, String.format vs. plain concatenation comes down to what you prefer. If you prefer looking at calls to .format over concatenation, then by all means, go with that. After all, code is read a lot more than it's written.
downvote count: 0
upvote count: 8
answers question: http://stackoverflow.com/q/513600
type: Answer
score: 8

http://stackoverflow.com/a/444098
type: Answer
has comment: http://stackoverflow.com/comment/265758
score: 4
has body: Not reflection, but I had a look at generating the toString method (along with equals/hashCode) as a post-compilation step using bytecode manipulation. Results were mixed.
answers question: http://stackoverflow.com/q/443730
downvote count: 0
upvote count: 4

http://stackoverflow.com/comment/397250
has text: I'm more interested in the (challenge and) ability to re-write the above algorithm with nonblocking constructs instead of locking/synchronization. Thus, i introduced the unpredictability requirement
comment on: http://stackoverflow.com/q/579925
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/513001
has comment: http://stackoverflow.com/comment/5781878
has comment: http://stackoverflow.com/comment/66001687
has comment: http://stackoverflow.com/comment/61305139
has comment: http://stackoverflow.com/comment/61259257
has comment: http://stackoverflow.com/comment/137830780
has body: Java 8 permits static interface methods With Java 8, interfaces can have static methods. They can also have concrete instance methods, but not instance fields. There are really two questions here: Why, in the bad old days, couldn't interfaces contain static methods? Why can't static methods be overridden? Static methods in interfaces There was no strong technical reason why interfaces couldn't have had static methods in previous versions. This is summed up nicely by the poster of a duplicate question. Static interface methods were initially considered as a small language change, and then there was an official proposal to add them in Java 7, but it was later dropped due to unforeseen complications. Finally, Java 8 introduced static interface methods, as well as override-able instance methods with a default implementation. They still can't have instance fields though. These features are part of the lambda expression support, and you can read more about them in Part H of JSR 335. Overriding static methods The answer to the second question is a little more complicated. Static methods are resolvable at compile time. Dynamic dispatch makes sense for instance methods, where the compiler can't determine the concrete type of the object, and, thus, can't resolve the method to invoke. But invoking a static method requires a class, and since that class is known statically—at compile time—dynamic dispatch is unnecessary. A little background on how instance methods work is necessary to understand what's going on here. I'm sure the actual implementation is quite different, but let me explain my notion of method dispatch, which models observed behavior accurately. Pretend that each class has a hash table that maps method signatures (name and parameter types) to an actual chunk of code to implement the method. When the virtual machine attempts to invoke a method on an instance, it queries the object for its class and looks up the requested signature in the class's table. If a method…
answers question: http://stackoverflow.com/q/512877
has comment: http://stackoverflow.com/comment/61338454
has comment: http://stackoverflow.com/comment/440103
has comment: http://stackoverflow.com/comment/5782247
has comment: http://stackoverflow.com/comment/85318492
has comment: http://stackoverflow.com/comment/85322690
has comment: http://stackoverflow.com/comment/9369268
has comment: http://stackoverflow.com/comment/28550665
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/85307968
has comment: http://stackoverflow.com/comment/61237262
accepted answer of: http://stackoverflow.com/q/512877
upvote count: 579
has comment: http://stackoverflow.com/comment/9371261
has comment: http://stackoverflow.com/comment/66008908
has comment: http://stackoverflow.com/comment/61294004
has comment: http://stackoverflow.com/comment/137951579
type: Answer
has comment: http://stackoverflow.com/comment/44492197
has comment: http://stackoverflow.com/comment/65933439
has comment: http://stackoverflow.com/comment/28547838
has comment: http://stackoverflow.com/comment/21608634
has comment: http://stackoverflow.com/comment/65930894
has comment: http://stackoverflow.com/comment/90839356
has comment: http://stackoverflow.com/comment/65977079
score: 578
downvote count: 1
has comment: http://stackoverflow.com/comment/85307929
has comment: http://stackoverflow.com/comment/65954279
has comment: http://stackoverflow.com/comment/5781844

http://stackoverflow.com/comment/681790
type: AnswerComment
comment on: http://stackoverflow.com/a/443746
type: Comment
score: 1
has text: "A method is not (yet) a first-class object in Java" -- well, there's the method class[1], of which you can certainly pass around instances. It's not the clean, idiomatic, OO code that you'd expect from java, but it might be expedient. Certainly something to consider, though. [1] http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/Method.html

http://stackoverflow.com/q/361266
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/191780
possible better answer: http://stackoverflow.com/a/361308
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/361288
has comment: http://stackoverflow.com/comment/191775
has comment: http://stackoverflow.com/comment/191817
answer count: 2
has title: Is it possible to write a method that returns a class object of T?
downvote count: 0
tagged with: generics
accepted answer: http://stackoverflow.com/a/361288
favorite count: 0
has body: If I have a base class such that public abstract class XMLSubscription &lt;T extends XMLMessage&gt; Is it possible to write a method in XMLSubscription that returns a class object of T? The only possible solution that I came up with is to have each descendant of XMLSubscription have a method like: public class XMLStatusSubscription extends XMLSubscription&lt;XMLStatusMessage&gt; { public Class &lt;XMLStatusMessage&gt; getExpectedMessageType() { return XMLStatusMessage.class; } }
upvote count: 2
has answer: http://stackoverflow.com/a/361308
score: 2

http://stackoverflow.com/q/606839
has body: I was just wondering if someone could give my XML validation code a once over to see if I'm doing it right. Here's the portion of code that is giving me the trouble... SAXParserFactory factory = SAXParserFactory.newInstance(); SchemaFactory schemaFactory = SchemaFactory .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); // *** CODE FAILS ON THE BELOW LINE **/ factory.setSchema(schemaFactory .newSchema(new Source[] { new StreamSource(schemaStream) })); SAXParser parser = factory.newSAXParser(); SAXReader reader = new SAXReader(parser.getXMLReader()); reader.setValidation(false); reader.setErrorHandler(new ResultProducingErrorHandler()); reader.read(content); Whenever I run the above code, I get an error along the lines of: src-resolve: Cannot resolve the name 'ns:myStructure' to a(n) 'type definition' component. The elements mentioned in the error messages are all ones that are imported into the schema via calls to &lt;xs:import /&gt;. The schema seems to validate OK via the W3C XML Schema Validator. Do I have to include each of these schema's individually or is Java smart enough to go off and fetch these extra schema's too? I tried adding them in the array passed to the newSchema call but that didn't make any difference. I don't think I can give out the link to the schema, so I'm really just looking for a yes or no regarding if my code looks at least acceptable.
has answer: http://stackoverflow.com/a/606852
answer count: 1
tagged with: xsd
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/606852
tagged with: java
has title: XML Validation: Am I Doing It Right?
tagged with: xml-validation
type: Question
score: 0

http://stackoverflow.com/q/484182
type: AnsweredQuestion
tagged with: java
answer count: 6
has answer: http://stackoverflow.com/a/484233
has body: Here's the scenario: I have a multi threaded java web application which is running inside a servlet container. The application is deployed multiple times inside the servlet container. There are multiple servlet containers running on different servers. Perhaps this graph makes it clear: server1 +- servlet container +- application1 | +- thread1 | +- thread2 +- application2 +- thread1 +- thread2 server2 +- servlet container +- application1 | +- thread1 | +- thread2 +- application2 +- thread1 +- thread2 There is a file inside a network shared directory which all those threads can access. And they do access the file frequently. Most of the time the file is only read by those threads. But sometimes it is written. I need a fail safe solution to synchronize all those threads so data consistency is guaranteed. Solutions which do not work (properly): Using java.nio.channels.FileLock I am able to synchronize threads from different servers using the FileLock class. But this does not work for threads inside the same process (servlet container) since file locks are available process wide. Using a separate file for synchronization I could create a separate file which indicates that a process is reading from or wrinting to the file. This solution works for all threads but has several drawbacks: Performance. Creating, deleting and checking files are rather slow operations. The low weight implementations with one synchronization file will prevent parallel reading of the file. The synchronization file will remain after a JVM crash making a manual clean up necessary. We have had already strange problems deleting files on network file systems. Using messaging We could implement a messaging system which the threads would use to coordinate the file access. But this seems too complex for this problem. And again: performance will be poor. Any thoughts?
tagged with: locking
has answer: http://stackoverflow.com/a/484215
downvote count: 0
has answer: http://stackoverflow.com/a/486822
favorite count: 0
possible better answer: http://stackoverflow.com/a/484215
upvote count: 6
tagged with: synchronization
accepted answer: http://stackoverflow.com/a/486822
tagged with: multithreading
tagged with: file
score: 6
has answer: http://stackoverflow.com/a/484428
has answer: http://stackoverflow.com/a/486817
has title: How to lock a file on different application levels?
has answer: http://stackoverflow.com/a/484221
type: Question

http://stackoverflow.com/a/578358
downvote count: 0
has body: The reflection not mantains the order of the Field in next calling: it's safier order the arrays. /* *declarations of variables */ Arrays.sort(oldFields);//natural order - choice 1 Arrays.sort(newFields, new Ordinator());//custom Comparator - choice 2 /* *logic of comparations between elements */ In choice 2 you can decide the logic of sorting (HOW SORTING THE ELEMENTS) with an inner class Ordinator extending Comparator. PS the code is a draft
upvote count: 3
answers question: http://stackoverflow.com/q/578209
type: Answer
score: 3

http://stackoverflow.com/a/694820
upvote count: 56
has comment: http://stackoverflow.com/comment/60134786
downvote count: 3
answers question: http://stackoverflow.com/q/628416
has comment: http://stackoverflow.com/comment/73512282
has comment: http://stackoverflow.com/comment/18784767
has body: Other users have provide some very useful links above so I am not going to bother with links. I have done a similar research in JAAS for web application and has ran into a "mind roadblock" until I finally realize JAAS is a framework tackling security at a different "layer" then web applications in the Java World. It is build to tackle security issues in Java SE not Java EE. JAAS is a security framework built for securing things at a much lower level then web-application. Some example of these things are code and resources available at the JVM level, hence all these ability to set policy files in the JVM level. However, since Java EE is built on top of Java SE, a few modules from JAAS were reused in Java EE security such as the LoginModules and Callbacks. Note that in addition to Java EE security, there is also Spring security (formerly known as Acegi), which similar to native Java EE security tackles a much higher "layer" in the securing web-application problem. It is a separate security implementation and is not built on top of standard Java EE security, although it behaves similarly in many regards. To summarize, unless you are looking to secure resources in the Java SE level (classes, System resources), I don't see any real use of JAAS other than the using the common class and interfaces. Just focus on using Spring Security or plain old Java EE security which both solve a lot of common web application security problems.
score: 53
type: Answer

http://stackoverflow.com/a/586999
has body: I didn't find any specification of the behavior in the Hibernate docs, but the between operator in HQL is translated to the between operator in SQL, which is inclusive. So between in HQL is also inclusive, that is A between 5 and 10 is equivalent to A &gt;= 5 and A &lt;= 10
type: Answer
answers question: http://stackoverflow.com/q/586077
has comment: http://stackoverflow.com/comment/122564717
has comment: http://stackoverflow.com/comment/37080503
score: 60
upvote count: 60
accepted answer of: http://stackoverflow.com/q/586077
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/479961
has answer: http://stackoverflow.com/a/517276
type: Question
answer count: 2
downvote count: 0
tagged with: documentum
has answer: http://stackoverflow.com/a/480461
favorite count: 0
upvote count: 2
has title: Documentum 5.3 connecting
accepted answer: http://stackoverflow.com/a/480461
score: 2
type: AnsweredQuestion
tagged with: java
has body: I am new to Documentum. I am creating a stand alone java application that needs to connect to a documentum instance (5.3). How would I go about connecting to the instance?
possible better answer: http://stackoverflow.com/a/517276

http://stackoverflow.com/a/26906947
downvote count: 0
has body: Another good alternative would be MockServer; it provides a fluent interface with which you can define the behaviour of the mocked web server.
upvote count: 8
answers question: http://stackoverflow.com/q/606352
type: Answer
has comment: http://stackoverflow.com/comment/80540774
score: 8

properties
tags question: http://stackoverflow.com/q/508735
tags question: http://stackoverflow.com/q/534199
type: Tag
tags question: http://stackoverflow.com/q/487826
tags question: http://stackoverflow.com/q/565932
tags question: http://stackoverflow.com/q/605127
tags question: http://stackoverflow.com/q/545177
tag name: properties
tags question: http://stackoverflow.com/q/522202
tags question: http://stackoverflow.com/q/603013
tags question: http://stackoverflow.com/q/551009
tags question: http://stackoverflow.com/q/441240
tags question: http://stackoverflow.com/q/479855
tags question: http://stackoverflow.com/q/398422
tags question: http://stackoverflow.com/q/624741
tags question: http://stackoverflow.com/q/376798
tags question: http://stackoverflow.com/q/554120
tags question: http://stackoverflow.com/q/487590
tags question: http://stackoverflow.com/q/604188

http://stackoverflow.com/comment/32421879
score: 4
type: AnswerComment
has text: @Shahe the first thing I would do is check the time portions of your dates. Chances are your `date` is early in the morning and `startDate` is after it.
type: Comment
comment on: http://stackoverflow.com/a/494200

http://stackoverflow.com/a/1322747
type: Answer
has body: As others have said, appendReplacement() and appendTail() are the tools you need, but there's something you have watch out for. If the replacement string contains any dollar signs, the method will try to interpret them as capture-group references. If there are any backslashes (which are used to escape the dollars sing), it will either eat them or throw an exception. If your replacement string is dynamically generated, you may not know in advance whether it will contain any dollar signs or backslashes. To prevent problems, you can append the replacement directly to the StringBuffer, like so: Pattern p = Pattern.compile("@([^@]*?)@"); Matcher m = p.matcher(s); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(""); sb.append(substitutionTable.lookupKey(m.group(1))); } m.appendTail(sb); You still have to call appendReplacement() each time, because that's what keeps you in sync with the match position. But this trick avoids a lot of pointless processing, which could give you a noticeable performance boost as a bonus.
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/463460
downvote count: 0

http://stackoverflow.com/q/627868
tagged with: java
has body: The documentation for ant's task states: The performance of the depend task is dependent on a number of factors such as class relationship complexity and how many class files are out of date. The decision about whether it is cheaper to just recompile all classes or to use the depend task will depend on the size of your project and how interrelated your classes are. I suspect that using the task before calling may speed up the build for the project I work on, and possibly prevent the need for clean builds in certain cases. However, the ant documentation is very cryptic for this task and I could use some clarification. I work with a large code base containing about 16k classes in src and 4k classes in testsrc. We build a core jar file containing about a quarter of the classes, followed by about 15 other jars that depend on the core.jar and not each other. I would just try it out, but our build.xml requires a lot of clean-up before I can make this change, and I want to understand the task better anyway.
answer count: 1
tagged with: ant
type: AnsweredQuestion
score: 2
downvote count: 0
has answer: http://stackoverflow.com/a/627947
favorite count: 0
type: Question
upvote count: 2
has title: Do you use ant's <depend> task?
tagged with: build
accepted answer: http://stackoverflow.com/a/627947

http://stackoverflow.com/a/32993311
type: Answer
score: 3
upvote count: 3
has body: The Unicode Script property is probably more useful. In Java, it can be looked up using the java.lang.Character.UnicodeScript class: Character.UnicodeScript script = Character.UnicodeScript.of(c);
answers question: http://stackoverflow.com/q/404733
downvote count: 0

http://stackoverflow.com/a/5268487
has body: I just don't know what the hell these Eclipse developers are thinking! Removing plug-ins from Eclipse became a pain in the ass since Helios! I hear you pal... I just went through the whole day trying to figure out as no one seems to give an straight answer like "do this, that, done." Man I'd rather be programming instead.... Found, in the middle of my evening that it is possible to uninstall pretty much everything. The issue is that the damn thing is hidden in the "HELP->ABOUT". Who would guess after going over and over through the "Help->Install New Software" or "Help->Check for updates" and never finding anything like "remove" or "reinstall" or "force reinstall". Seriouly, I'd rather go back to 1990 when we had Microsoft, Borland and Watcom.. you picked your platform and you'd be with 1/3 of the world of developers with you.. ok, perhaps Watcom didn't hit that mark but you get the point. So... to uninstall any plugin from Eclipse Helios (Service Release 1) or Springsource 3.5.2 (or 3.6.1 I 'm using), do this: close all your projects (just to be on the safe side); Hit menu "HELP-->ABOUT" (yeah.. help, about); Hit "Installation Details" button and you get the list with all plugins; Click on the one you want to remove; hit uninstall; If want to remove more than one, just apply the change without restart; Goto to 4) as needed Finally, restart Eclipse and reinstall what you need ! It was hard to find, but it worked very well for me.
score: 0
answers question: http://stackoverflow.com/q/369889
type: Answer
upvote count: 1
downvote count: 1

http://stackoverflow.com/a/1229988
type: Answer
answers question: http://stackoverflow.com/q/427726
has body: scope=page works for me
upvote count: 5
score: 5
downvote count: 0

http://stackoverflow.com/a/474368
has body: Not at the moment - one of the reasons they moved away from the Java conversion of EOF was the complications that arose from the translation (http://en.wikipedia.org/wiki/Core_Data).
type: Answer
answers question: http://stackoverflow.com/q/472377
score: 0

web-container
tag name: web-container
tags question: http://stackoverflow.com/q/531463
type: Tag

http://stackoverflow.com/q/477609
possible better answer: http://stackoverflow.com/a/477629
tagged with: callable
has answer: http://stackoverflow.com/a/477647
accepted answer: http://stackoverflow.com/a/477647
has title: How much logic is it "right" to put in a Callable?
upvote count: 3
answer count: 3
favorite count: 0
has answer: http://stackoverflow.com/a/477629
has body: I'm using callables quite often , and I've stubled upon a question that irritates me: Lets say that to run function foo() , one needs to do a couple of checks first. Should you 1. Insert the checks as part of the Callable : class A implements Callable&lt;Long&gt; { ... public Long call() { check1(); check2(); return (run()); } OR , insert all this logic into another class (ALogic) and use the Callable a mere shell for the executor? class A implements Callable { ... public Long call() { ALogic aLogic = new ALogic(); return (aLogic.run()); } What do you think are the pro's and con's? What do you usually prefer?
has answer: http://stackoverflow.com/a/477835
type: AnsweredQuestion
score: 3
downvote count: 0
tagged with: java
type: Question

http://stackoverflow.com/q/532988
type: UnansweredQuestion
favorite count: 0
has body: I am trying to keep Netbeans from printing statement like this // // #[regen=yes,id=DCE.B7E25FE1-C10B-ED91-77... // without deleting them from the code.
tagged with: printing
type: Question
score: 1
tagged with: netbeans
upvote count: 1
answer count: 1
tagged with: java
tagged with: comments
has answer: http://stackoverflow.com/a/543213
has title: How do I keep Netbeans from printing line like this // <editor-fold defaultstate="collapsed" desc=" UML Marker "> when printing code?
downvote count: 0

http://stackoverflow.com/a/74373834
type: Answer
score: 0
has body: You can use: Collections&lt;String, String&gt;.emptyMap();
answers question: http://stackoverflow.com/q/636126

http://stackoverflow.com/comment/222546
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/395816
has text: Overall, a switch is going to be better.

http://stackoverflow.com/q/615493
has answer: http://stackoverflow.com/a/615560
has answer: http://stackoverflow.com/a/615534
linked to: http://stackoverflow.com/q/37475810
has answer: http://stackoverflow.com/a/32295684
has comment: http://stackoverflow.com/comment/28549222
has answer: http://stackoverflow.com/a/13671129
type: Question
tagged with: jar
downvote count: 0
has comment: http://stackoverflow.com/comment/46807875
tagged with: tomcat
tagged with: manifest
linked to: http://stackoverflow.com/q/1272648
has body: I have a webapp which contains a manifest file, in which I write the current version of my application during an ant build task. The manifest file is created correctly, but when I try to read it in during runtime, I get some strange side-effects. My code for reading in the manifest is something like this: InputStream manifestStream = Thread.currentThread() .getContextClassLoader() .getResourceAsStream("META-INFFFF/MANIFEST.MF"); try { Manifest manifest = new Manifest(manifestStream); Attributes attributes = manifest.getMainAttributes(); String impVersion = attributes.getValue("Implementation-Version"); mVersionString = impVersion; } catch(IOException ex) { logger.warn("Error while reading version: " + ex.getMessage()); } When I attach eclipse to tomcat, I see that the above code works, but it seems to get a different manifest file than the one I expected, which I can tell because the ant version and build timestamp are both different. Then, I put "META-INFFFF" in there, and the above code still works! This means that I'm reading some other manifest, not mine. I also tried this.getClass().getClassLoader().getResourceAsStream(...) But the result was the same. What's the proper way to read the manifest file from inside of a webapp running in tomcat? Edit: Thanks for the suggestions so far. Also, I should note that I am running tomcat standalone; I launch it from the command line, and then attach to the running instance in Eclipse's debugger. That shouldn't make a difference, should it?
score: 48
answer count: 7
upvote count: 48
has title: How do I read the manifest file for a webapp running in apache tomcat?
favorite count: 0
linked to: http://stackoverflow.com/q/3468150
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/30984902
has answer: http://stackoverflow.com/a/2469399
has answer: http://stackoverflow.com/a/615545
tagged with: java

http://stackoverflow.com/comment/127616366
score: 0
type: AnswerComment
has text: The link does not exist anymore.
comment on: http://stackoverflow.com/a/10533493
type: Comment

http://stackoverflow.com/comment/427895
comment on: http://stackoverflow.com/q/615063
type: Comment
score: 0
has text: Does Java support an "internal" modifier like C# does? In C#, you can use internal to make things only visible within the same assembly.
type: QuestionComment

http://stackoverflow.com/a/537001
upvote count: 3
has comment: http://stackoverflow.com/comment/139738981
answers question: http://stackoverflow.com/q/536971
type: Answer
score: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/350394
has body: java is not C++: when you use a library you don't import a single line of code. You just load the library on request and use that. For this reason you don't need to recompile your code :)

http://stackoverflow.com/a/458520
has comment: http://stackoverflow.com/comment/277811
type: Answer
score: 2
has body: You can use an array of longs, encapsulated in a class that would handle all the operations on the array. Something like your own implementation of BitSet.
upvote count: 3
downvote count: 1
answers question: http://stackoverflow.com/q/458489

http://stackoverflow.com/a/627075
upvote count: 14
has body: The best way to do it is this: 1) create a directory with src\ and tests\ in it (the tests is optional if you are not using JUnit). 2) assuming you have package myjava; at the top of your files (and make sure that this is what your prof wants, it becomes a pain to mark things if they are not in the right place), make a src\myjava directory (and if you are doing JUnit a tests\myjava directory). 3) copy your files into the src\myjava directory 4) delete your NetBeans project and recreate it as a new on with exising sources. When you are setting up the src (and optional test) directories add the src\ (and optionally the tests\) directory. DO NOT add the src\myjava directory or it won't work in NetBeans. 5) make a directory called classes\ (so you you have src\, classes\, and maybe \tests all in the same place) 6) on the command line type javac -d classes -cp classes src/myjava/*.java -d tells the compiler where to put the .class files -cp tells the compiler where to look for classfiles src/myjava/*.java tells it to compile all of the .java files in src/myjava 7) run it via java -cp classes myjava.Main -cp classes tells it to look in the classes directory for the .class files myjava.Main is the name of the class to run
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/626940
score: 14

http://stackoverflow.com/a/600666
answers question: http://stackoverflow.com/q/600651
score: 1
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/412929
upvote count: 1
has body: There's a recent article by Eric Lippert about this. He's a programmer on the C# compiler, but whatever he says there has enough generality to be extended to other GC languages such as Java: http://blogs.msdn.com/ericlippert/archive/2009/02/17/references-are-not-addresses.aspx Quote from the article: Pointers are strictly "more powerful" than references; anything you can do with references you can do with pointers. [...] Pointers are typically implemented as addresses. An address is a number which is an offset into the "array of bytes" that is the entire virtual address space of the process. [...] For all these reasons we do not describe references as addresses in the specification. The spec just says that a variable of reference type "stores a reference" to an object, and leaves it completely vague as to how that might be implemented. Similarly, a pointer variable stores "the address" of an object, which again, is left pretty vague. Nowhere do we say that references are the same as addresses. So, in C# a reference is some vague thing that lets you reference an object. You cannot do anything with a reference except dereference it, and compare it with another reference for equality. And in C# a pointer is identified as an address. By contrast with a reference, you can do much more with a pointer that contains an address. Addresses can be manipulated mathematically; you can subtract one from another, you can add integers to them, and so on. Their legal operations indicate that they are "fancy numbers" that index into the "array" that is the virtual address space of the process.

http://stackoverflow.com/comment/451583
score: 0
type: AnswerComment
has text: But I don't think I should convert it to a string - so would IOUtils be of any use in this case?
type: Comment
comment on: http://stackoverflow.com/a/638348

http://stackoverflow.com/q/416432
answer count: 5
tagged with: jdbc
possible better answer: http://stackoverflow.com/a/416570
has comment: http://stackoverflow.com/comment/655726
has body: I am evaluating options for efficient data storage in Java. The data set is time stamped data values with a named primary key. e.g. Name: A|B|C:D Value: 124 TimeStamp: 01/06/2009 08:24:39,223 Could be a stock price at a given point in time, so it is, I suppose, a classic time series data pattern. However, I really need a generic RDBMS solution which will work with any reasonable JDBC compatible database as I would like to use Hibernate. Consequently, time series extensions to databases like Oracle are not really an option as I would like the implementor to be able to use their own JDBC/Hibernate capable database. The challenge here is simply the massive volume of data that can accumulate in a short period of time. So far, my implementations are focused around defining periodical rollup and purge schedules where raw data is aggregated into DAY, WEEK, MONTH etc. tables, but the downside is the early loss of granularity and the slight inconvenience of period mismatches between periods stored in different aggregates. The challenge has limited options since there is an absolute limit to how much data can be physically compressed while retaining the original granularity of the data, and this limit is exacerbated by the directive of using a relational database, and a generic JDBC capable one at that. Borrowing a notional concept from classic data compression algorithms, and leveraging the fact that many consecutive values for the same named key can expected to be identical, I am wondering if there is way I can seamlessly reduce the number of stored records by conflating repeating values into one logical row while also storing a counter that indicates, effectively, "the next n records have the same value". The implementation of just that seems simple enough, but the trade off is that the data model is now hideously complicated to query against using standard SQL, especially when using any sort of aggregate SQL functions. This significantly reduces the usefulness of the data…
has answer: http://stackoverflow.com/a/417136
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/416570
tagged with: compression
type: Question
tagged with: java
tagged with: hibernate
tagged with: database
has title: What are my options to store and query huge amounts of data where a lot of it is repeating?
accepted answer: http://stackoverflow.com/a/417136
has answer: http://stackoverflow.com/a/421360
upvote count: 4
has answer: http://stackoverflow.com/a/659066
downvote count: 0
score: 4
favorite count: 0
has answer: http://stackoverflow.com/a/421466

http://stackoverflow.com/a/405402
has comment: http://stackoverflow.com/comment/39749624
answers question: http://stackoverflow.com/q/405364
has comment: http://stackoverflow.com/comment/39762820
has comment: http://stackoverflow.com/comment/83795407
has comment: http://stackoverflow.com/comment/39761860
has body: Imports don't correlate with any instructions in compiled code. They establish aliases for use at compile time only. There are some reflective methods that allow the class to be loaded but not yet initialized, but in most cases, you can assume that whenever a class is referenced, it has been initialized. Static member initializers and static blocks are executed as if they were all one static initializer block in source code order. An object referenced through a static member variable is strongly referenced until the class is unloaded. A normal ClassLoader never unloads a class, but those used by application servers do under the right conditions. However, it's a tricky area and has been the source of many hard-to-diagnose memory leaks&mdash;yet another reason not to use global variables. As a (tangential) bonus, here's a tricky question to consider: public class Foo { private static Foo instance = new Foo(); private static final int DELTA = 6; private static int BASE = 7; private int x; private Foo() { x = BASE + DELTA; } public static void main(String... argv) { System.out.println(Foo.instance.x); } } What will this code print? Try it, and you'll see that it prints "6". There are a few things at work here, and one is the order of static initialization. The code is executed as if it were written like this: public class Foo { private static Foo instance; private static final int DELTA = 6; private static int BASE; static { instance = null; BASE = 0; instance = new Foo(); /* BASE is 0 when instance.x is computed. */ BASE = 7; } private int x; private Foo() { x = BASE + 6; /* "6" is inlined, because it's a constant. */ } }
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/39749643
upvote count: 34
has comment: http://stackoverflow.com/comment/39739557
has comment: http://stackoverflow.com/comment/39749630
has comment: http://stackoverflow.com/comment/39727008
type: Answer
has comment: http://stackoverflow.com/comment/39728304
has comment: http://stackoverflow.com/comment/39727637
downvote count: 0
has comment: http://stackoverflow.com/comment/39728806
has comment: http://stackoverflow.com/comment/39727710
has comment: http://stackoverflow.com/comment/39728559
accepted answer of: http://stackoverflow.com/q/405364
score: 34
has comment: http://stackoverflow.com/comment/39728650

http://stackoverflow.com/q/531126
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/531192
downvote count: 0
score: 1
tagged with: java
has body: Given: Object nestKey; Object nestedKey; Object nestedValue; Map&lt;T,Map&lt;T,T&gt;&gt; nest; Map&lt;T,T&gt; nested; How is a mapping added to nested where: nest.containsKey(nestKey) == true; ? Or is there an existing library of collections that would be more effective?
has answer: http://stackoverflow.com/a/531152
tagged with: collections
type: Question
possible better answer: http://stackoverflow.com/a/531152
has answer: http://stackoverflow.com/a/531153
upvote count: 1
tagged with: nested
favorite count: 0
has title: How to add a inner mapping in a nested collection?
has answer: http://stackoverflow.com/a/531149
accepted answer: http://stackoverflow.com/a/531192
tagged with: dictionary

http://stackoverflow.com/comment/45729933
type: Comment
has text: I know this is an old thread, but we're implementing the same kind of thing using javax.persistence. When we add: @ElementCollection(targetClass=Roles.class) @CollectionTable( name="USER_ROLES", joinColumns=@JoinColumn(name="USER_ID") ) @Column( name="ROLE", nullable=false ) @Enumerated(EnumType.STRING) private Set<Roles> roles; to our User table, things flake out in the entire model package. In our User object, even an error on the Primary key's @Id...@GeneratedValue generator and the first @OneToMany throw goofy errors on build.
type: AnswerComment
comment on: http://stackoverflow.com/a/642805
score: 0

http://stackoverflow.com/comment/6083438
type: AnswerComment
score: 5
has text: The latter suggestion won't work. The `-cp` (and `-classpath`) argument is **ignored** when `-jar` is used.
type: Comment
comment on: http://stackoverflow.com/a/502988

http://stackoverflow.com/a/1091963
answers question: http://stackoverflow.com/q/419858
downvote count: 0
type: Answer
upvote count: 1
score: 1
has body: Some folks suggest clone() -- just to be extra clear, clone() on a multi-dimensional array is only a shallow clone. original.clone()[0] == original[0]. But (for primitives) you can use clone() instead of System.arraycopy() once you're down to one-dimensional arrays.

http://stackoverflow.com/comment/370180
comment on: http://stackoverflow.com/q/558839
type: Comment
has text: I think a good question could come from this though
score: 0
type: QuestionComment

http://stackoverflow.com/a/50144499
type: Answer
answers question: http://stackoverflow.com/q/453023
score: 0
has body: The key here is the Garbage Collection of Class instances i.e. Objects. ClassLoader instance is, in essence, an Object. So if the Classloader object is not garbage collected, any references of them stored in heap (i.e. static stuff) will almost never be garbage collected. The exception is String pool. So before you suddenly decide to do private static MyGiantClass myGiantObject = new MyGiantClass() Think twice as I have learnt the hard way.

http://stackoverflow.com/comment/385353
comment on: http://stackoverflow.com/q/573543
score: 0
has text: I hope this is a joke. Basically what you're suggesting would destroy the whole OOP part of the language. No finalize? No public constructors (or protected), prevent overloading? Why would you remove finalize, but then prevent overloading?
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/121421093
type: Comment
has text: `File FileUtils.getUserDirectory()` | `String FileUtils.getUserDirectoryPath()` - https://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/FileUtils.html
comment on: http://stackoverflow.com/a/52757962
type: AnswerComment
score: 1

http://stackoverflow.com/comment/114548765
comment on: http://stackoverflow.com/a/17810863
has text: I'd like to like this, but each of your nodes requires 1024 bytes, and represents only one character. Also insertion now takes O(n^2) time because of Java's changed semantics of substring(). This implementation is really not very practical.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/54566928
answers question: http://stackoverflow.com/q/510462
downvote count: 0
type: Answer
score: 39
has body: Since Java 7, System.nanoTime() is guaranteed to be safe by JDK specification. System.nanoTime()'s Javadoc makes it clear that all observed invocations within a JVM (that is, across all threads) are monotonic: The value returned represents nanoseconds since some fixed but arbitrary origin time (perhaps in the future, so values may be negative). The same origin is used by all invocations of this method in an instance of a Java virtual machine; other virtual machine instances are likely to use a different origin. JVM/JDK implementation is responsible for ironing out the inconsistencies that could be observed when underlying OS utilities are called (e. g. those mentioned in Tom Anderson's answer). The majority of other old answers to this question (written in 2009&ndash;2012) express FUD that was probably relevant for Java 5 or Java 6 but is no longer relevant for modern versions of Java. It's worth mentioning, however, that despite JDK guarantees nanoTime()'s safety, there have been several bugs in OpenJDK making it to not uphold this guarantee on certain platforms or under certain circumstances (e. g. JDK-8040140, JDK-8184271). There are no open (known) bugs in OpenJDK wrt nanoTime() at the moment, but a discovery of a new such bug or a regression in a newer release of OpenJDK shouldn't shock anybody. With that in mind, code that uses nanoTime() for timed blocking, interval waiting, timeouts, etc. should preferably treat negative time differences (timeouts) as zeros rather than throw exceptions. This practice is also preferable because it is consistent with the behaviour of all timed wait methods in all classes in java.util.concurrent.*, for example Semaphore.tryAcquire(), Lock.tryLock(), BlockingQueue.poll(), etc. Nonetheless, nanoTime() should still be preferred for implementing timed blocking, interval waiting, timeouts, etc. to currentTimeMillis() because the latter is a subject to the "time going backward" phenomenon (e. g. due to server time correction), i. e. …
upvote count: 39

http://stackoverflow.com/comment/65345246
score: 0
has text: You can easily write to a `ByteArrayOutputStream` convert to `String`... seems easy to me
type: Comment
comment on: http://stackoverflow.com/a/25784117
type: AnswerComment

http://stackoverflow.com/comment/26586639
type: Comment
has text: @johnny Yes, 1.2 GB of memory on 32-bit Windows systems.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/592179

http://stackoverflow.com/q/426163
has answer: http://stackoverflow.com/a/426373
type: UnansweredQuestion
score: 6
downvote count: 0
tagged with: java
has body: There is a bunch of announcements from CES 2009 about new 3D displays used for games and movies. I was wondering if there is a setup that currently exist that also brings the 3D to a development environment. Such an environment would, for example, bring out compile errors to the front. Or maybe allow the programmer to quickly stack panels of code, instead of using 2D tabs. Do they even exist? Or would it be too tiresome for the eye after 5 hour of coding? The question applies to Java, since I'm mostly a Java developer. But I'm also curious is there is a good 3d developing environment for other language.
type: Question
has comment: http://stackoverflow.com/comment/249935
upvote count: 6
tagged with: ide
answer count: 2
tagged with: 3d
has answer: http://stackoverflow.com/a/426431
favorite count: 0
has title: Best "3D display" developing environment for Java? (do they even exist?)

http://stackoverflow.com/a/504632
answers question: http://stackoverflow.com/q/504103
score: 24
upvote count: 24
has body: Should the benchmark measure time/iteration or iterations/time, and why? It depends on what you are trying to test. If you are interested in latency, use time/iteration and if you are interested in throughput, use iterations/time.
downvote count: 0
type: Answer

http://stackoverflow.com/a/838951
upvote count: 127
type: AcceptedAnswer
downvote count: 1
has comment: http://stackoverflow.com/comment/2244932
has comment: http://stackoverflow.com/comment/656314
has comment: http://stackoverflow.com/comment/91471702
score: 126
type: Answer
has body: The above solution works fine but it creeps up again and again. An easier solution is to right click on the concerned project in Eclipse and choose Validate.
has comment: http://stackoverflow.com/comment/3486046
accepted answer of: http://stackoverflow.com/q/503157
answers question: http://stackoverflow.com/q/503157

http://stackoverflow.com/comment/15699248
type: AnswerComment
has text: @Hannele Most of the time yes, but sometimes it indeed *increases* it. For example, when computing sum of prices where each of them is given with two decimal places, the rounding to two decimal places *guarantees* a correct result (unless you're summing many billions of values).
type: Comment
comment on: http://stackoverflow.com/a/5886596
score: 1

http://stackoverflow.com/a/421401
answers question: http://stackoverflow.com/q/421357
score: -1
downvote count: 1
type: Answer
has body: I have been dealing with something similar recently. If you are running Java 5, perhaps you could consider using NIO file locks in conjunction with a ReentrantReadWriteLock? Make sure all code referencing the FileChannel object ALSO references the ReentrantReadWriteLock. This way the NIO locks it at a per-VM level while the reentrant lock locks it at a per-thread level. FileLock fileLock = filechannel.lock(position, size, shared); reentrantReadWriteLock.lock(); // do stuff fileLock.release(); reentrantReadWriteLock.unlock(); Of course, some exception handling would be required.
upvote count: 0

http://stackoverflow.com/a/620054
has comment: http://stackoverflow.com/comment/433042
has body: It sounds to me like the problem you are having is that you do not have a Perl compiler/interpreter available, yet you need to execute some Perl code. Unfortunately, I don't think that there exists anything like Jython for Perl. The only projects that I know of that can do what you are asking is PLJava and JPL. Unfortunately, it looks like both projects are abandoned. It would be a cool project though, as I believe there is a need for something like this.
downvote count: 0
answers question: http://stackoverflow.com/q/619822
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/comment/60822464
score: 1
has text: I ended up with using HTML escapes, without the `{@code}` tag. it rendered by IDEs as readable anyway. Also use of `` would make markup better.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/647202

http://stackoverflow.com/comment/63738773
score: 0
has text: Likely duplicate: [How do I time a method's execution in Java?](http://stackoverflow.com/q/180158/642706)
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/504103

http://stackoverflow.com/q/620153
accepted answer: http://stackoverflow.com/a/620196
type: AnsweredQuestion
tagged with: applet
favorite count: 0
has answer: http://stackoverflow.com/a/620299
possible better answer: http://stackoverflow.com/a/4695450
type: Question
has body: I've put together a basic applet where the user selects a file from their hard drive, it reads the first line of this file and passes that off to JavaScript for some additional preprocessing, and then when you click a button it tries to upload that file through an HTTP POST request. I found a very basic open source applet for uploading files that I copied and modified for this last bit. The trouble is, though, it doesn't quite work. It seems like it's running fine, but then I run into two snags related to permissions. The messages in the Java Console say that the applet had access denied errors on the following two permissions: java.lang.RuntimePermission setFactory java.io.FilePermission read I find this strange, because I thought I had granted permission to the applet already when I built it with the "self-signed" option checked in NetBeans, and then clicked to confirm the little security pop-up in the browser. Also, the part that I coded myself, where it reads the file and passes the first line on to JavaScript works fine. This is a pretty clear indicator that the applet is able to read from the local file system! The trouble doesn't start until I actually try to start the upload. One thing to note, I suppose, is that the upload process seems to run in a new thread, whereas the rest of it all runs in the main class without creating threads. I am a total novice to Java and know very little about threads in Java; do I need to pass the permissions onto this new thread somehow? Or something to that effect? Thanks in advance.
score: 5
has answer: http://stackoverflow.com/a/4695450
tagged with: permissions
tagged with: java
answer count: 3
has answer: http://stackoverflow.com/a/620196
upvote count: 5
tagged with: upload
downvote count: 0
has title: Java Applet Permissions

http://stackoverflow.com/q/546144
tagged with: swing
has answer: http://stackoverflow.com/a/546221
type: AnsweredQuestion
has title: Adding JTextField to a JPanel and showing them
score: 7
tagged with: java
tagged with: jpanel
tagged with: jtextfield
type: Question
has body: I'm building a little app using Java and Swing in NetBeans. Using NetBeans design window, I created a JFrame with a JPanel inside. Now I want to dynamically add some jTextFields to the JPanel. I wrote something like that: Vector textFieldsVector = new Vector(); JTextField tf; int i = 0; while (i &lt; 3) { tf = new JTextField(); textFieldVector.add(tf); myPanel.add(tf); //myPanel is the JPanel where I want to put the JTextFields i++; } myPanel.validate(); myPanel.repaint(); But nothing happens: when I run the app, the JFrame shows with the JPanel inside, but the JTextFields don't. I'm a total newbie in writing graphical Java apps, so I'm surely missing something very simple, but I can't see what.
has answer: http://stackoverflow.com/a/546198
downvote count: 0
answer count: 6
possible better answer: http://stackoverflow.com/a/546221
upvote count: 7
favorite count: 0
has answer: http://stackoverflow.com/a/3027450
has answer: http://stackoverflow.com/a/546264
has answer: http://stackoverflow.com/a/9039377
accepted answer: http://stackoverflow.com/a/546264
has answer: http://stackoverflow.com/a/546226

http://stackoverflow.com/q/594722
tagged with: findbugs
answer count: 6
score: 4
has answer: http://stackoverflow.com/a/594753
has comment: http://stackoverflow.com/comment/406497
tagged with: optimization
has answer: http://stackoverflow.com/a/594756
downvote count: 0
has answer: http://stackoverflow.com/a/595319
has title: What standard optimization refactoring can I do to my Java application?
favorite count: 0
has body: I have a semi big Java application. It's written quite poorly and I suspect there are quite a lot of simple things I can do that will clean things up a bit and improve performance. For example I recently found the String.matches(regex) function used quite a lot in loops with the same regex. So I've replaced that with precompiled Patterns. I use FindBugs (which is great BTW) but that didn't spot this problem and I'm limited on tools that I can use here at work. Is there anything else simple like this that I should look at?
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/594759
has answer: http://stackoverflow.com/a/594776
has comment: http://stackoverflow.com/comment/407415
tagged with: refactoring
tagged with: java
has answer: http://stackoverflow.com/a/595190
type: Question
upvote count: 4

http://stackoverflow.com/a/519058
answers question: http://stackoverflow.com/q/518267
type: Answer
upvote count: 1
has body: You may be having issues related to the mixing of fields and methods in your annotations. For example, if you have an @Id annotation in your parent class BaseParent, then Hibernate will by default look at fields and not methods. So basically if you had something like this: public class BaseParent { @Id private Integer id; protected List&lt;Child&gt; children; } public class Parent extends BaseParent { @ManyToOne public List&lt;Child&gt; getChildren() {super.getChildren();} } Hibernate is going to have a problem determining the @ManyToOne annotation. Also, that would probably explain why adding the annotation to the field in the parent class made it work. On the same page that is mentioned above (http://docs.jboss.org/ejb3/app-server/HibernateAnnotations/reference/en/html_single/index.html#d0e253), there is also this paragraph: Depending on whether you annotate fields or methods, the access type used by Hibernate will be field or property. The EJB3 spec requires that you declare annotations on the element type that will be accessed, i.e. the getter method if you use property access, the field if you use field access. Mixing EJB3 annotations in both fields and methods should be avoided. Hibernate will guess the access type from the position of @Id or @EmbeddedId. So, to get it to work, you probably want to choose one or the other (field vs method) and be consistent. That way, you will not come across these "strange" hibernate issues. Anyways, hope that is helpful.
score: 1
downvote count: 0

http://stackoverflow.com/comment/87050313
has text: what about <entry key="hibernate.hbm2ddl.auto" value="none"> ?
score: 3
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/43922047

http://stackoverflow.com/q/370818
downvote count: 1
has answer: http://stackoverflow.com/a/370874
possible better answer: http://stackoverflow.com/a/6992265
type: Question
has answer: http://stackoverflow.com/a/46627704
has answer: http://stackoverflow.com/a/371519
has answer: http://stackoverflow.com/a/370824
has answer: http://stackoverflow.com/a/370939
has answer: http://stackoverflow.com/a/371114
tagged with: java
answer count: 14
tagged with: sql
has answer: http://stackoverflow.com/a/370886
tagged with: string
favorite count: 0
tagged with: oracle-database
has answer: http://stackoverflow.com/a/370947
has answer: http://stackoverflow.com/a/43649872
upvote count: 124
score: 123
has title: Cleanest way to build an SQL string in Java
has answer: http://stackoverflow.com/a/9885794
has answer: http://stackoverflow.com/a/6992265
has answer: http://stackoverflow.com/a/502273
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/370891
accepted answer: http://stackoverflow.com/a/370891
has body: I want to build an SQL string to do database manipulation (updates, deletes, inserts, selects, that sort of thing) - instead of the awful string concat method using millions of "+"'s and quotes which is unreadable at best - there must be a better way. I did think of using MessageFormat - but its supposed to be used for user messages, although I think it would do a reasonable job - but I guess there should be something more aligned to SQL type operations in the java sql libraries. Would Groovy be any good?
has answer: http://stackoverflow.com/a/370907

http://stackoverflow.com/comment/257353
type: Comment
comment on: http://stackoverflow.com/a/434395
score: 0
type: AnswerComment
has text: Don't worry it happens to all of us... :)

distributed
tags question: http://stackoverflow.com/q/396569
tags question: http://stackoverflow.com/q/425891
tags question: http://stackoverflow.com/q/601956
tags question: http://stackoverflow.com/q/359426
tags question: http://stackoverflow.com/q/506911
type: Tag
tag name: distributed

http://stackoverflow.com/a/411599
score: 2
upvote count: 2
downvote count: 0
has body: JSR 296 Swing Application Framework has support for resource management (and it looks like will be part of Java 7). SAF aims to pre-build parts of a Swing app that many people frequently need while encapsulating best practices. You probably don't want to tie to it directly but its worth taking a look at what they do to see whether it gives you some ideas. If I recall, they use cascading resource bundles with well-defined naming conventions. The latter means you know where to look and the former means that you can reuse properties across some portion of your package hierarchy. Many JSR 296 resources collected here.
type: Answer
answers question: http://stackoverflow.com/q/411517

http://stackoverflow.com/a/36742140
has body: A sample using stream API in java 8: int first = 0; int count = 10; Iterator&lt;Integer&gt; it = IntStream.range(first, first + count).iterator(); while (it.hasNext()) { System.out.println(it.next()); } Without iterator, it could be: int first = 0; int count = 10; IntStream.range(first, first + count).forEach(i -&gt; System.out.println(i));
type: Answer
upvote count: 7
answers question: http://stackoverflow.com/q/371026
score: 7
downvote count: 0

http://stackoverflow.com/comment/35405444
score: 0
type: AnswerComment
type: Comment
has text: yes @LukeQuinane this doesn't seem to handle the urls with query params :(
comment on: http://stackoverflow.com/a/17167743

http://stackoverflow.com/a/410352
score: 1
has body: Why not have the compiler do it? public interface F&lt;A, B&gt; { public B $(A a); } Then you can pass an F&lt;Double, Double&gt; to a method that expects an F&lt;? extends Number, ? extends Number&gt;. EDIT: You say you want to provide a single class for the type of a function with any number of arguments. This can be done with the Java type system. Conceptually every function has only one argument. A function with two arguments is equivalent to a function that returns another function. So here's a variable whose value is a function that takes two doubles: F&lt;Double, F&lt;Double, Double&gt;&gt; f; Here's a method that passes two doubles to a given function: public Double operate(F&lt;Double, F&lt;Double, Double&gt;&gt; f, double a, double b) { return f.$(a).$(b); } Or, consider a type L&lt;A extends L&gt; with two subclasses C&lt;E, T extends L&lt;T&gt;&gt; representing a "cons", and a terminator type N: public abstract class L&lt;A extends L&lt;A&gt;&gt; { private L() {} private static final N nil = new N(); public static N nil() { return nil; } public static final class N extends L&lt;N&gt; { private N() {} public &lt;E&gt; C&lt;E, N&gt; cons(final E e) { return new C&lt;E, L&gt;(e, this); } } public static final class C&lt;E, L extends L&lt;L&gt;&gt; extends L&lt;C&lt;E, L&gt;&gt; { private E e; private L l; private C(final E e, final L l) { this.e = e; this.l = l; } public E head() { return e; } public L tail() { return l; } public &lt;E&gt; C&lt;E, C&lt;E, L&gt;&gt; cons(final E e) { return new C&lt;E, C&lt;E, L&gt;&gt;(e, this); } } } In such a case, you can implement a function type thusly: public interface F&lt;A extends L&lt;A&gt;, B&gt; { public B $(A args); } The following method expects a function with two Double arguments (and returns a Double), along with two doubles to apply it to: public Double operate(F&lt;C&lt;Double, C&lt;Double, N&gt;&gt;, Double&gt; f, double a, double b) { return f.$(N.nil().cons(b).cons(a)); } The implementation of the F in…
has comment: http://stackoverflow.com/comment/235261
upvote count: 1
has comment: http://stackoverflow.com/comment/235302
answers question: http://stackoverflow.com/q/410343
type: Answer
has comment: http://stackoverflow.com/comment/235341
has comment: http://stackoverflow.com/comment/235260
downvote count: 0

catch-block
tag name: catch-block
type: Tag
tags question: http://stackoverflow.com/q/512624
tags question: http://stackoverflow.com/q/534718

http://stackoverflow.com/a/451341
has body: In my company we've created two custom scopes, one that will use Thread or Request and another that will use either Thread or Session. The idea is that a single scope can be used for scoped beans without having to change configuration based on the execution environment (JUnit or Servlet container). This also really comes in handy for when you run items in Quartz and no longer have a Request or Session scope available.
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/450557
has comment: http://stackoverflow.com/comment/272236
score: 4
has comment: http://stackoverflow.com/comment/272045
has comment: http://stackoverflow.com/comment/272055
has comment: http://stackoverflow.com/comment/272163
type: Answer

http://stackoverflow.com/a/540614
has body: Short example for counting tests with @BeforeClass, @AfterClass and @Before. public class CountTest { static int count; @BeforeClass public static void beforeClass() { count = 0; } @Before public void countUp() { count++; } @AfterClass public static void printCount() { System.out.println(count + " tests."); } @Test public void test1() { assertTrue(true); } // some more tests Output will be, e.g.: 5 tests.
upvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/535929
score: 1
downvote count: 1

http://stackoverflow.com/a/421821
score: 10
upvote count: 11
has comment: http://stackoverflow.com/comment/21887264
has comment: http://stackoverflow.com/comment/21887066
has comment: http://stackoverflow.com/comment/25067573
type: Answer
downvote count: 1
has comment: http://stackoverflow.com/comment/25085419
answers question: http://stackoverflow.com/q/421280
has comment: http://stackoverflow.com/comment/249281
has body: This method does the same thing but a little more simply and possibly a little more performant and in the event you are using reflection, it skips those frames automatically. The only issue is it may not be present in non-Sun JVMs, although it is included in the runtime classes of JRockit 1.4-->1.6. (Point is, it is not a public class). sun.reflect.Reflection /** Returns the class of the method realFramesToSkip frames up the stack (zero-based), ignoring frames associated with java.lang.reflect.Method.invoke() and its implementation. The first frame is that associated with this method, so getCallerClass(0) returns the Class object for sun.reflect.Reflection. Frames associated with java.lang.reflect.Method.invoke() and its implementation are completely ignored and do not count toward the number of "real" frames skipped. */ public static native Class getCallerClass(int realFramesToSkip); As far as what the realFramesToSkip value should be, the Sun 1.5 and 1.6 VM versions of java.lang.System, there is a package protected method called getCallerClass() which calls sun.reflect.Reflection.getCallerClass(3), but in my helper utility class I used 4 since there is the added frame of the helper class invocation.
has comment: http://stackoverflow.com/comment/247395

http://stackoverflow.com/a/359632
has comment: http://stackoverflow.com/comment/197151
has comment: http://stackoverflow.com/comment/193261
has comment: http://stackoverflow.com/comment/190432
has comment: http://stackoverflow.com/comment/190458
has comment: http://stackoverflow.com/comment/196172
score: 9
has comment: http://stackoverflow.com/comment/190405
has comment: http://stackoverflow.com/comment/191107
has comment: http://stackoverflow.com/comment/190515
type: Answer
upvote count: 11
has body: You could use a regex, i.e. something like String.matches("^[\\d\\-\\.]+$"); (if you're not testing for negative numbers or floating point numbers you could simplify a bit). Not sure whether that would be faster than the method you outlined though. Edit: in the light of all this controversy, I decided to make a test and get some data about how fast each of these methods were. Not so much the correctness, but just how quickly they ran. You can read about my results on my blog. (Hint: Jon Skeet FTW).
downvote count: 2
has comment: http://stackoverflow.com/comment/191731
answers question: http://stackoverflow.com/q/359625

http://stackoverflow.com/a/4193666
type: Answer
has body: Here this one will work: selenium.waitForPageToLoad("60000"); selenium.click("link= my link");
answers question: http://stackoverflow.com/q/633600
upvote count: 2
score: 2
downvote count: 0

http://stackoverflow.com/q/645137
has comment: http://stackoverflow.com/comment/581561
has title: Calling a Java method with the implicit Graphics parameter, like repaint() or accessing the Graphics in a JPanel
has body: When you call repaint(), for example, repaintComponent(Graphics) gets called, and then you can call it from outside the class without the parameter Graphics. I'd like to have a function that takes more parameters I'm using, but I still want to be able to draw with it, so I need to be able to make a call like that (eg repaint() calls repaintComponent(Graphics)) or get access to Graphics to call the function, assuming it would get repainted by explicitly calling repaintComponent() anyway. I've been thinking about putting the data in the object and then drawing, but I'm not sure if it'd work and it would be pretty complicated, I think.
tagged with: java
type: Question
tagged with: graphics
has comment: http://stackoverflow.com/comment/458763
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/646765
type: UnansweredQuestion

http://stackoverflow.com/comment/465348
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/645327
has text: Thanks for your additional questions. I edited my question to include the following: "Yes, the process we are trying to start from the webservice was created by a fellow team member [cue: your eyes roll... now]"
type: Comment

http://stackoverflow.com/a/442066
has body: To borrow a thought from Andy Hunt, even your private methods must have some side effect that you're interested in. In other words, they must be called from some public method and perform an interesting task that causes the state of your object to change. Test for that state change. Suppose you have public method pubMethod and private method privMethod. When you call pubMethod, it in turn calls privMethod to perform a task (perhaps parsing a String). The pubMethod then uses this parsed String to set member variables' values in some way or to influence its own return value. Test by watching for the desired effect on pubMethod's return value or on member variables (possibly by using accessors to get to them).
answers question: http://stackoverflow.com/q/440786
score: 2
upvote count: 2
downvote count: 0
type: Answer

http://stackoverflow.com/a/3847324
answers question: http://stackoverflow.com/q/547219
type: Answer
score: -1
has body: If you get the no cipher overlap error on firefox, and you have left it at default settings, you are using what must be a very insecure site trying to use a very weak "export grade" cipher. Use of these ciphers is discouraged these days and I personally would stop using a site trying to use such a weak cipher.
downvote count: 2
upvote count: 1

http://stackoverflow.com/q/399546
has answer: http://stackoverflow.com/a/53429345
has answer: http://stackoverflow.com/a/1260517
type: Question
has answer: http://stackoverflow.com/a/402331
has answer: http://stackoverflow.com/a/29442491
has title: Synthetic Class in Java
has answer: http://stackoverflow.com/a/24271953
tagged with: synthetic
answer count: 13
tagged with: class
has answer: http://stackoverflow.com/a/6452833
has answer: http://stackoverflow.com/a/28282011
downvote count: 0
has answer: http://stackoverflow.com/a/58516673
favorite count: 0
accepted answer: http://stackoverflow.com/a/402331
has body: What is a synthetic class in Java? Why should it be used? How can I use it?
has answer: http://stackoverflow.com/a/399998
upvote count: 157
has comment: http://stackoverflow.com/comment/100620486
has answer: http://stackoverflow.com/a/400237
score: 157
has answer: http://stackoverflow.com/a/25176169
possible better answer: http://stackoverflow.com/a/399998
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/400206
has answer: http://stackoverflow.com/a/399554
has comment: http://stackoverflow.com/comment/75168582
tagged with: java

http://stackoverflow.com/a/5583498
has comment: http://stackoverflow.com/comment/17009193
answers question: http://stackoverflow.com/q/573184
has body: Android has always had the Uri class as part of the SDK: http://developer.android.com/reference/android/net/Uri.html You can simply do something like: String requestURL = String.format("http://www.example.com/?a=%s&amp;b=%s", Uri.encode("foo bar"), Uri.encode("100% fubar'd"));
has comment: http://stackoverflow.com/comment/21315458
downvote count: 0
upvote count: 45
score: 45
type: Answer

textures
tags question: http://stackoverflow.com/q/623923
tag name: textures
type: Tag

http://stackoverflow.com/comment/80939731
type: AnswerComment
type: Comment
score: 18
comment on: http://stackoverflow.com/a/27206052
has text: This may do more than what was asked for, but it does precisely what I wanted (get a map of distinct elements in a list to their counts). Furthermore, this question was the top result in Google when I searched.

http://stackoverflow.com/comment/1201737
type: Comment
comment on: http://stackoverflow.com/a/441389
score: 0
has text: @Pop: I disagree with "good class design more and more requires that your classes are serializable when they can be": that is over-engineering. If there's no need for them to be serializable, why should they? It's yet another cost for class design/impl, and costs are only warranted by benefit. I actually seldom need anything to be serializable; including objects I do need to trasfer.
type: AnswerComment

http://stackoverflow.com/comment/71886749
has text: @fmsf, not so in Java. A long is defined as having 64 bits independently of the machine word length.
type: AnswerComment
comment on: http://stackoverflow.com/a/517539
type: Comment
score: 1

http://stackoverflow.com/a/8351463
has body: It doesn't look like that's possible. You can increase the space between the chart and the legend box, but there's no option to increase the space between the box and the text. Perhaps you could try appending some spaces onto the series name when passing the data to BIRT (yes, that does sound like an awful workaround).
score: 0
answers question: http://stackoverflow.com/q/586478
type: Answer

http://stackoverflow.com/comment/134064014
score: 0
type: Comment
type: QuestionComment
has text: For anyone having to ask this, the simple answer is code design. Design the code to avoid errors from occurring, or design code to "expected" that an error is possible, and catch it. Else, catching exceptions should only be expected within the code design.
comment on: http://stackoverflow.com/q/581878

http://stackoverflow.com/comment/9497843
comment on: http://stackoverflow.com/a/518802
type: AnswerComment
score: 0
type: Comment
has text: Yes, the important part is that you have the global-method-security in the same Spring context as the components.

http://stackoverflow.com/comment/192784
comment on: http://stackoverflow.com/a/362588
type: AnswerComment
score: 0
type: Comment
has text: Thanks - any pointers to where I should be looking to find this defined, as I'm going to have to persuade some people who believe this is a valid thing to do?

http://stackoverflow.com/a/568300
type: AcceptedAnswer
downvote count: 0
score: 8
has comment: http://stackoverflow.com/comment/387866
upvote count: 8
type: Answer
answers question: http://stackoverflow.com/q/568227
has body: AFAIK, this just isn't possible without involving native extensions to Java in some manner - there is no Java API for this. You could take a look at the JNA project. It uses native code, but you don't have to write any - it's done for you. EDIT: If all you want to do is validate the username/password, then I believe that the JNDI/LDAP direction may work for you - I've done this before on the AS/400 from Java, though I was not totally happy with the end result. If you want to cause the O/S to recognize your JVM process as being credentialed as a particular user, you are going to need some form of access to non-portable native API's. BTW, what O/S(s) are we talking about. EDIT2: I am going to post fragments from how I used LDAP to verify a username/password, on the off chance that that is what you are after; these are lifted straight from my code, not intended to be directly compilable. This is some of the first Java code I ever wrote, please be merciful: import java.security.*; import java.util.*; import javax.naming.*; import javax.naming.directory.*; import javax.naming.ldap.*; ... private Hashtable masterEnv; // master environment settings private String authMethod; // default authentication method ... public void init() { // NOTE: Important to use a non-pooled context and a clone of the environment so that this authenticated // connection is not returned to the pool and used for other operations masterEnv=new Hashtable(); masterEnv.put(Context.INITIAL_CONTEXT_FACTORY,ldapFactory); masterEnv.put(Context.PROVIDER_URL,providerUrl); masterEnv.put(Context.SECURITY_PROTOCOL,secProtocol); masterEnv.put(Context.REFERRAL,"follow"); masterEnv.put("com.sun.jndi.ldap.connect.pool","false"); authMethod=System.getProperty("authenticationMethod","simple"); } ... private void verifyUserPassword(String ui, String pw, String am) throws NameNotFoundException, AuthenticationException, AuthenticationNotSupportedException, NamingException, NamingException { // ui=user ID // pw=passwor…
accepted answer of: http://stackoverflow.com/q/568227

http://stackoverflow.com/comment/341675
has text: Be aware: XStream does not handle namespaces properly.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/528669

http://stackoverflow.com/comment/67888874
has text: Perhaps clarity could be helped by using the variable name `newlineOrBlank` rather than `newline`.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/448347
type: Comment

http://stackoverflow.com/q/376093
answer count: 11
score: 33
has answer: http://stackoverflow.com/a/376307
has answer: http://stackoverflow.com/a/376275
accepted answer: http://stackoverflow.com/a/376275
favorite count: 0
has answer: http://stackoverflow.com/a/12900050
has answer: http://stackoverflow.com/a/376231
has answer: http://stackoverflow.com/a/72346654
possible better answer: http://stackoverflow.com/a/44527914
has answer: http://stackoverflow.com/a/44527914
upvote count: 33
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/376102
has answer: http://stackoverflow.com/a/376118
has answer: http://stackoverflow.com/a/45403414
downvote count: 0
tagged with: annotations
has body: @Column(name="DateOfBirth") private Date dateOfBirth; I specifically need the above code to create a column named "DateOfBirth," instead Hibernate gives me a column named date_of_birth. How can I change this? Is there a web.xml property? I came across DefaultNamingStrategy and ImprovedNamingStrategy, but not sure how to specify one or the other.
type: Question
has comment: http://stackoverflow.com/comment/204177
has answer: http://stackoverflow.com/a/376196
has answer: http://stackoverflow.com/a/79267703
has title: hibernate column name issues
tagged with: java
tagged with: hibernate
has comment: http://stackoverflow.com/comment/204118

http://stackoverflow.com/q/363329
tagged with: java
has body: In Netbeans (I have the 6.5 version), in the project properties under Application> Webstart there is a self-signed checkbox. What is its meaning? When I need to use it?
type: Question
answer count: 1
has title: What is the meaning of Self-signed checkbox in WebStart properties in Netbeans
tagged with: jar-signing
upvote count: 1
has answer: http://stackoverflow.com/a/363379
accepted answer: http://stackoverflow.com/a/363379
favorite count: 0
tagged with: netbeans
downvote count: 0
type: AnsweredQuestion
score: 1

http://stackoverflow.com/comment/31768362
type: QuestionComment
comment on: http://stackoverflow.com/q/577379
has text: possible duplicate of [Difference between thread's context class loader and normal classloader](http://stackoverflow.com/questions/1771679/difference-between-threads-context-class-loader-and-normal-classloader)
score: 0
type: Comment

http://stackoverflow.com/comment/35361223
has text: Could you explain briefly how this works/what it does?
type: Comment
score: 1
comment on: http://stackoverflow.com/a/12053269
type: AnswerComment

http://stackoverflow.com/comment/399303
type: AnswerComment
comment on: http://stackoverflow.com/a/586953
type: Comment
has text: it would make a difference if he is somehow keeping a hold of some of the other objects which in turn is causing the streams to be saved. THough once the stream is closed I cannot see why it would keep the file locked. I suspect he has some sort of resource leak.
score: 0

http://stackoverflow.com/q/516049
has answer: http://stackoverflow.com/a/516080
has answer: http://stackoverflow.com/a/42544494
has comment: http://stackoverflow.com/comment/15533923
has comment: http://stackoverflow.com/comment/329667
linked to: http://stackoverflow.com/q/29362048
has answer: http://stackoverflow.com/a/516059
answer count: 10
has answer: http://stackoverflow.com/a/516061
tagged with: finally
favorite count: 0
has body: I'm a Java rookie and I was wondering, if I have the following typical Java code public class MyApp { public static void main(String[] args) { try { // do stuff } catch { // handle errors } finally { // clean up connections etc. } } } does the JVM guarantee that the finally block will always be run? To understand where I'm coming from, I'm used to C/C++ programs that might just crash if you dereference a NULL pointer and you can't have any code to be run after that. But as I understand Java and the whole GC / managed memory business in general, there's no such thing as a null pointer dereferencing, everything is a catchable expection, so there's not really a way for my program to crash that could make it skip the finally, or is there? For example, in Python, I usually do try: # do stuff except AnExceptionIKnewMightHappen: # react in an appropriate way except: # log that weird error I had not known could happen and I have never had any app die without passing through my code. Of course, if the OS for some reason kills the process (or if something kills the whole system, like pulling the plug) there's not much Java can do. Also, from PHP I know non-catchable errors that you can't protect against, even though the interpreter was still there after it happened (at least it is able to output a proper message). Edit: Just for clarity (it wasn't really misunderstood by anyone), let me add that I was looking for things inside my code that could lead to the finally being bypassed. So pointing to System.exit was a helpful reminder, even though I can't see why I would want to do something like that. The JVM exiting is a rather obvious way and I'd count that as an external cause. The note pointing out that you also have to remember the possibilty of threads exiting while the JVM and the app keep running was very helpful, because even though it also seems obvious to me now, I hadn't thought of it.
has answer: http://stackoverflow.com/a/4066500
score: 25
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/519207
accepted answer: http://stackoverflow.com/a/516060
tagged with: java
tagged with: error-handling
possible better answer: http://stackoverflow.com/a/516076
type: Question
has answer: http://stackoverflow.com/a/516060
has answer: http://stackoverflow.com/a/516077
has title: In Java, is the "finally" block guaranteed to be called (in the main method)?
downvote count: 0
has answer: http://stackoverflow.com/a/516089
has answer: http://stackoverflow.com/a/516076
upvote count: 25

http://stackoverflow.com/a/570469
has body: If you are only accessing this database from within Java, a better solution would be Connector/MXJ. This will allow you to simply make a well formed JDBC call, and the library will take care of the database startup for you automatically. Basically, the jar file contains in instance (or, for multiple platforms, instances) of the mysql server executable. It also contains a skeleton where you can load prepopulated data for your database. The first time you access the JDBC connection, it will pull the proper mysql server out of the jar, and create the database in the current directory (using the prepopulated data from above). Any changes from that point on will be persistent, as expected. Here's some more info: Launching via JDBC Launching via a Java Object
has comment: http://stackoverflow.com/comment/382471
type: Answer
score: 1
upvote count: 2
has comment: http://stackoverflow.com/comment/382140
downvote count: 1
answers question: http://stackoverflow.com/q/570384

http://stackoverflow.com/comment/5720772
has text: hey not such a bad suggestion: http://code.google.com/apis/chart/docs/gallery/graphviz.html
type: AnswerComment
comment on: http://stackoverflow.com/a/562041
type: Comment
score: 1

http://stackoverflow.com/q/427750
type: AnsweredQuestion
tagged with: dependency-injection
has answer: http://stackoverflow.com/a/39692358
has answer: http://stackoverflow.com/a/427970
tagged with: java
answer count: 6
score: 15
has body: I've been a fan of EasyMock for many years now, and thanks to SO I came across references to PowerMock and it's ability to mock Constructors and static methods, both of which cause problems when retrofitting tests to a legacy codebase. Obviously one of the huge benefits of unit testing (and TDD) is the way it leads to (forces?) a much cleaner design, and it seems to me that the introduction of PowerMock may detract from that. I would see this mostly manifesting itself as: Going back to initialising collaborators rather than injecting them Using statics rather than making the method be owned by a collaborator In addition to this, something doesn't quite sit right with me about my code being bytecode manipulated for the test. I can't really give a concrete reason for this, just that it makes me feel a little uneasy as it's just for the test and not for production. At my current gig we're really pushing for the unit tests as a way for people to improve their coding practices and it feels like introducing PowerMock into the equation may let people skip that step somewhat and so I'm loathe to start using it. Having said that, I can really see where making use of it can cut down on the amount of refactoring that needs to be done to start testing a class. I guess my question is, what are peoples experiences of using PowerMock (or any other similar library) for these features, would you make use of them and how much overall do you want your tests influencing your design?
upvote count: 15
tagged with: junit
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/427970
has answer: http://stackoverflow.com/a/1056229
has title: Using PowerMock or How much do you let your tests affect your design?
has answer: http://stackoverflow.com/a/428159
possible better answer: http://stackoverflow.com/a/1056229
has answer: http://stackoverflow.com/a/446250
tagged with: unit-testing
type: Question
has answer: http://stackoverflow.com/a/429747

http://stackoverflow.com/comment/238450
has text: I've never installed it personally. Have installed Bugzilla - no walk in the park but manageable for someone without much Perl experience (i.e. me). The instructions were pretty good.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/413752

http://stackoverflow.com/a/4735911
answers question: http://stackoverflow.com/q/499010
has comment: http://stackoverflow.com/comment/66201031
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/120163584
has body: I have used this library, similar to jchardet for detecting encoding in Java: https://github.com/albfernandez/juniversalchardet
score: 81
has comment: http://stackoverflow.com/comment/90224575
has comment: http://stackoverflow.com/comment/6328608
type: Answer
upvote count: 84
downvote count: 3
accepted answer of: http://stackoverflow.com/q/499010
has comment: http://stackoverflow.com/comment/91609773

http://stackoverflow.com/a/736537
answers question: http://stackoverflow.com/q/510820
upvote count: 3
type: Answer
has body: See my answer to another question for some more examples of RTSJ commercial-grade implementations. The latest version (2.1) is compliant with JDK1.5, so you should have Swing/AWT available. While it is feasible to write a GUI to execute within the same JVM as real-time processes, it's not clear that this is a good architectural decision. It is more likely that you'd prefer to isolate the real-time behaviors in a JVM and provide a separable interface that implements to GUI in a separate memory space. In principle, you are supposed to be able to write RTSJ code such that it runs in the same JVM with non-real-time threads (and I have done a lot of this) but it can be tough to get synchronization right.
downvote count: 0
score: 3

http://stackoverflow.com/comment/101805178
score: 1
comment on: http://stackoverflow.com/a/480362
has text: @kuhajeyan Some reasons: 1) Perhaps the biggest reason is that JVM has always been multi-platform, running on most major OS:s, while CLR has been closely tied to Window (Windows is still at least privileged, I think). 2) The Java ecosystem has been seen as being bigger, having more library and components to interface with. 3) The runtime representation of generics on CLR can actually get in the way for dynamically typed languages, making interop with Java easier for those language. 4) The Java platform has been open source for long time, which is attractive to many language developers.
type: AnswerComment
type: Comment

http://stackoverflow.com/a/545452
downvote count: 0
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/545391
has body: I have come across some cases where this causes problems. During deserialization, some frameworks will not call the constructor, I don't know how or why they choose to do this but it happens. This can result in your values being null. I have also come across the case where the constructor is called but for some reason member variables are not initialized. In actual fact I'd use the following code instead of yours: public class ItemManager { ItemMaster itemMaster = new ItemMaster(); List&lt;ItemComponentManager&gt; components = new ArrayList&lt;ItemComponentManager&gt;(); ItemManager() { ... } ... }

http://stackoverflow.com/a/512971
score: 0
type: Answer
has body: I'm not sure if replacing a full-fledged Java desktop application with Flex is the best alternative. From Adobe Flex page: Flex is a highly productive, free open source framework for building and maintaining expressive web applications that deploy consistently on all major browsers, desktops, and operating systems. Adobe AIR is probably a better replacement for desktop applications, if you're considering Adobe realms of products.
answers question: http://stackoverflow.com/q/448561

http://stackoverflow.com/q/411982
favorite count: 0
tagged with: swing
accepted answer: http://stackoverflow.com/a/412820
has comment: http://stackoverflow.com/comment/236771
score: 4
type: AnsweredQuestion
has title: Override JComponent.getBaselineResizeBehavior() but keep Java5 compatibility
tagged with: java
has answer: http://stackoverflow.com/a/412002
type: Question
upvote count: 4
possible better answer: http://stackoverflow.com/a/412720
has comment: http://stackoverflow.com/comment/236787
has answer: http://stackoverflow.com/a/412720
has answer: http://stackoverflow.com/a/412128
has comment: http://stackoverflow.com/comment/236825
has answer: http://stackoverflow.com/a/412820
tagged with: baseline
has body: For my Swing project, I need to support both Java 5 and Java 6. I have defined a custom JComponent (call it Picture) and, after embedding it in a JScrollPane, I put it in a JPanel that uses DesignGridLayout manager. DesignGridLayout supports baseline alignment thanks to swing-layout open source library (implements baseline support for Java 5 and provides compatibility with the new Java 6 baseline support). My Picture class overrides public int getBaseline(int width, int height) so that I can define a correct baseline for it. Note that "override" is not completely correct: it overrides the method on Java6 but defines it in Java5. When I run my sample app on Java5, everything is fine: the Picture baseline I have defined is correctly used. However, when I use Java6, my Picture#getBaseline() method does not get called! And of course the baseline alignment of my picture is terrible (centered). After checking in Java6 source, I have seen that, in BasicScrollPaneUI, getBaseline() calls first getBaselineResizeBehavior() on the viewport component (my Picture instance). And it will call getBaseline() only if getBaselineResizeBehavior() returns Component.BaselineResizeBehavior.CONSTANT_ASCENT. Now my problem is that getBaselineResizeBehavior() is a Java6 method of JComponent that I cannot implement in Java5 because it returns an enum Component.BaselineResizeBehavior which does not exist in Java5. So my question (finally) is: how can I implement (or simulate?) getBaselineResizeBehavior() so that my class can still compile and run in a Java5 environment?
downvote count: 0
answer count: 4

http://stackoverflow.com/a/484180
has comment: http://stackoverflow.com/comment/300721
has comment: http://stackoverflow.com/comment/300798
has comment: http://stackoverflow.com/comment/300703
has comment: http://stackoverflow.com/comment/300760
has comment: http://stackoverflow.com/comment/300895
downvote count: 1
has comment: http://stackoverflow.com/comment/300891
has comment: http://stackoverflow.com/comment/300888
has comment: http://stackoverflow.com/comment/300770
has comment: http://stackoverflow.com/comment/300724
type: Answer
has comment: http://stackoverflow.com/comment/301500
has comment: http://stackoverflow.com/comment/300677
has comment: http://stackoverflow.com/comment/300792
has comment: http://stackoverflow.com/comment/300658
score: 7
has comment: http://stackoverflow.com/comment/300746
upvote count: 8
has comment: http://stackoverflow.com/comment/300796
has comment: http://stackoverflow.com/comment/300690
answers question: http://stackoverflow.com/q/484119
has comment: http://stackoverflow.com/comment/300740
has comment: http://stackoverflow.com/comment/300785
has body: In your example you're creating two threads to do the work that could be done by one. And introducing I/O delays into the mix. Do you have a better example? Or did I just answer your question. To pull some of the comments (at least my view of them) into the main response: Concurrency introduces complexity into an application. Instead of dealing with a single linear flow of data, you now have to be concerned about sequencing of independent data flows. In some cases, the added complexity may be justified, particularly if you can leverage multiple cores/CPUs to do CPU-intensive work. If you are in a situation where you can benefit from concurrent operations, there's usually a better way to coordinate the flow of data between threads. For example, passing objects between threads using a concurrent queue, rather than wrapping the piped streams in object streams. Where a piped stream may be a good solution is when you have multiple threads performing text processing, a la a Unix pipeline (eg: grep | sort). In the specific example, the piped stream allows use of an existing RequestEntity implementation class provided by HttpClient. I believe that a better solution is to create a new implementation class, as below, because the example is ultimately a sequential operation that cannot benefit from the complexity and overhead of a concurrent implementation. While I show the RequestEntity as an anonymous class, reusability would indicate that it should be a first-class class. post.setRequestEntity(new RequestEntity() { public long getContentLength() { return 0-1; } public String getContentType() { return "text/xml"; } public boolean isRepeatable() { return false; } public void writeRequest(OutputStream out) throws IOException { output.setByteStream(out); serializer.write(doc, output); } });

http://stackoverflow.com/comment/319016
type: Comment
comment on: http://stackoverflow.com/a/503011
type: AnswerComment
has text: The implementation would suit another SO question :)
score: 0

http://stackoverflow.com/a/516363
answers question: http://stackoverflow.com/q/516142
type: AcceptedAnswer
downvote count: 0
has body: The documentation suggests that the JMX agent uses a local port -- something unreachable from outside the machine -- unless you specify the following property: com.sun.management.jmxremote.port=portNum This is for security reasons, as well as for the reason given by Mr Potato Head. Thus, it looks like Java 6 does not open a default remotely accessible port for JMX. EDIT: Added after the OP added an answer with more information. Another option you have is to somehow create a local proxy that listens to all local JMX connections and exports this information. This way, you don't need to have such magic configuration of each JVM instance on the server. Instead the local proxy can connect to all JVMs via JMX and then somehow expose this information remotely. I am not positive exactly how you would implement this, but something like this may be less work than what you otherwise have to do to expose all of your JVMs remotely via JMX.
score: 38
upvote count: 38
accepted answer of: http://stackoverflow.com/q/516142
type: Answer

http://stackoverflow.com/comment/265256
type: Comment
comment on: http://stackoverflow.com/q/443558
type: QuestionComment
score: 0
has text: I don't follow your objection to serialisation. You can serialise maps, have maps to serialised objects, etc.

http://stackoverflow.com/comment/37587468
score: 2
type: AnswerComment
has text: `patch` can be simpler, since you want to get back default behaviors overridden by JTextArea. Just 2 lines: `component.setFocusTraversalKeys(KeyboardFocusManager.{FORWARD,BACKWARD}_TRAVERSAL_KEYS, null)` See http://stackoverflow.com/a/5043957/411282
type: Comment
comment on: http://stackoverflow.com/a/525867

http://stackoverflow.com/a/612538
has comment: http://stackoverflow.com/comment/425292
answers question: http://stackoverflow.com/q/612521
type: Answer
has comment: http://stackoverflow.com/comment/425251
has comment: http://stackoverflow.com/comment/117346911
score: 10
has body: The best you can do with the Java library is, I think: if (asList(a, b, c, d).contains(null)) {
upvote count: 10
has comment: http://stackoverflow.com/comment/117341089
has comment: http://stackoverflow.com/comment/425297
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/612521
downvote count: 0

http://stackoverflow.com/comment/64782169
score: 0
type: Comment
comment on: http://stackoverflow.com/a/4691609
has text: @Mubasher: ${basedir} and ${file.separator} are provided by default by Ant, you don't need to set them. You can try this in a simple build.xml file: <?xml version="1.0"?> ${basedir} ${file.separator}
type: AnswerComment

http://stackoverflow.com/comment/74404949
has text: @Benj: no surprise that answer from 8 years ago is no longer relevant ;-)
comment on: http://stackoverflow.com/a/553421
type: AnswerComment
score: 0
type: Comment

jmenupopup
tag name: jmenupopup
tags question: http://stackoverflow.com/q/482041
type: Tag

http://stackoverflow.com/comment/97885958
type: Comment
has text: IntelliJ gives me a hint that I can improve things by changing this solution to the String.join example from other answers with the following reasoning "Reports stream API call chains which can be simplified. It allows to avoid creating redundant temporary objects when traversing a collection."
score: 3
comment on: http://stackoverflow.com/a/38546936
type: AnswerComment

http://stackoverflow.com/comment/456504
type: Comment
comment on: http://stackoverflow.com/a/642524
type: AnswerComment
has text: Can you clarify the "extra complication" part? What is the exact benefit that you get from storing IDE specific files?
score: 0

http://stackoverflow.com/a/554888
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/554767
has body: Getters and setters are not just for protection/privacy. The main use is to change the way you expose the underlying data. For example, in asp.net c# the visible property of a control may have something such as: private bool visible = true; public bool Visible { get { return visible &amp;&amp; Parent.Visible; } set { visible = value; } } The external property (accessor/mutator) has a different meaning to the underlying variable. In addition, if you don't have the above functionality when you begin, when you have simple gets / sets it becomes something that you can add at a later date, easily. As for the performance point and saving every ounce of processor and memory you can. If this is going to make a noticeable impact then you're probably better off looking at a different language.
upvote count: 2
type: Answer

http://stackoverflow.com/comment/39728304
has text: Yes, it is *permissible* under the JLS for a JVM to unload the system class loader. How often does it happen? Would you consider the necessary manipulation of the class loader (system or otherwise) to be atypical? The point of my answer is that unless deliberate action is taken, a class stays loaded.
type: Comment
score: 0
comment on: http://stackoverflow.com/a/405402
type: AnswerComment

http://stackoverflow.com/q/453018
has answer: http://stackoverflow.com/a/35435739
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/14411695
tagged with: large-files
downvote count: 0
tagged with: line-numbers
score: 231
has answer: http://stackoverflow.com/a/39232425
tagged with: java
has answer: http://stackoverflow.com/a/4425569
has body: I use huge data files, sometimes I only need to know the number of lines in these files, usually I open them up and read them line by line until I reach the end of the file I was wondering if there is a smarter way to do that
has answer: http://stackoverflow.com/a/453068
linked to: http://stackoverflow.com/q/729692
has answer: http://stackoverflow.com/a/63173649
type: Question
has answer: http://stackoverflow.com/a/5342096
has answer: http://stackoverflow.com/a/1647015
has answer: http://stackoverflow.com/a/46661831
has title: Number of lines in a file in Java
has answer: http://stackoverflow.com/a/15704031
has answer: http://stackoverflow.com/a/28639152
upvote count: 231
has answer: http://stackoverflow.com/a/12537734
has answer: http://stackoverflow.com/a/453025
has answer: http://stackoverflow.com/a/17866694
favorite count: 0
has answer: http://stackoverflow.com/a/25829891
possible better answer: http://stackoverflow.com/a/5342096
has answer: http://stackoverflow.com/a/453067
answer count: 20
accepted answer: http://stackoverflow.com/a/453067
has answer: http://stackoverflow.com/a/53373144
has answer: http://stackoverflow.com/a/453033
has answer: http://stackoverflow.com/a/54891455
has answer: http://stackoverflow.com/a/77446046

http://stackoverflow.com/q/564759
linked to: http://stackoverflow.com/q/20938189
tagged with: user-interface
favorite count: 0
type: UnansweredQuestion
score: 11
has answer: http://stackoverflow.com/a/564791
downvote count: 0
tagged with: java
tagged with: eclipse
type: Question
has comment: http://stackoverflow.com/comment/376010
has title: How to redirect all console output to a GUI textbox?
upvote count: 11
has body: I currently have a program that prints lines of text to the screen in various manners such as 'System.out.println()' statements and for loops the print all elements in an array to screen. I am now adding a GUI to this program. My problem is that I want to print everything that prints to eclipse's console to a textbox in my GUI instead. Is this possible and if so how would I go about doing this. Thanks in Advance.
answer count: 2
has answer: http://stackoverflow.com/a/564806

http://stackoverflow.com/comment/272194
comment on: http://stackoverflow.com/q/442494
has text: but i cam using sftp-3 as the file transfer protocol using the software winscp. How do i configure to use binary mode?
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/628451
has body: Here are some of the links I used to help understand JAAS: http://www.owasp.org/index.php/JAAS_Tomcat_Login_Module http://www.javaworld.com/jw-09-2002/jw-0913-jaas.html http://jaasbook.wordpress.com/ http://roneiv.wordpress.com/2008/02/18/jaas-authentication-mechanism-is-it-possible-to-force-j_security_check-to-go-to-a-specific-page/ Also have a look at the Apache tomcat realms configuration how-to: http://tomcat.apache.org/tomcat-6.0-doc/realm-howto.html
downvote count: 2
answers question: http://stackoverflow.com/q/628416
has comment: http://stackoverflow.com/comment/63351583
accepted answer of: http://stackoverflow.com/q/628416
upvote count: 26
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/73512263
type: Answer
score: 24

http://stackoverflow.com/comment/371248
comment on: http://stackoverflow.com/a/542740
type: AnswerComment
score: 0
has text: I'm marking this as the correct answer since it does what I originally wanted. Also, laz provided me with the secondary answer (below) that I needed for the final solution.
type: Comment

http://stackoverflow.com/comment/129518261
score: 0
comment on: http://stackoverflow.com/a/46212970
type: Comment
has text: public static String lpad(String pString, int pTotalLength, char pPad) { return new String(lpad(pString.toCharArray(), pTotalLength, pPad)); }
type: AnswerComment

http://stackoverflow.com/q/573624
favorite count: 0
score: 2
downvote count: 0
accepted answer: http://stackoverflow.com/a/591584
tagged with: web-services
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/591584
tagged with: java
tagged with: apache-axis
has body: I’m trying to migrate a client side application from Axis to Axis 2. The application also supports connection through RMI so previously, we abstracted away the connection by using the stub and the locator file. For example, we did something like the following: AddFunctionLocator locator = new AddFunctionLocator (); AddFunction api = (AddFunctionSoapBindingStub) locator.getAddFunction() api.addInt(5, 3); And this worked because the locator class would return the stub class, which in addition to extending org.apache.axis.client.Stub, also implemented the AddFunction interface class. However, in Axis 2, using WSDL2Java, I cannot figure out if this arrangement is possible since neither the locator class is generated nor does the Stub class implement the original AddFunction interface class. Does anyone have any advice on either the proper options to use with WSDL2Java or another way that I implement so I can keep this abstraction in our client code? Thanks, Richard
type: Question
upvote count: 2
has title: Locator and stub class while migrating client side application from Axis to Axis 2
tagged with: axis
answer count: 1

http://stackoverflow.com/comment/306435
score: 0
has text: How big an effort is it to switch from DBCP to JDBC pooling?
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/490358

http://stackoverflow.com/q/617414
has answer: http://stackoverflow.com/a/1506777
has answer: http://stackoverflow.com/a/375927
has answer: http://stackoverflow.com/a/6403880
type: Question
has answer: http://stackoverflow.com/a/60206442
has answer: http://stackoverflow.com/a/8998916
has body: Is there a standard and reliable way of creating a temporary directory inside a Java application? There's an entry in Java's issue database, which has a bit of code in the comments, but I wonder if there is a standard solution to be found in one of the usual libraries (Apache Commons etc.) ?
linked to: http://stackoverflow.com/q/2513573
has answer: http://stackoverflow.com/a/375997
has answer: http://stackoverflow.com/a/24384306
has answer: http://stackoverflow.com/a/14574100
has answer: http://stackoverflow.com/a/375925
has answer: http://stackoverflow.com/a/43975187
tagged with: file-io
has answer: http://stackoverflow.com/a/618273
score: 417
has answer: http://stackoverflow.com/a/617438
downvote count: 0
tagged with: directory
upvote count: 417
favorite count: 0
has answer: http://stackoverflow.com/a/4672884
has answer: http://stackoverflow.com/a/6185359
has answer: http://stackoverflow.com/a/7803748
has answer: http://stackoverflow.com/a/8794812
has answer: http://stackoverflow.com/a/1305966
tagged with: temporary-directory
answer count: 18
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/617438
has title: How to create a temporary directory/folder in Java?
has answer: http://stackoverflow.com/a/37945114
tagged with: java
possible better answer: http://stackoverflow.com/a/6403880
linked to: http://stackoverflow.com/q/779519
tagged with: file

http://stackoverflow.com/comment/15128378
comment on: http://stackoverflow.com/a/859025
score: 2
type: AnswerComment
has text: The line `final DirectColorModel cm = (DirectColorModel) img.getColorModel();` seems to be an impossible cast -- ColorModel can't be cast to DirectColorModel (I tried the code and got a cast exception at runtime)
type: Comment

http://stackoverflow.com/a/421349
upvote count: 45
has body: Sounds like you're trying to avoid passing a reference to this into the method. Passing this is way better than finding the caller through the current stack trace. Refactoring to a more OO design is even better. You shouldn't need to know the caller. Pass a callback object if necessary.
has comment: http://stackoverflow.com/comment/29795143
downvote count: 11
has comment: http://stackoverflow.com/comment/2132475
type: Answer
score: 34
has comment: http://stackoverflow.com/comment/57374776
has comment: http://stackoverflow.com/comment/245344
answers question: http://stackoverflow.com/q/421280
has comment: http://stackoverflow.com/comment/2129340

http://stackoverflow.com/comment/456362
comment on: http://stackoverflow.com/a/642917
has text: In a "simple Java Array" you can set the pointer reference of the value in the array to "null" (and shift the other elements, maybe). That should be an answer.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/359213
upvote count: 2
tagged with: java
has body: On a Unix systems it's very easy to compile the CLASSPATH by using find: LIBDIR=`find lib/ -name \*.jar` for DIR in $LIBDIR: do CLASSPATH="$CLASSPATH:$DIR" done java -classpath $CLASSPATH com.example.MyClass What would be the aquivalent in a Windows batchfile?
has comment: http://stackoverflow.com/comment/190157
tagged with: classpath
type: Question
has answer: http://stackoverflow.com/a/359254
has answer: http://stackoverflow.com/a/359242
possible better answer: http://stackoverflow.com/a/359254
tagged with: batch-file
answer count: 2
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/359242
tagged with: windows
has title: Compile CLASSPATH in a Windows batchfile
score: 2
type: AnsweredQuestion

dining-philosopher
type: Tag
tags question: http://stackoverflow.com/q/604667
tag name: dining-philosopher

http://stackoverflow.com/comment/440443
type: Comment
score: 2
comment on: http://stackoverflow.com/a/627831
has text: +1 on constructor injection. Expresses dependencies a lot stronger and removes the need for 'funny' setters
type: AnswerComment

http://stackoverflow.com/a/370341
downvote count: 1
accepted answer of: http://stackoverflow.com/q/370310
upvote count: 12
type: AcceptedAnswer
type: Answer
answers question: http://stackoverflow.com/q/370310
has body: Well bear in mind they didn't get there by them selves ( I think a read some questions about dynamically creating these panels at runtime ) In the answers posted there, someone said you should kept reference to those textfields in an array. That's exactly what you need here: List&lt;JTextField&gt; list = new ArrayLists&lt;JTextField&gt;(); // your code... for (int i=0; i&lt;maxPoints; i++) { JTextField textField = new JTextField(); points.add(textField); list.add( textField ); // keep a reference to those fields. } // Later for( JTextField f : list ) { System.out.println( f.getText() ) ; } Wasn't that easy? Just remember to keep these kinds of artifacts ( list ) as private as possible. They are for your control only, I don't think they belong to the interface. Let's say you want to get the array of texts, instead of public List&lt;JTextField&gt; getFields(); You should consider: public List&lt;String&gt; getTexts(); // get them from the textfields ...
score: 11

http://stackoverflow.com/a/462582
type: Answer
has body: No, there really isn't a better way. You may want to relook at the problem. If you can redefine the problem, sometimes it makes the solution simpler because the problem has changed.
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/462534
downvote count: 0

http://stackoverflow.com/a/497862
type: Answer
answers question: http://stackoverflow.com/q/495674
has body: The easiest way is to not use BufferedReader.readLine(). For example: BufferedReader in = new BufferedReader(new FileReader(filePath)); char[] buf = new char[4096]; for (int count = in.read(buf); count != -1; count = in.read(buf)) { textArea.append(new String(buf, 0, count)); } EDIT I should have seen this before, but a much better way is to let the JTextArea read the file: BufferedReader in = new BufferedReader(new FileReader(filePath)); textArea.read(in, null); This will still read in the newline at the end, but it will normalize all the line endings in your text (see the javadocs for DefaultEditorKit for an explanation of how line endings are handled). So you can get rid of the trailing newline with something like this: // line endings are normalized, will always be "\n" regardless of platform if (textArea.getText().endsWith("\n")) { Document doc = ta.getDocument(); doc.remove(doc.getLength() - 1, 1); }
score: 2
upvote count: 2
downvote count: 0

http://stackoverflow.com/comment/283181
type: AnswerComment
has text: Not script, but to write the actual test in Groovy/JRuby. Not sure about JRuby, but you have java interoperability in Groovy, and thus can test you classes using Groovy.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/461832

hashmap
tags question: http://stackoverflow.com/q/512850
tags question: http://stackoverflow.com/q/634687
tags question: http://stackoverflow.com/q/444638
tags question: http://stackoverflow.com/q/434989
tags question: http://stackoverflow.com/q/603766
tags question: http://stackoverflow.com/q/436852
tags question: http://stackoverflow.com/q/636126
type: Tag
tags question: http://stackoverflow.com/q/460602
tags question: http://stackoverflow.com/q/537921
tag name: hashmap
tags question: http://stackoverflow.com/q/448122
tags question: http://stackoverflow.com/q/576912

http://stackoverflow.com/comment/40077457
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/599181
has text: if you want to print it in line Arrays.toString(list.toArray())
score: 0

http://stackoverflow.com/comment/279008
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/459479
has text: Will to to, but about what TF are you speaking about?
type: Comment

http://stackoverflow.com/q/529471
tagged with: stored-procedures
score: 7
tagged with: java
possible better answer: http://stackoverflow.com/a/529493
has answer: http://stackoverflow.com/a/529493
answer count: 2
accepted answer: http://stackoverflow.com/a/529634
downvote count: 0
favorite count: 0
tagged with: oracle-database
has title: Setting classpath for a Java stored procedure in Oracle
type: AnsweredQuestion
has body: I've got an Oracle 10g database, and I have a third-party jar file. I want to be able to run a SQL select query in my database that ultimately runs code in my third-party library to retrieve info for inclusion in a SQL result set. I see lots of tutorials on "Java stored procedures" and these seem to be a promising way to do this, but none seem to use third-party libraries, and I can't seem to figure out how to specify a classpath for my jar file that will be recognized when I am running in Oracle. How can I do this?
has answer: http://stackoverflow.com/a/529634
upvote count: 7
type: Question

http://stackoverflow.com/comment/328566
type: Comment
comment on: http://stackoverflow.com/a/514486
type: AnswerComment
score: 2
has text: @Axelle: You're missing the meaning of "pass by reference". Java *does* pass arguments by value. If it had pass-by-reference, the effect would be very different. You need to understand what pass-by-reference really means. It's not the same as "pass a reference by value".

http://stackoverflow.com/q/563144
tagged with: java
has answer: http://stackoverflow.com/a/563161
type: Question
downvote count: 0
has title: Log4J - Is there any point in explicitly specifying the class name in the call to LogManager.getLogger()?
has answer: http://stackoverflow.com/a/563167
accepted answer: http://stackoverflow.com/a/563161
has answer: http://stackoverflow.com/a/563303
tagged with: log4j
favorite count: 0
upvote count: 2
answer count: 5
has answer: http://stackoverflow.com/a/564633
score: 2
possible better answer: http://stackoverflow.com/a/563178
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/563178
has body: I'm working on some legacy code with a lot of code like private final Logger logger = LogManager.getLogger(ThisClassName.class); I'm wondering if there is any advantage to typing out "ThisClassName.class" as opposed to LogManager.getLogger(getClass()); As far as I can tell, there is none, but I'm wondering if there are any negative ramifications to using getClass(). Thanks.

http://stackoverflow.com/q/439704
accepted answer: http://stackoverflow.com/a/441182
answer count: 4
tagged with: c++
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/472848
score: 7
tagged with: java
has body: I have a client-server application written in Java using CORBA for the communication. The ORB used is orbd, the one provided by the Java6 platform. I have to replace the Java server implementation with another one written in C++. So the question is, of the free source implementations of CORBA libraries, which one better interoperates with this ORB? Should I replace the Java ORB and also use the ORB provided by the C++ library? The objective is to have an easy and smooth transition when replacing an already functioning server with the new C++ implementation. Is there anything else that I should take into account?
type: Question
has title: What is the best ORB for Java/C++ interoperation using CORBA?
tagged with: corba
has answer: http://stackoverflow.com/a/714864
upvote count: 7
has answer: http://stackoverflow.com/a/468745
possible better answer: http://stackoverflow.com/a/714864
favorite count: 0
has answer: http://stackoverflow.com/a/441182

storage
tag name: storage
tags question: http://stackoverflow.com/q/601956
type: Tag
tags question: http://stackoverflow.com/q/518936

http://stackoverflow.com/comment/63040287
type: AnswerComment
comment on: http://stackoverflow.com/a/1063588
score: 0
type: Comment
has text: @PeterAjtai yes, that's basically the answer on https://stackoverflow.com/questions/2102499/iterating-through-a-list-in-reverse-order-in-java

http://stackoverflow.com/q/441400
score: 10
has answer: http://stackoverflow.com/a/441554
answer count: 2
downvote count: 0
favorite count: 0
type: UnansweredQuestion
tagged with: c++
has body: Well, I've been given an assignment to basically figure out how memory allocation works for whatever language I'll be using. After some research, I have some questions and doubts which I'd like to get some insight in. For example: I read here that Java specifies exactly how the stack contents are organized. Looking at the JVM spec structure, it basically says the stack contains frames, and that the frames contain whatever is inside the class by properly allocating the variables and functions. Maybe I am missing something here, but I don't understand how this is any different than what C++ does. I ask because the first link says Java's specification of stack contents avoid compiler incompatibilities. Also, I have yet to find how the memory segments are exactly organized on top of each other. For example, I know the memory is divided into global variables, call stack, heap and code for C++, yet I don't know if the heap's address is higher than the stack's, or if that depends on the implementation. I also wonder whether a Java program has more than that, and how it would be laid out as well. I imagine there is a standard, since the JVM has to know where it all is to use it, though I suppose it could just have the pointers and leave the rest to the OS. I imagine too, that there must be at least a de facto standard. Another the thing I don't understand is the runtime constant pool. It's supposed to be "a per-class or per-interface runtime representation of the constant_pool table in a class file", but I don't think I understand what it does. It seems to have a tag to indicate what type the structure in question is? Then the name of the structure (given by the programmer or assigned by the underlying system?) Then it seems the rest of it varies with whatever the tag describes (a thread, an array, etc). If my interpretation of the runtime constant pool is right, then why are they necessary as well as stack frames? Is it because stack frames only take care of the stack segm…
tagged with: memory-management
has answer: http://stackoverflow.com/a/441432
upvote count: 10
type: Question
has title: About Memory Management in Java and C++
tagged with: java

http://stackoverflow.com/comment/11615522
has text: Pay attention: you inverted functions names; if you run it you'll see.
comment on: http://stackoverflow.com/a/9215633
type: AnswerComment
score: 4
type: Comment

http://stackoverflow.com/comment/263218
type: Comment
has text: What do you mean by "They encourage String references"?
type: QuestionComment
comment on: http://stackoverflow.com/q/441240
score: 0

http://stackoverflow.com/comment/2733237
type: AnswerComment
comment on: http://stackoverflow.com/a/1223263
type: Comment
has text: This answer is obsolete in Scala 2.8; see http://stackoverflow.com/questions/2708990/whats-the-new-way-to-iterate-over-a-java-map-in-scala-2-8-0
score: 37

http://stackoverflow.com/comment/92652522
type: AnswerComment
has text: Meanwhile there are also some alternatives available on GitHub, i.e. with source (unlike the suggested solution).
type: Comment
score: 1
comment on: http://stackoverflow.com/a/9122796

http://stackoverflow.com/comment/32073755
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/373833
type: Comment
has text: i think there are real problems with this question. 1 is it is is comparing totally unlike things, lumping parsers (xerces, crimson) together with dom-manipulation libraries (dom4j, xom, jdom). also the answers tend toward advocacy and are not that constructive.

http://stackoverflow.com/comment/139256916
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/609879
has text: We always store enums as ordinals in the DB (via an ORM). If not stored as an ordinal they can get stored as megalong FQCN+enumName+valueName - which locks you into not changing class name, package name or the name of the enum or any value for thousands of years (not to mention the extra CPUs cycles, diskspace, network traffic etc.,). A simple ordinal value storage strategy avoids this 'freeze' but we clearly mark a warning above each enum declaration: "!!!! ORDER CAN NEVER BE CHANGED - ALWAYS APPEND NEW VALUES TO THE END !!!!". Any good dev will abide by simple & important instructions ;)
type: Comment

http://stackoverflow.com/a/466931
downvote count: 1
upvote count: 17
has body: See GarbageCollectorMXBean.
answers question: http://stackoverflow.com/q/466878
has comment: http://stackoverflow.com/comment/289279
type: Answer
score: 16

http://stackoverflow.com/a/611312
score: 13
has body: If the "algorithms" are well-packaged, perhaps it's possible to create some automatic glue code, through JNI? That would cut down on the risk of errors (creating hundreds of individual components manually sounds risky), and make the cost independent of the number of algorithms to add, more or less. Rewriting hundreds of components sounds very risky, I would definitely recommend at least investigating JNI more closely first. What I/O requirements do the algorithms have with respect to the rest of the project? If they are fairly loosely coupled, perhaps it'd be possible to run them as free-standing separate programs, invoked as sub-processes from Java and using e.g. stdio to share data?
downvote count: 0
upvote count: 13
answers question: http://stackoverflow.com/q/611296
type: Answer

http://stackoverflow.com/comment/36495593
type: AnswerComment
comment on: http://stackoverflow.com/a/773028
type: Comment
has text: surprisingly worked! Thanks. Also saved half of my day.
score: 0

http://stackoverflow.com/comment/20714562
has text: If `attr` is a field, it would be a field access. Only if no field exists would there be a need to check for a function with suitable name and attributes.
comment on: http://stackoverflow.com/a/509291
score: 1
type: AnswerComment
type: Comment

http://stackoverflow.com/q/423360
has title: Vehicle tracking system/Jan08
tagged with: gprs
has comment: http://stackoverflow.com/comment/8674628
upvote count: 0
answer count: 1
has body: we are developing cost effective vehicle tracking system, for my knowledge Using GPS to track vehicle costs more. So we are looking to develop using GPRS system which costs less. my doubt is can track the vehicle using only GPRS (not using GPS at all) is this possible .please correct if i am wrong if you any documentation or link it will be useful. thanks in advance, Mahesh
favorite count: 0
type: UnansweredQuestion
tagged with: java
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/423421
has comment: http://stackoverflow.com/comment/34499115
score: -1

http://stackoverflow.com/a/453626
has body: Using classes from the com.sun.* packages that come with the Sun JDK.
score: 7
upvote count: 7
downvote count: 0
answers question: http://stackoverflow.com/q/453538
has comment: http://stackoverflow.com/comment/129131917
type: Answer

http://stackoverflow.com/q/414001
has answer: http://stackoverflow.com/a/414013
has answer: http://stackoverflow.com/a/414029
has body: In PHP, we (at least the good programmers) always start general variable names with a lower-case letter, but class variables/objects with an uppercase letter to distinguish them. In the same way we start general file names with a lower case letter, but files containing Classes with an upper case letter. E.g.: <?php $number = 123; $string = "a string"; $colors_array = array('red', 'blue', 'red'); $Cat = New Cat(); ?> Are the conventions the same in Java, i.e., objects starting with uppercase, but the rest with lowercase, or does everything start with lowercase as I've read in other places?
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/414023
answer count: 7
has title: Variable naming conventions in Java
accepted answer: http://stackoverflow.com/a/414029
possible better answer: http://stackoverflow.com/a/414023
has answer: http://stackoverflow.com/a/33501758
upvote count: 23
has answer: http://stackoverflow.com/a/414015
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/414028
tagged with: naming-conventions
tagged with: oop
tagged with: java
score: 23
has answer: http://stackoverflow.com/a/414126
linked to: http://stackoverflow.com/q/1365210

http://stackoverflow.com/a/17469014
upvote count: 2
has body: I've had a play with this, it wasn't working very well initially because the label bounds were exactly square and caused components to the right of the label to shift and become obscured. But I then realised that it was because I am using JGoodies FormLayout. If you use this layout manager, make sure you set the column size to "preferred" not "default". HTH.
answers question: http://stackoverflow.com/q/620929
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/comment/117256235
score: 0
type: Comment
type: QuestionComment
has text: @barfoon, based on the definition of `single character` and how the user accesses that character, there might be a different usage pattern. I have added [an answer](https://stackoverflow.com/questions/506105/how-can-i-check-if-a-single-character-appears-in-a-string/66324429#66324429)
comment on: http://stackoverflow.com/q/506105

http://stackoverflow.com/comment/307657
type: Comment
has text: Can you be a bit more specific? Do you look for the home directory of the user that runs grails, or for the home directory of an arbitrary user whose name or UID you have?
comment on: http://stackoverflow.com/q/491877
score: 0
type: QuestionComment

http://stackoverflow.com/a/34466811
score: 0
downvote count: 2
has body: You can use this under an actionListener -&gt; Runtime.getRuntime().exec("cmd.exe /c start chrome www.google.com")` or if you want to use Internet Explorer or Firefox replace chrome with iexplore or firefox
type: Answer
upvote count: 2
answers question: http://stackoverflow.com/q/527719

http://stackoverflow.com/a/417315
upvote count: 2
downvote count: 0
type: Answer
score: 2
has body: Yes. Using the synchronized keyword on an instance method uses 'this' as a monitor ,also using it on a class method (static method) uses the class' Class object (Foo.class). This way you can synchronize entire methods, and in the same time, synchronize it with a code snippet in another method using the synchronized-block style.
has comment: http://stackoverflow.com/comment/241562
answers question: http://stackoverflow.com/q/417285

http://stackoverflow.com/a/511657
type: Answer
upvote count: 4
downvote count: 0
has body: The JAX-WS Metro stack (the same one that ships with J2EE 1.5+ or J2SE 6+) can be downloaded and used independently of Glassfish. It makes it fairly easy to expose services, as it uses the @Webservice annotation. The Metro site also has a page about using it with Eclipse. I also found a blog post about getting it to work with Jetty... apparently Jetty embedded can still be used with jetty.xml
accepted answer of: http://stackoverflow.com/q/511523
answers question: http://stackoverflow.com/q/511523
score: 4
type: AcceptedAnswer

http://stackoverflow.com/comment/20784417
type: Comment
score: 3
comment on: http://stackoverflow.com/q/538870
has text: See also when not to use the keyword static in Java: http://stackoverflow.com/questions/1766715/when-not-to-use-the-static-keyword-in-java
type: QuestionComment

http://stackoverflow.com/comment/409684
has text: Still, consider changing your driver.
comment on: http://stackoverflow.com/q/596937
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/419437
downvote count: 0
has body: In spite of the risks, I'll offer a management perspective on this. :-) One challenge I've had with some team members is that they sometimes have a hard time seeing the big picture. That's obviously a statement that developers can make about their managers too--certainly managers (especially nontechnical managers) can fail to appreciate how hasty decisions now will lead to problems later. But I'll repeat that it's not just managers who can miss the big picture. Developers can too. One time my team was supposed to develop a simple demo, and I had two people working on it. This was in all likelihood a throwaway demo. Was there some chance that we might end up keeping it and elaborating it? Sure. The chance was even decent--maybe (just making up a number here) 25% just for argument's sake. After nearly a month there was no deliverable and finally I called BS. It turned out that the developers were "engineering" the thing. Setting it up to be modular, pluggable, testable, etc. I told them to stop and I wrote the demo myself in a single afternoon. The "big picture" was to deliver a proof of concept to the customer quickly, and if for whatever reason we decided that we wanted the demo to evolve into an actual piece of production software--fine--in the worst case we throw away a single afternoon's worth of "hard work". And that was the worst case. It wasn't like I was able to make a few hundred lines of code that complicated. No doubt sometimes managers make bad calls in the name of expediency, but just because I ask my team to do something quick-and-dirty doesn't mean I'm being short-sighted. Most of the time it means that delivering value quickly is more important in the situation that getting the engineering right. Unfortunately for some developers (a minority, to be sure), the very suggestion is blasphemy.
answers question: http://stackoverflow.com/q/417515
has comment: http://stackoverflow.com/comment/255364
score: 4
has comment: http://stackoverflow.com/comment/247695
type: Answer
upvote count: 4

http://stackoverflow.com/comment/349478
type: Comment
comment on: http://stackoverflow.com/a/536290
has text: just one thing: duffymo, your comment was useless :D and i now see you said "subclass" so i guess that would already rule out structs :) i should have read more closely. i'm sorry mad-j. anyway i will +1 this one :)
score: 0
type: AnswerComment

http://stackoverflow.com/a/412423
type: Answer
score: 16
has comment: http://stackoverflow.com/comment/92679884
upvote count: 16
has comment: http://stackoverflow.com/comment/73270038
has body: NPE is the most useless Exception in Java, period. It seems to be always lazily implemented and never tells exactly what caused it, even as simple as "class x.y.Z is null" would help a lot in debugging such cases. Anyway, the only good way I've found to find the NPE thrower in these cases is the following kind of refactoring: someObject.getSomething() .getSomethingElse() .getAnotherThing() .getYetAnotherObject() .getValue(); There you have it, now NPE points to correct line and thus correct method which threw the actual NPE. Not as elegant solution as I'd want it to be, but it works.
downvote count: 0
has comment: http://stackoverflow.com/comment/240623
answers question: http://stackoverflow.com/q/410890
has comment: http://stackoverflow.com/comment/75838216

http://stackoverflow.com/a/433473
upvote count: 7
accepted answer of: http://stackoverflow.com/q/433406
score: 7
type: AcceptedAnswer
downvote count: 0
has body: Try this ones: MemoryMXBean mem = ManagementFactory.getMemoryMXBean(); mem.getHeapMemoryUsage().getUsed(); mem.getNonHeapMemoryUsage().getUsed(); But they only offer snapshot data, not a cummulated value.
answers question: http://stackoverflow.com/q/433406
type: Answer
has comment: http://stackoverflow.com/comment/1946455

http://stackoverflow.com/a/641074
answers question: http://stackoverflow.com/q/641065
upvote count: 3
type: Answer
has body: I think ( not quite sure ) there is a method like "modelToView" which returns the actual index in the model a view index represents. So, for instance you have A,B,C,D and then you sort desc. D,C,B,A this method would return 0 for view index 3 ( A ) I think this was on JXTable which supports sorting or in JTable in Java 6. If you have build this sorting your self, consider adding this method.
downvote count: 0
score: 3

http://stackoverflow.com/comment/3095293
score: 0
type: AnswerComment
has text: In one afternoon? Probably not worth £80 then!
type: Comment
comment on: http://stackoverflow.com/a/3018647

http://stackoverflow.com/comment/15182360
has text: Any experiences to share with this?
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/376276
type: Comment

http://stackoverflow.com/a/25984478
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/625838
downvote count: 0
type: Answer
has body: Try this: String binaryString = String.format("%"+Integer.toString(size)+"s",Integer.toBinaryString(19)).replace(" ","0"); where size can be any number the user wants

http://stackoverflow.com/comment/2515148
score: 0
type: Comment
comment on: http://stackoverflow.com/a/520535
has text: is it required to extend HttpServlet? Is there no static method?
type: AnswerComment

http://stackoverflow.com/q/637907
accepted answer: http://stackoverflow.com/a/637916
tagged with: java
has body: Hi All I am a newcomer here, I am using the following code from an open source library (Matrix Toolkits for Java) which outputs the following matrix 1000 1000 5 3 5 1.000000000000e+00 I am trying to do a String split that will return me 1000,1000,5 I tried using String[] parts = str.trim().split("\\s"); but it seems using the \s as a String Token is wrong, any idea what I should use instead? thanks a lot! public String toString() { // Output into coordinate format. Indices start from 1 instead of 0 Formatter out = new Formatter(); out.format("%10d %10d %19d\n", numRows, numColumns, Matrices .cardinality(this)); for (MatrixEntry e : this) if (e.get() != 0) out.format("%10d %10d % .12e\n", e.row() + 1, e.column() + 1, e .get()); return out.toString(); }
tagged with: split
type: AnsweredQuestion
score: 2
downvote count: 0
tagged with: string
favorite count: 0
type: Question
has title: Trying to use String.split() regex on String created with Formatter
has answer: http://stackoverflow.com/a/637916
tagged with: space
tagged with: regex
possible better answer: http://stackoverflow.com/a/637927
upvote count: 2
answer count: 2
has answer: http://stackoverflow.com/a/637927

http://stackoverflow.com/a/514969
type: Answer
has body: Try the iText java library: iText is an ideal library for developers looking to enhance web- and other applications with dynamic PDF document generation and/or manipulation. It can be used for your parsing step. As for generating word documents - the OpenOffice Java API might be able to generate Word compatible docs (no personal experience with this API).
upvote count: 5
downvote count: 0
answers question: http://stackoverflow.com/q/514885
score: 5

http://stackoverflow.com/q/372639
downvote count: 0
favorite count: 0
answer count: 1
has comment: http://stackoverflow.com/comment/201401
tagged with: classloader
upvote count: 2
has title: Dynamically loading a class file with a non default package and no nested folders
score: 2
type: AnsweredQuestion
tagged with: reflection
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/201343
has answer: http://stackoverflow.com/a/372648
accepted answer: http://stackoverflow.com/a/372648
has body: I am writing a curriculum project for students new to Java. It has a folder structure as so. myjar.jar solutions/my/really/long/package/MySolution.class I got it so the jar can load all classes in the solutions/my/really/long/package/ directory. by adding 'solutions/' to the classpath. My question is if it is possible to set it up so there is no long nested folders for the package without using the default package. The resulting structure would be myjar.jar solutions/MySolution.class But the MySolution class would not have a default package.

http://stackoverflow.com/q/641065
downvote count: 0
tagged with: java
has body: Here's the thing: a sortable JTable backed by JTableModel with an array of objects that populate rows (one object = one row). Need to delete rows. Without sorting, deleting an object is simple: get selected row index, delete array object under the same index. With sorting, though, row indexes mess up in a sense that they no longer match backing array object indexes. What's the proper way to overcome this?
type: Question
tagged with: sorting
has title: Strategy for detecting an object in JTable row?
upvote count: 2
tagged with: jtable
answer count: 2
accepted answer: http://stackoverflow.com/a/641106
favorite count: 0
possible better answer: http://stackoverflow.com/a/641074
has answer: http://stackoverflow.com/a/641106
has answer: http://stackoverflow.com/a/641074
type: AnsweredQuestion
score: 2

http://stackoverflow.com/q/490897
tagged with: java
has answer: http://stackoverflow.com/a/490916
answer count: 5
has title: run a batch file that is present in remote machine
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/490930
type: Question
has body: The above code works fine if the batch file is present in local machine. I need to run the batch file that is present in the remote machine from the above code. class Visuals { public static void main(String arg[]) { try { String command = "cmd /C start C:/Visuals/VisualTimeSeries081308Ratnesh/VisualTimeSeries081308Ratnesh/bat/demo/StartVisTsDataCenterMySql-log.bat"; Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(command); //pr.destroy(); } catch (IOException e) { e.printStackTrace(); } } } How can I develop connection with the remote machine? I just have the IP address of the remote machine.
has answer: http://stackoverflow.com/a/491003
has answer: http://stackoverflow.com/a/861941
has answer: http://stackoverflow.com/a/491036
score: 0

http://stackoverflow.com/comment/13635847
type: Comment
has text: Not sure if this will help, but commons-fileupload (at least v1.2.1) has logic to default to the platform encoding if you don't configure another value. Take a look at `org.apache.commons.fileupload.FileUploadBase` and the `headerEncoding` field.
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/549634

http://stackoverflow.com/a/573598
type: Answer
answers question: http://stackoverflow.com/q/573543
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/385393
has comment: http://stackoverflow.com/comment/385410
upvote count: 2
has body: Disallow overloading. It was a mistake. (I know this one is a bit controvertial, and yet...) Not using overloading is IMO a bigger mistake that leads to less maintainable code. For example have a look at this page from OpenGL API. (C-language, no overloading) glColor Make good use of Enums in the library -- curerntly, a lot of older classes use int constants instead. Is something broken because of int constants? No offense, but this and most of your points sound just a bit obsessive compulsive instead of practical use of coding time. Good developer can already work around these things or refrain from using a feature that is not considered good. Also if a library already works, there's no reason to change it just to "use enums" etc. Throwing away good debugged code is a huge waste. Considering "reboots", here's a link to Joel of Software text on rewrites from scratch. Not 100% relevant but a bit anyway :) Things You Should Never Do, Part I
has comment: http://stackoverflow.com/comment/385389

http://stackoverflow.com/comment/461754
score: 0
type: AnswerComment
type: Comment
has text: If this is possible in a web app - read the password from the servlet input stream into a byte array, and then fill the array with zeroes after persisting the password, then it should turn out to be a viable approach. The OWASP Java project uses this in an example, but not for persisting passwords.
comment on: http://stackoverflow.com/a/646275

http://stackoverflow.com/comment/122173223
has text: Java 8 did some good things and while I like Streams (for concurrency mostly)... this is actually NOT a reason to use them. It buys the OP nothing and performs more poorly ... simply substituting a for/next loop through all items for a Stream version of the same (and not even in parallel). For a few entries.... who cares but to be clear, this is not some "it is way better because of Java 8" example. It's just a fluent-style green vs blue 'different' implementation of the same returning an Optional vs null (and fluent-style requires a non-null return for all joined methods).
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/45435127
score: 1

http://stackoverflow.com/q/607945
favorite count: 0
has answer: http://stackoverflow.com/a/607969
has answer: http://stackoverflow.com/a/607977
tagged with: java-6
has answer: http://stackoverflow.com/a/607974
has answer: http://stackoverflow.com/a/1381454
has answer: http://stackoverflow.com/a/607973
tagged with: macos
type: AnsweredQuestion
has title: Installing Java 6 on Mac OS
score: 7
upvote count: 7
possible better answer: http://stackoverflow.com/a/607966
has answer: http://stackoverflow.com/a/8977439
type: Question
answer count: 8
tagged with: java
accepted answer: http://stackoverflow.com/a/607977
has answer: http://stackoverflow.com/a/3744684
downvote count: 0
has answer: http://stackoverflow.com/a/607966
has body: Is it possible to install the latest JDK on Mac OS 10.5? What are the best options, considering that the Apple-supplied version is 1.5? Update: I am trying to install JDeveloper 11, which requires JDK 6.

http://stackoverflow.com/a/15990375
answers question: http://stackoverflow.com/q/370310
upvote count: 2
has body: //una forma de recorer todos los elementos dentro de un jpanel Component[] components = jPanelX.getComponents(); for (int i = 0; i &lt; components.length; i++) { if(components[i].getClass().getName().toString().equals("javax.swing.JTextField")){ components[i].setEnabled(false); } }
has comment: http://stackoverflow.com/comment/55825076
score: 2
downvote count: 0
type: Answer

http://stackoverflow.com/q/386083
has answer: http://stackoverflow.com/a/12730319
linked to: http://stackoverflow.com/q/46663
has answer: http://stackoverflow.com/a/10258776
tagged with: java
has body: I am trying to use Bill the Lizard's code to send an email using Google Apps. I am getting this error: Exception in thread "main" javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first. f3sm9277120nfh.74 at javax.mail.Transport.send0(Transport.java:219) at javax.mail.Transport.send(Transport.java:81) at SendMailUsingAuthentication.postMail(SendMailUsingAuthentication.java:81) at SendMailUsingAuthentication.main(SendMailUsingAuthentication.java:44) Bill's code contains the next line, which seems related to the error: props.put("mail.smtp.starttls.enable","true"); However, it does not help. These are my import statements: import java.util.Properties; import javax.mail.Authenticator; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; Does anyone know about this error?
type: Question
score: 20
tagged with: google-apps
upvote count: 20
downvote count: 0
answer count: 6
favorite count: 0
has answer: http://stackoverflow.com/a/46404186
has title: Must issue a STARTTLS command first. Sending email with Java and Google Apps
tagged with: email
has answer: http://stackoverflow.com/a/386238
has answer: http://stackoverflow.com/a/386166
has answer: http://stackoverflow.com/a/2184228
type: UnansweredQuestion

http://stackoverflow.com/a/551278
score: 0
has body: "Also, what if there are new products coming out all the time, each with different investibility decisions and I don't want to be updating my core Customer class every time this happens?" This springs to mind: interface Investable { boolean isIvestible(Customer c); } class FooInvestible implements Investible { public boolean isInvestible(final Customer c) { // whatever logic, be it switch or other things } } The "problem" with the original use of swtich and adding new types of decisions is that you likely wind up with some huge rats nest of code that is impossible to maintain in a sane way. Splitting the decisions up into classes forces the decision making to be split up. Then, even if you use switch, the code is likely to stay saner and maintainable.
has comment: http://stackoverflow.com/comment/362942
answers question: http://stackoverflow.com/q/550919
type: Answer

http://stackoverflow.com/a/629384
has body: If the messages come into you over SMPP have a look at the SMPPAPI. http://smppapi.sourceforge.net/ Talk to your mobile network they will tell you what format your messages will be delivered in.
type: Answer
answers question: http://stackoverflow.com/q/628880
score: 0

http://stackoverflow.com/comment/417505
type: Comment
has text: @EFraim: By reducing the amount of memory used you're increasing the chance of having everything in cache. Cache misses are very expensive. I wouldn't be at all surprised to see this factor make BitArray faster.
comment on: http://stackoverflow.com/a/605239
score: 9
type: AnswerComment

http://stackoverflow.com/comment/17367536
comment on: http://stackoverflow.com/a/624856
type: Comment
score: 8
has text: Use Restrictions instead (see my answer below)
type: AnswerComment

http://stackoverflow.com/a/371630
score: 6
answers question: http://stackoverflow.com/q/371607
type: AcceptedAnswer
downvote count: 0
has body: The error message is telling you that you are passing an Object into the method, not a String. If you are sure that the Object is a String, then you'll need to cast it to a String first. If this doesn't work, please post the actual code that is giving you trouble.
accepted answer of: http://stackoverflow.com/q/371607
type: Answer
upvote count: 6

http://stackoverflow.com/a/492228
type: Answer
has comment: http://stackoverflow.com/comment/308029
has comment: http://stackoverflow.com/comment/307966
upvote count: 3
score: 3
has comment: http://stackoverflow.com/comment/308015
answers question: http://stackoverflow.com/q/492207
downvote count: 0
has body: Yes: actually JDK or JRE can be just "copied" wherever you want, not "installed" (avoiding putting anything in c:\Windows\System32) I would also recommend not using global environment variables. That way, your applications depend entirely on local settings (local to the application), and not on external Java installation side-effects

http://stackoverflow.com/q/457682
tagged with: java
has body: How can I work with Novell eDirectory services in J2SE? Will JNDI work with eDirectory? What are some resources I can use to learn about whatever library or libraries you suggest? I just want to play around with retrieving information via LDAP for right now, and if I get things working the way I want, I will probably need to be able to modify objects later on. Thanks!
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/462478
answer count: 3
has answer: http://stackoverflow.com/a/457850
downvote count: 0
possible better answer: http://stackoverflow.com/a/1097547
favorite count: 0
has answer: http://stackoverflow.com/a/1097547
tagged with: ldap
tagged with: edirectory
type: AnsweredQuestion
has title: How can I work with Novell eDirectory services in J2SE?
accepted answer: http://stackoverflow.com/a/457850
score: 1

http://stackoverflow.com/a/32373318
has body: Which library to use? As of this writing, they are three libraries that emerge: GuessEncoding ICU4j juniversalchardet I don't include Apache Any23 because it uses ICU4j 3.4 under the hood. How to tell which one has detected the right charset (or as close as possible)? It's impossible to certify the charset detected by each above libraries. However, it's possible to ask them in turn and score the returned response. How to score the returned response? Each response can be assigned one point. The more points a response have, the more confidence the detected charset has. This is a simple scoring method. You can elaborate others. Is there any sample code? Here is a full snippet implementing the strategy described in the previous lines. public static String guessEncoding(InputStream input) throws IOException { // Load input data long count = 0; int n = 0, EOF = -1; byte[] buffer = new byte[4096]; ByteArrayOutputStream output = new ByteArrayOutputStream(); while ((EOF != (n = input.read(buffer))) && (count <= Integer.MAX_VALUE)) { output.write(buffer, 0, n); count += n; } if (count > Integer.MAX_VALUE) { throw new RuntimeException("Inputstream too large."); } byte[] data = output.toByteArray(); // Detect encoding Map<String, int[]> encodingsScores = new HashMap<>(); // * GuessEncoding updateEncodingsScores(encodingsScores, new CharsetToolkit(data).guessEncoding().displayName()); // * ICU4j CharsetDetector charsetDetector = new CharsetDetector(); charsetDetector.setText(data); charsetDetector.enableInputFilter(true); CharsetMatch cm = charsetDetector.detect(); if (cm != null) { updateEncodingsScores(encodingsScores, cm.getName()); } // * juniversalchardset UniversalDetector universalDetector = new UniversalDetector(null); universalDetector.handleData(data, 0, data.length); universalDetector.dataEnd(); String encodingName = universalDetector.getDetectedCharset(); if (encodingName != null) { updateEncodingsScores(encodingsScores, encodingName); } // Find winning encoding Map.…
downvote count: 0
answers question: http://stackoverflow.com/q/499010
type: Answer
score: 17
upvote count: 17

http://stackoverflow.com/q/520348
type: AnsweredQuestion
tagged with: java
answer count: 6
has answer: http://stackoverflow.com/a/1750277
tagged with: servlets
has answer: http://stackoverflow.com/a/521721
tagged with: browser
has body: I have a servlet which processes a request for a long time. It suppose to keep doing stuff in the loop inside doPost and send data through response's out writer. Effectively that continuously appends data in the clients browser . But the problems accures when client just closes the browser. Inspite of the broken connection the response's writer stream in the servlet never gets closed, thus servlet is unaware of the brocen connection, and keep dumping data into the writer without any errors. How is that posssible? And how do I detect and cancel long request processing in case of browser disconnect? I thougth checkError() on the response writer should do the trick, but it does not seam to work. Any ideas why? This is the servlet code which never stops: protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); System.out.println("Session " + session.getId() + " started"); response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { while (!out.checkError()) { try { Thread.sleep(1000); } catch (InterruptedException ex) { ex.printStackTrace(); } Date date = new Date(); // TODO append output to the client browser here out.println("....."); System.out.println("Session " + session.getId() + "data sent at: " + date); out.flush(); //break; // _TEST } } finally { System.out.println("Session " + session.getId() + " finished"); out.close(); } } Thanks, Mike
downvote count: 0
has answer: http://stackoverflow.com/a/520389
has title: Servlet long processing cancelation when browser closes
favorite count: 0
possible better answer: http://stackoverflow.com/a/520390
upvote count: 8
has answer: http://stackoverflow.com/a/520390
has answer: http://stackoverflow.com/a/18655864
score: 8
accepted answer: http://stackoverflow.com/a/520389
has answer: http://stackoverflow.com/a/43660123
tagged with: http
type: Question
tagged with: jakarta-ee

http://stackoverflow.com/comment/98208572
score: 1
type: AnswerComment
has text: @JudeDesir I'm pretty sure that feature doesn't exist anywhere, it would cause ridiculously bad performance.
type: Comment
comment on: http://stackoverflow.com/a/575368

http://stackoverflow.com/a/56362179
answers question: http://stackoverflow.com/q/407612
downvote count: 0
type: Answer
has body: Maybe jcmd? Jcmd utility is used to send diagnostic command requests to the JVM, where these requests are useful for controlling Java Flight Recordings, troubleshoot, and diagnose JVM and Java Applications. The jcmd tool was introduced with Oracle's Java 7 and is particularly useful in troubleshooting issues with JVM applications by using it to identify Java processes' IDs (akin to jps), acquiring heap dumps (akin to jmap), acquiring thread dumps (akin to jstack), viewing virtual machine characteristics such as system properties and command-line flags (akin to jinfo), and acquiring garbage collection statistics (akin to jstat). The jcmd tool has been called "a swiss-army knife for investigating and resolving issues with your JVM application" and a "hidden gem." Here’s the process you’ll need to use in invoking the jcmd: Go to jcmd &lt;pid&gt; GC.heap_dump &lt;file-path&gt; In which pid: is a Java Process Id, for which the heap dump will be captured Also, the file-path: is a file path in which the heap dump is be printed. Check it out for more information about taking Java heap dump.
score: 2
upvote count: 2

http://stackoverflow.com/a/395042
has body: To ensure type safety when casting an array like you intended (DataObject[] dataArray = (DataObject[]) objectArray;), the JVM would have to inspect every single object in the array, so it's not actually a simple operation like a type cast. I think that's why you have to pass the array instance, which the toArray() operation then fills.
type: Answer
score: 3
downvote count: 0
upvote count: 3
answers question: http://stackoverflow.com/q/395030

http://stackoverflow.com/q/599161
has answer: http://stackoverflow.com/a/24325306
has answer: http://stackoverflow.com/a/49547243
linked to: http://stackoverflow.com/q/395401
has body: I have an ArrayList that I want to output completely as a String. Essentially I want to output it in order using the toString of each element separated by tabs. Is there any fast way to do this? You could loop through it (or remove each element) and concatenate it to a String but I think this will be very slow.
has answer: http://stackoverflow.com/a/26172604
has answer: http://stackoverflow.com/a/599269
has answer: http://stackoverflow.com/a/29674295
type: Question
has answer: http://stackoverflow.com/a/21451778
accepted answer: http://stackoverflow.com/a/599181
upvote count: 352
has comment: http://stackoverflow.com/comment/32501781
downvote count: 0
has answer: http://stackoverflow.com/a/599631
has answer: http://stackoverflow.com/a/32730680
has answer: http://stackoverflow.com/a/18508511
tagged with: arraylist
score: 352
has answer: http://stackoverflow.com/a/29508728
has answer: http://stackoverflow.com/a/25051512
has comment: http://stackoverflow.com/comment/45888625
has answer: http://stackoverflow.com/a/599174
tagged with: string
favorite count: 0
has answer: http://stackoverflow.com/a/7779427
has answer: http://stackoverflow.com/a/12430087
has answer: http://stackoverflow.com/a/599181
has answer: http://stackoverflow.com/a/39708597
has answer: http://stackoverflow.com/a/40485514
has answer: http://stackoverflow.com/a/34207503
has answer: http://stackoverflow.com/a/3233312
has title: Best way to convert an ArrayList to a string
possible better answer: http://stackoverflow.com/a/23183963
has answer: http://stackoverflow.com/a/599169
has answer: http://stackoverflow.com/a/599258
has answer: http://stackoverflow.com/a/32770314
has answer: http://stackoverflow.com/a/599584
has answer: http://stackoverflow.com/a/23183963
answer count: 27
has answer: http://stackoverflow.com/a/49818122
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/5515861
has answer: http://stackoverflow.com/a/24176855
tagged with: java

http://stackoverflow.com/a/488048
score: 6
downvote count: 0
answers question: http://stackoverflow.com/q/487932
has body: A few months ago I was a Java web programmer who hadn't touched C since college. Now I've got one iPhone app completed (for my day job, stuck in the bureaucracy there so it's not in the app store yet) and my second app nearing completion. To answer your question the biggest hurdles are understanding the conventions (Delegate pattern, Categories, etc.), getting a grasp on memory management, and working with XCode (a good IDE but definitely steps behind Eclipse and IntelliJ). I also think the documentation in the Apple Developer Center website is well-written, and a good developer can get up and running quickly. To more specifically answer your question, I haven't tried Unit Testing yet but I think the OOP is great - my domain objects in my iPhone apps are as robust and powerful as those I've written in Java.
type: Answer
upvote count: 6

http://stackoverflow.com/q/371751
accepted answer: http://stackoverflow.com/a/371773
possible better answer: http://stackoverflow.com/a/371872
type: Question
has answer: http://stackoverflow.com/a/371872
score: 5
tagged with: mobile
has title: Java Mobile programming for a beginner, where to start?
has answer: http://stackoverflow.com/a/409579
has answer: http://stackoverflow.com/a/435920
has comment: http://stackoverflow.com/comment/200559
answer count: 4
has answer: http://stackoverflow.com/a/371773
favorite count: 0
downvote count: 2
upvote count: 7
tagged with: mobile-phones
type: AnsweredQuestion
has body: After I downloaded the Google Mail and Google Maps application into my mobile phone I got an idea about a service that I want to implement. My problem is that I never did any programming for the mobile platform and I need someone to point me out some resources for the Hello World on a mobile and then something a bit more complicated. Let's make it a bit broad, as in J2ME in general for the moment. I'll dig into Android once I get the non Android/*Berry/etc out of the way.
tagged with: java

http://stackoverflow.com/q/431044
has answer: http://stackoverflow.com/a/431394
type: Question
tagged with: fullscreen
has body: I am designing a psychology experiment with java applets. I have to make my java applets full screen. What is the best way of doing this and how can I do this. Since I haven't been using java applets for 3 years(The last time I've used it was for a course homework :) ) I have forgotten most of the concepts. I googled and found that link: Dani web But in the method described in above link you have to put a JFrame inside the applet which I have no idea how to do it. Whatever I need a quick and dirty method b'cause I don't have much time and this is the reason why I asked it here. Thanx in advance
accepted answer: http://stackoverflow.com/a/431097
downvote count: 0
tagged with: applet
favorite count: 0
possible better answer: http://stackoverflow.com/a/431067
has answer: http://stackoverflow.com/a/431067
score: 11
has answer: http://stackoverflow.com/a/18309412
answer count: 4
upvote count: 11
type: AnsweredQuestion
has title: How to make full screen java applets?
tagged with: java
has answer: http://stackoverflow.com/a/431097

http://stackoverflow.com/a/454548
downvote count: 0
score: 1
upvote count: 1
has body: If rotation also had to be catered for, the Generalised Hough Transform can be used.
type: Answer
answers question: http://stackoverflow.com/q/454498

http://stackoverflow.com/a/11327916
has comment: http://stackoverflow.com/comment/78349007
has comment: http://stackoverflow.com/comment/43441699
has comment: http://stackoverflow.com/comment/38538179
has body: String.split(System.lineSeparator()); This should be system independent
score: 65
upvote count: 79
has comment: http://stackoverflow.com/comment/43288859
type: Answer
has comment: http://stackoverflow.com/comment/15567568
has comment: http://stackoverflow.com/comment/77137910
has comment: http://stackoverflow.com/comment/53776377
answers question: http://stackoverflow.com/q/454908
downvote count: 14
has comment: http://stackoverflow.com/comment/43280084
has comment: http://stackoverflow.com/comment/33793609

http://stackoverflow.com/a/25230143
has body: It is also commonly used on Async-IO completion callbacks when you dont have the need for an Attachment object. In that case you specify null to the IO operation and implement CompletionHandler&lt;Integer,Void&gt;.
answers question: http://stackoverflow.com/q/643906
score: 0
type: Answer

http://stackoverflow.com/a/424771
type: Answer
downvote count: 0
has body: Forget getting good results by testing for concurrency problems. Attempt to reduce synchronization and make the problem smaller. Then use as high as possible library support to do synchronization. And only if you really have then try to handle the concurrency yourself. When you know each worker does its work correct and all your thinking tell you that you have the concurrency problem licked then generate some interesting load. Unittest frameworks and their extensions can do that job, but know that you are not testing any units anymore. (Remember, you already had that part covered) If your concurrency model gets complicated check out tools suited for that like SPIN.
score: 17
answers question: http://stackoverflow.com/q/424516
accepted answer of: http://stackoverflow.com/q/424516
type: AcceptedAnswer
upvote count: 17

http://stackoverflow.com/comment/269191
comment on: http://stackoverflow.com/a/448167
type: AnswerComment
score: 0
type: Comment
has text: That's just hiding problems, not really fixing them. @SuppressWarning("unchecked") should be used with GREAT caution.

http://stackoverflow.com/q/468562
has body: I'm doing some performance tuning on my application and would like to know a good way of measuring the size of the object that I am sending over RMI. The aim is to make my object leaner.
tagged with: rmi
tagged with: java
has answer: http://stackoverflow.com/a/470661
type: Question
accepted answer: http://stackoverflow.com/a/469446
tagged with: performance
possible better answer: http://stackoverflow.com/a/468631
has comment: http://stackoverflow.com/comment/286412
has answer: http://stackoverflow.com/a/468631
has comment: http://stackoverflow.com/comment/105283992
has comment: http://stackoverflow.com/comment/107404410
has answer: http://stackoverflow.com/a/469096
has title: How can I measure the size of the object I send over RMI?
downvote count: 0
favorite count: 0
upvote count: 2
has answer: http://stackoverflow.com/a/469446
answer count: 5
has answer: http://stackoverflow.com/a/43283498
score: 2
type: AnsweredQuestion

http://stackoverflow.com/q/385913
has title: Why wasn't the Java "throws" clause (in method declaration) included in C#?
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/385926
upvote count: 23
has answer: http://stackoverflow.com/a/386023
type: Question
has answer: http://stackoverflow.com/a/385926
tagged with: c#
has body: Why wasn't the Java "throws" clause (in method declaration) included in C#?
tagged with: java
has answer: http://stackoverflow.com/a/385915
downvote count: 0
score: 23
tagged with: programming-languages
favorite count: 0
tagged with: exception
answer count: 5
has answer: http://stackoverflow.com/a/397732
has answer: http://stackoverflow.com/a/385931
accepted answer: http://stackoverflow.com/a/385915

http://stackoverflow.com/comment/70734276
type: Comment
has text: What is missed here is that due to wall clock drift, service adjustments and generally poor resolution, System.currentTimeMills() comparisons (to calculate duration) can commonly result in "0" even though tens or hundreds of milliseconds have *actually elapsed*. So it is an issue of accuracy when measuring elapsed time of any operation that runs in under a second - such as when logging duration or cumulation calculation of very fast event durations.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/510940

http://stackoverflow.com/comment/123620187
has text: I wish this wasn't in alien language. Python makes no sense
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/68386190
type: Comment

http://stackoverflow.com/q/495710
tagged with: jetty
has answer: http://stackoverflow.com/a/496604
type: AnsweredQuestion
tagged with: java
type: Question
tagged with: http-status-code-503
has body: I would like to configure a webservice so that once the accept queue is full the service returns 503. Currently, these requests seem to just time out. I did set paramters like maxThreads and acceptQueuesize (as described here: http://www.restlet.org/documentation/1.1/ext/com/noelios/restlet/ext/jetty/JettyServerHelper). But the service does not respond with 503 once the acceptQueue is full. It seems jetty's ThrottlingFilter (http://www.mortbay.org/jetty/jetty-6/apidocs/index.html?index-all.html) is what I'm looking for, but I don't know how to apply within my restlet service.
accepted answer: http://stackoverflow.com/a/496604
tagged with: restlet
score: 0
has title: How to use a ThrottlingFilter for Jetty in Restlet
answer count: 1

state
tag name: state
tags question: http://stackoverflow.com/q/506220
type: Tag
tags question: http://stackoverflow.com/q/513343

http://stackoverflow.com/a/2265688
type: Answer
has comment: http://stackoverflow.com/comment/5234117
downvote count: 2
has body: The libs above are simple BOM detectors which of course only work if there is a BOM in the beginning of the file. Take a look at http://jchardet.sourceforge.net/ which does scans the text
score: 6
upvote count: 8
answers question: http://stackoverflow.com/q/499010

http://stackoverflow.com/a/896984
answers question: http://stackoverflow.com/q/390394
score: 0
has body: You want to use a Java framework to help you with the UI. For example, you can use JSF (Javaserver faces), which allows you to drag and drop components for a UI onto the site. Otherwise, you can use web programs such as Dreamweaver to design the UI, before coding the backend logic yourself in java.
type: Answer

http://stackoverflow.com/q/610896
tagged with: private
has body: I have a Java main application running on my PC that can send XML data to a servelet and recieve XML data back. http://iamt.wisconsin.gov/IAM-WiEntUser/WiEntUserService?xml= I can use https://iamt.wisconsin.gov/IAM-WiEntUser/WiEntUserService?xml= from IE and Firefox because I they allowed me to load the private certificate. I want to use https from the Java main application because some of the data is sensitive. I get an IOException with MSG=unkown certificate. Ok, That makes sense, Java does not know about the private certificate. I was hoping that it would be as simple as telling Java to trust the FireFox certificates. System.setProperty("javax.net.ssl.trustStore", "C:/Documents and Settings/kendajm/Application Data/Mozilla/Firefox/Profiles/6f8ggdi7.default/cert8.db" ); But that gives an IOException with MSG=Invalid keystore format. SSL communication, how hard can it be? I spent a good eight hours trying to track down how to do this. It seems that is so easy that it is not documented or very difficult and no one has a good example. Help.
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/611656
answer count: 4
has answer: http://stackoverflow.com/a/611125
tagged with: java
tagged with: certificate
type: Question
has answer: http://stackoverflow.com/a/610930
tagged with: program-entry-point
tagged with: ssl
score: 0
has title: SSL communication, how hard can it be?
has answer: http://stackoverflow.com/a/610912

http://stackoverflow.com/a/516920
downvote count: 0
upvote count: 2
has body: You should avoid breaking up your strings. Not only does this become a nightmare to translate, but it also makes grammatical assumptions which may not be correct in the target language. While placeholders can be helpful for many things, I would not recommend using placeholders for URLs. This allows you to customize the URL for different locales. After all, no sense sending them to an English language page when their locale is Argentine Spanish!
answers question: http://stackoverflow.com/q/516453
type: Answer
score: 2

http://stackoverflow.com/a/546772
type: Answer
answers question: http://stackoverflow.com/q/521117
upvote count: 1
has body: I'd go with Ant any day of the week. It's not perfect; XML is very verbose and implementing any logic at all is almost impossible, but even the most junior engineer on the team can at least understand what the ant file is doing within a day. Complex logic can be refactored using java and integrated in ant, if you so wish. Ant gives you all the power of java:) Dependency resolution is difficult no matter what system you use. With ant, the best solutions seem to be either a lib directory in which all your jars are stored, or an internal web server from which the libraries are copied at build time. I also have some experience with both Maven 1 and Maven 2. That experience left me with the feeling that Maven is awesome for hobby projects, but can have complications for software you need to maintain over time. I see two important problems with Maven: Any dependency you import using Maven may change over time without you knowing it, resulting in weird problems. You import the licenses of not only the software you import directly using Maven, but also the licenses used by the libraries which are indirectly imported In short, I dislike the fact that the build depends on the time it is started. That can be a true problem when producing a bugfix release a year after the production release. These problems can of course be managed (maybe using a nexus proxy) but you need to consider them before rebuilding the build system. At my company we decided to use Ant for all new project and try to port maven 1 and 2 to ant whenever the occasion presents itself. It's just too difficult to keep it working. My advice, if you and your team know how to deal with ant, try to refactor your ant file and don't jump on some other build tool. It just takes too much time to get it right; time you could spend making money and surviving as a company :)
score: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/576663

http://stackoverflow.com/comment/208920
has text: No. it does not auto increment in inserts.
score: 0
comment on: http://stackoverflow.com/q/381373
type: Comment
type: QuestionComment

http://stackoverflow.com/q/577377
score: 2
type: AnsweredQuestion
upvote count: 2
tagged with: artifactory
accepted answer: http://stackoverflow.com/a/619026
type: Question
has answer: http://stackoverflow.com/a/577383
tagged with: java
has title: "Missing artifact" errors with company repository
possible better answer: http://stackoverflow.com/a/577383
answer count: 2
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/619026
has body: I setup a company maven repository using artifactory. I deployed a project of us into the repository. If I now specify a dependency to that artifact, it doesn't get retrieved. Which it should, because I declared this in my settings.xml: company-internal company repository http://company.repository:8080/artifactory/repo/ * This works for all 3rdparty dependencies. The artifact is definitely in the reposity, manually I can download the artifact just fine. Why is maven not able to download it? Is it more likely to be a problem with maven (or the configuration there), or is there a bug in artifactory? Is there something which is handled differently in case of SNAPSHOTs?
tagged with: dependencies
tagged with: maven-2

http://stackoverflow.com/comment/103056458
has text: @ceving You don't have to deal with Unicode here as all characters outside the BMP can be simply copied as they are. The only five codepoints needing processing are in the BMP.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/10035382

http://stackoverflow.com/a/11186592
downvote count: 5
has body: I did this... Seems to work ok - I'm sure somebody will point out mistakes though... public final class MD5 { public enum SaltOption { BEFORE, AFTER, BOTH, NONE; } private static final String ALG = "MD5"; //For conversion to 2-char hex private static final char[] digits = { '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' , 'i' , 'j' , 'k' , 'l' , 'm' , 'n' , 'o' , 'p' , 'q' , 'r' , 's' , 't' , 'u' , 'v' , 'w' , 'x' , 'y' , 'z' }; private SaltOption opt; /** * Added the SaltOption constructor since everybody * has their own standards when it comes to salting * hashes. * * This gives the developer the option... * * @param option The salt option to use, BEFORE, AFTER, BOTH or NONE. */ public MD5(final SaltOption option) { //TODO: Add Char Encoding options too... I was too lazy! this.opt = option; } /** * * Returns the salted MD5 checksum of the text passed in as an argument. * * If the salt is an empty byte array - no salt is applied. * * @param txt The text to run through the MD5 algorithm. * @param salt The salt value in bytes. * @return The salted MD5 checksum as a byte[] * @throws NoSuchAlgorithmException */ private byte[] createChecksum(final String txt, final byte[] salt) throws NoSuchAlgorithmException { final MessageDigest complete = MessageDigest.getInstance(ALG); if(opt.equals(SaltOption.BEFORE) || opt.equals(SaltOption.BOTH)) { complete.update(salt); } complete.update(txt.getBytes()); if(opt.equals(SaltOption.AFTER) || opt.equals(SaltOption.BOTH)) { complete.update(salt); } return complete.digest(); } /** * * Returns the salted MD5 checksum of the file passed in as an argument. * * If the salt is an empty byte array - no salt is applied. * * @param fle The file to run through the MD5 algorithm. * @param salt The salt value in bytes. * @return The salted MD5 checksum as a byte[] * @throws IOException * @throws NoSuchAlgorithmException */ private byte[] createChecksum(final File fle, final byte[] salt) …
score: -4
answers question: http://stackoverflow.com/q/415953
type: Answer
upvote count: 1

http://stackoverflow.com/a/534929
has comment: http://stackoverflow.com/comment/347740
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/347774
has body: I think what you want is Thread#join threads = [] 10.times do threads &lt;&lt; Thread.new do some_method(:foo) end end threads.each { |thread| thread.join } #or threads.each(&amp;:join) puts 'Done with all threads'
type: Answer
score: 0
answers question: http://stackoverflow.com/q/534919

http://stackoverflow.com/comment/266560
type: Comment
has text: For this to work, you need access to the class file as it was when the object it was serialized. Hopefully it's in the Version Control archive?
type: AnswerComment
comment on: http://stackoverflow.com/a/444934
score: 0

http://stackoverflow.com/q/480566
has answer: http://stackoverflow.com/a/480591
has title: Does a running thread in an object prevent it from being garbage collected in java?
has answer: http://stackoverflow.com/a/480584
accepted answer: http://stackoverflow.com/a/480611
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/480591
tagged with: garbage-collection
type: Question
has comment: http://stackoverflow.com/comment/312784
tagged with: java
has answer: http://stackoverflow.com/a/480598
score: 10
has answer: http://stackoverflow.com/a/480624
answer count: 6
tagged with: concurrency
has comment: http://stackoverflow.com/comment/313899
upvote count: 10
has answer: http://stackoverflow.com/a/480611
has body: Given the code: new Thread(new BackgroundWorker()).start(); Intuitively it feels like the BackgroundWorker instance should be safe from GC until the thread exits, but is this the case ? And why ? Edit: All this heat is basically generated by me asking at least two different questions in the same post. The question in the title has one answer, the code sample leads in a different direction - with two possible outcomes depending on inlining. The answers posted are really excellent. I will be awarding Software Monkey the green checkbox. Please note that Darron's answer is equally valid, but Software Monkey explained the problem I was having; it was the answer that worked for me. Thank you all for making this a memorable affair ;)
downvote count: 0
has comment: http://stackoverflow.com/comment/313495
favorite count: 0
has answer: http://stackoverflow.com/a/480669

http://stackoverflow.com/q/506589
favorite count: 0
has title: How can I successfully extend Graphics in Java
has answer: http://stackoverflow.com/a/506620
possible better answer: http://stackoverflow.com/a/506678
has answer: http://stackoverflow.com/a/506678
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/506620
type: Question
tagged with: graphics
has body: I'm trying to create a generic graphics export tool which works by implementing the Graphics interface and intercepts and interprets the calls to its various methods. However although I can do this successfully for a single component my Graphics class is being replaced when I use it on a component which contains other components. Strangely this only happens on Windows and Linux. On OSX it works fine. Can anyone suggest how I can ensure that it's my original Graphics class which is passed to all subcomponents? I've got a short script which demonstrates the fundamental problem. When I explicitly call paint using an instance of MyGraphics I don't see MyGraphics in the JPanel - just sun.java2d.SunGraphics2D. import java.awt.*; import java.awt.image.*; import java.text.AttributedCharacterIterator; import javax.swing.*; public class GraphicsTest { public static void main(String[] args) { new GraphicsTest(); } public GraphicsTest () { JFrame frame = new JFrame(); frame.getContentPane().add(new MyPanel()); frame.setSize(500,500); frame.setVisible(true); try { Thread.sleep(2000); } catch (InterruptedException e) {} System.out.println("Using my graphics - expect to see 'MyGraphics' next"); frame.paint(new MyGraphics()); } class MyPanel extends JPanel { public void paint (Graphics g) { super.paint(g); System.out.println("Graphics is "+g); g.fillRect(10, 10, 20, 20); } } class MyGraphics extends Graphics { public String toString () { return "MyGraphics"; } public Graphics create() { return this; } // I've left out the huge list of abstract methods from the original script // since they're unchanged from the defaults and don't really matter here. } On my windows system the output is: Graphics is sun.java2d.SunGraphics2D[font=javax.swing.plaf.FontUIResource[family=Dialog,name=Dialog,style=plain,size=12],color=sun.swing.PrintColorUIResource[r=51,g=51,b=51]] Using my graphics - expect to see 'MyGraphics' next Graphics is sun.java2d.SunGraphics2D[font=javax.swing.plaf.FontUIResource…
tagged with: inheritance
score: 4
upvote count: 4
answer count: 2
downvote count: 0

http://stackoverflow.com/a/575693
score: 4
upvote count: 4
downvote count: 0
has body: How about this: https://commons.apache.org/proper/commons-jcs/ (updated to new address, as JCS is now in Apache Commons)
answers question: http://stackoverflow.com/q/575685
type: Answer
has comment: http://stackoverflow.com/comment/51151009

http://stackoverflow.com/a/46649027
score: 6
has comment: http://stackoverflow.com/comment/119614920
has comment: http://stackoverflow.com/comment/123342088
upvote count: 7
downvote count: 1
has comment: http://stackoverflow.com/comment/123667344
answers question: http://stackoverflow.com/q/613954
has comment: http://stackoverflow.com/comment/119215062
has comment: http://stackoverflow.com/comment/119214682
has comment: http://stackoverflow.com/comment/114931729
has comment: http://stackoverflow.com/comment/123667172
type: Answer
has comment: http://stackoverflow.com/comment/119258751
has body: One important thing nobody mentioned is how it interferes with interfaces and lambda expressions. Let's say you define a MyAppException extends Exception. It is the top level exception inherited by all exceptions thrown by your application. In some places you don't want to react to the particular exceptions, you want the caller to resolve it, so you declare throws MyAppException. All looks OK until you want to use someone else's interface. Obviously they don't declare intention to throw MyAppException, so compiler doesn't allow you to even call your methods that declare throws MyAppException in there. This is especially painful with java.util.function. However, if your exception extends RuntimeException, there will be no problem with interfaces. You can mention the exception in JavaDoc if you wish. But other than that it just silently bubbless through anything. Of course that means it can terminate your application. But in lots of enterprise software you have exception handling layer and unchecked exceptions save lots of trouble.

http://stackoverflow.com/q/512342
upvote count: 1
has title: Regex in Java, finding start and end tag
has answer: http://stackoverflow.com/a/18593777
type: Question
has answer: http://stackoverflow.com/a/11853012
possible better answer: http://stackoverflow.com/a/512426
has answer: http://stackoverflow.com/a/512426
has answer: http://stackoverflow.com/a/512445
downvote count: 0
score: 1
favorite count: 0
answer count: 5
tagged with: http://stackoverflow.com/tag/html
has answer: http://stackoverflow.com/a/512444
tagged with: regex
has body: I am trying to find data within a HTML document. I don't need a full blown parser as it is just the data between one tag. But, I want to detect the 'select' tag and the data in between. return Pattern.compile(pattern, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); /// End right angle bracket left off intentionally: track_pattern_buf.append("&lt;select"); track_pattern_buf.append("(.*?)"); track_pattern_buf.append("&lt;/select"); Is this the 'regex' that you would use?
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/512445
tagged with: java

http://stackoverflow.com/q/383995
tagged with: drawing
has answer: http://stackoverflow.com/a/387358
type: AnsweredQuestion
tagged with: java
downvote count: 2
type: Question
has answer: http://stackoverflow.com/a/384072
score: -2
has body: I have the points by the end of the GenerateButton class but now that I got my public double[][] matrix with all the points in, where do I begin drawing them??? my Main.java: import java.awt.*; import javax.swing.*; public class Main { public static Display display = new Display(); public static void main(String[] args) { display.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); display.setVisible(true); } } my Display.java: import java.awt.*; import java.awt.event.*; import java.awt.dnd.*; import java.util.Vector; import javax.swing.*; public class Display extends JFrame { final int FRAME_WIDTH = 910; final int FRAME_HEIGHT = 660; final int X_OFFSET = 40; final int Y_OFFSET = 40; final int GRAPH_OFFSETX = 15; final int GRAPH_OFFSETY = 40; final int GRAPH_WIDTH = 500; final int GRAPH_HEIGHT = 500; final int GRAPH_INTERVAL = 20; JButton submit; JTextField numPoint; JPanel bpanel; JPanel points; Vector&lt;JTextField&gt; pointsA = new Vector&lt;JTextField&gt;(); int maxPoints; public double[][] matrix; public Display() { init(); } public void init() { setBackground(Color.WHITE); setLocation(X_OFFSET, Y_OFFSET); setSize(FRAME_WIDTH, FRAME_HEIGHT); setTitle("Geometric Transformations"); getContentPane().setLayout(null); setDefaultLookAndFeelDecorated(true); numPoint = new JTextField(); numPoint.setText("# Points?"); numPoint.setBounds(530,200,120+20,25); SubmitButton submit = new SubmitButton("Submit"); submit.setBounds(530+150, 200, 100, 25); GenerateButton submitC = new GenerateButton("Generate"); submitC.setBounds(530-5, 200+130, 100, 25); points = new JPanel(new GridLayout(2,2)); points.setBounds(530, 200+40,100+270,80); this.add(numPoint); this.add(submit); this.add(submitC); this.add(points, BorderLayout.LINE_START); repaint(); } public void paint(Graphics g) { super.paint(g); g.setColor(Color.WHITE); g.fillRect(100, 100, 20, 30); g.setColor(Color.BLACK); genGraph(g, GRAPH_OFFSETX, GRAPH_OFFSETY, GRAPH_WIDTH, GRAPH_HEIGHT, GRAPH_INTERVAL); } public void genGraph (Gra…
has title: Where should I start drawing? (Java,GUI)
accepted answer: http://stackoverflow.com/a/384072
answer count: 2
upvote count: 0
tagged with: user-interface
favorite count: 0
tagged with: jframe
possible better answer: http://stackoverflow.com/a/387358

http://stackoverflow.com/comment/59979077
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/547219
has text: I am on Debian 7.9 and Firefox 38.7.1. Disabling OCSP (Preferences > Advanced > Certificates > Validation) worked for me. This problem is pretty commonly faced when accessing an internally developed Java web application. No one solution appears to work for all.
score: 0

http://stackoverflow.com/comment/368621
score: 0
type: Comment
type: QuestionComment
has text: I was looking for the JVM Eclipse was running on. I agree that my question was perhaps not that clear because I mentioned the part from the docs. Thanks for your answer though.
comment on: http://stackoverflow.com/q/557169

http://stackoverflow.com/a/404583
upvote count: 1
type: Answer
has body: but my impression of frameworks is that they're mostly used for large J2EE applications and involve a lot of complex configuration Not necessarily true. The good frameworks are built to scale well so that they will take you from small apps to very large apps. Many of the frameworks today are moving towards zero configuration so you will find them easier and easier to use. You are right that it does take an initial effort to learn the framework itself but that investment pays for itself in the very first application you build. And meta frameworks like AppFuse makes it even easier to get started since it pre-configures the frameworks for you.
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/403825

http://stackoverflow.com/a/371034
has comment: http://stackoverflow.com/comment/199860
downvote count: 8
answers question: http://stackoverflow.com/q/371026
score: 4
accepted answer of: http://stackoverflow.com/q/371026
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/99387567
upvote count: 12
has comment: http://stackoverflow.com/comment/80641672
type: Answer
has body: Straight-forward implementation of your homework: List&lt;Integer&gt; ints = new ArrayList&lt;Integer&gt;(); for (int i = 0; i &lt; count; i++) { ints.add(first + i); }

http://stackoverflow.com/comment/406361
comment on: http://stackoverflow.com/q/594613
score: 0
type: Comment
has text: Ironically, I'm trying to get away from Datatables/Datasets and just use Business Objects/DAL/UI layer in my ASP.NET app.
type: QuestionComment

http://stackoverflow.com/q/458817
type: AnsweredQuestion
tagged with: java
has title: Java Swing: Libraries, Tools, Layout Managers
downvote count: 1
accepted answer: http://stackoverflow.com/a/459609
type: Question
possible better answer: http://stackoverflow.com/a/459543
has answer: http://stackoverflow.com/a/459526
has answer: http://stackoverflow.com/a/459543
has body: What libraries/tools do you have in your Java Swing Tool set? XUL Layout Managers Packagers/Installers Books etc.....
answer count: 7
has answer: http://stackoverflow.com/a/459494
has answer: http://stackoverflow.com/a/458937
favorite count: 0
has answer: http://stackoverflow.com/a/459609
has answer: http://stackoverflow.com/a/458983
score: 16
tagged with: swing
tagged with: devtools
upvote count: 17
has answer: http://stackoverflow.com/a/458968

http://stackoverflow.com/a/421815
answers question: http://stackoverflow.com/q/421782
has body: While it doesn't work for edge cases, building a Map between Classes and Converters X.getClass() -> X Converter Y.getClass() -> Y Converter would get you a lot closer. You'd want to also check superclasses if the leaf class is not found.
score: 0
type: Answer

http://stackoverflow.com/q/563952
tagged with: interface
favorite count: 0
has body: I've been looking at the JMS API from J2EE and found a strange behavior where certain methods that are declared in an interface (e.g., createQueue in Session) are declared again in the subinterfaces such as QueueSession, and with identical documentation. Since an subinterface "inherits" all the method declarations of the interface it inherits, and since the JavaDoc tool has no problem sorting out the JavaDocs of the subinterface and creating an "inherited operations" list, I can't figure out what this achieves. The only think of is that initially the call was in Session, and then moved to QueueSession when the specific subclass was created, though then I would have expected to see something in the documentation of the upperclass. But this is just conjecture. So the question is: Is there a convincing reason to redeclare a method in a subinterface?
has answer: http://stackoverflow.com/a/564022
score: 9
accepted answer: http://stackoverflow.com/a/564041
has title: In Java when one interface extends another, why would one redeclare a method in a subinterface?
has answer: http://stackoverflow.com/a/567646
upvote count: 9
tagged with: java
answer count: 5
possible better answer: http://stackoverflow.com/a/567646
has answer: http://stackoverflow.com/a/563976
downvote count: 0
has answer: http://stackoverflow.com/a/564165
has answer: http://stackoverflow.com/a/564041
type: Question
type: AnsweredQuestion

http://stackoverflow.com/comment/231481
has text: @Andrew :I am using jsf and not struts.Do you know dependency for tiles in jsf?
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/406562

http://stackoverflow.com/q/442322
has answer: http://stackoverflow.com/a/443162
score: 6
has answer: http://stackoverflow.com/a/442398
has comment: http://stackoverflow.com/comment/264311
has answer: http://stackoverflow.com/a/442578
has answer: http://stackoverflow.com/a/442366
has answer: http://stackoverflow.com/a/442481
answer count: 15
has comment: http://stackoverflow.com/comment/22506267
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/442565
has answer: http://stackoverflow.com/a/442341
tagged with: java
downvote count: 3
tagged with: language-features
accepted answer: http://stackoverflow.com/a/442333
has answer: http://stackoverflow.com/a/442629
type: Question
has body: Are primitives worth keeping? Should all the deprecated stuff be deleted? Do we need 2 GUI frameworks? ...
upvote count: 9
has answer: http://stackoverflow.com/a/442483
has comment: http://stackoverflow.com/comment/265062
has title: Should Java break backwards compatibility in future versions for the benefit of a cleaner language?
has answer: http://stackoverflow.com/a/442333
has answer: http://stackoverflow.com/a/442382
has answer: http://stackoverflow.com/a/442345
has answer: http://stackoverflow.com/a/3329939
linked to: http://stackoverflow.com/q/314540
favorite count: 0
possible better answer: http://stackoverflow.com/a/442629
has answer: http://stackoverflow.com/a/442558
has answer: http://stackoverflow.com/a/442327

http://stackoverflow.com/q/587899
has title: JMS Messaging Performance: Lots of Topics/Queues vs. Extensive Filtering (Message Selectors)
tagged with: jms
possible better answer: http://stackoverflow.com/a/685275
accepted answer: http://stackoverflow.com/a/673558
has answer: http://stackoverflow.com/a/588194
has answer: http://stackoverflow.com/a/588357
upvote count: 24
tagged with: messaging
type: AnsweredQuestion
tagged with: performance
tagged with: java
score: 24
tagged with: jboss
type: Question
has body: I'm working on a project that is going to make heavy use of JBoss Messaging (JMS). I'm tasked with building an easy to use wrapper around Messaging for other developers and am thinking about using JMS's Message Selectors to provide a filtering technique to keep unnecessary sending of messages to a minimum. I'm curious if anyone has any experience with doing so in regards to performance? My fear is that the JMS provider may get bogged down with the Message Selectors, effectively defeating the whole purpose. It would be much nicer however than creating a long list of Topics/Queues for every message type. Ultimately I'll undoubtedly end up using some combination of the two, but am concerned with the impact on performance whichever way I lean more towards.
has answer: http://stackoverflow.com/a/673558
has answer: http://stackoverflow.com/a/587934
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/685275
answer count: 5

http://stackoverflow.com/comment/133400088
type: AnswerComment
score: 0
type: Comment
has text: Learn to give recognition. This is taken from @Mark Byers at https://stackoverflow.com/questions/11149342/adding-space-between-characters
comment on: http://stackoverflow.com/a/49058835

http://stackoverflow.com/a/792007
answers question: http://stackoverflow.com/q/602249
has body: There's no text serialization format for AttributedString, you'd have to write your own. AttributedString/AttributedCharacterIterator is an old API first introduced in Java 1.2 and has never been 'beefed up' to provide a good styled text model. You'll notice for example that it's missing a few obvious things, such as a 'length()' method, or implementing Externalizable/Serializable. You can iterate over it by getting an AttributedCharacterIterator for it, but since a custom subclass of AttributedCharacterIterator.Attribute can be present, you can't reliably record everything without native serialization. It's better to just use AttributedString as an intermediate format used for talking to the InputMethod or TextLayout APIs, and store your styled text some other way.
type: Answer
score: 0

http://stackoverflow.com/q/450520
has body: In Java 1.4.2, class java.math.BigInteger implements interfaces Comparable, Serializable. In Java 1.5.0, class java.math.BigInteger implements interfaces Serializable, Comparable&lt;BigInteger&gt;. This is just an example to help me ask about &lt; and &gt;. What I am really wondering about is the &lt; and &gt; stuff. My question is threefold: what does the &lt;BigInteger&gt; part of the implements statement mean? what is that syntax called? and what does it do? P.S.: It's really hard to google for &lt; and &gt; and impossible to search SO for &lt; and &gt; in the first place. Thanks!
tagged with: generics
possible better answer: http://stackoverflow.com/a/450526
has title: What do < and > mean such as implements Comparable<BigInteger>?
downvote count: 0
has answer: http://stackoverflow.com/a/450526
has answer: http://stackoverflow.com/a/450527
accepted answer: http://stackoverflow.com/a/450527
type: Question
type: AnsweredQuestion
tagged with: syntax
score: 7
tagged with: java
tagged with: comparable
answer count: 2
upvote count: 7
favorite count: 0

pdfbox
tag name: pdfbox
tags question: http://stackoverflow.com/q/586257
type: Tag

http://stackoverflow.com/comment/351980
comment on: http://stackoverflow.com/a/538538
score: 0
has text: I've seen numerous references citing modules are the way to go. What is an example of an OCaml implementation of Singleton using modules? Does it enforce all of the characteristics of Singleton (e.g. private constructor, single instance enforcement, etc.)? Thanks!
type: AnswerComment
type: Comment

static-methods
tags question: http://stackoverflow.com/q/595301
tags question: http://stackoverflow.com/q/587280
tags question: http://stackoverflow.com/q/538870
tags question: http://stackoverflow.com/q/512877
tags question: http://stackoverflow.com/q/606196
tags question: http://stackoverflow.com/q/370962
tag name: static-methods
type: Tag

http://stackoverflow.com/q/405078
has title: Best way to get started on simple 3D user interfaces using Java?
type: Question
has answer: http://stackoverflow.com/a/1239514
tagged with: 3d
answer count: 3
downvote count: 0
favorite count: 0
type: UnansweredQuestion
upvote count: 1
has answer: http://stackoverflow.com/a/405115
score: 1
tagged with: java
has body: I'm writing a time management application and I have an idea for presenting timelines and todo items in 3D. Visually, I imagine this as looking down a corridor or highway in 3D, with upcoming deadlines and tasks represented as signposts - more important items are larger and upcoming deadlines are nearer. I want to do this in Java, however I have no idea how to begin. For example, I would like to be able to render text and 2D graphics (dates, calendars etc) on the floor/walls of the corridoor, as well as on task items. The tasks themselves could be simple blocks. However examples of 3D code I have seen all look to operate on a very low level, and what I can't figure out are the appropriate co-ordinates to be using, or how the user would be able to interact with the view by selecting items with the mouse (for example clicking an expand or info button to get/edit task properties with the usual swing components). Is there any higher level API I could be using, or example code that does this sort of thing? Any other ideas for how best to approach this problem? edit: removed Java3D requirement - I just need to do this in Java.
has answer: http://stackoverflow.com/a/405276

http://stackoverflow.com/a/4374736
has body: I would say I personally like to use HtmlUnit and Selenium as my 2 favorite tools for Screen Scraping.
downvote count: 0
type: Answer
upvote count: 2
score: 2
answers question: http://stackoverflow.com/q/422913

http://stackoverflow.com/q/570401
favorite count: 0
has answer: http://stackoverflow.com/a/65371616
has body: I know using .NET languages such as C#, one can do something like Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) to find the redirected location of the Desktop. However, under Java, I cannot think of a good way to do this. What is the most appropriate way to find a redirected user Desktop directory from Java, without using JNI? The specific purpose here is for the purposes of managing a desktop shortcut, if the user wants one, for a Java Web Start application. This application needs to write to the "Application Data" tree as well as optionally to the Desktop. I am making the assumption that %APPDATA% is always correctly populated, even when folders are redirected, for finding the "Application Data" tree. So my open question is how to reliably find the Desktop folder. NOTE: I believe that the Java system property ${user.home} actually (and erroneously) locates the user's Desktop directory via registry keys and then tries to navigate up one directory to find the "home" directory. This works fine when no directories are redirected, and otherwise may or may not return something useful.
answer count: 3
tagged with: windows
upvote count: 13
has title: In java under Windows, how do I find a redirected Desktop folder?
tagged with: http-redirect
score: 13
has answer: http://stackoverflow.com/a/570536
has answer: http://stackoverflow.com/a/10201804
type: AnsweredQuestion
tagged with: java
tagged with: desktop
type: Question
tagged with: find
downvote count: 0
accepted answer: http://stackoverflow.com/a/570536
possible better answer: http://stackoverflow.com/a/65371616

http://stackoverflow.com/a/479579
has comment: http://stackoverflow.com/comment/61541042
type: Answer
answers question: http://stackoverflow.com/q/479565
downvote count: 1
has body: Aren't enums best choice for these kinds of stuff?
upvote count: 5
has comment: http://stackoverflow.com/comment/135552623
score: 4

http://stackoverflow.com/comment/52038507
comment on: http://stackoverflow.com/a/440801
type: AnswerComment
has text: http://docs.oracle.com/javase/7/docs/api/java/lang/ClassLoader.html#getResource(java.lang.String) says: `The name of a resource is a '/'-separated path name that identifies the resource`. So you shouldn't use File.separator. You're specifying resource name here, not file system path.
type: Comment
score: 2

tomcat
tags question: http://stackoverflow.com/q/468649
tags question: http://stackoverflow.com/q/601497
tags question: http://stackoverflow.com/q/579224
tags question: http://stackoverflow.com/q/605749
tags question: http://stackoverflow.com/q/607232
tags question: http://stackoverflow.com/q/624607
tags question: http://stackoverflow.com/q/498534
tags question: http://stackoverflow.com/q/376561
tags question: http://stackoverflow.com/q/503057
tags question: http://stackoverflow.com/q/567810
tags question: http://stackoverflow.com/q/456162
tags question: http://stackoverflow.com/q/613514
tags question: http://stackoverflow.com/q/558502
tags question: http://stackoverflow.com/q/446439
tags question: http://stackoverflow.com/q/371495
tags question: http://stackoverflow.com/q/375332
tags question: http://stackoverflow.com/q/565871
tags question: http://stackoverflow.com/q/483963
tags question: http://stackoverflow.com/q/450165
tags question: http://stackoverflow.com/q/582418
tags question: http://stackoverflow.com/q/403902
tags question: http://stackoverflow.com/q/444731
tags question: http://stackoverflow.com/q/415520
tags question: http://stackoverflow.com/q/362665
tags question: http://stackoverflow.com/q/445049
tags question: http://stackoverflow.com/q/571565
tag name: tomcat
tags question: http://stackoverflow.com/q/376279
tags question: http://stackoverflow.com/q/460752
tags question: http://stackoverflow.com/q/550024
tags question: http://stackoverflow.com/q/466589
tags question: http://stackoverflow.com/q/473011
tags question: http://stackoverflow.com/q/523051
tags question: http://stackoverflow.com/q/584804
tags question: http://stackoverflow.com/q/615493
tags question: http://stackoverflow.com/q/477886
tags question: http://stackoverflow.com/q/369023
tags question: http://stackoverflow.com/q/615222
tags question: http://stackoverflow.com/q/435069
tags question: http://stackoverflow.com/q/611465
type: Tag
tags question: http://stackoverflow.com/q/578073
tags question: http://stackoverflow.com/q/634092
tags question: http://stackoverflow.com/q/640022
tags question: http://stackoverflow.com/q/490792
tags question: http://stackoverflow.com/q/580682
tags question: http://stackoverflow.com/q/559433
tags question: http://stackoverflow.com/q/605127
tags question: http://stackoverflow.com/q/545177
tags question: http://stackoverflow.com/q/472896
tags question: http://stackoverflow.com/q/497830
tags question: http://stackoverflow.com/q/627769
tags question: http://stackoverflow.com/q/546097
tags question: http://stackoverflow.com/q/434385
tags question: http://stackoverflow.com/q/407405
tags question: http://stackoverflow.com/q/436752
tags question: http://stackoverflow.com/q/640161
tags question: http://stackoverflow.com/q/388208
tags question: http://stackoverflow.com/q/525408

http://stackoverflow.com/q/519631
has title: Is null a Java keyword?
answer count: 9
accepted answer: http://stackoverflow.com/a/519632
linked to: http://stackoverflow.com/q/2707322
has body: Is null is a keyword in Java?
type: Question
has answer: http://stackoverflow.com/a/522252
has answer: http://stackoverflow.com/a/20523133
has answer: http://stackoverflow.com/a/519638
downvote count: 11
tagged with: java
has answer: http://stackoverflow.com/a/46871558
tagged with: keyword
has answer: http://stackoverflow.com/a/13399828
upvote count: 24
has answer: http://stackoverflow.com/a/522918
has comment: http://stackoverflow.com/comment/333609
tagged with: null
has answer: http://stackoverflow.com/a/519632
has comment: http://stackoverflow.com/comment/333188
has comment: http://stackoverflow.com/comment/8733583
has answer: http://stackoverflow.com/a/519642
has answer: http://stackoverflow.com/a/519635
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/519635
favorite count: 0
score: 13

http://stackoverflow.com/comment/324885
comment on: http://stackoverflow.com/a/509268
score: 0
type: AnswerComment
type: Comment
has text: Thanks a lot… That was the problem, I should compile with Java 5 and extend the entity limit: Java -DentityExpansionLimit=512000 Main

http://stackoverflow.com/a/460859
downvote count: 0
score: 1
has body: Wicket has "proper mark-up/logic separation" (as they put it).
upvote count: 1
has comment: http://stackoverflow.com/comment/279793
answers question: http://stackoverflow.com/q/460850
type: Answer

http://stackoverflow.com/comment/36090952
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/23102809
type: Comment
has text: Note: Turns out, after actually trying it later... the above does not actually work. I tried it with a few different javac flags and was unable to get the name used for the parameter to be retained.

http://stackoverflow.com/a/563178
has comment: http://stackoverflow.com/comment/374617
score: 6
has body: Also, getClass() will obscure the actual class if there's a subclass that's actually invoking the method. For example, assume that in class A, method X, you call log.debug() and class B extends class A, overwriting method X, but calling super.X at some point. The log file will show class B, not class A.
has comment: http://stackoverflow.com/comment/374498
answers question: http://stackoverflow.com/q/563144
has comment: http://stackoverflow.com/comment/374502
downvote count: 0
type: Answer
upvote count: 6

http://stackoverflow.com/comment/439937
has text: The problem I see here is: This solution want stop any thread from adding data to the list. In the other solutions above this is done through synchronzied-blocks.
type: Comment
score: 0
comment on: http://stackoverflow.com/a/627242
type: AnswerComment

http://stackoverflow.com/a/396624
has body: If you only need value objects then just ensure the POJOs implement Serializable and write the objects across sockets (using ObjectOutputStream). On the receiving end read the objects using ObjectInputStream. The receiving end has to have a compatible version of the POJO (see serialVersionUID). Hessian/Burlap 'protocol-ize this: http://hessian.caucho.com/ and http://www.caucho.com/resin-3.0/protocols/burlap.xtp
score: 0
answers question: http://stackoverflow.com/q/396569
type: Answer

http://stackoverflow.com/comment/32170024
type: AnswerComment
has text: Your answer holds no value since it is just a subset of the previously approved answer. You should try not to answer in this manner, especially not considering it is a very old question with a already existing quality answer.
type: Comment
score: 16
comment on: http://stackoverflow.com/a/21338583

http://stackoverflow.com/a/587124
downvote count: 0
type: Answer
has body: #!/bin/bash function failure() { echo "$@" &gt;&amp;2 exit 1 } javac *.java || failure "Failed to compile" java -ea HelloWorld &gt; HelloWorld.txt || failure "Failed to run" mv HelloWorld.txt ./HelloWorldDir || failure "Failed to move" Also you have to ensure that java exits with a non-zero exit code, but that's quite likely for a uncaught exception. Basically exit the shell script if the command fails.
upvote count: 3
score: 3
answers question: http://stackoverflow.com/q/587099

http://stackoverflow.com/q/520902
downvote count: 0
tagged with: maven-2
favorite count: 0
has answer: http://stackoverflow.com/a/527924
accepted answer: http://stackoverflow.com/a/527924
has title: Trouble getting Hibernate Core and Hibernate Annotations using Apache Ivy (but it's also Maven2 related.)
type: AnsweredQuestion
tagged with: java
tagged with: hibernate
tagged with: ivy
tagged with: annotations
has answer: http://stackoverflow.com/a/523941
type: Question
has body: It's a long one! ;-) There are a lot of copy pasted text in this question which makes it look complicated. And to be honest, it's a lot of information! However to an experienced person a lot of it might be unnecessary and easy to skim over. In its essence I'm only wondering why my basic Hibernate Core + Hibernate Annotations test project doesn't work. I suspect missing dependencies, but I'm using Apache Ivy which I thought would get transitive dependencies automatically from the Maven2 repository ibiblio, but there clearly are dependencies missing (see headline lower in the post about dependencies). My test project I have a small test project: hibernate.cfg.xml <?xml version="1.0" encoding="UTF-8"?> <hibernate-configuration> com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/webcookieschema webcookieuser tHePaSsWoRd org.hibernate.dialect.MySQLInnoDBDialect </hibernate-configuration> Test.java public class Test { public static void main(String[] args) { UserDAO udao = new HibernateUserDAO(); User u = new User(); u.setName("somename"); udao.store(u); } } HibernateUserDAO.java import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.AnnotationConfiguration; public class HibernateUserDAO implements UserDAO { private SessionFactory sessionFactory; public HibernateUserDAO() { AnnotationConfiguration annotConf = new AnnotationConfiguration(); annotConf.addAnnotatedClass(User.class); annotConf.configure(); // The line below generates the exception! sessionFactory = annotConf.buildSessionFactory(); } @Override public void store(User user) { Session session = sessionFactory.openSession(); Transaction tx = session.getTransaction(); try { tx.begin(); session.saveOrUpdate(user); tx.commit(); } catch (RuntimeException e) { tx.rollback(); throw e; } finally { session.close(); } } } log4j.properties log4j.appender.Stdout=org.apache.log4j.ConsoleAppender log4j.appender.Stdout.layout=org.apache.log4j.PatternLayout lo…
upvote count: 12
possible better answer: http://stackoverflow.com/a/523941
score: 12
answer count: 2

http://stackoverflow.com/a/628072
score: 7
has body: Personally I really like immutable types. I would write p.plus(q) instead of p.add(q) and make it return a new polynomial. Immutability has a lot going for it, not just in terms of thread-safety (which sounds like it won't be an issue in this case) but also in terms of reasoning about your code. It's a lot easier to predict what's going to happen if you know that nothing can change the contents of an object under your feet once you've stashed a reference to it.
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/628049
accepted answer of: http://stackoverflow.com/q/628049
type: Answer
upvote count: 7

http://stackoverflow.com/a/642920
downvote count: 0
type: Answer
has body: OK, second take (I left the first one as it might interest somebody for some other usage, who know? Say it is there for educational purpose... :-)). I had a look at the source code of JTable and found out that mouse events are handled by the look and feel. Knowing how it handles the control key, I could safely override the changeSelection method to do what you need. I find requirements a bit strange (you can still use Shift+click, no?) but I don't know context. class SpecialTable extends JTable { SpecialTable(Object[][] data, String[] columnNames) { super(data, columnNames); // That's already the default // setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } /** * Called by javax.swing.plaf.basic.BasicTableUI.Handler.adjustSelection(MouseEvent) * like: table.changeSelection(pressedRow, pressedCol, e.isControlDown(), e.isShiftDown()); */ @Override public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) { if (toggle &amp;&amp; !isRowSelected(rowIndex)) return; // Don't do the selection super.changeSelection(rowIndex, columnIndex, toggle, extend); } } Much simpler and exactly what you need! BTW, thanks for providing such simple good test case, I might have not tried if I had to write it myself... :-D It was an interesting and learning challenge.
has comment: http://stackoverflow.com/comment/456393
accepted answer of: http://stackoverflow.com/q/639397
answers question: http://stackoverflow.com/q/639397
score: 10
upvote count: 10
type: AcceptedAnswer

porting
tags question: http://stackoverflow.com/q/397867
tag name: porting
tags question: http://stackoverflow.com/q/427035
type: Tag

http://stackoverflow.com/a/2067784
downvote count: 0
type: Answer
has body: I've used both teçhnologies for some time. Futureproof - both of them will be succesful i guess, but every technology will be prefered in different situations. For example flex in large (mostly intranet) enterprises with desired desktop like ui (Flex can be used on the top of the any server platform(jvm,.Net,php,ruby,coldfusion)). GWT otherwise will be dominant in small to medium app with traditional jvm backend (tomcat+spring etc.) Works on all major browsers - both are non-problematic in this way. Flex absolutly excellent, when flash plugin is installed there is not need to solve any cross-browser compatibility (of course... browser are passive, when flash app runs:). I remember we had some minor problems with GWT and tradional troublemaker IE6, but nothing horrible... Fast &amp; responsive user experience - both are the top in their category. Flex i think absolutly the top of the all RIA solutions(maybe silverlight, java fx can be only competitors in richnest), expecially integrated with LCDS with cool features like data management, real server side data push etc. GWT is the one of the top in ajax framework category. The more richest and complicated ui you need, the more reasons to using flex you have. Intepreted javascript in any case can't be faster&amp;responsive then compiled actionscript/swf. Code should be unit testable - yes, they are greatly testable. Code must be maintainable - both excellent, maintaining actionscript is comparable to java(gwt), if you use a good IDE for example Flex Builder. Speed &amp; ease of development - both perfect if you know your staff. Everything depends of your backround. For typical java developer learning curve to flex will be probably a little bit more difficult(You need to learn a new compliler/runtime and probably new IDE or at least new eclipse IDE plugin:). Some knowledge of flash is a +, but not required and only usually with specific tasks like building your own components etc. Supports vector graphics of some sort (S…
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/424895
has comment: http://stackoverflow.com/comment/3602881

http://stackoverflow.com/a/519777
upvote count: 2
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/414915
has body: This is caused by AWT erasing the GLCanvas every time before JOGL repaints it and can be worked around by inserting the following line into your main() method: System.setProperty("sun.awt.noerasebackground", "true"); While this solves the given problem, side effects are possible in other areas of the application such as visible artifacts when resizing the window. I use this in all my JOGL apps though without any problems.
type: Answer
has comment: http://stackoverflow.com/comment/5627911

http://stackoverflow.com/comment/88065032
type: AnswerComment
comment on: http://stackoverflow.com/a/568241
type: Comment
has text: Maybe it's the 9 years since the original reply, but for me (Windows, Maven 3.5) running 'mvn dependency:copy-dependencies' is working event without the new element on pom.xml
score: 3

http://stackoverflow.com/a/826600
type: Answer
score: 0
has body: If you understand the idea of OOP through your Java experience, and if you have a basic idea of what pointers and memory management are, then the last obstacle in your way will be the alien syntax. Syntax: I found this tutorial, among others, very clear and concise. In my mind, I conceptually mapped Objective-C and Java infrastructure, which you can do for the most part (i.e. a message is for the most part a method, a protocol is an interface, and so forth). Once you get over the initial shock, you will find that Objective-C development for UI applications can be rather intuitive and pleasant. Structure: I don't program UI so much, so I found that I needed to get a better grasp of the MVC paradigm. You may also find some cool language features, such as categories, that you wish you had in Java. I likewise find the lack of some other constructs, such as the lack of static members.
answers question: http://stackoverflow.com/q/487932

http://stackoverflow.com/q/403378
has answer: http://stackoverflow.com/a/403418
tagged with: java
has answer: http://stackoverflow.com/a/403472
has body: new to Java. I want to use the org.apache.commons.lang.WordUtils package. Tried importing it. Tried downloading it and adding it to my build path. When I use intellisense for the word WordUtils Eclipse auto puts the import statement at the top of the file. I get the following error when compiling: ConvertToUrl.java:3: package org.apache.commons.lang import org.apache.commons.lang.WordUtils; ^ ConvertToUrl.java:36: cannot find symbol symbol : variable WordUtils location: class d6.common.ConvertToUrl url = WordUtils.capitalizeFully(url); ^ 2 errors And when I remove the import statement at the top I get: ConvertToUrl.java:34: cannot find symbol symbol : variable WordUtils location: class d6.common.ConvertToUrl url = WordUtils.capitalizeFully(url); ^ 1 error Thanks
has answer: http://stackoverflow.com/a/403506
tagged with: eclipse
has comment: http://stackoverflow.com/comment/228532
tagged with: classpath
type: Question
answer count: 8
has answer: http://stackoverflow.com/a/403404
score: 0
has answer: http://stackoverflow.com/a/403482
has title: Java cannot find symbol compile error
has answer: http://stackoverflow.com/a/403413
has answer: http://stackoverflow.com/a/403461
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/228529
has answer: http://stackoverflow.com/a/5192797

http://stackoverflow.com/comment/281667
type: Comment
comment on: http://stackoverflow.com/a/463078
has text: Thank you. C#'s using keyword is great, but sometimes it cannot be used (e.g. with a type that does not implement IDisposable, or when Dispose() should be called conditionally). As for Java, I have no experience actually with such issues, but can't a thread be interrupted?
type: AnswerComment
score: 0

http://stackoverflow.com/a/620893
has comment: http://stackoverflow.com/comment/9292864
upvote count: 6
has body: Turns out that part of the heap was getting swapped out to disk, so that garbage collection had to pull a bunch of data off the disk back into memory. I resolved this by setting Linux's "swappiness" parameter to 0 (so that it wouldn't swap data out to disk).
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/574021
answers question: http://stackoverflow.com/q/574021
type: Answer
downvote count: 0
score: 6

http://stackoverflow.com/a/617601
downvote count: 1
has comment: http://stackoverflow.com/comment/430561
has comment: http://stackoverflow.com/comment/430537
has comment: http://stackoverflow.com/comment/430721
score: 6
has comment: http://stackoverflow.com/comment/430546
has comment: http://stackoverflow.com/comment/430568
has comment: http://stackoverflow.com/comment/430556
answers question: http://stackoverflow.com/q/617585
has body: Personally, I just enabled HTTP compression in the server and I leave my HTML readable. But for what you want, you could just use String.replaceAll() with a regex that matching what you have specified. Off the top of my head, something like: small=large.replaceAll("\\s{2,}"," ");
type: Answer
has comment: http://stackoverflow.com/comment/430605
has comment: http://stackoverflow.com/comment/430726
upvote count: 7

http://stackoverflow.com/comment/398768
comment on: http://stackoverflow.com/a/586917
has text: FYI, the folder that corresponds to the user's home directory is CSIDL_PROFILE. See http://msdn.microsoft.com/en-us/library/bb762494(VS.85).aspx.
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/a/629900
score: 1
answers question: http://stackoverflow.com/q/629506
has comment: http://stackoverflow.com/comment/442812
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/447109
downvote count: 0
has body: Since Swing didn't change much in the last ten years, you should not run into many problems. Java 6 also hasn't many new features over Java 5 (mostly internal cleanup). I suggest to just try to compile your app with Java 5 and run it. It might work out of the box.
has comment: http://stackoverflow.com/comment/442673
has comment: http://stackoverflow.com/comment/447381

http://stackoverflow.com/comment/139555763
type: Comment
score: 1
has text: instead of editing the registry, maybe be better use the `ftype` (and `assoc`) commands for Windows (`assoc /?` and `ftype /?` for help)
type: AnswerComment
comment on: http://stackoverflow.com/a/79143602

http://stackoverflow.com/comment/379566
has text: It turns out that OS X localization works by changing the name displayed to the user, not the actual filename. Reference below. http://developer.apple.com/documentation/MacOSX/Conceptual/BPInternational/Articles/LocalizingPathnames.html#//apple_ref/doc/uid/20002141-BBCFJBFB
type: Comment
score: 2
comment on: http://stackoverflow.com/a/567902
type: AnswerComment

http://stackoverflow.com/a/605866
downvote count: 0
accepted answer of: http://stackoverflow.com/q/605859
score: 3
answers question: http://stackoverflow.com/q/605859
has comment: http://stackoverflow.com/comment/418016
has comment: http://stackoverflow.com/comment/418024
type: AcceptedAnswer
has body: You could call getClass() on the first object in the list. That would give you a Class&lt;? extends T&gt; rather than Class&lt;T&gt; though - and in particular that means may will be some methods which are given which shouldn't be (because they're not methods on T itself).
upvote count: 3
type: Answer

http://stackoverflow.com/comment/17722572
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/493177
has text: One quick question erickson, how did you figure out how many bytes are being read with the ProcessMonitor? I'm having the same problem trying to profile our builds with Windows XP

http://stackoverflow.com/comment/72164820
score: 1
type: AnswerComment
has text: Neither links you provided work any longer. Not surprising since you posted this 8 years ago :)
type: Comment
comment on: http://stackoverflow.com/a/439761

http://stackoverflow.com/q/438463
has answer: http://stackoverflow.com/a/444454
has answer: http://stackoverflow.com/a/29670746
has answer: http://stackoverflow.com/a/444374
has title: JOptionPane won't show its dialog on top of other windows
upvote count: 13
has answer: http://stackoverflow.com/a/438815
tagged with: joptionpane
type: UnansweredQuestion
tagged with: java
score: 13
tagged with: swing
type: Question
answer count: 6
has answer: http://stackoverflow.com/a/445385
has body: I have problem currently for my swing reminder application, which able to minimize to tray on close. My problem here is, I need JOptionPane dialog to pop up on time according to what I set, but problem here is, when I minimize it, the dialog will pop up, but not in the top of windows when other application like explorer, firefox is running, anyone know how to pop up the dialog box on top of windows no matter what application is running?
downvote count: 0
has answer: http://stackoverflow.com/a/15604780
favorite count: 0

http://stackoverflow.com/q/540738
favorite count: 0
has answer: http://stackoverflow.com/a/541308
answer count: 2
accepted answer: http://stackoverflow.com/a/540762
upvote count: 3
tagged with: java
has comment: http://stackoverflow.com/comment/354478
has title: Excessive memory allocation in Java Sandbox security
tagged with: resources
downvote count: 0
tagged with: security
has answer: http://stackoverflow.com/a/540762
type: Question
type: AnsweredQuestion
score: 3
has body: Under the Java security model it is possible to block most dangerous actions from untrusted classes, but the last time I checked (a few years ago now) it was still possible for untrusted code to perform a denial of service attack by continually allocating memory until the JVM crashes with an OutOfMemoryException. Looking now, I can't see any improvement in the situation. I have a requirement to run untrusted code from 3rd parties inside a Java application and I'd like to know if it is possible to somehow restrict the heap/stack space that a class or thread can allocate in the Java security model. Thus preventing memory allocation based DoS attacks. I know about -Xss, but as I understand it that restricts all threads, most of which need no restriction. I have also considered creating a container for the untrusted code that will run in its own JVM and communicate with the main app through sockets, or doing some static analysis on the untrusted code. However, these both sound like more effort than I hoped, although if someone knows of a trick or opensource library for this I'm interested. So, is there a way to restrict the amount of memory than a thread can allocate to itself or some other way of preventing memory allocation denial of service attacks in Java?
possible better answer: http://stackoverflow.com/a/541308

http://stackoverflow.com/a/438589
downvote count: 0
has comment: http://stackoverflow.com/comment/15598458
has comment: http://stackoverflow.com/comment/262208
type: Answer
has comment: http://stackoverflow.com/comment/261238
score: 5
upvote count: 5
answers question: http://stackoverflow.com/q/438397
has comment: http://stackoverflow.com/comment/261114
has comment: http://stackoverflow.com/comment/261240
has body: In order to print, the security manager needs to allow it to access the printer. This means either signing the applet or, at least with recent versions of Sun's Java plugin, if an unsigned applet tries to print, the user will be prompted to ask whether to allow permission.

http://stackoverflow.com/a/510047
has comment: http://stackoverflow.com/comment/324783
score: 3
has body: If you add the annotation: @org.hibernate.annotations.Entity(dynamicUpdate = true) to the top of your entity only the fields that have changed will be sent to the database.
downvote count: 0
answers question: http://stackoverflow.com/q/509950
type: Answer
upvote count: 3
has comment: http://stackoverflow.com/comment/327590

http://stackoverflow.com/a/27396847
downvote count: 0
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/441196
has body: Read this to understand Serializable Interface and why we should make only few classes Serializable and also we shopuld take care where to use transient keyword in case we want to remove few fields from the storing procedure. http://www.codingeek.com/java/io/object-streams-serialization-deserialization-java-example-serializable-interface/
type: Answer

http://stackoverflow.com/comment/280898
has text: boolean is clearer for something is 2-state. By using an enum it's essentially 3-state; ASSESSED, NOT_ASSESSED and null.
type: Comment
comment on: http://stackoverflow.com/a/461467
score: 1
type: AnswerComment

http://stackoverflow.com/comment/434676
type: AnswerComment
comment on: http://stackoverflow.com/a/398650
type: Comment
has text: I mostly agree with this answer, but there is definitely a non-constant concatenation happening in the call to preparetatement, so I too would expect the check to trigger.
score: 0

http://stackoverflow.com/comment/88962130
has text: same thing can be done with abstract class StorageDevice and FDD and HDD classes extending StorageDevice class. but if we use abstract class we cant take advantage of multiple inheritance.
comment on: http://stackoverflow.com/a/50983439
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/520922
answer count: 3
tagged with: clr
has title: Java and .NET heap overhead
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/3564039
upvote count: 3
tagged with: garbage-collection
possible better answer: http://stackoverflow.com/a/3564039
type: Question
tagged with: jit
score: 3
has answer: http://stackoverflow.com/a/521056
has answer: http://stackoverflow.com/a/521144
tagged with: java
has body: I have understanding how heap and garbage collector works: garbage collection happens in generations, memory allocation happens sequentially, during garbage collection free/unused space compacted by shifting data and forming continues block, etc. Is there any headers for allocated memory chunks are present and how big are they (I heard it’s 8-16 bytes for .NET CLR) and if byte, word or quad-word alignment present? I’m interested in any information for JIT (Java) and CLR (.NET Framework or Mono) implementation for x86 and x64 processor architectures.
downvote count: 0
tagged with: .net
favorite count: 0
accepted answer: http://stackoverflow.com/a/521144

http://stackoverflow.com/q/367706
has answer: http://stackoverflow.com/a/367734
has answer: http://stackoverflow.com/a/12265563
has answer: http://stackoverflow.com/a/41022241
downvote count: 7
has answer: http://stackoverflow.com/a/367714
type: Question
has answer: http://stackoverflow.com/a/74048983
has answer: http://stackoverflow.com/a/367717
has title: How do I parse command line arguments in Java?
has answer: http://stackoverflow.com/a/57004094
score: 697
has answer: http://stackoverflow.com/a/367716
has answer: http://stackoverflow.com/a/369212
has answer: http://stackoverflow.com/a/45898630
has answer: http://stackoverflow.com/a/367719
has answer: http://stackoverflow.com/a/15896393
has comment: http://stackoverflow.com/comment/50503589
has answer: http://stackoverflow.com/a/7829772
has comment: http://stackoverflow.com/comment/48204690
has answer: http://stackoverflow.com/a/52024523
has body: What is a good way of parsing command line arguments in Java?
has answer: http://stackoverflow.com/a/52434900
answer count: 21
accepted answer: http://stackoverflow.com/a/367714
has answer: http://stackoverflow.com/a/46812436
favorite count: 0
has answer: http://stackoverflow.com/a/367718
tagged with: command-line
has comment: http://stackoverflow.com/comment/112599480
upvote count: 704
has comment: http://stackoverflow.com/comment/20854917
has comment: http://stackoverflow.com/comment/54996146
has comment: http://stackoverflow.com/comment/112599481
has answer: http://stackoverflow.com/a/51421535
possible better answer: http://stackoverflow.com/a/3337023
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/39068600
has answer: http://stackoverflow.com/a/65495766
has answer: http://stackoverflow.com/a/43780433
has answer: http://stackoverflow.com/a/3337023
has comment: http://stackoverflow.com/comment/50464250
tagged with: java
tagged with: command-line-arguments

http://stackoverflow.com/q/417590
has answer: http://stackoverflow.com/a/417604
tagged with: java
upvote count: 10
type: Question
has body: I have class B, which inherits from class A. The superclass A is abstract, containing one abstract method. I don't want to implement the abstract method in class B, therefore I need to declare class B as abstract as well. Declaring class B abstract, two things are working for me (the programs compile and run correctly): 1.) I don't declare any abstract methods in class B, even thought the class is abstract. This works, I assume, because the class inherits the abstract method of class A, and this is enough for the class to be declared as abstract: we don't need any other abstract methods directly declared in the class. 2.) I do declare the same abstract method in class B as it is declared in class A. This is some kind of overriding (?), not in the same sense as overriding in java (using the same header, but providing different implementation), here I just use again the same header of the method. Both things are working, and I am not sure whether they are both Ok, and whether some of them is preferred (more correct) that the other. Are the two ways the same (do they mean the same to Java)? Here I give some example classes, so that what I mean is more clear for you: Case 1.): public abstract class A { public abstract String giveSum(); } public abstract class B extends A { } Case 2.): public abstract class A { public abstract String giveSum(); } public abstract class B extends A { public abstract String giveSum(); } Regards
has title: Abstract classes and methods in Java, Inheritance
score: 10
downvote count: 0
tagged with: inheritance
tagged with: abstract-class
has answer: http://stackoverflow.com/a/417610
favorite count: 0
has answer: http://stackoverflow.com/a/417605
answer count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/417787
has answer: http://stackoverflow.com/a/417647

http://stackoverflow.com/comment/24039664
type: Comment
has text: Yes, sample code would be good if you could provide an example/
comment on: http://stackoverflow.com/a/402331
score: 2
type: AnswerComment

http://stackoverflow.com/a/441177
answers question: http://stackoverflow.com/q/439215
accepted answer of: http://stackoverflow.com/q/439215
type: Answer
score: 2
upvote count: 2
has body: If you want to do RTF, These are text files and they are support in all versions of Word. you can use itext for simple stuff http://itextdocs.lowagie.com/tutorial/rtf/index.php ro you can export them the hard way //-- save as example.doc ------------- { \rtf1 \ansi \ansicpg1252 \deff0 \deflang1033 {\fonttbl {\f0 \fswiss \fcharset0 Arial; } } { \* \generator Msftedit 5.41.21.2500; } \viewkind4 \uc1 \pard \f0 \fs20 Hello World \par }
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/110455465
has text: I just (re)discovered that variables declared in case 1 can still be in scope in case 2. Eg: `...case 1: int a = 10; break; case 2: int a = 11; break; ...` doesn't compile. (tested with Oracle JDK 8)
type: AnswerComment
score: 1
type: Comment
comment on: http://stackoverflow.com/a/633540

http://stackoverflow.com/a/401619
answers question: http://stackoverflow.com/q/401598
score: 3
upvote count: 4
has body: This may be related to this "bug" (or rather "feature") The listeners are notified of the key events prior to processing them to allow the listeners to "steal" the events by consuming them. This gives compatibility with the older awt notion of consuming events. The "typed" event does not mean text was entered into the component. This is NOT a bug, it is intended behavior. A possible solution is to listen to an associated Document // Listen for changes in the text myTextField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { // text was changed } public void removeUpdate(DocumentEvent e) { // text was deleted } public void insertUpdate(DocumentEvent e) { // text was inserted } }); Note this works no matter how the text gets changed; via a clipboard cut/paste, progamatic "setText()" on the TextField, or the user typing into the field on the UI.
type: Answer
downvote count: 1

http://stackoverflow.com/comment/2505109
score: 0
type: Comment
comment on: http://stackoverflow.com/a/632994
has text: Do you have experience with the PDF or PS input flavours for this?
type: AnswerComment

http://stackoverflow.com/comment/388813
comment on: http://stackoverflow.com/a/576863
has text: int[] a = new int[4] would accomplish the same thing, since 0 is the default value.
type: AnswerComment
type: Comment
score: 11

outputcache
tags question: http://stackoverflow.com/q/617644
type: Tag
tag name: outputcache

http://stackoverflow.com/q/576228
has answer: http://stackoverflow.com/a/576287
has title: Why are the methods of the Math class static?
has answer: http://stackoverflow.com/a/576231
has answer: http://stackoverflow.com/a/576232
favorite count: 0
type: UnansweredQuestion
score: 6
upvote count: 6
has body: Why are the methods of the Math class static ?
has answer: http://stackoverflow.com/a/576234
tagged with: java
has answer: http://stackoverflow.com/a/576237
has answer: http://stackoverflow.com/a/576845
has answer: http://stackoverflow.com/a/576236
type: Question
has answer: http://stackoverflow.com/a/576233
answer count: 8
downvote count: 0

http://stackoverflow.com/a/505828
has body: All this assumes you’re talking about Java on Z/OS and not running Linux VM’s on the mainframe to take advantage of the cost savings that come with fewer machines. My thoughts on virtualization are at the end of this and it’s probably the route you want to look at but I’ll start out with Z/OS since it’s what mainframes are traditionally associated with and what I have familiarity with. I have some experience with mainframe Java. The short answer is, it depends, but probably not. What exactly are your applications? The mainframe is a difficult environment compared to x86 servers. If you're running I/O-intensive workloads under something like Websphere, it might be worth it, assuming your mainframe is underutilized. In my experience, Java is horribly slow on a mainframe but that’s because the system I used was set up for developer flexibility rather than performance. That just goes to prove performance tuning on the mainframe is usually much more complicated then on an average server since mainframes will be running many more workloads then a generic x86 server. Remember that the mainframe is designed primarily for I/O throughput and can outperform any normal x86 server at that. It was not designed to do a lot of computationally intensive calculations so won’t outperform a small cluster of x86 servers if your doing a lot of math. The change controls on mainframes are there for a good reason - if one x86 server has a problem, you reboot it. If a mainframe has a problem, every second that it’s down is costing the company money. You also have to take into account any native code your apps depend on or third party libraries that may use native code. All that code would have to be ported. Configuration of a mainframe also takes a lot longer on average then on an x86 server. I would suggest that, if you want to seriously look into this, you make a better business case than power savings, such as tight integration with current business apps and start out small either with a …
upvote count: 3
has comment: http://stackoverflow.com/comment/320735
has comment: http://stackoverflow.com/comment/1159991
accepted answer of: http://stackoverflow.com/q/505284
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/505284
has comment: http://stackoverflow.com/comment/46703934
has comment: http://stackoverflow.com/comment/46755336
type: Answer
score: 3
has comment: http://stackoverflow.com/comment/1159996

http://stackoverflow.com/a/374408
upvote count: 2
has comment: http://stackoverflow.com/comment/202969
answers question: http://stackoverflow.com/q/374348
downvote count: 0
has comment: http://stackoverflow.com/comment/202992
type: Answer
has body: Not a template, but I use array.clone() instead of System.arraycopy(). Is there anything wrong with that? Edit: A template I use when implementing a decorator, especially for an interface with many methods: wrapped.${enclosing_method}(${enclosing_method_arguments}) It generates an implementation of the current method by delegating the call to a wrapped instance, thus preventing copy/paste errors.
has comment: http://stackoverflow.com/comment/202985
has comment: http://stackoverflow.com/comment/203213
score: 2

http://stackoverflow.com/comment/55684394
type: AnswerComment
score: 0
has text: Since `MyEnumComparator` has no state, it should just be a singleton, especially if you're doing what @Bombe suggests; instead, you would do something like `MyEnumComparator.INSTANCE.compare(enum1, enum2)` to avoid unnecessary object creation
type: Comment
comment on: http://stackoverflow.com/a/519844

http://stackoverflow.com/comment/73793273
score: 0
type: Comment
has text: but then if you use a JPA provider that doesn't have "proxies" then you don't have that problem aka "your JPA provider is imposing on you".
comment on: http://stackoverflow.com/a/2869468
type: AnswerComment

http://stackoverflow.com/a/470013
answers question: http://stackoverflow.com/q/469874
score: 0
type: Answer
has body: You could always use javascript to manipulate the text further. a
has comment: http://stackoverflow.com/comment/287649

http://stackoverflow.com/a/421659
has comment: http://stackoverflow.com/comment/245888
has body: Are aware that both TCP and UDP (and IP, and Ethernet, and...) already provide checksum protection to data in transit? Unless you're doing something really weird, if you're seeing corruption, something is very wrong. I suggest starting with a memory tester. Also, you receive strong data integrity protection if you use SSL/TLS.
has comment: http://stackoverflow.com/comment/246011
upvote count: 7
has comment: http://stackoverflow.com/comment/250632
downvote count: 1
answers question: http://stackoverflow.com/q/421419
type: Answer
score: 6

http://stackoverflow.com/a/28362526
has body: Bit late, but I came across this question when I was having this issue in WebLogic. My solution was to add this to my weblogic.xml: &lt;?xml version='1.0' encoding='UTF-8'?&gt; &lt;weblogic-web-app&gt; &lt;container-descriptor&gt; &lt;show-archived-real-path-enabled&gt;true&lt;/show-archived-real-path-enabled&gt; &lt;/container-descriptor&gt; &lt;/weblogic-web-app&gt; I found this solution better for when you don't want to (or can't) edit the configuration on the WebLogic server.
answers question: http://stackoverflow.com/q/536228
upvote count: 18
score: 18
downvote count: 0
type: Answer

http://stackoverflow.com/comment/245158
has text: Thank you, jamesh, I was ignorant of NLS. Your answer was better than mine. I'll have to look into it.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/420221
type: Comment

http://stackoverflow.com/q/415520
tagged with: java
upvote count: 7
tagged with: caching
type: Question
has answer: http://stackoverflow.com/a/415541
has title: How do I make Tomcat stop caching my servlet responses?
tagged with: tomcat
tagged with: servlets
downvote count: 0
has answer: http://stackoverflow.com/a/415640
favorite count: 0
answer count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/438597
has answer: http://stackoverflow.com/a/5478593
has body: I'm learning Servlets programming, using Apache Tomcat 6 on a Ubuntu 8.10 machine, and I'm running with a very annoying issue -- apparently, related to caching. This is what I'm doing: I write a servlet, put it in a nice directory structure and deploy it using the Tomcat Web Application Manager. It works as expected. Then I edit the servlet, recompile and try to access it again, but Tomcat keeps returning the same old version. Reloading the Application or even restarting the server does not work. The only thing that works is "Undeploying" the Application, then deploying it all over again. I have to do this every single time I make any small change on my code. It sucks. I'm sure there is a way around this, but I couldn't find the answer anywhere on the web (and I did search a lot). I would really appreciate any help. Thanks!
has answer: http://stackoverflow.com/a/415546
score: 7

http://stackoverflow.com/a/494957
has comment: http://stackoverflow.com/comment/15024245
upvote count: 120
has comment: http://stackoverflow.com/comment/46597559
downvote count: 0
answers question: http://stackoverflow.com/q/494869
score: 120
has comment: http://stackoverflow.com/comment/36038987
type: Answer
has body: I've written a log file monitor before, and I found that the impact on system performance of polling the attributes of a single file, a few times a second, is actually very small. Java 7, as part of NIO.2 has added the WatchService API The WatchService API is designed for applications that need to be notified about file change events.

http://stackoverflow.com/comment/14860915
type: Comment
comment on: http://stackoverflow.com/a/438063
type: AnswerComment
has text: can you explain the meaning of third parameter `property` in `writer.writeAttribute("id", id, null);`, please?
score: 0

http://stackoverflow.com/a/619835
answers question: http://stackoverflow.com/q/619822
score: 1
has comment: http://stackoverflow.com/comment/432742
upvote count: 2
downvote count: 1
has body: Look at Sleep is a multi-paradigm scripting language for the Java Platform easy to learn with Perl and Objective-C inspired syntax executes scripts fast with a small package size (~250KB) excels at data manipulation, component integration, and distributed communication seamlessly uses Java objects and 3rd party libraries
type: Answer

http://stackoverflow.com/comment/679546
has text: Have you been able to solve this? I get the same annoying problem on Ubuntu 8.10.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/641255

http://stackoverflow.com/comment/345033
type: AnswerComment
comment on: http://stackoverflow.com/a/531390
type: Comment
has text: As provided in romaintaz' answer: import org.junit.Test; // for @Test import org.junit.Before; // for @Before
score: 0

http://stackoverflow.com/q/463194
score: 4
has body: I'm currently working on a project where I need to consume a Java webservice. If I connect to the service using old webservices (asmx) it works fine. However, If I try to do the same thing with a WCF client I get the following error: The content type text/xml; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. My is very simple and it looks like the following: //classic web service OldSkoolService.HelloService serviceCall = new esb_wsdlsample.OldSkoolService.HelloService(); Console.WriteLine(serviceCall.SoapVersion); Console.WriteLine(serviceCall.sayHello("something")); HelloServiceClient prototypeClient = new HelloServiceClient(); var serviceChannel = prototypeClient.ChannelFactory; Console.WriteLine(serviceChannel.Endpoint.Binding.MessageVersion); Console.WriteLine(prototypeClient.sayHello("somethinge")); //&lt;-- Error occurs here The the binding/endpoint config file is quite simple as well: &lt;bindings&gt; &lt;customBinding&gt; &lt;binding name="Soap12Binding"&gt; &lt;textMessageEncoding messageVersion="Soap12"/&gt; &lt;httpTransport /&gt; &lt;/binding&gt; &lt;/customBinding&gt; &lt;/bindings&gt; &lt;client&gt; &lt;endpoint address="http://10.10.6.51:7001/esb/HelloService" behaviorConfiguration="" binding="customBinding" bindingConfiguration="Soap12Binding" contract="Prototype.ESB.HelloService" name="HelloServicePort" /&gt; &lt;/client&gt; As a side note I'm trying to use soap 1.2, because I need to be able to catch exceptions from the service.
favorite count: 0
has answer: http://stackoverflow.com/a/463296
has answer: http://stackoverflow.com/a/464424
type: UnansweredQuestion
tagged with: wcf
upvote count: 4
has title: WCF client errors when consuming Java services
tagged with: java
type: Question
answer count: 2
downvote count: 0

http://stackoverflow.com/a/626367
has comment: http://stackoverflow.com/comment/439086
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/626328
has comment: http://stackoverflow.com/comment/439125
answers question: http://stackoverflow.com/q/626328
type: Answer
has comment: http://stackoverflow.com/comment/439121
has comment: http://stackoverflow.com/comment/439024
has body: Mocking libraries don't typically work with expression trees. They build a type which implements the appropriate interface and responds to method calls either by recording them or validating them and returning the preprogrammed responses. This is usually done with either a proxy (e.g. RealProxy in .NET, Proxy in Java) or with dynamic code generation. In the case of EasyMock, it uses Proxy (for interfaces, anyway), as you can see in the source code: look at org.easymock.internal.JavaProxyFactory.
has comment: http://stackoverflow.com/comment/439130
score: 5
upvote count: 5

http://stackoverflow.com/a/588853
downvote count: 0
has comment: http://stackoverflow.com/comment/113895352
type: Answer
upvote count: 10
answers question: http://stackoverflow.com/q/586284
has body: ArrayList&lt;&gt; Sieve of Eratosthenes // Return primes less than limit static ArrayList&lt;Integer&gt; generatePrimes(int limit) { final int numPrimes = countPrimesUpperBound(limit); ArrayList&lt;Integer&gt; primes = new ArrayList&lt;Integer&gt;(numPrimes); boolean [] isComposite = new boolean [limit]; // all false final int sqrtLimit = (int)Math.sqrt(limit); // floor for (int i = 2; i &lt;= sqrtLimit; i++) { if (!isComposite [i]) { primes.add(i); for (int j = i*i; j &lt; limit; j += i) // `j+=i` can overflow isComposite [j] = true; } } for (int i = sqrtLimit + 1; i &lt; limit; i++) if (!isComposite [i]) primes.add(i); return primes; } Formula for upper bound of number of primes less than or equal to max (see wolfram.com): static int countPrimesUpperBound(int max) { return max &gt; 1 ? (int)(1.25506 * max / Math.log((double)max)) : 0; }
score: 10

http://stackoverflow.com/q/408051
accepted answer: http://stackoverflow.com/a/408522
tagged with: jpa
downvote count: 0
possible better answer: http://stackoverflow.com/a/67538776
has answer: http://stackoverflow.com/a/73556509
answer count: 4
has answer: http://stackoverflow.com/a/67538776
favorite count: 0
has answer: http://stackoverflow.com/a/408522
has answer: http://stackoverflow.com/a/408613
has title: Ordering return of Child objects in JPA query
type: AnsweredQuestion
upvote count: 9
tagged with: java
tagged with: hibernate
has body: So if my JPA query is like this: Select distinct p from Parent p left join fetch p.children order by p.someProperty I correctly get results back ordered by p.someProperty, and I correctly get my p.children collection eagerly fetched and populated. But I'd like to have my query be something like "order by p.someProperty, p.children.someChildProperty" so that the collection populated inside each parent object was sub-ordered by someChildProperty. This seems intuitive when I think in terms of the sql that is actually generated for these calls, but I guess less so when it tries to map back to hierarchical objects.
score: 9
type: Question

http://stackoverflow.com/comment/382172
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/570384
has text: Looks like this guy did the same thing with C# so it should be possible. http://jdconley.com/blog/archive/2006/08/01/using-the-mysql-command-line-from-c.net.aspx IF you paste the code we can see if you have the order wrong. Remember to read output before calling waitFor().
score: 0

http://stackoverflow.com/q/486948
tagged with: .net-3.5
score: 26
has answer: http://stackoverflow.com/a/71229249
tagged with: java
upvote count: 26
has answer: http://stackoverflow.com/a/487006
answer count: 8
has answer: http://stackoverflow.com/a/487005
has comment: http://stackoverflow.com/comment/303269
downvote count: 0
tagged with: .net
has answer: http://stackoverflow.com/a/61335178
has comment: http://stackoverflow.com/comment/303263
possible better answer: http://stackoverflow.com/a/487006
favorite count: 0
has title: LinkedHashMap in .NET
accepted answer: http://stackoverflow.com/a/487005
has body: I wonder if there is a counterpart to java.util.LinkedHashMap in .NET? (ie. the elements are (re)ordered automatically if I access an element. (boolean accessOrder) ).
has comment: http://stackoverflow.com/comment/303274
has answer: http://stackoverflow.com/a/69710689
linked to: http://stackoverflow.com/q/1396718
has answer: http://stackoverflow.com/a/23572488
has comment: http://stackoverflow.com/comment/37916750
has answer: http://stackoverflow.com/a/956359
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/36474833
has comment: http://stackoverflow.com/comment/62178717
type: Question
tagged with: linkedhashmap
linked to: http://stackoverflow.com/q/29205934

http://stackoverflow.com/comment/317652
score: 0
type: Comment
comment on: http://stackoverflow.com/q/502614
type: QuestionComment
has text: Where's the return type?

http://stackoverflow.com/a/10202809
score: 1
upvote count: 1
has body: Like this its work if you want to parse some string which is coming from mYearInDB.toString() =[2013] it will give 2013 Matcher n = MY_PATTERN.matcher("FOO[BAR]"+mYearInDB.toString()); while (n.find()) { extracredYear = n.group(1); // s now contains "BAR" } System.out.println("Extrated output is : "+extracredYear);
downvote count: 0
answers question: http://stackoverflow.com/q/600733
type: Answer

http://stackoverflow.com/comment/393564
has text: http://stackoverflow.com/questions/581722/when-does-it-make-sense-to-return-this-reference
comment on: http://stackoverflow.com/a/577588
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/9514496
has comment: http://stackoverflow.com/comment/12050072
score: 0
has body: Okay, this is really late. But what I found the best solutions (as extensions don't really say something about the content) was to use file.getContentType() ... E.g., for jpeg images the return value will be a string image/jpeg that you can easily test. Same for other file formats (png, gif, ...). Hope this helps.
type: Answer
answers question: http://stackoverflow.com/q/362972

http://stackoverflow.com/comment/105354847
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/59594774
has text: Please provide your answer in a reproducible code format.

http://stackoverflow.com/comment/434996
comment on: http://stackoverflow.com/q/620943
type: Comment
type: QuestionComment
has text: Are you sure you get XmlNode and XmlDocument on the Java side? Those seem to be C# terms. This remark may seem stupid, but there are quit a lot of XML parsers around, and all behave differently :)
score: 0

http://stackoverflow.com/a/449420
type: Answer
score: 8
downvote count: 1
upvote count: 9
has comment: http://stackoverflow.com/comment/276451
answers question: http://stackoverflow.com/q/449409
has body: At least in java, it's not voodoo programming at all. When you create an object in java using something like Foo bar = new Foo(); you do two things: first, you create a reference to an object, and second, you create the Foo object itself. So long as that reference or another exists, the specific object can't be gc'd. however, when you assign null to that reference... bar = null ; and assuming nothing else has a reference to the object, it's freed and available for gc the next time the garbage collector passes by.
has comment: http://stackoverflow.com/comment/271427

http://stackoverflow.com/comment/2227035
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/377804
has text: o will not be eligible for garbage collection intil it is removed from the list as well!
type: Comment

http://stackoverflow.com/a/15904385
has body: Facing the same problem, none of these answers worked for me. It took me some time and looking through the java runtime source to figure this out. Sun.net.www.protocol.http.ntlm.NTLMAuthentication attempts to use transparent authentication, what is basically use of current user credentials to login to remote server. In my server to server scenario (Java EE server to Sharepoint) this wasn't acceptable. In order to disable transparent authentication we need to let authentication provider know that connection is not trusted and it needs to authenticate with every call: static { NTLMAuthenticationCallback.setNTLMAuthenticationCallback(new NTLMAuthenticationCallback() { @Override public boolean isTrustedSite(URL url) { return false; } }); }
downvote count: 0
answers question: http://stackoverflow.com/q/480895
has comment: http://stackoverflow.com/comment/33373180
score: 5
has comment: http://stackoverflow.com/comment/22886222
upvote count: 5
type: Answer
has comment: http://stackoverflow.com/comment/23128112

http://stackoverflow.com/a/483439
downvote count: 0
score: 3
has body: Try the book Garbage Collection: Algorithms for Automatic Dynamic Memory Management. It wont have the more recent stuff in it, but it'll get you on your way.
upvote count: 3
answers question: http://stackoverflow.com/q/483427
type: Answer

http://stackoverflow.com/a/609536
score: 9
upvote count: 9
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/609528
downvote count: 0
has comment: http://stackoverflow.com/comment/423770
has comment: http://stackoverflow.com/comment/423360
type: Answer
has body: Mostly Java: http://cmusphinx.sourceforge.net/html/cmusphinx.php
has comment: http://stackoverflow.com/comment/22179136
answers question: http://stackoverflow.com/q/609528

http://stackoverflow.com/a/601171
downvote count: 0
has comment: http://stackoverflow.com/comment/426787
type: Answer
score: 11
upvote count: 11
has body: There is absolutely nothing wrong a try with a finally and no catch. Consider the following: InputStream in = null; try { in = new FileInputStream("file.txt"); // Do something that causes an IOException to be thrown } finally { if (in != null) { try { in.close(); } catch (IOException e) { // Nothing we can do. } } } If an exception is thrown and this code doesn't know how to deal with it then the exception should bubble up the call stack to the caller. In this case we still want to clean up the stream so I think it makes perfect sense to have a try block without a catch.
answers question: http://stackoverflow.com/q/601152
has comment: http://stackoverflow.com/comment/413432
has comment: http://stackoverflow.com/comment/413477

http://stackoverflow.com/comment/47565516
type: AnswerComment
comment on: http://stackoverflow.com/a/29279143
type: Comment
has text: I'm sorry, but the one who rejected the change request has no clue of Java programming **It is a good suggestion, but as is it is wrong** because if executed in the same mili second it will give the same number, not random.
score: 0

http://stackoverflow.com/comment/260436
type: QuestionComment
comment on: http://stackoverflow.com/q/437878
score: 0
has text: It's extremely relevant in contemporary programming... especially now that all the new processors are looking to improve performance by adding cores...
type: Comment

http://stackoverflow.com/a/1655359
score: 0
type: Answer
has body: I am author of jni4net, open source interprocess bridge between JVM and CLR. It's build on top of JNI and PInvoke. No C/C++ code needed. I hope it will help you.
answers question: http://stackoverflow.com/q/420617

http://stackoverflow.com/a/483446
answers question: http://stackoverflow.com/q/483427
type: Answer
downvote count: 0
upvote count: 8
has body: It's too complex topic to be covered in one simple answer. Here is a list of recommended reading: Wikipedia: Garbage collection (computer science) Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework Garbage Collection: Part 2: Automatic Memory Management in the Microsoft .NET Framework Java theory and practice: A brief history of garbage collection
score: 8

http://stackoverflow.com/comment/15127726
type: Comment
has text: aside from that, the solution of simulating the down arrow keypress does work.
comment on: http://stackoverflow.com/a/7754567
type: AnswerComment
score: 0

event-handling
tag name: event-handling
tags question: http://stackoverflow.com/q/400994
tags question: http://stackoverflow.com/q/501533
tags question: http://stackoverflow.com/q/565458
type: Tag
tags question: http://stackoverflow.com/q/584449
tags question: http://stackoverflow.com/q/375265

http://stackoverflow.com/a/25294769
has comment: http://stackoverflow.com/comment/73048193
score: 2
answers question: http://stackoverflow.com/q/536228
has body: if you want to write into use this.getClass().getResource("/").getPath(); to get the path
type: Answer
upvote count: 3
downvote count: 1

http://stackoverflow.com/q/643055
has body: So in my persistence.xml I turned on hibernate.generate_statistics. true My question is how do I access them? Where do the statistics go?
tagged with: jpa
tagged with: jboss
accepted answer: http://stackoverflow.com/a/643979
has answer: http://stackoverflow.com/a/8338748
has answer: http://stackoverflow.com/a/56018215
has answer: http://stackoverflow.com/a/44075532
downvote count: 0
possible better answer: http://stackoverflow.com/a/643182
favorite count: 0
score: 28
has answer: http://stackoverflow.com/a/643182
upvote count: 28
answer count: 5
has title: How to get access to the Hibernate Statistics
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/643979
tagged with: java
tagged with: hibernate
type: Question
tagged with: jakarta-ee

http://stackoverflow.com/a/65248356
has comment: http://stackoverflow.com/comment/128830424
upvote count: 2
answers question: http://stackoverflow.com/q/492184
has body: If you intend to load all subclassess of given class which are in the same package, you can do so: public static List&lt;Class&gt; loadAllSubClasses(Class pClazz) throws IOException, ClassNotFoundException { ClassLoader classLoader = pClazz.getClassLoader(); assert classLoader != null; String packageName = pClazz.getPackage().getName(); String dirPath = packageName.replace(&quot;.&quot;, &quot;/&quot;); Enumeration&lt;URL&gt; srcList = classLoader.getResources(dirPath); List&lt;Class&gt; subClassList = new ArrayList&lt;&gt;(); while (srcList.hasMoreElements()) { File dirFile = new File(srcList.nextElement().getFile()); File[] files = dirFile.listFiles(); if (files != null) { for (File file : files) { String subClassName = packageName + '.' + file.getName().substring(0, file.getName().length() - 6); if (! subClassName.equals(pClazz.getName())) { subClassList.add(Class.forName(subClassName)); } } } } return subClassList; }
score: 2
downvote count: 0
type: Answer

http://stackoverflow.com/comment/212201
comment on: http://stackoverflow.com/a/384005
type: AnswerComment
type: Comment
has text: Bobme: try that sample code with and without the calls to gc(), and you'll see that there's a difference. Maybe all gc() is doing is updating my array of WeakReferences, but it's doing something.
score: 0

http://stackoverflow.com/q/560710
tagged with: database
downvote count: 0
answer count: 1
score: 1
tagged with: synchronization
favorite count: 0
type: UnansweredQuestion
has body: I'm working on a service that runs in a java app server farm that needs to do some periodic jobs (say, once every 2 minutes). The service must interface to external entities, and it is necessary to synchronize the different instances so that only one of them works on the job at a given time. Since the service uses a DB during this job, I thought of implementing the synchronization based on a simple DB table: id, owner, stamp where id is the lock's id, owner is the current owner and stamp is the time it was locked. The methods would be: tryLock(id, maxAge, owner) - to try to lock a record or break an old record refresh(id, owner) - to update the stamp to signal we're still around working on the job release(id, owner) - to release the lock How would you implement this? Edit: removed my implementation, I'll post it as an "answer"
has title: Simple database-based instance synchronization
has answer: http://stackoverflow.com/a/560721
upvote count: 1
type: Question
tagged with: jakarta-ee
tagged with: java

http://stackoverflow.com/comment/207801
type: Comment
has text: I think this solution fails in the case where elements that are .equals() appear in both partitions.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/379846

http://stackoverflow.com/comment/138286307
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/78435245
has text: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).

http://stackoverflow.com/comment/21272350
type: AnswerComment
has text: @DanNeely compiler warnings exist for a reason, we would all benefit as engineers from not ignoring them.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/509230

http://stackoverflow.com/comment/429640
comment on: http://stackoverflow.com/q/616700
score: 0
has text: Yes. I'm opening a cmd window to run a script. And then I need to go to another directory that is inside my working directory and run another series of commands. This means that I have multiple cmd windows opening. I want to seamlessly run a series of commands one after the other in the same window.
type: Comment
type: QuestionComment

http://stackoverflow.com/q/565932
has answer: http://stackoverflow.com/a/38651779
upvote count: 42
has answer: http://stackoverflow.com/a/52979575
downvote count: 0
has body: Though java.util.properties allows reading and writing properties file, the writing does not preserve the formatting. Not surprising, because it is not tied to the property file. Is there a PropertyFile class out there -- or some such -- that preserves comments and blank lines and updates property values in place?
possible better answer: http://stackoverflow.com/a/29564721
has answer: http://stackoverflow.com/a/565996
accepted answer: http://stackoverflow.com/a/565996
tagged with: properties
type: Question
answer count: 8
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/565979
tagged with: java
has answer: http://stackoverflow.com/a/29564721
score: 42
favorite count: 0
has answer: http://stackoverflow.com/a/53783476
has answer: http://stackoverflow.com/a/62143127
has title: A better class to update property files?
has answer: http://stackoverflow.com/a/565977

http://stackoverflow.com/comment/368002
comment on: http://stackoverflow.com/a/516564
type: AnswerComment
score: 0
type: Comment
has text: Sure, MS is always happy to push some of it's solutions over you, but you always have choices. They do not hinder any attemps in creating software and different solutions based in the .NET infrastructure. I have used many different tools and frameworks so far as a C# dev, without any drawbacks.

http://stackoverflow.com/a/483068
type: Answer
score: 0
has comment: http://stackoverflow.com/comment/300392
answers question: http://stackoverflow.com/q/483054
has comment: http://stackoverflow.com/comment/299675
has comment: http://stackoverflow.com/comment/299752
has body: A PipedInputStream does not store any data at all. Also, where do you get that 300 MB byte array from?

http://stackoverflow.com/q/397713
has answer: http://stackoverflow.com/a/398125
downvote count: 0
answer count: 1
has body: I have strange problem with token &lt; NULL: "null" > in my JavaCC parser. In expression like String IsNullClause(): { String res = ""; } { &lt;IS&gt; {res += " IS ";} [&lt;NOT&gt; {res += " NOT ";} ] &lt;NULL&gt; {res += " NULL ";} { return res; } } parser doesn't see NULL token and throws exception that "null" expected. If I change token definition to &lt; NULL: "null_val" > or something else it works fine. Is this my mistake or JavaCC doesn't accept 'null' as a token value?
tagged with: parsing
favorite count: 0
type: UnansweredQuestion
tagged with: javacc
upvote count: 3
tagged with: java
has title: NULL token in JavaCC
type: Question
score: 3

http://stackoverflow.com/comment/24271722
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/421447
has text: Link now broken unfortunately.

http://stackoverflow.com/comment/1681248
score: 0
comment on: http://stackoverflow.com/a/1335281
type: AnswerComment
type: Comment
has text: microsoft's engine also used to be based on sphinx. now i think they perhaps rely more heavily on HTK, another open source speech recognition system. your accent is not a subjective issue from the point of view of an ASR system. the results will be heavily dependent on how well the characteristics of your voice match those of the voices in the training data. differences which may seem trivial to you, for example a canadian versus an american accent, may have a very significant impact on the ASR quality. these days most systems rely on the same algorithms, the difference is the data.

http://stackoverflow.com/comment/446758
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/612135
has text: I think the point is that in the first sentence 'trade' is a verb and in the second it is used a noun. The meaning of the word is dependent on the context in which it is used.

http://stackoverflow.com/comment/414107
score: 0
type: AnswerComment
has text: Thanks for your response. I was hoping that is should be possible to use sockets rather than RMI. Thanks for verifying that.
type: Comment
comment on: http://stackoverflow.com/a/599386

http://stackoverflow.com/a/14663807
upvote count: 2
answers question: http://stackoverflow.com/q/435740
score: 2
downvote count: 0
has body: I tried a few libraries and ended up using argparse4j. It's a really nice Java port of Python's argparse.
type: Answer

http://stackoverflow.com/comment/78286073
score: 0
type: AnswerComment
type: Comment
has text: @Elazar any chance you're targeting an exotic framework? Unity, mono, net standard, etc? It definitely exists in .NET : https://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.methodimploptions(v=vs.110).aspx
comment on: http://stackoverflow.com/a/541348

http://stackoverflow.com/comment/230265
has text: thanks - I've edited the question accordingly to remove the java3D requirement. any java solution will do.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/405115

http://stackoverflow.com/q/574798
favorite count: 0
has answer: http://stackoverflow.com/a/574853
type: Question
tagged with: singleton
has answer: http://stackoverflow.com/a/574852
score: 1
upvote count: 1
has body: If I declare a singleton servlet like public static class SomeServlet extends HttpServlet {..... It gives the error indicating that modifier static not allowed here in NetBeans. Please let me know how to create a singleton servlet which allows only one client at a time to execute. Thanks in Advance, Mahes
has answer: http://stackoverflow.com/a/574823
has comment: http://stackoverflow.com/comment/386761
tagged with: java
answer count: 5
tagged with: servlets
has title: Singleton servlet?
has answer: http://stackoverflow.com/a/574822
downvote count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/574806

http://stackoverflow.com/a/489361
has body: Using Swing per se, you very probably can't; that's a Widnows specific thing.
answers question: http://stackoverflow.com/q/489255
has comment: http://stackoverflow.com/comment/140002863
type: Answer
upvote count: 0
score: -1
has comment: http://stackoverflow.com/comment/306510
has comment: http://stackoverflow.com/comment/139996834
downvote count: 1

http://stackoverflow.com/a/558927
has body: Another approach may be to pass the variable value to the JVM with -D parameter. That way you can tie your code to the same variable name and then pass different values at the time of start-up. I haven't tried this, but i'm thinking it should work for an app deployed in Tomcat as well, if you modify startCatalina script to pass -D parameter to JVM
score: 0
type: Answer
answers question: http://stackoverflow.com/q/558502

http://stackoverflow.com/comment/417800
comment on: http://stackoverflow.com/a/604689
has text: Yes, the `java.util.concurrent.ConcurrentMap` interface has several interesting methods in it that would allow you to implement a solution.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/432926
comment on: http://stackoverflow.com/a/619002
type: AnswerComment
score: 0
has text: Aha! This can only mean that your query is returning duplicate records, updates fine the first time, fails the second time. :) Why would this be the case?
type: Comment

http://stackoverflow.com/comment/269957
score: 0
type: Comment
comment on: http://stackoverflow.com/a/448904
has text: I think i just found a solution with just varying the PreferredSize when i change something in the GraphPanel
type: AnswerComment

http://stackoverflow.com/comment/269324
type: Comment
score: 5
type: AnswerComment
comment on: http://stackoverflow.com/a/416198
has text: Another problem with locking on 'this' blindly is that you could have several methods contending on the same lock that logically do not need to be mutually exclusive.

http://stackoverflow.com/a/567447
has comment: http://stackoverflow.com/comment/378934
has comment: http://stackoverflow.com/comment/378977
has comment: http://stackoverflow.com/comment/379023
type: Answer
has body: log4j can be configured to log with the timestamp in the line. At least that's what I think you're asking. Use %d in your PatternLayout. Now I understand: log4j is asynchronous, so you may have time stamps out of order. If you want synchronous logging, I believe that is possible, but it is slower.
downvote count: 0
has comment: http://stackoverflow.com/comment/378840
score: 1
has comment: http://stackoverflow.com/comment/379008
answers question: http://stackoverflow.com/q/567382
has comment: http://stackoverflow.com/comment/379063
has comment: http://stackoverflow.com/comment/381119
upvote count: 1
has comment: http://stackoverflow.com/comment/449459
has comment: http://stackoverflow.com/comment/379021

http://stackoverflow.com/a/559477
downvote count: 0
type: Answer
score: 9
answers question: http://stackoverflow.com/q/559433
upvote count: 9
has body: At the Kepler Science Operations Center we have about 50 machines with 32-64G each. The JVMs heaps are typically 7-20G. We are using Java 6. The OS has Linux 2.6 kernel. When we migrated to 64bit I expected there would be some issues with running the 64-bit JVM But really there have not been. Out of memory conditions are more difficult to debug since the heap dumps are so much larger. The Java Service Wrapper needed some modifications to support larger heap sizes. There are some sites on the web claiming GC does not scale well past 2G, but I've not seen any problems. Finally, we are doing throughput intensive rather interactive intensive computing. I've never looked at latency differences; my guess is worst case GC latency will be longer with the larger heap sizes.

sun
tags question: http://stackoverflow.com/q/647330
type: Tag
tag name: sun
tags question: http://stackoverflow.com/q/362500

http://stackoverflow.com/comment/71118650
type: AnswerComment
comment on: http://stackoverflow.com/a/29062820
type: Comment
score: 2
has text: The method `hasContentEqualTo` is deprecated as of this comment. Use `hasSameContentAs` instead.

http://stackoverflow.com/a/531366
accepted answer of: http://stackoverflow.com/q/531353
answers question: http://stackoverflow.com/q/531353
type: AcceptedAnswer
downvote count: 0
has body: Merge your jars to one jar. See this thread.
type: Answer
score: 3
upvote count: 3

http://stackoverflow.com/comment/2566374
type: Comment
score: 2
type: AnswerComment
has text: Hand conversion is always required, but a lot of code can go over as is. Replacing small syntax differences like uses of final, checked exceptions, and synchronized goes a long way when porting.
comment on: http://stackoverflow.com/a/443034

http://stackoverflow.com/comment/451548
type: Comment
has text: i want to "discover" where java is.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/638334

http://stackoverflow.com/q/493247
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/494047
upvote count: 3
favorite count: 0
has body: I am trying to create a JPopupMenu that has a scrollbar so that I can display a large number of items. There are a couple of implementations on the web that all have problems: http://forums.sun.com/thread.jspa?threadID=5128630 Looks correct (except for issues with separators) but if you scroll it the highlighting and selection no longer work. http://www.beginner-java-tutorial.com/scrollable-jpopupmenu.html Does not look like a JPopupMenu (no L&amp;F background or highlighting) but works except for the fact you can't put JMenuItems in it - instead you have to use some hacked button. Can anyone point me to a working solution before I try and debug either of these or write my own?
has title: How to create a scrollable JPopupMenu
type: UnansweredQuestion
tagged with: swing
score: 3
has answer: http://stackoverflow.com/a/494717
downvote count: 0
tagged with: java

http://stackoverflow.com/a/602099
has comment: http://stackoverflow.com/comment/1660350
type: Answer
upvote count: 2
downvote count: 2
has comment: http://stackoverflow.com/comment/414380
has body: Have you tried compressing the stream (GZIPOutputStream) ?
has comment: http://stackoverflow.com/comment/416470
score: 0
answers question: http://stackoverflow.com/q/602079

http://stackoverflow.com/q/421782
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/421815
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/421815
type: Question
has answer: http://stackoverflow.com/a/421824
has title: Simple/elegant way to do object to object transformation in Java?
downvote count: 0
has body: I have to take over and improve/finish some code that transforms Java objects from a third party library into internal objects. Currently this is done through a big if-else statement along the lines of: if (obj instanceOf X) { //code to initialize internal object } else if (obj instanceOf Y) { //code to initialize different object } else if (obj instanceOf Z) { //more init code } ... Personally I don't find this solution satisfactory; it's long and messy and to make matters worse many of the if-else blocks contain more if-else blocks dealing with subclasses and edge cases. Is there a better solution to this problem?
has answer: http://stackoverflow.com/a/421803
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/422087
upvote count: 1
accepted answer: http://stackoverflow.com/a/421803
has comment: http://stackoverflow.com/comment/245674

http://stackoverflow.com/comment/72847576
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/14733855
has text: @AmrinderArora Not really. The [Blackhole](http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java) is a pretty complicated thing doing something with the input, so it can't be optimized away. It's optimized for speed even in the multithreaded case.
score: 0

http://stackoverflow.com/q/471749
score: 46
type: Question
downvote count: 0
upvote count: 46
favorite count: 0
accepted answer: http://stackoverflow.com/a/471775
answer count: 3
has answer: http://stackoverflow.com/a/471775
has body: In Java, is there any way to use the JDK libraries to discover the private classes implemented within another class? Or do I need so use something like asm?
possible better answer: http://stackoverflow.com/a/471759
type: AnsweredQuestion
tagged with: reflection
tagged with: java
has answer: http://stackoverflow.com/a/8938851
has title: Can I discover a Java class' declared inner classes using reflection?
has answer: http://stackoverflow.com/a/471759

http://stackoverflow.com/a/440014
has comment: http://stackoverflow.com/comment/263153
answers question: http://stackoverflow.com/q/439958
score: 12
type: AcceptedAnswer
type: Answer
upvote count: 13
downvote count: 1
has body: You could try something like Prevayler (basically an in-memory cache that handles serialization and backup for you so data persists and is transactionally safe). There are other similar projects. I've used it for a large project, it's safe and extremely fast. If it's the same set of 20,000 objects, or at least not 20,000 new objects every 5 seconds but lots of changes, you might be better off cacheing the changes and periodically writing the changes in batch mode (jdbc batch updates are much faster than individual row updates). Depends on whether you need each write to be transactionally wrapped, and whether you'll need a record of the change logs or just aggregate changes. Edit: as other posts have mentioned Prevayler I thought I'd leave a note on what it does: Basically you create a searchable/serializable object (typically a Map of some sort) which is wrapped in a Prevayler instance, which is serialized to disk. Rather than making changes directly to your map, you make changes by sending your Prevayler instance a serializable record of your change (just an object that contains the change instruction). Prevayler's version of a transaction is to write your serialization changes to disk so that in the event of failure it can load the last complete backup and then replay the changes against that. It's safe, although you do have to have enough memory to load all of your data, and it's a fairly old API, so no generic interfaces, unfortunately. But definitely stable and works as advertised.
accepted answer of: http://stackoverflow.com/q/439958

http://stackoverflow.com/a/1595000
downvote count: 13
has comment: http://stackoverflow.com/comment/40304753
has comment: http://stackoverflow.com/comment/139069831
has comment: http://stackoverflow.com/comment/48469316
has comment: http://stackoverflow.com/comment/54550350
has comment: http://stackoverflow.com/comment/51716644
has body: Poor language design. It would be much more effective to call directly a static abstract method than creating an instance just for using that abstract method. Especially true when using an abstract class as a workaround for enum inability to extend, which is another poor design example. Hope they solve those limitations in a next release.
type: Answer
has comment: http://stackoverflow.com/comment/18829237
score: 407
has comment: http://stackoverflow.com/comment/36597502
upvote count: 420
answers question: http://stackoverflow.com/q/370962
has comment: http://stackoverflow.com/comment/34458585

http://stackoverflow.com/q/633585
possible better answer: http://stackoverflow.com/a/633599
has comment: http://stackoverflow.com/comment/446630
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/633610
tagged with: constructor
tagged with: inner-classes
has answer: http://stackoverflow.com/a/633863
has answer: http://stackoverflow.com/a/35412211
type: Question
tagged with: java
answer count: 6
has title: Strange syntax for instantiating an inner class
upvote count: 43
downvote count: 0
has answer: http://stackoverflow.com/a/633599
has answer: http://stackoverflow.com/a/633602
has comment: http://stackoverflow.com/comment/446658
score: 43
favorite count: 0
has body: I didn't imagine that I would encounter radically new syntax in Java anymore at this stage, but lo and behold, I just encountered something: The exact context and what the code below should do is pretty irrelevant - it's there just to give some kind of context. I'm trying to synthetically create an event in IT Mill Toolkit, so I wrote this kind of line: buttonClick(new Button.ClickEvent(button)); But, Eclipse gives me the following error message: No enclosing instance of type Button is accessible. Must qualify the allocation with an enclosing instance of type Button (e.g. x.new A() where x is an instance of Button). When I rewrite the line above as follows, it doesn't complain anymore: buttonClick(button.new ClickEvent(button)); // button instanceof Button So, my question is: What does the latter syntax mean, exactly, and why doesn't the first snippet work? What is Java complaining about, and what's it doing in the second version? Background info: Both Button and Button.ClickEvent are non-abstract public classes.
has answer: http://stackoverflow.com/a/633965
accepted answer: http://stackoverflow.com/a/633602

http://stackoverflow.com/a/4459010
type: Answer
upvote count: 2
score: 0
downvote count: 2
answers question: http://stackoverflow.com/q/508665
has body: Because you might be using jdk1.5+ and there it is auto converting to int. So in your code its first returning Integer and then auto converted to int. your code is same as int abc = new Integer(123);

http://stackoverflow.com/comment/397412
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/585492
type: Comment
has text: One way to parent to child may be problematic. Little rusty. One way from child to parent is easier. The problem with P->C is the foreign key resides in the child so needs to be mapped. Can you elaborate on your situation?

http://stackoverflow.com/comment/330507
has text: Not true, variables and methods are in separate name spaces.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/516783

http://stackoverflow.com/q/375128
tagged with: webwork
upvote count: 1
has body: Is there a way to configure Velocity to use something other than toString() to convert an object to a string in a template? For example, suppose I'm using a simple date class with a format() method, and I use the same format every time. If all of my velocity code looks like this: $someDate.format('M-D-yyyy') is there some configuration I could add that would let me just say $someDate instead? (Assuming I'm not in a position to just edit the date class and give it an appropriate toString()). I'm doing this in the context of a webapp built with WebWork, if that helps.
favorite count: 0
possible better answer: http://stackoverflow.com/a/376865
tagged with: velocity
has answer: http://stackoverflow.com/a/376865
tagged with: templates
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/505306
downvote count: 0
has title: Configure velocity to render an object with something other than toString?
has answer: http://stackoverflow.com/a/30990288
type: Question
tagged with: tostring
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/505297
accepted answer: http://stackoverflow.com/a/505297

http://stackoverflow.com/comment/15703198
comment on: http://stackoverflow.com/a/612063
has text: I have since designed three different trading systems for different funds and used `double` for prices or `long` cents.
type: AnswerComment
score: 2
type: Comment

http://stackoverflow.com/a/572643
score: 0
answers question: http://stackoverflow.com/q/572134
type: Answer
has body: I wrote a regex in perl that replaces the string "System.out.println" with ";//System.out.println". I believe that there are very few cases where this would break the build. It would just become an "else ;", which is compiled to zero bytecode instructions. It looks like this is what you've proposed. It worked for me -- except if you have additional statements on the same line. However, that is bad style to begin with (and I knew I didn't do that).

http://stackoverflow.com/q/490124
has answer: http://stackoverflow.com/a/1670181
type: Question
has answer: http://stackoverflow.com/a/490755
has answer: http://stackoverflow.com/a/491960
downvote count: 0
has answer: http://stackoverflow.com/a/497400
favorite count: 0
possible better answer: http://stackoverflow.com/a/491960
answer count: 5
has title: Mask URL in JSF
has body: I have an enterprise application written in JAVA with JSF (using RichFaces 3.3). Currently my URL looks like this: http://localhost/WebApplication/faces/folder1/page.jsp Question is how do I mask my url to make it like this: http://localhost/folder1/page.jps Basically i want to hide "Application/faces/" Thanks
accepted answer: http://stackoverflow.com/a/490755
score: 2
tagged with: jsf
upvote count: 2
has answer: http://stackoverflow.com/a/12996002
type: AnsweredQuestion
tagged with: java
tagged with: friendly-url
tagged with: glassfish

http://stackoverflow.com/a/520574
downvote count: 0
upvote count: 6
answers question: http://stackoverflow.com/q/520527
score: 6
has body: Java generics are compile-time only and are compiled into non-generic code. In C#, the actual compiled MSIL is generic. This has huge implications for performance because Java still casts during runtime. See here for more.
type: Answer

http://stackoverflow.com/comment/97702270
has text: Commons Transaction buyer beware (see project web page): We have decided to move the project to dormant as we are convinced that the main advertised feature transactional file access can not be implemented reliably. We are convinced that no such implementation can be possible on top of an ordinary file system. Although there are other useful parts (as multi level locking including deadlock detection) the transactional file system is the main reason people use this library for. As it simply can not be made fully transactional, it does not work as advertised.
type: AnswerComment
comment on: http://stackoverflow.com/a/595924
type: Comment
score: 2

http://stackoverflow.com/comment/236949
score: 1
comment on: http://stackoverflow.com/a/406873
has text: Then I'd say that common interfaces need to be packaged into separate JARs that can be part of both modules.
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/81696418
has text: @Basic Okay. It seems to me that my comment balances things a bit *in this answers comments*, regardless of what any person's personal philosophies or knowledge are.
comment on: http://stackoverflow.com/a/499534
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/a/1723239
has body: Here's a nifty utility I use: /** * A common method for all enums since they can't have another base class * @param &lt;T&gt; Enum type * @param c enum type. All enums must be all caps. * @param string case insensitive * @return corresponding enum, or null */ public static &lt;T extends Enum&lt;T&gt;&gt; T getEnumFromString(Class&lt;T&gt; c, String string) { if( c != null &amp;&amp; string != null ) { try { return Enum.valueOf(c, string.trim().toUpperCase()); } catch(IllegalArgumentException ex) { } } return null; } Then in my enum class I usually have this to save some typing: public static MyEnum fromString(String name) { return getEnumFromString(MyEnum.class, name); } If your enums are not all caps, just change the Enum.valueOf line. It is too bad I can't use T.class for Enum.valueOf as T is erased.
type: Answer
upvote count: 151
answers question: http://stackoverflow.com/q/604424
has comment: http://stackoverflow.com/comment/3510352
score: 136
has comment: http://stackoverflow.com/comment/9989082
downvote count: 15
has comment: http://stackoverflow.com/comment/122432773
has comment: http://stackoverflow.com/comment/11442821
has comment: http://stackoverflow.com/comment/126668475

http://stackoverflow.com/a/526069
score: 3
has comment: http://stackoverflow.com/comment/339249
upvote count: 3
answers question: http://stackoverflow.com/q/526037
type: Answer
has body: This isn't cross-platform, but on Mac OS X you can do Runtime.getRuntime().exec("open filename"); The open(1) executable uses LaunchServices to pick the right program to execute, and then uses that to open the file named filename.
downvote count: 0

http://stackoverflow.com/q/626131
downvote count: 0
has body: I create a combo-box control in org.eclipse.swt.widgets.Table The code snippet is below ... TableEditor editor = new TableEditor (table_LLSimDataFileInfo); CCombo combo = new CCombo (table_LLSimDataFileInfo, SWT.NONE); combo.setText("CCombo"); combo.add("item 1"); combo.add("item 2"); editor.grabHorizontal = true; editor.setEditor(combo, items[i], 0); ... How can I dynamically change the combo-box list for a selected row in the table (For e.g. item1, item2 etc changed to item4, item5, item7 etc for row 5 only) by triggering of some event. The event in my case is selection in another combo-box whose list does not change
tagged with: combobox
favorite count: 0
type: UnansweredQuestion
tagged with: swt
score: 3
has answer: http://stackoverflow.com/a/626212
upvote count: 3
tagged with: java
tagged with: eclipse
has answer: http://stackoverflow.com/a/626229
type: Question
has title: Dynamic combo-box list in java swt table
answer count: 2

http://stackoverflow.com/q/473540
has answer: http://stackoverflow.com/a/473614
has title: Correct way to use Actions to create menus, toolbars, and other components in Java
accepted answer: http://stackoverflow.com/a/474090
has comment: http://stackoverflow.com/comment/291395
favorite count: 0
upvote count: 8
has answer: http://stackoverflow.com/a/473739
has answer: http://stackoverflow.com/a/473586
score: 8
has answer: http://stackoverflow.com/a/473886
tagged with: swing
has answer: http://stackoverflow.com/a/473879
type: AnsweredQuestion
has body: The naive way of writing building a menu in a Java Swing app is to do something like: JMenu fileMenu = new JMenu("File"); JMenuItem openItem = new JMenuItem("Open..."); openItem.addActionListener(new ActionListener() { /* action listener stuff */ } ) fileMenu.addMenuItem(openItem); A more experienced developer will recognize that actions can be accessed through a variety of mechanisms - menus, toolbar buttons, maybe even other workflows in the system. That person is more likely to write: Action openAction = new AbstractAction(); openAction.setName("Open..."); openAction.addActionListener(new ActionListener() { /* action listener stuff */ } ) ... JMenuItem openItem = new JMenuItem(openAction); My question is, what is the best way to manage these Action objects so they can be used across menus, toolbars, etc? Create a factory class that returns specific actions? Declare all of the actions as private static final Action in some utility class? Take advantage of a Java application framework? Something else?
tagged with: java
answer count: 6
type: Question
has answer: http://stackoverflow.com/a/474090
possible better answer: http://stackoverflow.com/a/473614
tagged with: user-interface
downvote count: 0

http://stackoverflow.com/comment/460315
type: Comment
score: 0
comment on: http://stackoverflow.com/a/647012
type: AnswerComment
has text: Could you give me an example of a concurrency utility I could use? At least a name.

http://stackoverflow.com/a/610482
downvote count: 1
has body: Probably you can change it in your IDE (in Eclipse Preferences -> Java -> Compiler -> Errors/Warnings)
score: 1
answers question: http://stackoverflow.com/q/610458
upvote count: 2
type: Answer

http://stackoverflow.com/a/432467
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/395675
downvote count: 0
has body: Did you try the Groovy Plugin? It may do this.
type: Answer

http://stackoverflow.com/a/647886
type: Answer
answers question: http://stackoverflow.com/q/645981
score: 0
has body: The reply that you received from John sounds about right - if you have installed the new plugin and can see the code, but keep getting this error only outside IntelliJ, you should try cleaning your grails cache - it's very possible that an older copy of the plugin is precompiled on the cache. Are you using Grails 1.1? I haven't yet tested it with the latest grails, but I understand it keeps the plugins not under the project but in a separate directory. Do let me know and I'll try it out.

http://stackoverflow.com/comment/10605583
type: AnswerComment
type: Comment
score: 1
comment on: http://stackoverflow.com/a/570173
has text: This is the least error prone and readable answer (given that Aces play a dual role)

swing
tags question: http://stackoverflow.com/q/407506
tags question: http://stackoverflow.com/q/491812
tags question: http://stackoverflow.com/q/401598
tags question: http://stackoverflow.com/q/613981
tags question: http://stackoverflow.com/q/573826
tags question: http://stackoverflow.com/q/411945
tags question: http://stackoverflow.com/q/416893
tags question: http://stackoverflow.com/q/491323
tags question: http://stackoverflow.com/q/431579
tags question: http://stackoverflow.com/q/559696
tags question: http://stackoverflow.com/q/411982
tags question: http://stackoverflow.com/q/491726
tags question: http://stackoverflow.com/q/493965
tags question: http://stackoverflow.com/q/419157
tags question: http://stackoverflow.com/q/559559
tags question: http://stackoverflow.com/q/504189
tags question: http://stackoverflow.com/q/489255
tags question: http://stackoverflow.com/q/446056
tags question: http://stackoverflow.com/q/512151
tags question: http://stackoverflow.com/q/416947
tags question: http://stackoverflow.com/q/399929
tags question: http://stackoverflow.com/q/519725
tags question: http://stackoverflow.com/q/532449
tags question: http://stackoverflow.com/q/465107
tags question: http://stackoverflow.com/q/613603
tags question: http://stackoverflow.com/q/538240
tags question: http://stackoverflow.com/q/431663
tags question: http://stackoverflow.com/q/428256
tags question: http://stackoverflow.com/q/431481
tags question: http://stackoverflow.com/q/629315
tags question: http://stackoverflow.com/q/561231
tags question: http://stackoverflow.com/q/432818
tags question: http://stackoverflow.com/q/532201
tags question: http://stackoverflow.com/q/468696
tags question: http://stackoverflow.com/q/620929
tags question: http://stackoverflow.com/q/510610
tags question: http://stackoverflow.com/q/460832
tags question: http://stackoverflow.com/q/359993
tags question: http://stackoverflow.com/q/495674
tags question: http://stackoverflow.com/q/590352
tags question: http://stackoverflow.com/q/536478
tags question: http://stackoverflow.com/q/641025
tags question: http://stackoverflow.com/q/590951
tags question: http://stackoverflow.com/q/495217
tags question: http://stackoverflow.com/q/621685
tags question: http://stackoverflow.com/q/508723
tags question: http://stackoverflow.com/q/595424
tags question: http://stackoverflow.com/q/565458
tags question: http://stackoverflow.com/q/482547
tags question: http://stackoverflow.com/q/492457
tags question: http://stackoverflow.com/q/555795
tags question: http://stackoverflow.com/q/570785
tags question: http://stackoverflow.com/q/564156
tags question: http://stackoverflow.com/q/569351
tags question: http://stackoverflow.com/q/606582
tags question: http://stackoverflow.com/q/379675
tags question: http://stackoverflow.com/q/571026
tags question: http://stackoverflow.com/q/479317
tags question: http://stackoverflow.com/q/370369
tags question: http://stackoverflow.com/q/616958
tags question: http://stackoverflow.com/q/578786
type: Tag
tags question: http://stackoverflow.com/q/542234
tags question: http://stackoverflow.com/q/360898
tags question: http://stackoverflow.com/q/386792
tags question: http://stackoverflow.com/q/553759
tags question: http://stackoverflow.com/q/593765
tags question: http://stackoverflow.com/q/460978
tags question: http://stackoverflow.com/q/476721
tags question: http://stackoverflow.com/q/476678
tags question: http://stackoverflow.com/q/520615
tags question: http://stackoverflow.com/q/639397
tags question: http://stackoverflow.com/q/461112
tags question: http://stackoverflow.com/q/518471
tags question: http://stackoverflow.com/q/556478
tags question: http://stackoverflow.com/q/400235
tags question: http://stackoverflow.com/q/580391
tags question: http://stackoverflow.com/q/640208
tags question: http://stackoverflow.com/q/485530
tags question: http://stackoverflow.com/q/578000

http://stackoverflow.com/comment/7422341
has text: I been looking for this and I was goofing with the rawstride value. You code worked like a charm for me.. Thanks... +1 :)
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/392342

http://stackoverflow.com/comment/15130006
type: AnswerComment
type: Comment
has text: To get the 3.6 version of your example to work i had to create a new type which was basically a wrapper around the TimeStampType then set that type on the field.
score: 2
comment on: http://stackoverflow.com/a/3430957

http://stackoverflow.com/q/443239
type: AnsweredQuestion
has body: Lets say you have interface definition. That interface can be Operation. Then you have two applications running in different JVMs and communicating somehow remotely by exchanging Operation instances. Lets call them application A and application B. If application A implements Operation with the class that is not available in the classpath of the application B, will application B still be able to handle that implementation of interface? Even when B is in different JVM?
possible better answer: http://stackoverflow.com/a/443270
tagged with: java
has answer: http://stackoverflow.com/a/443270
has answer: http://stackoverflow.com/a/443258
type: Question
has title: Interface implementation through different JVMs
has comment: http://stackoverflow.com/comment/265001
has comment: http://stackoverflow.com/comment/264991
score: 0
answer count: 3
accepted answer: http://stackoverflow.com/a/443258
tagged with: jvm
has answer: http://stackoverflow.com/a/443249

http://stackoverflow.com/comment/283588
type: AnswerComment
has text: This is good advice to be sure, but does not list a Java concurrency bug.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/464613

http://stackoverflow.com/comment/311665
has text: It didn't solve the hostname problem necessarily, but it meant that I didn't have to depend on the hostname anymore.
comment on: http://stackoverflow.com/a/495545
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/12749557
score: 1
type: AnswerComment
has text: I like the above approach the best if for nothing else its simplicity! Since we are dealing with times and durations I typically use Joda. An example if you have two DateTimes, start and end respectively: `Duration dur = new Duration(start, end);` `long millis = dur.getMillis();`
type: Comment
comment on: http://stackoverflow.com/a/9311087

http://stackoverflow.com/comment/226845
comment on: http://stackoverflow.com/a/401434
has text: Not in Java. At least not in Java source code. To confuse the issue slightly it *is* allowed in Java byte code...
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/825171
has text: Right click on bar and choose Insert Breakpoint... Not hard at all. Know your tools.
type: Comment
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/1015869

http://stackoverflow.com/comment/138493922
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/544056
has text: For those who come here later, I have been looking into a very similar situation. From [my research](https://stackoverflow.com/questions/78387597/what-is-the-standard-modern-way-to-use-cac-piv-card-authentication-in-java-tomca), it seems that [this answer](https://stackoverflow.com/a/16617019/15811117) is the best process.

http://stackoverflow.com/q/427046
downvote count: 0
tagged with: java
tagged with: certificate
type: Question
tagged with: ssl
score: 4
tagged with: client-server
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/427371
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/250734
upvote count: 4
has body: For two way verification is it necessary to import certicate from both sides?
has title: Java SSL socket based client/server application

eclipse
tags question: http://stackoverflow.com/q/446694
tags question: http://stackoverflow.com/q/455563
tags question: http://stackoverflow.com/q/414180
tags question: http://stackoverflow.com/q/635170
tags question: http://stackoverflow.com/q/390231
tag name: eclipse
tags question: http://stackoverflow.com/q/516196
tags question: http://stackoverflow.com/q/559326
tags question: http://stackoverflow.com/q/434379
tags question: http://stackoverflow.com/q/374348
tags question: http://stackoverflow.com/q/605181
tags question: http://stackoverflow.com/q/438628
tags question: http://stackoverflow.com/q/398654
tags question: http://stackoverflow.com/q/585802
tags question: http://stackoverflow.com/q/511317
tags question: http://stackoverflow.com/q/503157
tags question: http://stackoverflow.com/q/413214
tags question: http://stackoverflow.com/q/373328
tags question: http://stackoverflow.com/q/634801
tags question: http://stackoverflow.com/q/395675
tags question: http://stackoverflow.com/q/399760
tags question: http://stackoverflow.com/q/512778
tags question: http://stackoverflow.com/q/618716
tags question: http://stackoverflow.com/q/610442
tags question: http://stackoverflow.com/q/478883
tags question: http://stackoverflow.com/q/360282
tags question: http://stackoverflow.com/q/547169
tags question: http://stackoverflow.com/q/644262
tags question: http://stackoverflow.com/q/591172
tags question: http://stackoverflow.com/q/575336
tags question: http://stackoverflow.com/q/566877
tags question: http://stackoverflow.com/q/479558
tags question: http://stackoverflow.com/q/408110
tags question: http://stackoverflow.com/q/369406
tags question: http://stackoverflow.com/q/573970
tags question: http://stackoverflow.com/q/433358
tags question: http://stackoverflow.com/q/600834
tags question: http://stackoverflow.com/q/461260
tags question: http://stackoverflow.com/q/480891
tags question: http://stackoverflow.com/q/440931
tags question: http://stackoverflow.com/q/528007
tags question: http://stackoverflow.com/q/461255
tags question: http://stackoverflow.com/q/431465
tags question: http://stackoverflow.com/q/359287
tags question: http://stackoverflow.com/q/477871
tags question: http://stackoverflow.com/q/564759
tags question: http://stackoverflow.com/q/530209
tags question: http://stackoverflow.com/q/473068
tags question: http://stackoverflow.com/q/561432
tags question: http://stackoverflow.com/q/381586
tags question: http://stackoverflow.com/q/482345
tags question: http://stackoverflow.com/q/619560
tags question: http://stackoverflow.com/q/479977
tags question: http://stackoverflow.com/q/381546
tags question: http://stackoverflow.com/q/631066
tags question: http://stackoverflow.com/q/504441
tags question: http://stackoverflow.com/q/495264
tags question: http://stackoverflow.com/q/434385
tags question: http://stackoverflow.com/q/619567
tags question: http://stackoverflow.com/q/374043
tags question: http://stackoverflow.com/q/629557
tags question: http://stackoverflow.com/q/437382
tags question: http://stackoverflow.com/q/370814
tags question: http://stackoverflow.com/q/403378
tags question: http://stackoverflow.com/q/374007
tags question: http://stackoverflow.com/q/596462
tags question: http://stackoverflow.com/q/491726
tags question: http://stackoverflow.com/q/464687
tags question: http://stackoverflow.com/q/564913
tags question: http://stackoverflow.com/q/384101
tags question: http://stackoverflow.com/q/478788
tags question: http://stackoverflow.com/q/426084
tags question: http://stackoverflow.com/q/587612
tags question: http://stackoverflow.com/q/615181
tags question: http://stackoverflow.com/q/458820
tags question: http://stackoverflow.com/q/436920
tags question: http://stackoverflow.com/q/442138
tags question: http://stackoverflow.com/q/453896
tags question: http://stackoverflow.com/q/368260
tags question: http://stackoverflow.com/q/529391

http://stackoverflow.com/comment/4109973
type: Comment
comment on: http://stackoverflow.com/a/442570
type: AnswerComment
has text: [The explanation for synchronized methods from the official Java documentation](http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#260369)
score: 0

http://stackoverflow.com/q/439758
has title: Access sound card or OS synthesizer device in Java
has answer: http://stackoverflow.com/a/582834
type: Question
has comment: http://stackoverflow.com/comment/33524659
answer count: 2
has body: When I try to list Synthesizer devices in Java (1.6.0), I get only one device, Java Sound Synthesizer. I want to use the Synthesizer in the sound card or use any other installed synthesizer, eg. the Microsoft Synthesizer. How can I go about doing that ? If this capability is not inbuilt, is there any open source project that act as front end to synthesizer drivers installed ?
downvote count: 0
possible better answer: http://stackoverflow.com/a/445103
has answer: http://stackoverflow.com/a/445103
accepted answer: http://stackoverflow.com/a/582834
tagged with: synthesizer
favorite count: 0
upvote count: 1
type: AnsweredQuestion
score: 1
tagged with: java

http://stackoverflow.com/comment/255364
type: AnswerComment
has text: Cute, but a good example of missing the big picture, which is that quality trades against other concerns. It's legit and often sensible for a customer to choose budget or schedule over quality, and not the individual developer's place to undermine that decision once made. Advise yes, undermine no.
comment on: http://stackoverflow.com/a/419437
type: Comment
score: 0

http://stackoverflow.com/a/1086368
has body: Yes you can rollback to your JPA implementation if you wish in order to have the control you defined. JPA 1.0 is rich on EL-HQL but light on Criteria API support, however this has been addressed in 2.0. Session session = (Session) entityManager.getDelegate(); session.setFlushMode(FlushMode.MANUAL);
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/448181
score: 1
downvote count: 0

http://stackoverflow.com/q/607863
has answer: http://stackoverflow.com/a/607991
has answer: http://stackoverflow.com/a/607912
has title: Do you find java.util.logging sufficient?
tagged with: logging
has answer: http://stackoverflow.com/a/608691
accepted answer: http://stackoverflow.com/a/608184
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/607920
has comment: http://stackoverflow.com/comment/4050431
type: Question
has answer: http://stackoverflow.com/a/608184
possible better answer: http://stackoverflow.com/a/958211
has answer: http://stackoverflow.com/a/3436828
has answer: http://stackoverflow.com/a/8999608
has answer: http://stackoverflow.com/a/608109
tagged with: frameworks
has answer: http://stackoverflow.com/a/608442
has answer: http://stackoverflow.com/a/608099
score: 42
has answer: http://stackoverflow.com/a/2235910
has answer: http://stackoverflow.com/a/607886
has answer: http://stackoverflow.com/a/607908
has answer: http://stackoverflow.com/a/608339
upvote count: 42
has answer: http://stackoverflow.com/a/1687044
has comment: http://stackoverflow.com/comment/15511429
has body: Per the title, do you find the default Java logging framework sufficient for your needs? Do you use alternative logging services such as log4j or others? If so, why? I'd like to hear any advice you have regarding logging requirements in different types of projects, and when integrating frameworks is actually necessary and/or useful.
downvote count: 0
has answer: http://stackoverflow.com/a/1998619
answer count: 17
has answer: http://stackoverflow.com/a/958211
favorite count: 0

python
tags question: http://stackoverflow.com/q/377556
tags question: http://stackoverflow.com/q/520615
tags question: http://stackoverflow.com/q/448095
tags question: http://stackoverflow.com/q/564469
tags question: http://stackoverflow.com/q/597483
tags question: http://stackoverflow.com/q/454498
tags question: http://stackoverflow.com/q/433945
tags question: http://stackoverflow.com/q/404795
tags question: http://stackoverflow.com/q/610516
tag name: python
tags question: http://stackoverflow.com/q/428308
tags question: http://stackoverflow.com/q/438594
tags question: http://stackoverflow.com/q/417158
tags question: http://stackoverflow.com/q/471000
tags question: http://stackoverflow.com/q/630296
tags question: http://stackoverflow.com/q/369664
tags question: http://stackoverflow.com/q/440036
tags question: http://stackoverflow.com/q/456926
tags question: http://stackoverflow.com/q/476968
tags question: http://stackoverflow.com/q/452969
type: Tag
tags question: http://stackoverflow.com/q/565060
tags question: http://stackoverflow.com/q/441824
tags question: http://stackoverflow.com/q/392624
tags question: http://stackoverflow.com/q/376221
tags question: http://stackoverflow.com/q/376765
tags question: http://stackoverflow.com/q/454182
tags question: http://stackoverflow.com/q/516798
tags question: http://stackoverflow.com/q/567682
tags question: http://stackoverflow.com/q/635159

http://stackoverflow.com/a/15701010
upvote count: 5
type: Answer
downvote count: 0
score: 5
answers question: http://stackoverflow.com/q/457629
has body: Use of following Entry object Example : public Entry&lt;A,B&gt; methodname(arg) { ....... return new AbstractMap.simpleEntry&lt;A,B&gt;(instanceOfA,instanceOfB); }

http://stackoverflow.com/comment/376165
type: Comment
comment on: http://stackoverflow.com/a/564791
type: AnswerComment
has text: Just look at the post given by theomega !
score: 0

http://stackoverflow.com/comment/74801549
type: Comment
has text: There are a millions reasons to have only one implementation. Only one word is enough to describe them all: ABSTRACTION
comment on: http://stackoverflow.com/a/542097
type: AnswerComment
score: 0

http://stackoverflow.com/a/28897005
answers question: http://stackoverflow.com/q/647195
type: Answer
score: 3
upvote count: 3
has body: At least as of Java 1.8.0_31, I can't reproduce the issue anymore. Your input renders as expected: &lt;code&gt;&amp;lt;custom:meatball color="&amp;lt;%= Meatball.RED %&amp;gt; nincompoop="${person}" /&amp;gt;&lt;/code&gt; My tests indicate that javadoc takes into consideration balanced curly braces inside @code, and only ends it when the corresponding curly brace is found. So if the code has balanced curly braces {} like your example, it now works as expected. But I still don't know what to do with unbalanced curly braces like: {@code printf"}&lt;b&gt;outside&lt;/b&gt;"} Also, the behavior depends on which inline tag you are using. man javadoc explicitly says that for @link: If you need to use the right brace (}) inside the label, then use the HTML entity notation &amp;#125;. So in that case it is impossible to do any better. Unfortunately, I couldn't find a similar quote for @code which backs my experiments.
downvote count: 0

http://stackoverflow.com/comment/265758
score: 2
has text: That looks pretty interesting, I will have to read through it when I get a chance. That seems like it might be a really good approach. Alittle much for my particular domain, business apps, but if some could get your approach working without a hitch it would make a good JSR.
type: AnswerComment
comment on: http://stackoverflow.com/a/444098
type: Comment

http://stackoverflow.com/comment/51710666
type: AnswerComment
has text: The above does not work on Liberty if you have a JASPIC enabled site and the validateRequest checks if you are in SSL mode.
comment on: http://stackoverflow.com/a/531598
type: Comment
score: 0

http://stackoverflow.com/a/588260
upvote count: 4
has body: Look into BeanShell or Groovy. Both will give you reasonable solutions--but those solutions rely on my interpretation of your problem, which may be flawed.
downvote count: 0
answers question: http://stackoverflow.com/q/588242
type: Answer
score: 4

http://stackoverflow.com/comment/1759165
type: AnswerComment
score: 0
type: Comment
has text: When the framework your app relies on isn't ported to a new version of Java because of incompatibilities, leaving you stranded in 1.3.x land (or worse), you'll understand. I've been on multiple projects where this was an issue. And no, changing out the framework was not a possibility.
comment on: http://stackoverflow.com/a/442558

http://stackoverflow.com/a/500495
has comment: http://stackoverflow.com/comment/113369197
upvote count: 230
has comment: http://stackoverflow.com/comment/28070354
has body: Try using: if(NewType* v = dynamic_cast&lt;NewType*&gt;(old)) { // old was safely casted to NewType v-&gt;doSomething(); } This requires your compiler to have rtti support enabled. EDIT: I've had some good comments on this answer! Every time you need to use a dynamic_cast (or instanceof) you'd better ask yourself whether it's a necessary thing. It's generally a sign of poor design. Typical workarounds is putting the special behaviour for the class you are checking for into a virtual function on the base class or perhaps introducing something like a visitor where you can introduce specific behaviour for subclasses without changing the interface (except for adding the visitor acceptance interface of course). As pointed out dynamic_cast doesn't come for free. A simple and consistently performing hack that handles most (but not all cases) is basically adding an enum representing all the possible types your class can have and check whether you got the right one. if(old-&gt;getType() == BOX) { Box* box = static_cast&lt;Box*&gt;(old); // Do something box specific } This is not good oo design, but it can be a workaround and its cost is more or less only a virtual function call. It also works regardless of RTTI is enabled or not. Note that this approach doesn't support multiple levels of inheritance so if you're not careful you might end with code looking like this: // Here we have a SpecialBox class that inherits Box, since it has its own type // we must check for both BOX or SPECIAL_BOX if(old-&gt;getType() == BOX || old-&gt;getType() == SPECIAL_BOX) { Box* box = static_cast&lt;Box*&gt;(old); // Do something box specific }
has comment: http://stackoverflow.com/comment/315866
has comment: http://stackoverflow.com/comment/315858
score: 228
has comment: http://stackoverflow.com/comment/316031
has comment: http://stackoverflow.com/comment/33573367
has comment: http://stackoverflow.com/comment/315915
answers question: http://stackoverflow.com/q/500493
downvote count: 2
has comment: http://stackoverflow.com/comment/43546538
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/500493
has comment: http://stackoverflow.com/comment/26652982
has comment: http://stackoverflow.com/comment/127253673
type: Answer
has comment: http://stackoverflow.com/comment/20519333
has comment: http://stackoverflow.com/comment/26576955
has comment: http://stackoverflow.com/comment/47874909

http://stackoverflow.com/a/589897
has comment: http://stackoverflow.com/comment/717879
has comment: http://stackoverflow.com/comment/401802
answers question: http://stackoverflow.com/q/589870
has comment: http://stackoverflow.com/comment/401861
has comment: http://stackoverflow.com/comment/401824
has comment: http://stackoverflow.com/comment/402812
score: 15
has comment: http://stackoverflow.com/comment/401713
has comment: http://stackoverflow.com/comment/402005
downvote count: 4
has comment: http://stackoverflow.com/comment/401785
has comment: http://stackoverflow.com/comment/401718
has comment: http://stackoverflow.com/comment/401790
has comment: http://stackoverflow.com/comment/401805
has body: The answer is: it depends JODA (and JSR-310) is a fully-functional date/time library, including support for use with multiple calendar systems. Personally I found JODA to be a step too far in terms of complexity for what I need. The 2 principal (IMHO) mistakes in the standard java Date and Calendar classes are: They are mutable They mix up the concept of a Year-Month-Day from an Instant-In-Time Although these are addressed by JODA, you'll find it quite easy to roll your own classes for YearMonthDay and Instant, which both use the java classes under the hood for actual "calendrical" calculations. Then you don't have to familiarize yourself with an API of >100 classes, a different formatting/parsing mechanism etc. Of course, if you do need complete representation of different chronologies (e.g. Hebrew) or wish to be able to define your own imaginary Calendar system (e.g. for a game you are writing) then perhaps JODA or JRS-310 is for you. If not, then I would suggest that rolling your own is possibly the way to go. The JSR-310 spec lead is Stephen Colebourne who wrote JODA in the 1st place, so will logically replace JODA.
has comment: http://stackoverflow.com/comment/84335188
has comment: http://stackoverflow.com/comment/402817
has comment: http://stackoverflow.com/comment/401674
has comment: http://stackoverflow.com/comment/402766
has comment: http://stackoverflow.com/comment/401679
type: Answer
upvote count: 19
has comment: http://stackoverflow.com/comment/401725
has comment: http://stackoverflow.com/comment/401677
has comment: http://stackoverflow.com/comment/32260670

http://stackoverflow.com/comment/86448776
type: Comment
comment on: http://stackoverflow.com/a/49241488
has text: Can you give any resources to your answer?
score: 0
type: AnswerComment

http://stackoverflow.com/a/601454
has comment: http://stackoverflow.com/comment/413789
has comment: http://stackoverflow.com/comment/413740
upvote count: 2
has comment: http://stackoverflow.com/comment/413758
has body: New to programming? Well, let's have a look at the code together! The first thing that I see is the conditional inside the loop: if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) This checks if the current date stored in the Calendar cal has a DAY_OF_WEEK which is SUNDAY. If it is, it does one thing, and if it isn't, it does another. Now that we know what the loop's "brain" is looking for, let's look at the loop's declaration: for (int i = 0, inc = 1; i &lt; 366 &amp;&amp; cal.get(Calendar.YEAR) == year; i+=inc) The for loop is split into three parts: initialization, condition, and "increment". The initialization, is run only once, before th loop starts running: int i = 0, inc = 1 Which, as I'm sure you know, creates two variables: i and inc. It sets i to 0, and inc to 1. The condition of the loop gets checked before running each iteration of the loop. It is: i &lt; 366 &amp;&amp; cal.get(Calendar.YEAR) == year Which checks whether i is still less than 366 and also that the date stored in cal has the YEAR of year. This, in effect, makes sure we are still in the same year we started with. The last section of the for, is this: i+=inc Which adds the value of inc to the value of i and stores it in i. So what do we have so far in the loop? The loop starts with an i of 0 and an inc of 1 The loop keeps going as long as i is smaller than the length of a Gregorian year (366 on leap-years), (AND) the date in cal still has the same year as the year in year. i is advanced by inc Let's have another look at the body of the loop: if (condition_that_checks_if_it_is_a_sunday) { // this is a sunday cal.add(Calendar.DAY_OF_MONTH, 7); inc = 7; } else { cal.add(Calendar.DAY_OF_MONTH, 1); } As you can see, if it's a Sunday, two things happen: inc is set to 7, and 7 DAY_OF_MONTH are added to cal. This would mean that in the next iteration of the loop, the expression i+=inc will mean i+=7 and not i+=1 which is did when inc was 1 (like it was when the initialization was done.) If it's n…
has comment: http://stackoverflow.com/comment/413755
answers question: http://stackoverflow.com/q/601380
has comment: http://stackoverflow.com/comment/413747
type: Answer
has comment: http://stackoverflow.com/comment/413749
score: 2
downvote count: 0

http://stackoverflow.com/a/2799236
has comment: http://stackoverflow.com/comment/54130585
has comment: http://stackoverflow.com/comment/80131514
downvote count: 0
has comment: http://stackoverflow.com/comment/60485306
has comment: http://stackoverflow.com/comment/32549273
type: Answer
has comment: http://stackoverflow.com/comment/80132750
upvote count: 14
score: 14
has comment: http://stackoverflow.com/comment/54130484
has body: If you use Groovy, you're basically throwing away useful information about types. This leaves your code "groovy": nice and concise. Bird b becomes def b Plus you get to play with all the meta-class stuff and dynamic method calls which are a torture in Java. However -- and yes I have tried IntelliJ, Netbeans and Eclipse extensively -- serious automatic refactoring is not possible in Groovy. It's not IntelliJ's fault: the type information just isn't there. Developers will say, "but if you have unit tests for every single code path (hmmmm), then you can refactor more easily." But don't believe the hype: adding more code (unit tests) will add to the safety of massive refactoring, but they don't make the work easier. Now you have to hand fix the original code and the unit tests. So this means that you don't refactor as often in Groovy, especially when a project is mature. While your code will be concise and easy to read, it will not be as brilliant as code that has been automatically refactored daily, hourly and weekly. When you realize that a concept represented by a class in Java is no longer necessary, you can just delete it. In Eclipse or Netbeans or whatever, your project hierarchy lights up like a Christmas tree, telling you exactly what you've screwed up with this change. def thing tells the compiler (and therefore your IDE) nothing about how a variable will be used, whether the method exists, etc. And IDEs can only do so much guessing. In the end, Java code is filled with "boilerplate," but it's been kneaded into its final form after many refactorings. And to me, that's the only way to get high-quality, readable code for future programmers, including when those future programmers are you-in-the-future.
answers question: http://stackoverflow.com/q/456140
has comment: http://stackoverflow.com/comment/32619697

http://stackoverflow.com/a/43905810
downvote count: 0
answers question: http://stackoverflow.com/q/642925
upvote count: 2
has body: Here's mine, I add CtrlW as closing shorcut aswell Action closeAction = new AbstractAction(){ public void actionPerformed(ActionEvent e){ dispose(); } }; KeyStroke esc = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0); getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(esc, "closex"); getRootPane().getActionMap().put("closex", closeAction); KeyStroke ctrlW = KeyStroke.getKeyStroke("control W"); getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ctrlW, "close"); getRootPane().getActionMap().put("close", closeAction);
type: Answer
score: 2

http://stackoverflow.com/a/64026770
downvote count: 0
type: Answer
score: 2
has body: You can utilize a HashMap<String, Object> as follows public HashMap<String, Object> yourMethod() { .... different logic here HashMap<String, Object> returnHashMap = new HashMap<String, Object>(); returnHashMap.put("objectA", objectAValue); returnHashMap.put("myString", myStringValue); returnHashMap.put("myBoolean", myBooleanValue); return returnHashMap; } Then when calling the method in a different scope, you can cast each object back to its initial type: // call the method HashMap<String, Object> resultMap = yourMethod(); // fetch the results and cast them ObjectA objectA = (ObjectA) resultMap.get("objectA"); String myString = (String) resultMap.get("myString"); Boolean myBoolean = (Boolean) resultMap.get("myBoolean");
upvote count: 2
answers question: http://stackoverflow.com/q/457629

slf4j
tags question: http://stackoverflow.com/q/462566
tags question: http://stackoverflow.com/q/467879
tag name: slf4j
type: Tag

http://stackoverflow.com/a/10257143
upvote count: 2
answers question: http://stackoverflow.com/q/643906
has body: Void was created to wrap its primitive void type. Every primitive type has its corresponding Reference type. Void is used to instantiate a generic class or use of a generic method, a generic argument which you are not interested in. Here is an example... public void onNewRegistration() { newRegistrationService.createNewUser(view.getUsername(), view.getPassword(), view.getInitialAmount(), view.getCurrency(), new AsyncCallback&lt;Void&gt;() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(Void result) { eventBus.fireEvent(new NewRegistrationSuccessEvent()); } }); } Here, as you can see, I don't want anything from the server that I am asking to create a new registration ,but public interface AsyncCallback&lt;T&gt; { .... } is a generic interface, so i provide Void since generics don't accept primitive types
downvote count: 0
type: Answer
score: 2

http://stackoverflow.com/a/581958
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/578003
has body: I tried to run your code with no modifications and it worked fine for me. Your issue might be related to the Java version or the classpath. The javax.xml.ws (JAX-WS) is only part of the Java SE starting with Java 6. If you are not running this test in Java 6, that might be your problem. That is probably not your issue since if you were not, I would not expect you to be able to resolve those interfaces. The other thing it might be is a classpath issue. External JAX-WS providers can be plugged into the Java runtime. Do you have anything on your classpath that is the JAX-WS provider? Perhaps it is an earlier version.
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/578003
downvote count: 0

http://stackoverflow.com/comment/4695159
comment on: http://stackoverflow.com/a/558262
type: Comment
has text: This does not take care of rolling over of log files.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/437408
has text: The reason I didn't originally do this is that it's ususally the business logic that has to be transactional as opposed to the individual persistence calls. I didn't want Spring imports all over the place - I wanted the persistence implementation details to be isolated as much as possible
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/624504

http://stackoverflow.com/a/8473326
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/463349
has body: I had exactly this problem with the exception that the Person class had a embedded key class. My own solution was to join them in the query AND remove @Fetch(FetchMode.JOIN) My embedded id class: @Embeddable public class MessageRecipientId implements Serializable { @ManyToOne(targetEntity = Message.class, fetch = FetchType.LAZY) @JoinColumn(name="messageId") private Message message; private String governmentId; public MessageRecipientId() { } public Message getMessage() { return message; } public void setMessage(Message message) { this.message = message; } public String getGovernmentId() { return governmentId; } public void setGovernmentId(String governmentId) { this.governmentId = governmentId; } public MessageRecipientId(Message message, GovernmentId governmentId) { this.message = message; this.governmentId = governmentId.getValue(); } }
downvote count: 0
type: Answer

http://stackoverflow.com/a/379198
has comment: http://stackoverflow.com/comment/206882
upvote count: 5
type: Answer
has body: One problem you might run into is that not all fractional values can be represented by doubles. Even some values that look simple, like 0.1. Now on with the pseudocode algorithm. You would probably be best off determining the number of 64ths of an inch, but dividing the decimal portion by 0.015625. After that, you can reduce your fraction to the lowest common denominator. However, since you state inches, you may not want to use the smallest common denominator, but rather only values for which inches are usually represented, 2,4,8,16,32,64. One thing to point out however, is that since you are using inches, if the values are all proper fractions of an inch, with a denominator of 2,4,8,16,32,64 then the value should never contain floating point errors, because the denominator is always a power of 2. However if your dataset had a value of .1 inch in there, then you would start to run into problems.
downvote count: 0
score: 5
answers question: http://stackoverflow.com/q/379176

http://stackoverflow.com/a/631754
downvote count: 51
has comment: http://stackoverflow.com/comment/88865177
accepted answer of: http://stackoverflow.com/q/631598
has comment: http://stackoverflow.com/comment/86583791
answers question: http://stackoverflow.com/q/631598
upvote count: 102
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/65741066
has comment: http://stackoverflow.com/comment/56116122
type: Answer
has comment: http://stackoverflow.com/comment/18488004
score: 51
has comment: http://stackoverflow.com/comment/97436845
has comment: http://stackoverflow.com/comment/45352100
has body: IMHO it's bad practice to have unit tests create or wait on threads, etc. You'd like these tests to run in split seconds. That's why I'd like to propose a 2-step approach to testing async processes. Test that your async process is submitted properly. You can mock the object that accepts your async requests and make sure that the submitted job has correct properties, etc. Test that your async callbacks are doing the right things. Here you can mock out the originally submitted job and assume it's initialized properly and verify that your callbacks are correct.
has comment: http://stackoverflow.com/comment/7571522
has comment: http://stackoverflow.com/comment/40084869

http://stackoverflow.com/a/541640
downvote count: 0
has comment: http://stackoverflow.com/comment/353812
answers question: http://stackoverflow.com/q/541241
has body: What you want is to open a session with the client (i.e. stateful SOAP instead of stateless). This blog post contains some answers. And you have to pass the session ID to the client. Otherwise, you can't tell if a second request is coming from the same client or not.
type: Answer
upvote count: 1
score: 1

http://stackoverflow.com/comment/336388
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/522870
has text: Yes, floating point currency storage can lead to very bad things after a bit of computation.
type: Comment

http://stackoverflow.com/comment/18280264
type: Comment
has text: @Will, I think you misunderstood the meaning of WRAP_CONTENT.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/558825

http://stackoverflow.com/q/435892
upvote count: 8
has answer: http://stackoverflow.com/a/435949
score: 8
has title: Is there a way to have expander icons for multiple roots in a JTree?
type: AnsweredQuestion
tagged with: java
type: Question
has body: I have a JTree with multiple "roots" (Of course, I actually have an invisible real root with multiple children). The nodes expand and collapse on double click, but there's no visual indication that you can do this as there is no expander icon. This is made worse by the fact that the tree is collapsed by default, but expanding the "roots" doesn't really help, as each has many children and it would look cluttered. Is there a way to display the expander icons without making the real (and utterly valueless) root visible? Any other suggestions to make the display clearer welcome.
tagged with: jtree
accepted answer: http://stackoverflow.com/a/435949
downvote count: 0
answer count: 1
favorite count: 0

http://stackoverflow.com/comment/109151434
comment on: http://stackoverflow.com/a/582592
score: 0
type: AnswerComment
has text: If anyone still wondering whether to use GeneratedValue at all? I don't think annotating the ID as @GeneratedValue is a good idea as it takes a lot of hit on the performance. For details refer this [link](https://medium.com/@maqbool.ahmed.mca/spring-data-jpa-vs-data-jdbc-evaluation-b36d8834ead6)
type: Comment

http://stackoverflow.com/a/9891313
downvote count: 0
score: 40
has comment: http://stackoverflow.com/comment/134930688
answers question: http://stackoverflow.com/q/435890
has body: I really like the reflections library for doing this. It provides a lot of different types of scanners (getTypesAnnotatedWith, getSubTypesOf, etc), and it is dead simple to write or extend your own.
upvote count: 40
type: Answer

http://stackoverflow.com/q/449915
tagged with: applet
possible better answer: http://stackoverflow.com/a/450063
has answer: http://stackoverflow.com/a/450063
favorite count: 0
upvote count: 5
has body: I have a Component which I am using both in a standalone Java application as well as in a Java applet. How can I figure out from within the Component whether my component is in an applet? Also, once I figure out that I'm running in an Applet, how can I get access to the Applet?
has title: How to tell if my Java component is in an Applet?
accepted answer: http://stackoverflow.com/a/449938
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/449938
type: Question
answer count: 2
score: 5
downvote count: 0

http://stackoverflow.com/comment/98304390
type: Comment
has text: I know I'm a bit late here, but I see your point on how it shouldn't be necessary, though recently I had run into a situation that actually needed it, and that situation was in the override of Object's equals method. I needed to create a special case within HashMap that agreed with equality, but the usual equals method did not work. There may have been a better method for doing so, but the instanceof function really helped
comment on: http://stackoverflow.com/a/541788
score: 0
type: AnswerComment

http://stackoverflow.com/a/376865
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/375128
type: Answer
upvote count: 1
has body: Velocity allows for a JSTL like utility called velocimacros: http://velocity.apache.org/engine/devel/user-guide.html#Velocimacros This would allow you to define a macro like: #macro( d $date) $date.format('M-D-yyyy') #end And then call it like so: #d($someDate)
has comment: http://stackoverflow.com/comment/204783

http://stackoverflow.com/q/579454
tagged with: architecture
has answer: http://stackoverflow.com/a/579562
has body: I have just started to learn Java and is curious is it any good practice in Java for good object decomposition? Let me describe a problem. In big software project it's always a big classes like 'core' or 'ui' that tends to have a lot of methods and are intended as a mediators between smaller classes. For example, if user clicks a button on some window, this window's class sends a message to 'ui' class. This 'ui' class catches this message and acts accordingly by doing something with application user interface ( via calling method of one of it's member objects ) or by posting message to application 'core' if it's something like 'exit application' or 'start network connection'. Such objects is very hard to break apart since they are a mere mediators between a lots of small application objects. But having a classes in application with hundreds and thousands of methods is not very handy, event if such methods are trivial task delegation from one object to another. C# solves such problem by allowing to break class implementation into multiple source files: you can divide god object any way you choose, and it will work. Any practices by dividing such objects in Java?
upvote count: 12
type: AnsweredQuestion
tagged with: oop
downvote count: 0
has answer: http://stackoverflow.com/a/579894
possible better answer: http://stackoverflow.com/a/579562
tagged with: refactoring
tagged with: java
type: Question
score: 12
has answer: http://stackoverflow.com/a/579639
favorite count: 0
has answer: http://stackoverflow.com/a/579545
accepted answer: http://stackoverflow.com/a/579545
has title: Big class decomposition in Java
has answer: http://stackoverflow.com/a/579496
answer count: 5

http://stackoverflow.com/q/442496
answer count: 2
downvote count: 0
score: 18
tagged with: sockets
tagged with: android
favorite count: 0
has body: Can anybody tell my why this doesn't work in the Android emulator? From the browser I have access and the server is internal. All I can think of is that I'm missing some configuration on my app so it can access the network layer. try { InetAddress server = Inet4Address.getByName("thehost"); //Doesn't work either //or InetAddress server2 = Inet4Address.getByAddress(new String("192.168.1.30").getBytes()); if(server.isReachable(5000)){ Log.d(TAG, "Ping!"); } Socket clientsocket = new Socket(server, 8080); } catch (UnknownHostException e) { Log.e(TAG, "Server Not Found"); } catch (IOException e) { Log.e(TAG, "Couldn't open socket"); } Throws an UnknownHostException Thanks
has answer: http://stackoverflow.com/a/442590
has answer: http://stackoverflow.com/a/1508968
has title: Android HTTP Connection
type: AnsweredQuestion
tagged with: network-programming
tagged with: java
accepted answer: http://stackoverflow.com/a/442590
possible better answer: http://stackoverflow.com/a/1508968
upvote count: 18
type: Question

http://stackoverflow.com/a/400331
accepted answer of: http://stackoverflow.com/q/400250
has comment: http://stackoverflow.com/comment/228076
upvote count: 2
type: AcceptedAnswer
has body: The AgitarOne JUnit Generator comes to mind. I'm not sure it's what you're thinking of, though.
type: Answer
score: 2
answers question: http://stackoverflow.com/q/400250
downvote count: 0

http://stackoverflow.com/comment/21150758
has text: Thanks for posting your answer! Please be sure to read the [FAQ on Self-Promotion](http://stackoverflow.com/faq#promotion) carefully. Also note that it is *required* that you post a disclaimer every time you link to your own site/product.
score: 0
comment on: http://stackoverflow.com/a/15041513
type: Comment
type: AnswerComment

http://stackoverflow.com/a/48507508
downvote count: 1
upvote count: 10
type: Answer
has body: import java.security.*; import javax.xml.bind.*; byte[] bytesOfMessage = yourString.getBytes("UTF-8"); MessageDigest md = MessageDigest.getInstance("MD5"); byte[] bytesOfDigest = md.digest(bytesOfMessage); String digest = DatatypeConverter.printHexBinary(bytesOfDigest).toLowerCase();
score: 9
answers question: http://stackoverflow.com/q/415953

http://stackoverflow.com/q/529085
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/4986724
has answer: http://stackoverflow.com/a/10021028
tagged with: reflection
has answer: http://stackoverflow.com/a/44811546
has answer: http://stackoverflow.com/a/529094
has answer: http://stackoverflow.com/a/18362577
has answer: http://stackoverflow.com/a/30799960
tagged with: java
has answer: http://stackoverflow.com/a/530289
accepted answer: http://stackoverflow.com/a/530289
answer count: 32
has answer: http://stackoverflow.com/a/22200232
has answer: http://stackoverflow.com/a/529358
has answer: http://stackoverflow.com/a/40120447
type: Question
has answer: http://stackoverflow.com/a/46237256
has answer: http://stackoverflow.com/a/4221845
has answer: http://stackoverflow.com/a/18254084
tagged with: arrays
has answer: http://stackoverflow.com/a/33183279
has comment: http://stackoverflow.com/comment/342261
has answer: http://stackoverflow.com/a/12213683
has title: How can I create a generic array in Java?
downvote count: 2
upvote count: 1253
has answer: http://stackoverflow.com/a/529140
has answer: http://stackoverflow.com/a/49922710
linked to: http://stackoverflow.com/q/9542076
has answer: http://stackoverflow.com/a/18806548
has answer: http://stackoverflow.com/a/58731117
has answer: http://stackoverflow.com/a/536195
has answer: http://stackoverflow.com/a/35531219
has body: Due to the implementation of Java generics, you can't have code like this: public class GenSet&lt;E&gt; { private E a[]; public GenSet() { a = new E[INITIAL_ARRAY_LENGTH]; // Error: generic array creation } } How can I implement this while maintaining type safety? I saw a solution on the Java forums that goes like this: import java.lang.reflect.Array; class Stack&lt;T&gt; { public Stack(Class&lt;T&gt; clazz, int capacity) { array = (T[])Array.newInstance(clazz, capacity); } private final T[] array; } What's going on?
tagged with: generics
linked to: http://stackoverflow.com/q/12462079
possible better answer: http://stackoverflow.com/a/2924453
favorite count: 0
linked to: http://stackoverflow.com/q/5670972
has answer: http://stackoverflow.com/a/25853468
has answer: http://stackoverflow.com/a/2924453
has answer: http://stackoverflow.com/a/6348905
has comment: http://stackoverflow.com/comment/342483
has answer: http://stackoverflow.com/a/40515696
score: 1251
has answer: http://stackoverflow.com/a/30611850
has answer: http://stackoverflow.com/a/74749313
has comment: http://stackoverflow.com/comment/76656206
has comment: http://stackoverflow.com/comment/136565836
has answer: http://stackoverflow.com/a/24655212
has answer: http://stackoverflow.com/a/8052827
has answer: http://stackoverflow.com/a/18137953
has answer: http://stackoverflow.com/a/45045080
has answer: http://stackoverflow.com/a/61964765
tagged with: instantiation

http://stackoverflow.com/q/419833
tagged with: jar
accepted answer: http://stackoverflow.com/a/419912
has body: I have a list of jar files, all containing slightly different versions of the same system. I want to execute a set of test cases on each jar file while being able to obtain the results for each jar (via RunListener or something like that). I am a bit confused with the class loading problems that are implied. How can I nicely do this ?
possible better answer: http://stackoverflow.com/a/419861
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/419861
has answer: http://stackoverflow.com/a/419912
type: Question
tagged with: java
score: 0
answer count: 2
has title: How to run test cases on a list of slightly different jars?
tagged with: junit

http://stackoverflow.com/comment/369394
has text: Seems like the best answer. Unless you are running a LOT of threads, it shouldn't matter--I've run quite a few and until you are in the thousands, don't stress too much. Waiting threads don't drain CPU.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/557387

http://stackoverflow.com/a/491319
has comment: http://stackoverflow.com/comment/5300726
upvote count: 2
has comment: http://stackoverflow.com/comment/307184
answers question: http://stackoverflow.com/q/491177
type: Answer
has body: Here's a solution: public static void main(String[] args) { int nRows = 0; int nChars = 0; int nWords = 0; final HashMap&lt;String, Integer&gt; map = new HashMap&lt;String, Integer&gt;(); try { BufferedReader input = new BufferedReader(new FileReader("c:\\test.txt")); try { String line = null; Pattern p = Pattern.compile("[^\\w]+"); while ((line = input.readLine()) != null) { nChars += line.length(); nRows++; String[] words = p.split(line); nWords += words.length; for (String w : words) { String word = w.toLowerCase(); Integer n = map.get(word); if (null == n) map.put(word, 1); else map.put(word, n.intValue() + 1); } } TreeMap&lt;String, Integer&gt; treeMap = new TreeMap&lt;String, Integer&gt;(new Comparator&lt;String&gt;() { @Override public int compare(String o1, String o2) { if (map.get(o1) &gt; map.get(o2)) return -1; else if (map.get(o1) &lt; map.get(o2)) return 1; else return o1.compareTo(o2); } }); treeMap.putAll(map); System.out.println("N.º Rows: " + nRows); System.out.println("N.º Words: " + nWords); System.out.println("N.º Chars: " + nChars); System.out.println(); System.out.println("Top 10 Words:"); for (int i = 0; i &lt; 10; i++) { Entry&lt;String, Integer&gt; e = treeMap.pollFirstEntry(); System.out.println("Word: " + e.getKey() + " Count: " + e.getValue()); } } finally { input.close(); } } catch (IOException ex) { ex.printStackTrace(); } }
has comment: http://stackoverflow.com/comment/5270352
has comment: http://stackoverflow.com/comment/5300973
downvote count: 0
has comment: http://stackoverflow.com/comment/5299036
has comment: http://stackoverflow.com/comment/5298943
has comment: http://stackoverflow.com/comment/5299012
score: 2

security
tags question: http://stackoverflow.com/q/581655
tags question: http://stackoverflow.com/q/438508
tags question: http://stackoverflow.com/q/429352
tags question: http://stackoverflow.com/q/494860
tags question: http://stackoverflow.com/q/540738
tags question: http://stackoverflow.com/q/530972
tags question: http://stackoverflow.com/q/571081
tags question: http://stackoverflow.com/q/646224
tags question: http://stackoverflow.com/q/360520
tags question: http://stackoverflow.com/q/628416
tags question: http://stackoverflow.com/q/435912
tags question: http://stackoverflow.com/q/368792
tags question: http://stackoverflow.com/q/557746
tags question: http://stackoverflow.com/q/367530
tags question: http://stackoverflow.com/q/377901
tags question: http://stackoverflow.com/q/528938
tags question: http://stackoverflow.com/q/626043
tags question: http://stackoverflow.com/q/636172
tags question: http://stackoverflow.com/q/476640
tags question: http://stackoverflow.com/q/495392
tags question: http://stackoverflow.com/q/442995
tags question: http://stackoverflow.com/q/547219
tags question: http://stackoverflow.com/q/605589
tags question: http://stackoverflow.com/q/579224
tags question: http://stackoverflow.com/q/442862
tags question: http://stackoverflow.com/q/491109
tags question: http://stackoverflow.com/q/506939
tags question: http://stackoverflow.com/q/637496
type: Tag
tags question: http://stackoverflow.com/q/461886
tags question: http://stackoverflow.com/q/407990
tags question: http://stackoverflow.com/q/612121
tags question: http://stackoverflow.com/q/529997
tag name: security

http://stackoverflow.com/comment/71646227
has text: reading this book at the moment... im wondering... if that list was private instead of public and only had the putIfAbsent method, synchronized(this) would be sufficient right? the issue at hand is because the list can be modified outside that ListHelper as well?
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/41044620

http://stackoverflow.com/q/598046
tagged with: image
upvote count: 3
answer count: 2
has answer: http://stackoverflow.com/a/598277
favorite count: 0
has title: Java (J2ME) Convert Image to byte[], then back to Image
tagged with: byte
type: AnsweredQuestion
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/769419
type: Question
score: 3
has body: I'm trying to convert an Image object to a byte array then back to an Image (so that I can store the image in a blob object in an Apache Derby Database). I can convert an Image to a byte array (code below) but I cann't convert the bytes back to an image. As a further complication I'm using J2ME, so I can't use javax.image.*. Can you help? Thanks package six.util; import java.awt.Image; import java.awt.image.BufferedImage; import java.awt.image.ImageObserver; import java.awt.Component; import java.awt.MediaTracker; import java.awt.Graphics; import java.awt.image.DataBufferByte; import java.awt.image.WritableRaster; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.image.PixelGrabber; import java.util.ArrayList; public class ImageConverter extends Component { private MediaTracker mediaTracker; private Image image; private ImageConverter(Image image) { super(); this.mediaTracker = new MediaTracker(this); this.mediaTracker.addImage(image, 0); this.image = image; } private BufferedImage convert() { /* * Have to wait for image to load. */ try { this.mediaTracker.waitForID(0); }catch(InterruptedException e) { } System.out.println("-1"); GraphicsConfiguration graphicsConfig = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); BufferedImage bimage = graphicsConfig.createCompatibleImage(this.image.getWidth(null),this.image.getHeight(null)); System.out.println("-2"); Graphics g = bimage.getGraphics(); g.drawImage(image, 0, 0, null); return bimage; } private static byte[] convertIntToByteArray(int integer) { byte[] bytes = new byte[4]; bytes[0] =(byte)( integer &gt;&gt; 24 ); bytes[1] =(byte)( (integer &lt;&lt; 8) &gt;&gt; 24 ); bytes[2] =(byte)( (integer &lt;&lt; 16) &gt;&gt; 24 ); bytes[3] =(byte)( (integer &lt;&lt; 24) &gt;&gt; 24 ); return bytes; } private static int convertByteArrayToInt(byte[] bytes) { return (bytes[0] &lt;&lt; 32) | (bytes[1] &lt;&…
accepted answer: http://stackoverflow.com/a/598277
possible better answer: http://stackoverflow.com/a/769419

http://stackoverflow.com/q/582248
has answer: http://stackoverflow.com/a/582279
favorite count: 0
has answer: http://stackoverflow.com/a/584504
answer count: 5
tagged with: war
tagged with: deployment
type: AnsweredQuestion
has body: I'm currently working on a j2ee project that's been in beta for a while now. Right now we're just hammering out some of the issues with the deployment process. Specifically, there are a number of files embedded in the war (some xml-files and .properties) that need different versions deploying depending on whether you are in a dev, testing or production environment. Stuff like loglevels, connection pools, etc. So I was wondering how developers here structure their process for deploying webapps. Do you offload as much configuration as you can to the application server? Do you replace the settings files programmatically before deploying? Pick a version during build process? Manually edit the wars? Also how far do you go in providing dependencies through the application servers' static libraries and how much do you put in the war themselves? All this just to get some ideas of what the common (or perhaps best) practice is at the moment.
tagged with: java
tagged with: web-applications
possible better answer: http://stackoverflow.com/a/582279
type: Question
tagged with: jakarta-ee
upvote count: 15
has answer: http://stackoverflow.com/a/583077
score: 15
has title: How do you manage embedded configuration files and libraries in java webapps?
has answer: http://stackoverflow.com/a/584724
downvote count: 0
has answer: http://stackoverflow.com/a/584589
accepted answer: http://stackoverflow.com/a/584589

http://stackoverflow.com/a/567093
downvote count: 1
type: Answer
has body: If you are using JDK 6 then you might want to check out ConcurrentHashMap Note the putIfAbsent method in that class.
upvote count: 16
answers question: http://stackoverflow.com/q/567068
score: 15

http://stackoverflow.com/comment/1269225
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/498756
score: 1
has text: watchout for a division by zero when i = 3.

http://stackoverflow.com/q/635594
downvote count: 0
has body: Are there any tools available for transforming types defined in an xsd schema (may or may not include other xsd files) into ActionScript value objects? I've been googling this for a while but can't seem to find any tools and I'm pondering wether writing such a tool would save us more time right now than to simply code our value objects by hand. Another possibility I've been considering is using a tool such as XMLBeans to transform the types defined by the schema to Java classes and then converting those classes in ActionScript. However, I've come to realize that there are about a gazillion java -> as3 converters out there and the general consesus seems to be that they sort of work, ie, I have no idea which tool is a good fit. Any thoughts?
tagged with: actionscript
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/647555
favorite count: 0
type: Question
upvote count: 2
answer count: 2
tagged with: apache-flex
has title: Generating ActionScript value objects from an xsd schema
has answer: http://stackoverflow.com/a/635710
tagged with: xsd
possible better answer: http://stackoverflow.com/a/635710
tagged with: java
accepted answer: http://stackoverflow.com/a/647555
tagged with: value-objects
score: 2

http://stackoverflow.com/q/526037
has title: How to open user system preferred editor for given file?
upvote count: 15
has comment: http://stackoverflow.com/comment/339589
has body: I'm trying to figure out how to open the system preferred editor for a given file. Say, we have a file manager, written in Java. User goes to folder and sees the list of files. And, for example, there is a file Icon.jpg. User double clicks on the filename and file opens in system's preferred editor (i.e. Gimp). The main issue is - how to do that? We can do Runtime.getRuntime().exec("something file"), but this way you should know which program is preferred in user environment. But how? We also are able to do Desktop.getDesktop().edit(File file), but this way we cannot track process and aren't able to know then this child process is closed. Other issue - function doesn't work on linux (at least on Ubuntu 8.10). There is also Desktop.getDesktop().open(File file), but it forces to open file viewer, instead of system viewer for that file type. I am searching for a solution all week, but didn't got any suitable and generic one. Do you know the other approaches to this question? For my project it would be enough if it would work on Windows+Linux+Mac. Thank you for your answers and advices. Edit on 2009-02-08 23:04 Other suggestion: can I force "application selection" window in Windows and in Linux, as in Mac with "open file"? For example, then you trying to open file, you are being asked to choose application from list of system preferred ones? (something like "Open with..." in Windows explorer). Do you know?
downvote count: 0
linked to: http://stackoverflow.com/q/23566667
favorite count: 0
has answer: http://stackoverflow.com/a/526080
tagged with: system
has answer: http://stackoverflow.com/a/70576680
answer count: 5
has answer: http://stackoverflow.com/a/33361413
tagged with: editor
score: 15
tagged with: java
tagged with: file
has answer: http://stackoverflow.com/a/526069
possible better answer: http://stackoverflow.com/a/526072
accepted answer: http://stackoverflow.com/a/526080
linked to: http://stackoverflow.com/q/33094981
type: Question
has answer: http://stackoverflow.com/a/526072
type: AnsweredQuestion

http://stackoverflow.com/a/78433963
has body: Instead of populating the map in the constructor you could do that in a static block. Or since Java 8 you could use Stream and Lambdas like this public enum Day { Sunday("Sun"), Monday("Mon"), Tuesday("Tue"), Wednesday("Wed"), Thursday("Thu"), Friday("Fri"), Saturday("Sat"); private final String abbreviation; Day(String abbreviation) { this.abbreviation = abbreviation; } public String getAbbreviation() { return abbreviation; } private static final Map<String, Day> ABBREV_MAP = Stream.of(values()).collect(Collectors.toMap(e -> e.abbreviation, e -> e)); public static Day getByAbbreviation(String abbreviation) { return ABBREV_MAP.get(abbreviation); } }
type: Answer
score: 0
answers question: http://stackoverflow.com/q/443980

dynamic-dispatch
type: Tag
tag name: dynamic-dispatch
tags question: http://stackoverflow.com/q/370812

http://stackoverflow.com/a/483422
has body: You'll have to create a "working set" specifically to include that jar: Ctrl-H -> File h-> Working Set (Choose) -> "Java" -> (Pick your resources and jars)
has comment: http://stackoverflow.com/comment/301993
has comment: http://stackoverflow.com/comment/306049
downvote count: 0
upvote count: 2
has comment: http://stackoverflow.com/comment/304057
type: Answer
answers question: http://stackoverflow.com/q/482345
score: 2

http://stackoverflow.com/q/393252
answer count: 4
type: AnsweredQuestion
downvote count: 0
has title: Converting a generic argument to an int in java, provided that it is a number
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/54794858
score: 4
has answer: http://stackoverflow.com/a/393258
accepted answer: http://stackoverflow.com/a/393258
has answer: http://stackoverflow.com/a/393257
tagged with: generics
possible better answer: http://stackoverflow.com/a/393297
favorite count: 0
has answer: http://stackoverflow.com/a/393297
has body: Here's what I've been trying to do, in a nutshell: class example &lt;T extends Number&gt; { private int function(T number) { int x = (int) number; ... } ... } Basically, I'm trying to make it so that T is a number so I can convert it to an int inside that function. The problem is that I'm getting an "incovertible types" error, so I must be doing something wrong.
upvote count: 4

http://stackoverflow.com/a/462322
type: Answer
accepted answer of: http://stackoverflow.com/q/462297
answers question: http://stackoverflow.com/q/462297
has body: Using the generified version of class Class allows you, among other things, to write things like Class&lt;? extends Collection&gt; someCollectionClass = someMethod(); and then you can be sure that the Class object you receive extends Collection, and an instance of this class will be (at least) a Collection.
upvote count: 163
type: AcceptedAnswer
score: 161
downvote count: 2

http://stackoverflow.com/a/476667
has body: script signing Conceptually, that's just reaching into your cryptographic toolbox and using the tools that exist. Have people sign their code, validate the signatures on download, and check that the originator of the signature is trusted. The hard(er) question is what makes people worthy of trust, and who gets to choose that. Unless your users are techies, they don't want to think about that, and so they won't set good policy. On the other hand, you'll probably have to let the users introduce trust [unless you want to go for an iPhone AppStore-style walled garden, which it doesn't sound like]. script authentication How's this different from signing? Or, is your question just that: "what are the concepts that I should be thinking about here"? The real question is of course: what do you want your users to be secured against? Is it only in-transit modification, or do you also want to make guarantees about the behavior of the scripts? Some examples might be: scripts can't access the file system, scripts can only access a particular subtree of the file system, scripts can't access the network, etc. I think it might be possible [with a modest amount of work] to provide some guarantees about how scripts access the outside world if they were done in haskell and the IO monad was broken into smaller pieces. Or, possibly, if you had the scripts run in their own opaque monad with access to a limited part of IO. Be sure to remove access to unsafe functions. You may also want to look at the considerations that went into the Java (applet) security model. I hope this gives you something to think about.
type: Answer
upvote count: 2
has comment: http://stackoverflow.com/comment/294646
score: 2
answers question: http://stackoverflow.com/q/476640
downvote count: 0

http://stackoverflow.com/a/27518972
answers question: http://stackoverflow.com/q/450557
type: Answer
has body: In my company, we have also implemented spring custom scope. We have a multi tenant system where every customer can customize settings. Instance based scope of ours, caches the beans which are customer specific. So each time user of a customer logs in, these settings are cached and reused again when other users of the same customers sign in.
score: 0

http://stackoverflow.com/a/489980
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/305972
score: 3
has body: for (int i = 2; i &lt; 64; i &lt;&lt;= 1) //System.out.print(Integer.toString(i, 2)); System.out.print(Integer.toString(i, 2).replaceAll("[01]", "$0 "));
answers question: http://stackoverflow.com/q/489927
upvote count: 3

http://stackoverflow.com/comment/267399
score: 0
has text: But what can i do to beware the scenario that some one buys it and then put it on the internet for all the other. The USB stick would prevent this
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/445945

http://stackoverflow.com/comment/265045
comment on: http://stackoverflow.com/a/443260
score: 1
type: AnswerComment
type: Comment
has text: "if this would be expected by the logic..." is a point I am trying to get across as well. I don't see the point of *always* using private locks, although the general consensus seems to be that it is better, since it doesn't hurt and is more defensive.

http://stackoverflow.com/a/21873525
downvote count: 1
score: 20
has body: public static String getCurrentMethodName() { return Thread.currentThread().getStackTrace()[2].getClassName() + "." + Thread.currentThread().getStackTrace()[2].getMethodName(); }
answers question: http://stackoverflow.com/q/442747
upvote count: 21
type: Answer
has comment: http://stackoverflow.com/comment/67668614
has comment: http://stackoverflow.com/comment/134499002

http://stackoverflow.com/comment/3893425
comment on: http://stackoverflow.com/q/453684
type: Comment
type: QuestionComment
has text: Vector has not been deprecated yet.
score: 0

http://stackoverflow.com/q/626940
has answer: http://stackoverflow.com/a/626980
tagged with: java
has answer: http://stackoverflow.com/a/64616632
score: 18
has answer: http://stackoverflow.com/a/37993372
upvote count: 18
has answer: http://stackoverflow.com/a/46127081
downvote count: 0
has answer: http://stackoverflow.com/a/68242069
favorite count: 0
has answer: http://stackoverflow.com/a/627075
answer count: 9
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/4150409
has body: My professor asked us to create a Java program that would be able to run in command prompt but could also be opened using NetBeans. The program is about using the different types of sorting (specifically Selection, Insertion, Exchange, Quick, and Heap sorting). our professor specifically told us to use object oriented programming in Java, and that she wants to see a main class plus the different classes that would do the sorting. I tried to write the program in NetBeans — thinking that later I could simply run the program in cmd using javac. In cmd, I typed the path where my NetBeans project was saved and I tried to compile the files using javac. but it says that "'javac' is not recognized as an internal or external command, operable program or batch file." So I tried to save the files in sun>sdk>jdk>bin, and from there I tried to compile the files, and it was fine. The problem sets in when I tried to run them. Here's how I tried to compile the files: javac Main.java Sortchoice.java Selection.java SelectionSort.java Insertion.java InsertionSort.java Exchange.java ExchangeSort.java (I havent finished the syntax for the next two sorting.) Here's how I tried to run the files in cmd: java Main Sortchoice Selection SelectionSort Insertion InsertionSort Exchange ExchangeSort and cmd says: exception in thread "main" java.lang.NoClassDefFoundError: main (wring name: myjava/Main) at java.lang.ClassLoader.defineClass1(Nativ... Method)" at java.lang.ClassLoader.defineClass(ClassL... at java.security.SecureClassLoader.defineCl... at java.net.URLClassLoader.defineClass(URLC... at java.net.URLClassLoader.access$000(URLCl... at java.net.URLClassLoader$1.run(URLClassLo... at java.security.AccessController.doPrivile... Method) at java.net.URLClassLoader.findClass(URLCla... at java.lang.ClassLoader.loadClass(ClassLoa... at sun.misc.Launcher&amp;AppClassLoader.loadCla... at java.lang.ClasLoader.loadClass(ClassLoad... at java.lang.ClassLoader.loadClassInternal(... What should I do? (So…
tagged with: command-line
tagged with: netbeans
has answer: http://stackoverflow.com/a/4938671
has answer: http://stackoverflow.com/a/627067
has title: How to run a NetBeans project in command prompt?
type: Question

http://stackoverflow.com/q/574240
has answer: http://stackoverflow.com/a/574253
answer count: 23
linked to: http://stackoverflow.com/q/4201713
has answer: http://stackoverflow.com/a/574502
favorite count: 0
has answer: http://stackoverflow.com/a/574267
has comment: http://stackoverflow.com/comment/8681651
tagged with: multithreading
possible better answer: http://stackoverflow.com/a/574253
has answer: http://stackoverflow.com/a/34250800
has answer: http://stackoverflow.com/a/20646571
has answer: http://stackoverflow.com/a/5709000
has answer: http://stackoverflow.com/a/574525
has answer: http://stackoverflow.com/a/41044620
type: AnsweredQuestion
has title: Is there an advantage to use a Synchronized Method instead of a Synchronized Block?
has answer: http://stackoverflow.com/a/45702347
tagged with: java
has answer: http://stackoverflow.com/a/574247
downvote count: 2
linked to: http://stackoverflow.com/q/442564
has answer: http://stackoverflow.com/a/15990099
tagged with: concurrency
has body: Can any one tell me the advantage of synchronized method over synchronized block with an example?
accepted answer: http://stackoverflow.com/a/574267
has answer: http://stackoverflow.com/a/54518713
type: Question
has answer: http://stackoverflow.com/a/19087933
has answer: http://stackoverflow.com/a/574258
tagged with: locking
linked to: http://stackoverflow.com/q/416183
has answer: http://stackoverflow.com/a/3243869
has answer: http://stackoverflow.com/a/575722
has answer: http://stackoverflow.com/a/18186063
has answer: http://stackoverflow.com/a/17671873
has comment: http://stackoverflow.com/comment/387529
tagged with: synchronized
has comment: http://stackoverflow.com/comment/48288567
has answer: http://stackoverflow.com/a/13802864
has answer: http://stackoverflow.com/a/574259
score: 421
has answer: http://stackoverflow.com/a/37366467
upvote count: 423
has answer: http://stackoverflow.com/a/33398492
has answer: http://stackoverflow.com/a/23194019

http://stackoverflow.com/q/390449
upvote count: 5
tagged with: java
linked to: http://stackoverflow.com/q/371495
has title: determining java memory usage
has answer: http://stackoverflow.com/a/390466
tagged with: memory
downvote count: 0
has answer: http://stackoverflow.com/a/390856
favorite count: 0
has answer: http://stackoverflow.com/a/395573
has answer: http://stackoverflow.com/a/390840
has body: Hmmm. Is there a primer anywhere on memory usage in Java? I would have thought Sun or IBM would have had a good article on the subject but I can't find anything that looks really solid. I'm interested in knowing two things: at runtime, figuring out how much memory the classes in my package are using at a given time at design time, estimating general memory overhead requirements for various things like: how much memory overhead is required for an empty object (in addition to the space required by its fields) how much memory overhead is required when creating closures how much memory overhead is required for collections like ArrayList I may have hundreds of thousands of objects created and I want to be a "good neighbor" to not be overly wasteful of RAM. I mean I don't really care whether I'm using 10% more memory than the "optimal case" (whatever that is), but if I'm implementing something that uses 5x as much memory as I could if I made a simple change, I'd want to use less memory (or be able to create more objects for a fixed amount of memory available). I found a few articles (Java Specialists' Newsletter and something from Javaworld) and one of the builtin classes java.lang.instrument.getObjectSize() which claims to measure an "approximation" (??) of memory use, but these all seem kind of vague... (and yes I realize that a JVM running on two different OS's may be likely to use different amounts of memory for different objects)
has answer: http://stackoverflow.com/a/393491
type: UnansweredQuestion
score: 5
has comment: http://stackoverflow.com/comment/23148919
has answer: http://stackoverflow.com/a/390591
has answer: http://stackoverflow.com/a/393057
type: Question
answer count: 8
has answer: http://stackoverflow.com/a/390749
linked to: http://stackoverflow.com/q/3966411

http://stackoverflow.com/comment/271967
type: QuestionComment
has text: is this a interview/classroom questions?
comment on: http://stackoverflow.com/q/451182
score: 0
type: Comment

http://stackoverflow.com/comment/395884
score: 0
type: Comment
comment on: http://stackoverflow.com/a/583874
has text: Because of my last point... this must be made to run using JavaME on a mobile phone.
type: AnswerComment

http://stackoverflow.com/a/631289
score: 9
answers question: http://stackoverflow.com/q/631099
has comment: http://stackoverflow.com/comment/443963
upvote count: 9
type: Answer
downvote count: 0
has body: Ok, problem solved. As usual, the problem was less wierd than I thought. The project I'm working on is in the unfortunate condition of having some duplicate class names. I was creating the class using foo.MyInterface and testing for instance of bar.MyInterface. Thanks for the responses. It really did help me think it through.
has comment: http://stackoverflow.com/comment/76459263

http://stackoverflow.com/a/439621
upvote count: 16
score: 16
answers question: http://stackoverflow.com/q/434950
accepted answer of: http://stackoverflow.com/q/434950
has comment: http://stackoverflow.com/comment/33192083
has body: A number of techniques are evolving, but the problem is still sufficiently cutting edge that the standardization process has not yet provided us with a totally portable solution. Option one, you can make the web services transaction aware. This of course assumes you have control over them, although writing a transaction aware proxy for non-transactional services is also an option in some cases. The WS-AT and WS-BA protocols are the leading standards for transactional web services. Unfortunately they specify the protocol only, not the language bindings. In other words, there is no standard API at the programming language level. For Java the nearest thing is JSR-156, but it's not ready yet. Then the problem becomes: how to tie the EJB (i.e. JTA/XA) transaction to the WS one. Since the models used by the WS-AT and XA protocols are closely related, this can be achieved by means of a protocol bridge. Several app servers provide something alone these lines. JBoss presented theirs at JavaOne - see http://anonsvn.jboss.org/repos/labs/labs/jbosstm/workspace/jhalliday/txbridge/BOF-4182.odp Note that the protocol bridging technique can also be used the other way around, to allow an EJB that uses e.g. an XA database backend, to be exposed as a transactional web service. However, the locking model used by two phase commit transactions is really only suitable for short lived transactions in the same domain of control. If your services run in the same company datacenter you'll probably get away with it. For wider distribution, be it geographical or administrative, you probably want to look at WS-BA, a web service transactions protocol specifically designed for such use. WS-BA uses a compensation based model that is harder to program. It's essentially based on the technique you mention: the effect of service methods is undone by calling a compensation method. This can be tricky to get right, but a JBoss intern did a rather nice annotation framework that allows you to define compens…
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/275819
type: Answer

http://stackoverflow.com/a/22913525
has body: If you want to avoid relying on third-party libraries for such a simple task, here is a plain Java implementation: public static double cosineSimilarity(double[] vectorA, double[] vectorB) { double dotProduct = 0.0; double normA = 0.0; double normB = 0.0; for (int i = 0; i &lt; vectorA.length; i++) { dotProduct += vectorA[i] * vectorB[i]; normA += Math.pow(vectorA[i], 2); normB += Math.pow(vectorB[i], 2); } return dotProduct / (Math.sqrt(normA) * Math.sqrt(normB)); } Note that the function assumes that the two vectors have the same length. You may want to explictly check it for safety.
upvote count: 72
downvote count: 0
score: 72
answers question: http://stackoverflow.com/q/520241
type: Answer
has comment: http://stackoverflow.com/comment/65455401

http://stackoverflow.com/a/459658
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/456742
has body: OK, I see the problem better now. After checking some Swing source code, it is clear you cannot use the DefaultStyledDocument and have it use a physical font (one you created yourself with createFont) out of the box. However, what I think you could do is implement your own StyleContext this way: public class MyStyleContext extends javax.swing.text.StyleContext { @Override public Font getFont(AttributeSet attr) { Font font = attr.getAttribute("MyFont"); if (font != null) return font; else return super.getFont(attr); } } Then you have to: create a DefaultStyledDocument with a new MyStyleContext() "attach" it to the JTextPane call attributes.addAttribute("MyFont", myCustomFont); in your snippet above I did not try it but I think it should work or it might be a good path to investigate.
type: Answer
upvote count: 2
answers question: http://stackoverflow.com/q/456742
has comment: http://stackoverflow.com/comment/278968
score: 2

http://stackoverflow.com/q/625302
has answer: http://stackoverflow.com/a/625342
tagged with: opengl
score: 0
tagged with: java
has comment: http://stackoverflow.com/comment/438076
possible better answer: http://stackoverflow.com/a/625342
type: Question
accepted answer: http://stackoverflow.com/a/625322
has comment: http://stackoverflow.com/comment/438098
answer count: 3
has answer: http://stackoverflow.com/a/16388714
has comment: http://stackoverflow.com/comment/438108
tagged with: jar
has body: I'm trying to turn my JoGL project into a jar file. What am I doing wrong? Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/opengl/GL EventListener at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$000(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) Caused by: java.lang.ClassNotFoundException: javax.media.opengl.GLEventListener at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) ... 12 more Could not find the main class: chartest. Program will exit. Contents of the JAR file: META-INF\MANIFEST.MF gluegen-rt.jar jogl.jar chartest$1.class chartest.class gluegen-rt.dll jogl.dll jogl_awt.dll jogl_cg.dll test.png
has title: What's wrong with this .jar file?
tagged with: jogl
has answer: http://stackoverflow.com/a/625322
type: AnsweredQuestion

http://stackoverflow.com/a/492301
type: Answer
has body: I haven't checked the implementation or the performance, but commons-io has an listFiles() method. It might be worth a try.
has comment: http://stackoverflow.com/comment/308469
answers question: http://stackoverflow.com/q/479762
score: 0

http://stackoverflow.com/comment/363168
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/551528
score: 0
has text: Ive found myself doing the very same thing - after like 15 iterations of going from new Date().getTime() to Calendar.setTime() and back again you get really compelled to just make your own class that does all the boilerplate for you...

http://stackoverflow.com/comment/447122
type: QuestionComment
type: Comment
has text: thanks carson I have added more detail to the question
score: 0
comment on: http://stackoverflow.com/q/634102

http://stackoverflow.com/comment/401512
has text: JDK also comes with most of the JDK source - which will be very useful when stepping through the code.
type: AnswerComment
comment on: http://stackoverflow.com/a/589176
score: 0
type: Comment

http://stackoverflow.com/a/402466
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/402459
upvote count: 1
score: 1
has body: JMF API http://www.deitel.com/articles/java_tutorials/20060422/PlayingVideowithJMF/
answers question: http://stackoverflow.com/q/402459

http://stackoverflow.com/q/590069
has answer: http://stackoverflow.com/a/23326613
has answer: http://stackoverflow.com/a/590236
possible better answer: http://stackoverflow.com/a/2900916
tagged with: java
has answer: http://stackoverflow.com/a/590167
has answer: http://stackoverflow.com/a/2900916
linked to: http://stackoverflow.com/q/7266042
score: 46
downvote count: 1
type: Question
tagged with: c#
has answer: http://stackoverflow.com/a/6565735
has comment: http://stackoverflow.com/comment/12793820
has comment: http://stackoverflow.com/comment/137706648
answer count: 13
has title: How would you code an efficient Circular Buffer in Java or C#?
has answer: http://stackoverflow.com/a/31752006
has comment: http://stackoverflow.com/comment/2843643
accepted answer: http://stackoverflow.com/a/590167
upvote count: 47
has answer: http://stackoverflow.com/a/2889822
has comment: http://stackoverflow.com/comment/401886
has answer: http://stackoverflow.com/a/2805585
has answer: http://stackoverflow.com/a/24027858
has answer: http://stackoverflow.com/a/592130
has comment: http://stackoverflow.com/comment/12793569
favorite count: 0
has answer: http://stackoverflow.com/a/42625327
has answer: http://stackoverflow.com/a/8427649
has answer: http://stackoverflow.com/a/593295
has body: I want a simple class that implements a fixed-size circular buffer. It should be efficient, easy on the eyes, generically typed. For now it need not be MT-capable. I can always add a lock later, it won't be high-concurrency in any case. Methods should be: .Add() and I guess .List(), where I retrieve all the entries. On second thought, Retrieval I think should be done via an indexer. At any moment I will want to be able to retrieve any element in the buffer by index. But keep in mind that from one moment to the next Element[n] may be different, as the circular buffer fills up and rolls over. This isn't a stack, it's a circular buffer. Regarding "overflow": I would expect internally there would be an array holding the items, and over time the head and tail of the buffer will rotate around that fixed array. But that should be invisible from the user. There should be no externally-detectable "overflow" event or behavior. This is not a school assignment - it is most commonly going to be used for a MRU cache or a fixed-size transaction or event log.
type: AnsweredQuestion
tagged with: class-design

http://stackoverflow.com/a/438815
downvote count: 0
score: 3
type: Answer
answers question: http://stackoverflow.com/q/438463
upvote count: 3
has body: Windows is blocking this operation since XP. The scenario before was like: Your a tiping in some text in an editor and not recognize that another dialog is coming to front when you are tipping the text. The coming dialog gets the focus and you are tiping in the new dialog. Maybe you click enter after you are ready and do this in the wrong dialog, which is asking whether you realy want to delet your hard disk ;) The come to front call in java is only working for java windows. The possibibilty to notify the user of a new window is to implement a Frame, which will highlighted/flashing in the windows task bar.
has comment: http://stackoverflow.com/comment/261292

http://stackoverflow.com/a/68302971
upvote count: 2
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/542979
type: Answer
has body: If you only configure -XX:+HeapDumpOnOutOfMemoryError parameter then heapdump will be generated in JBOSS_HOME/bin directory for OpenJDK/Oracle JDK. If you are using IBM JDK then heapdump will be created under /tmp directory as phd file. -XX:HeapDumpPath option gives us more feasibility for configuring our custom headpump path location (-XX:HeapDumpPath=/my-custom-jboss-server-path/). It's recommended to have this parameters configured in your environment as it will collect heapdump on OutOfMemory error for analyzing the issue with memory leak of the application or checking any large object retention in the application.

http://stackoverflow.com/comment/10768843
type: AnswerComment
has text: Yeah, it's actually like that in most almost-at-the-metal graphics libraries - one step up from, say, OpenGL, at scene graph level. The main reason is that the way the positioning of bodies in the world works, if you enforce the parent-child relationship, calculating the world orientation of children is much cheaper, among other reasons. This can sometimes even be done on the graphics card if you maintain this sort of API. Libraries at this level seem to "organize" rendering, not simplify it. Perhaps there's a better library now that this question is a few years old...
type: Comment
comment on: http://stackoverflow.com/a/555380
score: 1

http://stackoverflow.com/a/37405037
has body: I recommend you to use the GSON Lib fo Java. if You use Maven you can use this. Or you can download the Jar file from here. Here example how to use it: Gson gson = new GsonBuilder().setPrettyPrinting().create(); String json = gson.toJson(obj); System.out.println(json);
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/603013
upvote count: 1
type: Answer

http://stackoverflow.com/comment/612052
type: Comment
type: QuestionComment
has text: What do you realy want to do? - break lines as they are entered in the JTextArea? - finding where the JTextArea is doing line wraps? - ???
comment on: http://stackoverflow.com/q/454908
score: 0

http://stackoverflow.com/q/624181
answer count: 1
tagged with: deployment
has body: Question 1: How should I structure my project so the sound and images files can be loaded most easily? Right now, I have the folder: C:\java\pacman with the sub-directory C:\java\pacman\src containing all the code, and C:\java\pacman\assets containing the images and .wav files. Is this the best structure or should I put the assets somewhere else? Question 2: What's the best way to refer to the images/sounds without using the full path e.g C:\java\pacman\assets\something.png to them? If I use the getCodeBase() function it seems to refer to the C:\java\pacman\bin instead of C:\java\pacman\. I want to use such a function/class which would work automatically when i compile the applet in a jar as well as right now when I test the applet through eclipse. Question 3: How should I load the images/sounds? This is what I'm using now: 1) For general images: import java.awt.Image; public Image getImg(String file) { //imgDir in this case is a hardcoded string containing //"C:\\java\\pacman\\assets\\" file=imgDir + file; return new ImageIcon(file).getImage(); } The images returned from this function are used in the drawImage method of the Graphics class in the paint method of the applet. 2) For a buffered image, which is used to get subImages and load sprites from a sprite sheet: public BufferedImage getSheet() throws IOException { return ImageIO.read(new File(img.getPath("pacman-sprites.png"))); } Later: public void loadSprites() { BufferedImage sheet; try { sheet=getSheet(); redGhost.setNormalImg(sheet.getSubimage(0, 60, 20, 20)); redGhost.setUpImg(sheet.getSubimage(0, 60, 20, 20)); redGhost.setDownImg(sheet.getSubimage(30, 60, 20, 20)); redGhost.setLeftImg(sheet.getSubimage(30, 60, 20, 20)); redGhost.setRightImg(sheet.getSubimage(60, 60, 20, 20)); } catch (IOException e) { System.out.println("Couldnt open file!"); System.out.println(e.getLocalizedMessage()); } } 3) For sound files: import sun.audio.*; import java.io.*; public synchronized void play() { try { InputStream in = n…
type: AnsweredQuestion
tagged with: java
has title: How to use sound and images in a Java applet?
type: Question
accepted answer: http://stackoverflow.com/a/624209
tagged with: jar
tagged with: applet
score: 0
has answer: http://stackoverflow.com/a/624209

http://stackoverflow.com/q/635935
has answer: http://stackoverflow.com/a/2796052
has answer: http://stackoverflow.com/a/636001
has answer: http://stackoverflow.com/a/39163900
possible better answer: http://stackoverflow.com/a/636258
tagged with: time
has comment: http://stackoverflow.com/comment/964545
has comment: http://stackoverflow.com/comment/449179
has body: I want to take two times (in seconds since epoch) and show the difference between the two in formats like: 2 minutes 1 hour, 15 minutes 3 hours, 9 minutes 1 minute ago 1 hour, 2 minutes ago How can I accomplish this??
has comment: http://stackoverflow.com/comment/449204
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/7291054
has comment: http://stackoverflow.com/comment/449182
has comment: http://stackoverflow.com/comment/449518
has comment: http://stackoverflow.com/comment/449193
tagged with: java
has answer: http://stackoverflow.com/a/635973
score: 44
tagged with: formatting
tagged with: date
has answer: http://stackoverflow.com/a/10225253
upvote count: 44
type: Question
has answer: http://stackoverflow.com/a/635959
has answer: http://stackoverflow.com/a/635949
has answer: http://stackoverflow.com/a/636258
has answer: http://stackoverflow.com/a/46998297
has answer: http://stackoverflow.com/a/67340205
linked to: http://stackoverflow.com/q/38922754
has answer: http://stackoverflow.com/a/636005
downvote count: 0
has answer: http://stackoverflow.com/a/2795991
has comment: http://stackoverflow.com/comment/72067120
accepted answer: http://stackoverflow.com/a/2796052
has comment: http://stackoverflow.com/comment/449899
has answer: http://stackoverflow.com/a/42462296
has answer: http://stackoverflow.com/a/635962
has answer: http://stackoverflow.com/a/21586870
answer count: 18
has title: How can I calculate a time span in Java and format the output?
has answer: http://stackoverflow.com/a/42453327
favorite count: 0
has answer: http://stackoverflow.com/a/636749

http://stackoverflow.com/q/480891
tagged with: config
favorite count: 0
upvote count: 22
has comment: http://stackoverflow.com/comment/297634
type: AnsweredQuestion
has title: Is there a way to tell Eclipse to "Save all" before building?
tagged with: java
has body: Does anyone know if there's a way to get Eclipse to do a "Save all" before building java code? (I don't use the "Build automatically" option, I'm talking when you use "Ctrl+B" to do a build all) I've dug thru the preferences, and can't seem to find anything, so I figured I'd check the hive mind at Stack Overflow just in case. I'm using Ganymede, V3.4.1, Build id: M20080911-1700, if it's relevant. Thanks in advance, Dave Mackie
type: Question
has comment: http://stackoverflow.com/comment/17279887
score: 22
tagged with: eclipse
has comment: http://stackoverflow.com/comment/297599
has answer: http://stackoverflow.com/a/480944
accepted answer: http://stackoverflow.com/a/480944
has comment: http://stackoverflow.com/comment/304724
downvote count: 0
answer count: 1

http://stackoverflow.com/a/604246
type: Answer
has body: Properties provide a simple method to abstract the details behind a set of logic in an object down to a single value to the outside world. While your property may start out only as a value, this abstraction decouples the interface such that it's details can be changed later with minimal impact. A general rule of thumb is that abstraction and loose coupling are good things. Properties are a pattern that achieve both.
answers question: http://stackoverflow.com/q/604188
score: 0

http://stackoverflow.com/a/564362
downvote count: 0
answers question: http://stackoverflow.com/q/564320
has body: if you want to limit the scope of Bar bar I'd add { and } around the code that Michael posted. void foo() { // some code ... // this block limits the scope of "Bar bar" so that the rest of the method cannot see // it. { Bar bar; if(foo!=null && (bar = foo.getBar())!=null){ System.out.println("Success: " + bar); } else { System.out.println("Failiure."); } } } You might also want to check into the null object pattern if it makes sense. I personally try to avoid things being null if I can... really think about if you want null to be allowed or not.
score: 7
upvote count: 7
type: Answer

http://stackoverflow.com/a/583631
type: Answer
upvote count: 6
has body: Two options: iText - it seems the PdfTextExtractor class can do what you want. Apache PDFBox claims "PDF to text extraction" as its top feature. There's an ExtractText command line tool specifically for this (source code), based on its PDFTextStripper class. And there's a PDFBox Text Extraction Guide, too!
has comment: http://stackoverflow.com/comment/396106
has comment: http://stackoverflow.com/comment/395652
downvote count: 0
answers question: http://stackoverflow.com/q/583615
has comment: http://stackoverflow.com/comment/16254249
score: 6

http://stackoverflow.com/a/644579
type: Answer
score: 1
answers question: http://stackoverflow.com/q/644320
upvote count: 1
downvote count: 0
has body: as Michale B said, it can be arbitrary. I work on systems that are using file sizes as security. If the .class files change in size, the class won't be given certain permissions. Normally that would be easy to get around, but we have fairly complete control over the environment, so it's actually pretty functional. Anyway, any time the classes that are watched are recompiled, it seems, we have to recalculate the size. Another thing--a special key number is generated when the file is compiled. I don't know much about this, but it often prevents classes from working together. I believe the procedure is, compile class A and save it (call it a1). compile class a again (a2). Compile class b against class a2. Try to run b against a1. I believe that in this case it will fail at runtime. If you could learn more about that key number, it might give you the info you are after.

http://stackoverflow.com/a/2037620
upvote count: 2
answers question: http://stackoverflow.com/q/609528
type: Answer
score: 2
downvote count: 0
has body: you can download vPass (voice password) from http://www.basic-signalprocessing.com. The components are designed for Java and .Net language. The recognition period is 5 seconds. VPass is well tested vText is not, still new, that's why not packaged yet.

http://stackoverflow.com/q/586363
has answer: http://stackoverflow.com/a/18606694
has answer: http://stackoverflow.com/a/8150579
has answer: http://stackoverflow.com/a/28541116
score: 436
has answer: http://stackoverflow.com/a/586401
has answer: http://stackoverflow.com/a/1076496
has title: Why is super.super.method(); not allowed in Java?
has answer: http://stackoverflow.com/a/2789260
accepted answer: http://stackoverflow.com/a/586397
possible better answer: http://stackoverflow.com/a/586581
answer count: 22
tagged with: superclass
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/1677993
has answer: http://stackoverflow.com/a/586581
has answer: http://stackoverflow.com/a/586496
has answer: http://stackoverflow.com/a/52940545
tagged with: java
has answer: http://stackoverflow.com/a/6238790
linked to: http://stackoverflow.com/q/357307
has answer: http://stackoverflow.com/a/19655572
has answer: http://stackoverflow.com/a/51863006
type: Question
has answer: http://stackoverflow.com/a/29691163
has answer: http://stackoverflow.com/a/6761383
has answer: http://stackoverflow.com/a/2692379
has body: I read this question and thought that would easily be solved (not that it isn't solvable without) if one could write: @Override public String toString() { return super.super.toString(); } I'm not sure if it is useful in many cases, but I wonder why it isn't and if something like this exists in other languages. What do you guys think? EDIT: To clarify: yes I know, that's impossible in Java and I don't really miss it. This is nothing I expected to work and was surprised getting a compiler error. I just had the idea and like to discuss it.
has answer: http://stackoverflow.com/a/5451377
has answer: http://stackoverflow.com/a/586388
has answer: http://stackoverflow.com/a/45554749
linked to: http://stackoverflow.com/q/580984
downvote count: 0
upvote count: 436
linked to: http://stackoverflow.com/q/1513520
has comment: http://stackoverflow.com/comment/35049958
has answer: http://stackoverflow.com/a/22956198
favorite count: 0
has answer: http://stackoverflow.com/a/586578
has answer: http://stackoverflow.com/a/586397
has answer: http://stackoverflow.com/a/15097562

http://stackoverflow.com/a/448904
accepted answer of: http://stackoverflow.com/q/448832
has comment: http://stackoverflow.com/comment/269937
answers question: http://stackoverflow.com/q/448832
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/269913
has comment: http://stackoverflow.com/comment/269876
has comment: http://stackoverflow.com/comment/269986
has comment: http://stackoverflow.com/comment/269872
type: Answer
has comment: http://stackoverflow.com/comment/269897
has body: You should not subclass JScrollPane, it is not necessary. But if you do so, don't forget to add the component to the scrollpane. In your subclass you are not adding the GraphPanel to the scroll pane.: public class ScrollPanel extends JScrollPane { public ScrollPanel(GraphPanel gp){ // :::: HERE ::: you are not doing anything with gp // like this.setViewPort( gp ) or something like that this.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); this.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); this.repaint(); } } Try: public class ScrollPanel extends JScrollPane { public ScrollPanel(GraphPanel gp){ super( gp ); .... etc ... And have GraphPanel extend JComponent or JPanel
has comment: http://stackoverflow.com/comment/269963
has comment: http://stackoverflow.com/comment/269891
has comment: http://stackoverflow.com/comment/269918
has comment: http://stackoverflow.com/comment/269969
has comment: http://stackoverflow.com/comment/269929
has comment: http://stackoverflow.com/comment/269943
score: 2
has comment: http://stackoverflow.com/comment/269947
has comment: http://stackoverflow.com/comment/269936
downvote count: 0
has comment: http://stackoverflow.com/comment/269957
has comment: http://stackoverflow.com/comment/269925
upvote count: 2

http://stackoverflow.com/a/420965
score: -6
has body: I use them when ever I can. I have IntelliJ setup to remind me if I forget. I think it looks much cleaner than a fully qualified package name.
downvote count: 9
upvote count: 3
has comment: http://stackoverflow.com/comment/245128
answers question: http://stackoverflow.com/q/420791
type: Answer
has comment: http://stackoverflow.com/comment/245167

clr
type: Tag
tags question: http://stackoverflow.com/q/517502
tags question: http://stackoverflow.com/q/520922
tags question: http://stackoverflow.com/q/440390
tag name: clr

http://stackoverflow.com/comment/353428
comment on: http://stackoverflow.com/a/541316
has text: @Anand: if you need to map the same key to several Strings, use a Collection as the value. I.e., define your map something like this: Map<String, Collection<String>> tempMap.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/585802
has body: I'm writing an Eclipse command plugin and want to retrieve the currently selected node in the package explorer view. I want to be able to get the absolute filepath, where the selected node resides on the filesystem (i.e. c:\eclipse\test.html), from the returned result. How do I do this ?
favorite count: 0
tagged with: eclipse-rcp
has answer: http://stackoverflow.com/a/586013
upvote count: 18
downvote count: 0
type: UnansweredQuestion
tagged with: java
tagged with: rcp
has title: How to get the selected node in the package explorer from an Eclipse plugin
tagged with: eclipse
type: Question
answer count: 2
tagged with: user-interface
score: 18
has answer: http://stackoverflow.com/a/585883

http://stackoverflow.com/a/564570
has body: Garry's Mod was written using Half-Life 2's Source engine, presumably using the Hammer editor. Granted, this is arguably closer to level design than game design, but might be interesting regardless.
score: 1
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/564469
type: Answer

http://stackoverflow.com/a/8063140
type: Answer
has body: public static MyEnum getFromValue(String value) { MyEnum resp = null; MyEnum nodes[] = values(); for(int i = 0; i &lt; nodes.length; i++) { if(nodes[i].value.equals(value)) { resp = nodes[i]; break; } } return resp; }
score: 6
upvote count: 7
downvote count: 1
answers question: http://stackoverflow.com/q/604424

http://stackoverflow.com/a/382661
answers question: http://stackoverflow.com/q/382536
downvote count: 0
score: 4
has body: Hard to tell if you meant this by "standard online documentation" but the Java Tutorial is excellent and what many of us old-timers started with.
type: Answer
upvote count: 4

http://stackoverflow.com/comment/401802
type: AnswerComment
comment on: http://stackoverflow.com/a/589897
score: 6
type: Comment
has text: I'm not a moron either, but I've still had problems with the Java D&T APIs. They're painfully easy to misuse. The reason why people are more likely to be able to use Joda properly is that Joda is better designed - it *encourages* you to do the right thing.

http://stackoverflow.com/a/385624
score: 13
answers question: http://stackoverflow.com/q/385532
has body: It seems multiple persistence.xml files is a general problem with JPA, solved only by classloading tricks. A workaround that works for me is to define multiple persistence units in one persistence.xml file and then make sure that your deployment and test code use a different binding (in Spring you can set the "persistenceUnitName" property on the entity manager factory). It pollutes your deployment file with the test configuration, but if you don't mind that it works ok.
upvote count: 13
downvote count: 0
type: Answer

http://stackoverflow.com/a/444914
type: Answer
score: -3
upvote count: 1
answers question: http://stackoverflow.com/q/444909
downvote count: 4
has comment: http://stackoverflow.com/comment/567437
has comment: http://stackoverflow.com/comment/21113146
has body: It is documented that Serialization is not intended to be used for persisting data. In order to get that data back, you will need to downgrade your version of the JVM to the version that was used to output that data. For future reference, don't use serialization to persist data between sessions of the JVM.

http://stackoverflow.com/q/451647
has comment: http://stackoverflow.com/comment/9449698
accepted answer: http://stackoverflow.com/a/451696
tagged with: java
answer count: 3
tagged with: object
upvote count: 12
downvote count: 0
tagged with: access-modifiers
tagged with: protected
has title: How are java.lang.Object's protected methods protected from subclasses?
has answer: http://stackoverflow.com/a/451696
has answer: http://stackoverflow.com/a/451694
type: AnsweredQuestion
has body: The keyword protected grants access to classes in the same package and subclasses (http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html). Now, every class has java.lang.Object as superclass (http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html). Hence I conclude that every class may access java.lang.Object's methods even if they are protected. Take a look at the following example: public class Testclass { public Object getOne() throws CloneNotSupportedException { return this.clone(); } public Object getTwo() throws CloneNotSupportedException { return ((Object) this).clone(); } } While getOne() compiles fine, getTwo() gives Testclass.java:6: clone() has protected access in java.lang.Object return ((Object) this).clone(); I neither understand why getTwo() doesn't compile nor what's the difference (regarding the access of java.lang.Objects members) with getOne().
has answer: http://stackoverflow.com/a/451716
possible better answer: http://stackoverflow.com/a/451694
favorite count: 0
type: Question
score: 12

http://stackoverflow.com/comment/270421
has text: I guess this is applicable only when reference count algo. is in use or otherwise also ?
score: 0
comment on: http://stackoverflow.com/a/449416
type: AnswerComment
type: Comment

http://stackoverflow.com/a/1369363
score: 2
downvote count: 0
type: Answer
upvote count: 2
has body: If you want to experiment with 3D, it's far easier to get up and running than to try to do anything with DirectX (although the DirectX API more closely matches what game developers actually do, of course). The fact that it's community-supported does mean you won't get a lot of richness today, but for a lot of tools, it's still plenty capable. For instance, a simple data visualization tool for business - not for games - is easy to do in Java3D (this is what I use it for, mostly).
answers question: http://stackoverflow.com/q/482212

http://stackoverflow.com/comment/90862097
score: 0
type: AnswerComment
has text: Imagine case where you have B, C, D, E, etc. Solution becomes very verbose. [Pattern matching](https://docs.scala-lang.org/tour/pattern-matching.html) is much better but is [still in proposal state](http://openjdk.java.net/jeps/305).
comment on: http://stackoverflow.com/a/541769
type: Comment

http://stackoverflow.com/comment/33271581
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/416505
has text: Thank you Neil, that was bloody awesome!

http://stackoverflow.com/a/589247
has comment: http://stackoverflow.com/comment/401101
score: 0
type: Answer
has body: A suggestion: grab the output and error streams and see what they are printing out. You may see that there is an error happening with the batch file making it return sooner than you expect.
answers question: http://stackoverflow.com/q/589231

http://stackoverflow.com/comment/136341103
has text: More than a decade later, it's still not available: https://bugs.openjdk.org/browse/JDK-8148344, and https://bugs.openjdk.org/browse/JDK-8204845
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/397113

http://stackoverflow.com/a/423046
has body: You class can use package protection and still implement an interface: class Foo implements Runnable { public void run() { } } If you want some methods to be protected / package and others not, it sounds like your classes have more than one responsibility, and should be split into multiple. Edit after reading comments to this and other responses: If your are somehow thinking that the visibility of a method affects the ability to invoke that method, think again. Without going to extremes, you cannot prevent someone from using reflection to identify your class' methods and invoke them. However, this is a non-issue: unless someone is trying to crack your code, they're not going to invoke random methods. Instead, think of private / protected methods as defining a contract for subclasses, and use interfaces to define the contract with the outside world. Oh, and to the person who decided my example should use K&amp;R bracing: if it's specified in the Terms of Service, sure. Otherwise, can't you find anything better to do with your time?
type: Answer
upvote count: 13
has comment: http://stackoverflow.com/comment/246860
downvote count: 2
has comment: http://stackoverflow.com/comment/246848
has comment: http://stackoverflow.com/comment/246863
score: 11
has comment: http://stackoverflow.com/comment/10666946
has comment: http://stackoverflow.com/comment/247863
has comment: http://stackoverflow.com/comment/247437
has comment: http://stackoverflow.com/comment/108651173
answers question: http://stackoverflow.com/q/423032

http://stackoverflow.com/a/465367
has comment: http://stackoverflow.com/comment/3395414
score: 10
answers question: http://stackoverflow.com/q/464098
downvote count: 0
has comment: http://stackoverflow.com/comment/3389592
type: Answer
has body: try { for (;;); } finally { System.err.println("?"); } In that case the finally will not execute (unless the deprecated Thread.stop is called, or an equivalent, say, through a tools interface).
upvote count: 10

http://stackoverflow.com/comment/75085796
score: 0
has text: @ranieribt maybe too complicated, I use getLogicBounds() instead of getPixelBounds()
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/12495108

http://stackoverflow.com/a/359762
type: Answer
has comment: http://stackoverflow.com/comment/191251
upvote count: 7
score: 7
has comment: http://stackoverflow.com/comment/190730
has body: One of the main issues is when you have regions of one-liners and non-one liners, along with separation from the control statment (for, if, what have you) and the end of the statment. For example: for (...) { for (...) for (...) { // a couple pages of code } // which for block is ending here? A good text editor will tell you, // but it's not obvious when you're reading the code }
downvote count: 0
answers question: http://stackoverflow.com/q/359732
has comment: http://stackoverflow.com/comment/190580
has comment: http://stackoverflow.com/comment/192219

http://stackoverflow.com/q/576850
has answer: http://stackoverflow.com/a/2949318
tagged with: ntlm
has answer: http://stackoverflow.com/a/2881476
has body: Are there any alternatives for JCIFS NTLM library?
downvote count: 0
has answer: http://stackoverflow.com/a/2033120
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/15020734
has answer: http://stackoverflow.com/a/1675004
has answer: http://stackoverflow.com/a/34276513
score: 19
type: Question
tagged with: jcifs
has title: Alternatives for JCIFS NTLM library
favorite count: 0
linked to: http://stackoverflow.com/q/46079711
tagged with: josso
has answer: http://stackoverflow.com/a/916846
has comment: http://stackoverflow.com/comment/102927465
upvote count: 19
tagged with: java
has answer: http://stackoverflow.com/a/1148721
answer count: 7

http://stackoverflow.com/a/72904459
upvote count: 1
has comment: http://stackoverflow.com/comment/134464676
answers question: http://stackoverflow.com/q/554481
downvote count: 0
has body: Michael's answer is perfect, just the imports it is missing: import java.lang.reflect.Field; import org.hibernate.Criteria; import org.hibernate.criterion.DetachedCriteria; import org.hibernate.criterion.Order; import org.hibernate.criterion.Projections; import org.hibernate.criterion.Property; import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Subqueries; import org.hibernate.engine.spi.LoadQueryInfluencers; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.internal.CriteriaImpl; import org.hibernate.internal.SessionImpl; import org.hibernate.loader.OuterJoinLoader; import org.hibernate.loader.criteria.CriteriaLoader; import org.hibernate.persister.entity.OuterJoinLoadable; CriteriaImpl c = (CriteriaImpl) criteria; SessionImpl s = (SessionImpl) c.getSession(); SessionFactoryImplementor factory = (SessionFactoryImplementor) s.getSessionFactory(); String[] implementors = factory.getImplementors(c.getEntityOrClassName()); LoadQueryInfluencers lqis = new LoadQueryInfluencers(); CriteriaLoader loader = new CriteriaLoader((OuterJoinLoadable) factory.getEntityPersister(implementors[0]), factory, c, implementors[0], lqis); Field f = OuterJoinLoader.class.getDeclaredField("sql"); f.setAccessible(true); String sql = (String) f.get(loader);
type: Answer
score: 1

http://stackoverflow.com/comment/34254768
type: QuestionComment
has text: @Anirudh Search StackOverflow for "joda" and term such as "span", "Interval", "Duration", "Period". You will find many examples with discussion.
comment on: http://stackoverflow.com/q/453388
score: 0
type: Comment

http://stackoverflow.com/a/10828110
type: Answer
upvote count: 3
downvote count: 2
has comment: http://stackoverflow.com/comment/51273786
score: 1
answers question: http://stackoverflow.com/q/434718
has body: In my case it helped to try and connect to the port - if service is already present, it would respond. try { log.debug("{}: Checking if port open by trying to connect as a client", portNumber); Socket sock = new Socket("localhost", portNumber); sock.close(); log.debug("{}: Someone responding on port - seems not open", portNumber); return false; } catch (Exception e) { if (e.getMessage().contains("refused")) { return true; } log.error("Troubles checking if port is open", e); throw new RuntimeException(e); }

http://stackoverflow.com/a/1457276
answers question: http://stackoverflow.com/q/602537
has body: Maybe you created Java Project with Existing Sources instead of Java Application? I had similar problem and creating new Java Application and then manually copying src files solved the problem - everything worked "out of the box".
type: Answer
upvote count: 1
score: 1
downvote count: 0

http://stackoverflow.com/a/420966
upvote count: 3
score: 1
downvote count: 2
has body: The only thing that matters (IMHO) is that the parts of the package name are “sorted” by importance, i.e. that you don’t end up with gui.myprog, util.myprog, main.myprog but with myprog.gui, myprog.util, and myprog.main. Whether the package name really begins with a top-level domain followed by a domain name is of no concern to me.
has comment: http://stackoverflow.com/comment/245325
type: Answer
answers question: http://stackoverflow.com/q/420945

http://stackoverflow.com/a/46704502
upvote count: 4
has body: Many programmers must have read this statement in "3.1.2. Non-Atomic 64bit Operations" in java concurrency in practice . I have referred the latest JLS 17.7. Non-Atomic Treatment of double and long. They still nowhere claim that 64 bit jVM are norm these days. So 64 bit operations are broken into 32 bit operations that break atomicity and dangerous to use in multithreaded environment until declared volatile . Long and double are 64 bit long in java. So writing and reading operations are not atomic in java.
downvote count: 0
score: 4
answers question: http://stackoverflow.com/q/517532
type: Answer

http://stackoverflow.com/comment/85068318
has text: be carefull of empty array according to Bombe's answer and javadoc indication. Some JVM may not fill the stacktrace array?
comment on: http://stackoverflow.com/a/32329165
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/519076
has comment: http://stackoverflow.com/comment/332704
type: Answer
score: 3
has comment: http://stackoverflow.com/comment/332740
has body: Just confirming pax assumptions, with a very naive benchmark public static void main(String[] args) { int size = 120000; String[] arr = new String[size]; ArrayList al = new ArrayList(size); for (int i = 0; i &lt; size; i++) { String put = Integer.toHexString(i).toString(); // System.out.print(put + " "); al.add(put); arr[i] = put; } Random rand = new Random(); Date start = new Date(); for (int i = 0; i &lt; 10000000; i++) { int get = rand.nextInt(size); String fetch = arr[get]; } Date end = new Date(); long diff = end.getTime() - start.getTime(); System.out.println("array access took " + diff + " ms"); start = new Date(); for (int i = 0; i &lt; 10000000; i++) { int get = rand.nextInt(size); String fetch = (String) al.get(get); } end = new Date(); diff = end.getTime() - start.getTime(); System.out.println("array list access took " + diff + " ms"); } and the output: array access took 578 ms array list access took 907 ms running it a few times the actual times seem to vary some, but generally array access is between 200 and 400 ms faster, over 10,000,000 iterations.
upvote count: 3
has comment: http://stackoverflow.com/comment/334295
answers question: http://stackoverflow.com/q/518936
downvote count: 0
has comment: http://stackoverflow.com/comment/576095
has comment: http://stackoverflow.com/comment/332542

http://stackoverflow.com/comment/293734
score: 0
type: Comment
has text: @Mike that is one way to see it. Another possible way would be to flush the streams after reading and writing.
type: AnswerComment
comment on: http://stackoverflow.com/a/475706

http://stackoverflow.com/comment/139561217
type: AnswerComment
comment on: http://stackoverflow.com/a/79143602
score: 0
type: Comment
has text: And change the default app (must run with Administration role) > ftype jarfile="C:\Program Files\Java\jdk-22\bin\java.exe" -jar %1 specify the correct location of java.exe

http://stackoverflow.com/a/498644
has comment: http://stackoverflow.com/comment/314411
answers question: http://stackoverflow.com/q/498636
upvote count: 15
has comment: http://stackoverflow.com/comment/314317
downvote count: 0
has comment: http://stackoverflow.com/comment/314515
has comment: http://stackoverflow.com/comment/314332
has comment: http://stackoverflow.com/comment/314614
has comment: http://stackoverflow.com/comment/314455
has comment: http://stackoverflow.com/comment/314503
score: 15
has body: I suspect that either your file isn't actually encoded as ISO-8859-1, or System.out doesn't know how to print the character. I recommend that to check for the first, you examine the relevant byte in the file. To check for the second, examine the relevant character in the string, printing it out with System.out.println((int) s.getCharAt(index)); In both cases the result should be 244 decimal; 0xf4 hex. See my article on Unicode debugging for general advice (the code presented is in C#, but it's easy to convert to Java, and the principles are the same). In general, by the way, I'd wrap the stream with an InputStreamReader with the right encoding - it's easier than creating new strings "by hand". I realise this may just be demo code though. EDIT: Here's a really easy way to prove whether or not the console will work: System.out.println("Here's the character: \u00f4");
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/314320
has comment: http://stackoverflow.com/comment/314452
has comment: http://stackoverflow.com/comment/314324
accepted answer of: http://stackoverflow.com/q/498636
type: Answer

http://stackoverflow.com/comment/416748
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/603598
type: Comment
has text: JPL was removed from Perl 5.10. I wouldn't recommend adopting a dead API. Use Inline::Java instead.

http://stackoverflow.com/comment/39369239
type: Comment
comment on: http://stackoverflow.com/a/24989737
score: 5
type: AnswerComment
has text: Add mailapi.jar and activation.jar as @Marco Brochet stated. I used -classpath and replaced ";" with ":". java -classpath axis.jar:commons-logging-1.0.4.jar:commons-discovery-0.2.jar:jaxrpc.jar:saaj.jar:wsdl4j-1.5.1.jar:mailapi.jar:activation.jar org.apache.axis.wsdl.WSDL2Java https://api.clickatell.com/soap/webservice.php?WSDL

http://stackoverflow.com/comment/103230770
type: Comment
has text: @Frontear There are even more than one: 1) If the compiler/JIT doesn't optimize `% 2` accordingly–which I don't know–shift operations are much more performant than math operations since they are implemented hard-wired in any CPU I'm aware of. 2) There are only rare cases where shift operations can be used in high-level languages, so I use them whenever I can to remind myself– and others who read my code–that they exist. 3) It increases the lifetime of the other operators due to reduced wearout [just kidding, of course, but I wanted it to be three :]
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/52266947

http://stackoverflow.com/a/607978
score: 0
upvote count: 1
has comment: http://stackoverflow.com/comment/420242
type: Answer
answers question: http://stackoverflow.com/q/607934
downvote count: 1
has body: You will need to to scan package(s) and clasess to find ones that extend your superclass - unfortunately, this cannot be done with the Reflection API, but must be done through URLs (file system classes, jar files etc). Annotation use is probably better in this case, and lots of open source products use this method (Hibernate etc). Then you can have a static method in each (either consistent naming or annotated) which you should be able to invoke with as method.invoke(MyObject.class, arguments) The other option is to put a registry map in the abstract class - if you need to mandate it, the abstract constructor takes the static value (or just stores the subclass if calculations are needed). If you're controlling all subclasses, just make sure you have a static block in each one to add it to the registry.

http://stackoverflow.com/q/465994
score: 4
favorite count: 0
has answer: http://stackoverflow.com/a/466338
tagged with: jogl
has answer: http://stackoverflow.com/a/466486
possible better answer: http://stackoverflow.com/a/466338
tagged with: graphics
type: AnsweredQuestion
has body: As part of a larger project I'm trying to implement a facility using JOGL that will export 3D renderings to bitmap formats. We do this by creating a GLJPanel and drawing the scene we want to it, then extracting the bitmap. This all works fine as long as the system has at least one visible window on the screen - not necessarily the window containing the panel we are drawing to. But if we try to do this without making any window visible the GLJPanel won't draw. Stepping through the JOGL source I find that it won't draw unless it has a valid peer - essentially unless addNotify() has been called on it. The documentation says that addNotify() is only called when the panel is made part of a visible window heirarchy. Changing to a GLCanvas doesn't make much difference - the failure mode is different. WindowsOnscreenGLDrawable.realized is not set, and this means lockSurface returns LOCK_SURFACE_NOT_READY, causing makeCurrent() to fail. Any help would be welcome on how to create a Java app that can create and export 3D scenes without having to make it's window visible.
tagged with: java
type: Question
upvote count: 4
answer count: 2
has title: Draw offscreen with JOGL
accepted answer: http://stackoverflow.com/a/466486
downvote count: 0

http://stackoverflow.com/a/721084
downvote count: 0
type: Answer
score: 1
has body: If there's at least a minor chance that list of values will need to be updated than it's 1. Otherwise, it's 3.
upvote count: 1
answers question: http://stackoverflow.com/q/492096

http://stackoverflow.com/comment/341075
has text: AWT tries to be platform specific and provide native support to UI widgets while Swing tries to be the cross-platform one. Considering .Forms and WPF both _are_ platform specific it would seem to me at least more natural to compare those to AWT directly instead of Swing. End result is the same tho'.
type: Comment
comment on: http://stackoverflow.com/a/521337
score: 0
type: AnswerComment

http://stackoverflow.com/a/382365
has comment: http://stackoverflow.com/comment/210010
has comment: http://stackoverflow.com/comment/209992
answers question: http://stackoverflow.com/q/382361
has comment: http://stackoverflow.com/comment/209974
has body: The best thing I could come up with so far is to put the query into several stored procedures, the same way I would handle a method thats too long in Java.
has comment: http://stackoverflow.com/comment/209950
downvote count: 0
has comment: http://stackoverflow.com/comment/210015
has comment: http://stackoverflow.com/comment/210017
has comment: http://stackoverflow.com/comment/210005
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/209972
upvote count: 2
has comment: http://stackoverflow.com/comment/209983

http://stackoverflow.com/a/538518
type: Answer
upvote count: 2
has body: My experiences with how WTP (or any flavor of Eclipses) treats Java code in scriptlet blocks in a JSP file has always been horrible: it never works well or the way you expect. I've seen Eclipse add &lt;jsp:import&gt; statements in the middle of the JSP file, and do all other sorts of weird formatting. My only advice is to stay away from editing a code in a JSP inside Eclipse. (My other piece of advice would be to not put Java code directly in a JSP file, and move to a MVC architecture, but that's a subject for another day...)
score: 2
answers question: http://stackoverflow.com/q/538239
downvote count: 0

http://stackoverflow.com/a/582314
has comment: http://stackoverflow.com/comment/394185
has comment: http://stackoverflow.com/comment/394180
downvote count: 0
has comment: http://stackoverflow.com/comment/397929
has comment: http://stackoverflow.com/comment/394197
answers question: http://stackoverflow.com/q/581873
type: Answer
has comment: http://stackoverflow.com/comment/394741
upvote count: 7
has body: Some general constructor tips: Try to focus all initialization in a single constructor and call it from the other constructors This works well if multiple constructors exist to simulate default parameters Never call a non-final method from a constructor Private methods are final by definition Polymorphism can kill you here; you can end up calling a subclass implementation before the subclass has been initialized If you need "helper" methods, be sure to make them private or final Be explicit in your calls to super() You would be surprised at how many Java programmers don't realize that super() is called even if you don't explicitly write it (assuming you don't have a call to this(...) ) Know the order of initialization rules for constructors. It's basically: this(...) if present (just move to another constructor) call super(...) [if not explicit, call super() implicitly] (construct superclass using these rules recursively) initialize fields via their declarations run body of current constructor return to previous constructors (if you had encountered this(...) calls) The overall flow ends up being: move all the way up the superclass hierarchy to Object while not done init fields run constructor bodies drop down to subclass For a nice example of evil, try figuring out what the following will print, then run it package com.javadude.sample; /** THIS IS REALLY EVIL CODE! BEWARE!!! */ class A { private int x = 10; public A() { init(); } protected void init() { x = 20; } public int getX() { return x; } } class B extends A { private int y = 42; protected void init() { y = getX(); } public int getY() { return y; } } public class Test { public static void main(String[] args) { B b = new B(); System.out.println("x=" + b.getX()); System.out.println("y=" + b.getY()); } } I'll add comments describing why the above works as it does... Some of it may be obvious; some is not...
score: 7

http://stackoverflow.com/a/557232
has body: To address your issue with JTree (which I agree with), you should look into using glazed lists if you want nice JList and JTable interaction in your app: http://publicobject.com/glazedlists/ You get a lot of functionality (sortable table headers, e.g) with a few tweaks to your code. Aside from that, keep it simple.
has comment: http://stackoverflow.com/comment/384506
upvote count: 3
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/556478
score: 3

http://stackoverflow.com/a/7157273
downvote count: 3
has comment: http://stackoverflow.com/comment/36961944
has comment: http://stackoverflow.com/comment/37022353
upvote count: 4
has comment: http://stackoverflow.com/comment/37039546
has comment: http://stackoverflow.com/comment/37039376
answers question: http://stackoverflow.com/q/613954
has comment: http://stackoverflow.com/comment/36982944
type: Answer
score: 1
has comment: http://stackoverflow.com/comment/82177911
has comment: http://stackoverflow.com/comment/36994691
has comment: http://stackoverflow.com/comment/37022328
has body: Despite having read the whole page, I still can't find a single reasonable argument against checked exceptions. Most people are instead talking about poor API design, either at some Java classes or at their own classes. The only scenario where this feature may be annoying is prototiping. This could be solved by adding some mechanism to the language (for instance, some @supresscheckedexceptions annotation). But for regular programming, I think checked exceptions are a good thing.
has comment: http://stackoverflow.com/comment/37039488

http://stackoverflow.com/comment/139170861
type: Comment
has text: I was using leftPad but definetely missed this one... Thanks!
comment on: http://stackoverflow.com/a/473332
type: AnswerComment
score: 0

http://stackoverflow.com/a/529509
score: 1
upvote count: 1
has body: As far as I know, you can't Right click project > Import With respect to your platform, something roughly equivalent to: java &lt;classname&gt;. (Make sure java is in your path, otherwise use the absolute path to the it.)
type: Answer
answers question: http://stackoverflow.com/q/529391
downvote count: 0

http://stackoverflow.com/a/449875
type: Answer
accepted answer of: http://stackoverflow.com/q/442995
has body: This is not currently supported by ActiveMQ security implementation, but you can always define a user that can connect without a password with read-only privileges. You can raise Jira enhancement request (https://issues.apache.org/activemq/browse/AMQ) for this non-authenticated users feature and better yet provide a patch for current plugins.
upvote count: 1
has comment: http://stackoverflow.com/comment/271686
score: 1
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/442995

http://stackoverflow.com/comment/457398
score: 0
type: AnswerComment
has text: Of all the possibilities anyone has listed, thus far "DSP Laboratory" (a dead open source project) looks like it might have the right spirit, but I can't tell from the code. I don't understand its FOB, FTB, FTJ, etc.
comment on: http://stackoverflow.com/a/637199
type: Comment

http://stackoverflow.com/comment/99172347
type: Comment
comment on: http://stackoverflow.com/a/575368
has text: Is there a similar method for local variables within methods?
type: AnswerComment
score: 0

http://stackoverflow.com/comment/846935
has text: That's why I said "I don't think it makes any difference in speed (and if it did, it would probably be too small to make a difference overall)."
type: AnswerComment
type: Comment
score: 3
comment on: http://stackoverflow.com/a/538909

http://stackoverflow.com/comment/371777
has text: ya i'm getting response as flash ok,but i'm unable to write to outputstream for second time.
comment on: http://stackoverflow.com/a/560653
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/561365
favorite count: 0
upvote count: 61
score: 60
answer count: 4
has answer: http://stackoverflow.com/a/561385
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/561391
tagged with: java
has answer: http://stackoverflow.com/a/561396
accepted answer: http://stackoverflow.com/a/561391
downvote count: 1
type: Question
linked to: http://stackoverflow.com/q/94361
has body: Possible Duplicate: When do you use Java’s @Override annotation and why? Is there any reason to annotate a method with @Override other than to have the compiler check that the superclass has that method?
tagged with: overriding
has title: What is @Override for in Java?
duplicate of: http://stackoverflow.com/q/94361
possible better answer: http://stackoverflow.com/a/561381
has comment: http://stackoverflow.com/comment/13423444
has answer: http://stackoverflow.com/a/561381

http://stackoverflow.com/comment/122613019
has text: I followed something closer to the answer given by @Jamie as I didn't have much time to spend on reading this full doc.
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/12362776

http://stackoverflow.com/a/409941
has comment: http://stackoverflow.com/comment/234906
has comment: http://stackoverflow.com/comment/236229
answers question: http://stackoverflow.com/q/409919
has comment: http://stackoverflow.com/comment/235156
has body: You never created an instance of MyObj. There are two logical places to create the necessary object. Hello's initialization. public MyObj an_obj= new MyObj(); public static void main(String[] args) { setObj(); } Inside main() public MyObj an_obj; public static void main(String[] args) { an_obj= new MyObj() setObj(); } Either way, you have to actually create an object. Additionally, you can make setObj static. However, this is rarely what you intend. The correct thing is for main to (1) create relevant objects, and (2) turn control over to those objects. This is what you should do. class Hello { public MyObj an_obj= new MyObj(); public static void main(String[] args) { Hello aHelloObject= new Hello(); aHelloOject.setObj(); } public void setObj() { this.an_obj.set_size(7); say("size is " + this.an_obj.get_size()); } }
has comment: http://stackoverflow.com/comment/237638
has comment: http://stackoverflow.com/comment/236751
has comment: http://stackoverflow.com/comment/234930
has comment: http://stackoverflow.com/comment/236830
has comment: http://stackoverflow.com/comment/235061
has comment: http://stackoverflow.com/comment/235106
has comment: http://stackoverflow.com/comment/235000
type: Answer
has comment: http://stackoverflow.com/comment/235108
has comment: http://stackoverflow.com/comment/236956
upvote count: 3
has comment: http://stackoverflow.com/comment/234922
has comment: http://stackoverflow.com/comment/235032
downvote count: 1
has comment: http://stackoverflow.com/comment/234933
score: 2

http://stackoverflow.com/comment/386509
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/574686
has text: java.security.AccessControlException: access denied (java.net.SocketPermission root.xelluloid.de:80 connect,resolve) seems to be a security problem?
score: 0

http://stackoverflow.com/comment/199584
comment on: http://stackoverflow.com/a/362597
type: AnswerComment
has text: to Gwyn: the app need to contain a portlet.xml, but the file may consist just of an empty portlet-app tag. But i dont know whether your container will allow this.
type: Comment
score: 0

http://stackoverflow.com/a/942010
downvote count: 0
answers question: http://stackoverflow.com/q/402302
upvote count: 2
type: Answer
has body: When defining your checkbox, use "theme = simple" attribute as shown in the following: The "simple" theme will put your checkbox in the same row as the other fields of your. Cheers.
score: 2

http://stackoverflow.com/a/26924352
downvote count: 0
type: Answer
has body: XML has xpath and xquery. But YAML has complex keys and lets you copy one value into many places with aliases (&amp; * syntax). I think YAML's strength is not human readability, like they say... I can read properly formatted XML just fine. Actually YAML's strength is human writability. If you are on an iPhone typing up a quick bit of data as you architect a data model or such, YAML is so much easier to type in. The aliases are awesome for that. Then you can convert it to whatever. The more advanced features of YAML like strict typing and tags, I never use that. The YAML guys are currently discussing issuing a "micro YAML" to compete with JSON, for those of us who use it basically just as cleaner JSON with aliases. But XML is better as a markup language where you want to visually distinguish what parts of the data are visible to the end user, as someone else pointed out.
answers question: http://stackoverflow.com/q/561286
score: 4
upvote count: 4

http://stackoverflow.com/a/373805
has body: I'll be cautious about giving or taking security-related advice from a forum... the specifics are quite intricate, and often become outdated quickly. Having said that, I think Sun's Java Cryptography Architecture (JCA) Reference Guide is a good starting point. Check out the accompanying code example illustrating Password-Based Encryption (PBE). Btw, the standard JRE provides only a few options out-of-the-box for PBE ("PBEWithMD5AndDES" is one of them). For more choices, you'll need the "strong encryption pack" or some third-party provider like Bouncy Castle. Another alternative would be to implement your own PBE using the hash and cipher algorithms provided in the JRE. You can implement PBE with SHA-256 and AES-128 this way (sample encrypt/decrypt methods). Briefly, the encrypt method for PBE may involve the following steps: Get password and cleartext from the user, and convert them to byte arrays. Generate a secure random salt. Append the salt to the password and compute its cryptographic hash. Repeat this many times. Encrypt the cleartext using the resulting hash as the initialization vector and/or secret key. Save the salt and the resulting ciphertext.
type: Answer
score: 11
accepted answer of: http://stackoverflow.com/q/372268
downvote count: 1
answers question: http://stackoverflow.com/q/372268
upvote count: 12
type: AcceptedAnswer

http://stackoverflow.com/q/645756
tagged with: language-features
has answer: http://stackoverflow.com/a/645842
type: Question
has title: How to deliver a Java program locally through a browser
has answer: http://stackoverflow.com/a/645767
has answer: http://stackoverflow.com/a/645952
tagged with: browser
has comment: http://stackoverflow.com/comment/459417
downvote count: 0
favorite count: 0
answer count: 9
has answer: http://stackoverflow.com/a/645860
has answer: http://stackoverflow.com/a/645942
has answer: http://stackoverflow.com/a/645886
tagged with: jdbc
has answer: http://stackoverflow.com/a/646080
has body: I want to write an application that runs entirely locally on one machine - there is no need for connection to the internet or to any external machines. I was thinking that it would be a good idea to use a web browser as the platform for this application so that I would not have to mess around with lots of UI stuff - I could just knock together the web pages fairly quickly and take advantage of CSS to get consistent styles throughout the application. However I want to interact with a MYSQL database on the machine in question. With this in mind I was thinking that I could somehow use Java to process the information that the user inputs from the application and communicate it to the database via JDBC. I know that I could use an applet to do this but the downside to that is that I would like the user to be able to save files to the local machine - and I have read that applets run in a sandbox which prevents them from gaining any access to the local machine. I also know that I could use PHP but I would like to take advantage of object oriented design which Java is perfect for. Does anyone have any thoughts, suggestions or links to tutorials/webpages which could help me to decide how best to go about this. Any thoughts are very much appreciated..
has answer: http://stackoverflow.com/a/645912
score: 2
has answer: http://stackoverflow.com/a/646025
upvote count: 2
type: UnansweredQuestion
tagged with: java
tagged with: mysql

http://stackoverflow.com/a/478118
answers question: http://stackoverflow.com/q/478006
score: 0
has body: i don' t want to sound condescending, but always try to remember tip #26 from the excellent pragmatic programmer book select isn't broken it is very rare to find a java bug. keeping this in mind often helps me to look over my code again, turn it around, and shake out the loose bits until i finally discover where i was wrong. of course asking for help early enough is very encouraged, too :)
type: Answer
has comment: http://stackoverflow.com/comment/295217

http://stackoverflow.com/a/471759
upvote count: 6
has body: I think this is what you're after: Class.getClasses()
downvote count: 2
answers question: http://stackoverflow.com/q/471749
has comment: http://stackoverflow.com/comment/136245998
score: 4
has comment: http://stackoverflow.com/comment/129373458
type: Answer

http://stackoverflow.com/comment/269857
has text: so while your comment is partially right, it's incomplete. because initializer lists interleave. data-members on the one side and base-class subobjects on the other side. the base-classes are initialized in order from derived-to-base, but data-members are initialized in order from base-to-derived.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/448819
score: 0

http://stackoverflow.com/q/504689
score: 2
has answer: http://stackoverflow.com/a/504861
tagged with: java
has answer: http://stackoverflow.com/a/504929
tagged with: memory
has comment: http://stackoverflow.com/comment/319532
has answer: http://stackoverflow.com/a/818051
has answer: http://stackoverflow.com/a/504711
type: Question
downvote count: 0
has comment: http://stackoverflow.com/comment/323179
has title: Big XML file and OutOfMemoryError
answer count: 7
has comment: http://stackoverflow.com/comment/319451
has body: I’m trying to parse a XML file up to 500 mb in java. I tried to use SAX but it gives me this error java.lang.OutOfMemoryError: Java heap space at com.sun.org.apache.xerces.internal.util.XMLStringBuffer.append(Unknown Source) Can you help me? Thanks a lot. P.S. Smaller XML files works just fine
tagged with: parsing
tagged with: http://stackoverflow.com/tag/xml
favorite count: 0
has answer: http://stackoverflow.com/a/504718
has answer: http://stackoverflow.com/a/25515181
tagged with: out-of-memory
upvote count: 2
has answer: http://stackoverflow.com/a/504795
type: UnansweredQuestion

http://stackoverflow.com/comment/93313223
score: 3
comment on: http://stackoverflow.com/a/1426730
type: AnswerComment
type: Comment
has text: @DuncanJones Why the proposed alternative is "more efficient"?

http://stackoverflow.com/q/361723
has comment: http://stackoverflow.com/comment/192178
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/361772
has comment: http://stackoverflow.com/comment/192194
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/361761
upvote count: 1
downvote count: 1
has answer: http://stackoverflow.com/a/361755
tagged with: java
has body: I am having difficulty with the following method. I can't figure out if my problem is, but I have narrowed it down to not populating the array list from the file. Any help is greatly appreciated. private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) { //create arraylists ArrayList&lt;String&gt; model = new ArrayList&lt;String&gt;(); ArrayList&lt;String&gt; length = new ArrayList&lt;String&gt;(); ArrayList&lt;String&gt; width = new ArrayList&lt;String&gt;(); ArrayList&lt;String&gt; radius = new ArrayList&lt;String&gt;(); ArrayList&lt;String&gt; depth = new ArrayList&lt;String&gt;(); ArrayList&lt;String&gt; volume = new ArrayList&lt;String&gt;(); ArrayList&lt;String&gt; shape = new ArrayList&lt;String&gt;(); //fill arraylists from file try { String outputline = ""; BufferedReader fin = new BufferedReader(new FileReader("stock.dat")); while((outputline = fin.readLine()) != null) { // for(int i = 0; i &lt; outputline.length(); i++) { int i = 0; //model boolean flag = false; String pass = ""; while(flag = false) { if(outputline.charAt(i) != ',') pass.concat(Character.toString(outputline.charAt(i))); else flag = true; i++; } model.add(pass); //length flag = false; pass = ""; while(flag = false) { if(outputline.charAt(i) != ',') pass.concat(Character.toString(outputline.charAt(i))); else flag = true; } length.add(pass); //width flag = false; pass = ""; while(flag = false) { if(outputline.charAt(i) != ',') pass.concat(Character.toString(outputline.charAt(i))); else flag = true; } width.add(pass); //radius flag = false; pass = ""; while(flag = false) { if(outputline.charAt(i) != ',') pass.concat(Character.toString(outputline.charAt(i))); else flag = true; } radius.add(pass); //depth flag = false; pass = ""; while(flag = false) { if(outputline.charAt(i) != ',') pass.concat(Character.toString(outputline.charAt(i))); else flag = true; } depth.add(pass); //volume flag = false; pass = ""; while(flag = false) { if(outputline.charAt(i) != ',') pass.concat(Charact…
type: Question
has answer: http://stackoverflow.com/a/361762
tagged with: arraylist
score: 0
has title: Problem with ArrayLists and reading a file

http://stackoverflow.com/a/559825
has body: Check out my Bean annotations http://code.google.com/p/javadude/wiki/Annotations Things like @Bean( cloneable=true, defineSimpleEqualsAndHashCode=true, properties={ @Property(name="name", bound=true), @Property(name="age", type=int.class, bound=true), @Property(name="friend", type=Person.class, kind=PropertyKind.LIST) }, observers={ @Observer(type=FeverListener.class) } ) public class Person extends PersonGen { } The annotation processor generates the PersonGen superclass. Note that I'm currently working on a major change to them and the API is changing (I'll still leave the current version available, but the 3.x.x version stream will be breaking) I'm trying to get the new version done in the next couple of weeks.
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/549053
has comment: http://stackoverflow.com/comment/547809
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/549144

http://stackoverflow.com/a/632498
has body: XMLBeans is an easy to use (once you get the hang of it) tool to deal with XML without having to deal with the annoyances of parsing. It requires that you have a schema for the XML file, but it also provides a tool to generate a schema from an exisint XML file (depending on your needs the generated on is probably fine).
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/632043
score: 1
upvote count: 1

http://stackoverflow.com/a/4552649
score: 1
upvote count: 1
has body: GWT designer (Java UI) designer for eclipse
type: Answer
answers question: http://stackoverflow.com/q/521110
downvote count: 0

gmail
type: Tag
tags question: http://stackoverflow.com/q/483048
tags question: http://stackoverflow.com/q/397933
tag name: gmail

http://stackoverflow.com/q/614995
tagged with: php
duplicate of: http://stackoverflow.com/q/614894
has answer: http://stackoverflow.com/a/616330
tagged with: java
type: Question
downvote count: 0
favorite count: 0
has title: Calling PHP from Java
has answer: http://stackoverflow.com/a/616127
has body: Possible Duplicate: invoking a php method from java I am writing a Java class. And I have some logic in test.php. One of the methods of that Java class should invoke test.php, so that test.php performs some computation and returns the result to the invoking Java method. Can I do that with something like the following? Runtime rt = runtime.getRuntime(); process exec = rt.exec(test.php);
has answer: http://stackoverflow.com/a/615009
answer count: 4
has answer: http://stackoverflow.com/a/615029
score: 2
upvote count: 2
type: UnansweredQuestion

http://stackoverflow.com/q/531776
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/344823
has body: <%@ page import="java.io.*" %> <%-- <%@ page contentType="text/html;charset=ISO-8859-1" %> --%> <% int iLf = 10; char cLf = (char)iLf; File outputFile = new File(generate.xml); outputFile.createNewFile(); FileWriter outfile = new FileWriter(outputFile); outfile.write(" <?xml version='1.0' encoding='UTF-8'?> "+cLf); outfile.write(" " +cLf); outfile.write(" My Band Rocks Your Socks "+cLf); outfile.write(" "+cLf); %> <%! String[] sports; %> <% sports = request.getParameterValues("sports"); if (sports != null) { for (int i = 0; i < sports.length; i++) { // outfile.writeln (sports[i]); String total=sports[i]; String[] sa=total.split("[,]"); // String[] sub=new String(); outfile.write(" "+cLf); for (int j=0;j<sa.length;j++) { // outfile.writeln(sa[j]); // outfile.writeln("sa["+j+"]="+sa[j]); if( j == 0) { outfile.write(" " + sa[0] +" "+cLf); } else if (j == 1) { outfile.write(" " + sa[1] +" "+cLf); } else if( j==2) { outfile.write(" " + sa[2] +" "+cLf); } }// end of inner for loop() outfile.write(" "+cLf); //outfile.writeln(); }// end of outer for() } //else outfile.writeln ("none"); outfile.write(" "+cLf); outfile.write(" "+cLf); outfile.close(); %> The exception thrown is An error occurred at line: 7 in the jsp file: /sports3.jsp generate.xml cannot be resolved to a type 4: <% 5: int iLf = 10; 6: char cLf = (char)iLf; 7: File outputFile = new File(generate.xml); 8: outputFile.createNewFile(); 9: FileWriter outfile = new FileWriter(outputFile); 10: outfile.write(" <?xml version='1.0' encoding='UTF-8'?> "+cLf); please tell me how to rectify.
type: Question
tagged with: debugging
tagged with: java
has answer: http://stackoverflow.com/a/531782
has title: please tell me where i made error in this jsp program
has comment: http://stackoverflow.com/comment/344631
score: 0
has answer: http://stackoverflow.com/a/531781
tagged with: jsp
has answer: http://stackoverflow.com/a/531791
has comment: http://stackoverflow.com/comment/344627
has answer: http://stackoverflow.com/a/531789
answer count: 4

http://stackoverflow.com/comment/100309418
has text: The official answer should by YES since " both Java and Python have virtual machines are binary bytecode interpreters." Period.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/53356426
score: 0

http://stackoverflow.com/comment/227611
type: Comment
comment on: http://stackoverflow.com/a/402088
score: 0
type: AnswerComment
has text: Couldn't agree more. Just, in thread matter, you have to know the "mechanism" but don't put too much effort in master it ( there are more important things at your level ) JavaRanch excellent ( at least some years ago ) . Also, until you master simple JSP you shouldn't try anything else. Nice answer

http://stackoverflow.com/a/487006
has comment: http://stackoverflow.com/comment/32727033
has comment: http://stackoverflow.com/comment/32735661
has comment: http://stackoverflow.com/comment/303404
has comment: http://stackoverflow.com/comment/110628605
has comment: http://stackoverflow.com/comment/327750
has comment: http://stackoverflow.com/comment/303300
downvote count: 1
upvote count: 17
type: Answer
has comment: http://stackoverflow.com/comment/303309
score: 16
has comment: http://stackoverflow.com/comment/23012642
answers question: http://stackoverflow.com/q/486948
has body: Just to clarify a bit for readers: LinkedHashMap only behaves that way when built with one particular constructor overload. Normally the elements are maintained in insert order. (This feels a little odd to me, but never mind.) I don't believe there's any such class in .NET. It wouldn't be too hard to build one, using a linked list of elements and a dictionary from key to linked list node. Access would then consist of fetching the linked list node, moving it to the head, and returning the value. I'd be happy to implement it tonight or tomorrow if you want - although probably not with full unit tests etc. (Fully testing a collection is a time-consuming business!)
has comment: http://stackoverflow.com/comment/32731891

http://stackoverflow.com/a/582812
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/8770571
upvote count: 14
has body: You should always construct a valid and legitimate object; and if you can't using constructor parms, you should use a builder object to create one, only releasing the object from the builder when the object is complete. On the question of constructor use: I always try to have one base constructor that all others defer to, chaining through with "omitted" parameters to the next logical constructor and ending at the base constructor. So: class SomeClass { SomeClass() { this("DefaultA"); } SomeClass(String a) { this(a,"DefaultB"); } SomeClass(String a, String b) { myA=a; myB=b; } ... } If this is not possible, then I try to have an private init() method that all constructors defer to. And keep the number of constructors and parameters small - a max of 5 of each as a guideline.
score: 14
answers question: http://stackoverflow.com/q/581873

http://stackoverflow.com/comment/290699
comment on: http://stackoverflow.com/q/473088
has text: You might consider making this a community wiki...
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/481543
downvote count: 0
has comment: http://stackoverflow.com/comment/50026144
has comment: http://stackoverflow.com/comment/2229374
has comment: http://stackoverflow.com/comment/2244867
type: Answer
has body: I usually do it like this: try { // Use the resource. } catch( Exception ex ) { // Problem with the resource. } finally { // Put away the resource. closeQuietly( resource ); } Elsewhere: protected void closeQuietly( Resource resource ) { try { if (resource != null) { resource.close(); } } catch( Exception ex ) { log( "Exception during Resource.close()", ex ); } }
has comment: http://stackoverflow.com/comment/299696
answers question: http://stackoverflow.com/q/481446
has comment: http://stackoverflow.com/comment/2229415
score: 74
upvote count: 74
accepted answer of: http://stackoverflow.com/q/481446
has comment: http://stackoverflow.com/comment/298396
has comment: http://stackoverflow.com/comment/61610543
type: AcceptedAnswer

http://stackoverflow.com/a/459164
upvote count: 1
has body: SpringSource dm Server supports modular applications - you can divide your application into OSGi bundles and share any infrastructure services you care to provide between applications. This gets you away from the monolithic structures such as WARs defined by Java EE. Typically this means you get a very rapid edit/save/redeploy cycle during development. OSGi then lets you version modules and the packages they export as well as dynamically update modules without have to restart the whole server. SpringSource dm Server was built from scratch as OSGi bundles. So you can configure which subsystems of dm Server are loaded if you don't want the standard set.
answers question: http://stackoverflow.com/q/381071
downvote count: 0
type: Answer
score: 1

http://stackoverflow.com/a/7754567
has comment: http://stackoverflow.com/comment/15125211
answers question: http://stackoverflow.com/q/482041
type: Answer
upvote count: 1
score: 1
has body: MenuSelectionManager.defaultManager() is indeed a good solution, but it won't work when you'll try to pre-select your JPopupMenu's sub menus (it will hide the parent menu). Also, it messes up other keyboard navigation behaviors (you can't press left to hide the sub-menu etc.) Unfortunatelly, there's no good solution for this question in Swing... My solution is ugly, but sadly does the job perfect: public static void setMenuSelectedIndex(final JPopupMenu popupMenu, final int index) { SwingUtilities.invokeLater(new Runnable(){public void run() { for (int i=0; i &lt; index+1; i++) { popupMenu.dispatchEvent(new KeyEvent(popupMenu, KeyEvent.KEY_PRESSED, 0, 0, KeyEvent.VK_DOWN, '\0')); } }}); } As you can see, I'm basically simulating 'Down' Keyboard Key-Presses on the popupmenu... A better solution might be not to Hardcodedly simulate VK_DOWN, but to read the Popup's input map and determine which KeyCode means "select next menu item" - but I think most of us will get along with this hack... You might also want to look at this method, which selects a menu's item once it gets selected It utilizes the previous method public static void setSelectedIndexWhenVisible(final JMenu menu, final int index) { menu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { PopupUtils.setMenuSelectedIndex(menu.getPopupMenu(), index); menu.getPopupMenu().removePopupMenuListener(this); } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } @Override public void popupMenuCanceled(PopupMenuEvent e) { } }); }
has comment: http://stackoverflow.com/comment/15127726
downvote count: 0

http://stackoverflow.com/a/482511
has comment: http://stackoverflow.com/comment/38275719
type: Answer
has comment: http://stackoverflow.com/comment/302503
score: 17
has comment: http://stackoverflow.com/comment/12871157
has body: In general, this works. But you need to check very carefully which classes are where. If your task class can be loaded in a classloader higher up in the classloader hierarchy (like CLASSPATH or ANT_HOME/lib) then your classpathref will simply get ignored. Read the FAQ entry for more details. Ant's class loader implementation uses Java's delegation model The ClassLoader class uses a delegation model to search for classes and resources. Each instance of ClassLoader has an associated parent class loader. When called upon to find a class or resource, a ClassLoader instance will delegate the search for the class or resource to its parent class loader before attempting to find the class or resource itself. The virtual machine's built-in class loader, called the bootstrap class loader, does not itself have a parent but may serve as the parent of a ClassLoader instance. Note: running ant -diagnostics can help too.
upvote count: 17
answers question: http://stackoverflow.com/q/482303
accepted answer of: http://stackoverflow.com/q/482303
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/12871235

http://stackoverflow.com/a/610702
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/610628
has body: Well, I think there's no way to do this without calling getCause(). It you think it's ugly implement a utility class for doing this: public class ExceptionUtils { public static boolean wasCausedBy(Throwable e, Class&lt;? extends Throwable&gt;) { // call getCause() until it returns null or finds the exception } }
upvote count: 1

http://stackoverflow.com/comment/120639739
type: AnswerComment
comment on: http://stackoverflow.com/a/493503
has text: This doesn't work for "-2147483648", guess why ?
score: 0
type: Comment

http://stackoverflow.com/q/442463
has answer: http://stackoverflow.com/a/70054671
tagged with: java
possible better answer: http://stackoverflow.com/a/442649
has answer: http://stackoverflow.com/a/442649
type: Question
has answer: http://stackoverflow.com/a/41952546
has body: Using the Java version of Lucene, how would you find out the number of documents in an index?
has answer: http://stackoverflow.com/a/14029561
tagged with: lucene
has answer: http://stackoverflow.com/a/442599
downvote count: 0
has title: Finding the number of documents in a Lucene index
favorite count: 0
answer count: 5
score: 13
upvote count: 13
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/442599

http://stackoverflow.com/a/79494264
has body: Better Swing Application Framework (BSAF, do not confuse with Swing**)**. The Swing Application Framework (JSR 296) provides a basic architecture and a set of commonly used services for Swing applications. Most applications must implement and manage lifecycle events, UI component event handling, threading, localizable resources, and simple persistence. The framework provides services for managing all these common needs, allowing you to concentrate on your application's unique functionality. Framework architecture includes Application and ApplicationContext classes. The ApplicationContext instance will provide help for session and local storage, task management, resource management, and most other services that the framework provides. Your framework application has a well-defined life cycle. Each lifecycle stage has a corresponding method that your application can override to provide its unique functionality. Framework applications have support for application- and class-level resources. Using the ResourceManager and ResourceMap classes, you can automatically inject those resources into your application, making them easy to localize. JavaFX (OpenJFX). Indefinitely promoted as next generation client application platform for desktop and embedded systems for use with the JDK. It is a collaborative effort by many individuals and companies with the goal of producing a modern, efficient, and fully featured toolkit for developing rich client applications. NetBeans Platform (apache-netbeans RCP). The NetBeans Platform is a broad Java framework on which you can base large desktop applications. The NetBeans Platform contains APIs that simplify the handling of windows, actions, files, and many other things typical in applications. Each distinct feature in a NetBeans Platform application can be provided by a distinct NetBeans module, which is comparable to a plugin. A NetBeans module is a group of Java classes that provides an application with a specific feature. IntelliJ IDEA C…
score: -1
answers question: http://stackoverflow.com/q/548415
upvote count: 0
type: Answer
downvote count: 1

http://stackoverflow.com/q/622814
tagged with: swing
upvote count: 16
has title: Window events for JFrames that are hidden/shown via setVisible?
type: Question
has answer: http://stackoverflow.com/a/622839
answer count: 2
downvote count: 0
tagged with: events
favorite count: 0
possible better answer: http://stackoverflow.com/a/25131409
has body: Which kind of listener do I have to add to a JFrame to detect when it is being hidden or shown via setVisible? I tried using a WindowListener and the windowOpened and windowClosed methods, but they only work for the first time that a window is opened (windowOpened) or, respectively, when the window is closed using the dispose method (windowClosed). That is not enough for me. I want to be notified every time the window is made visible and invisible on the screen using setVisible. Is there a standard Swing way to achieve this, or do I need to make my own (by, say, overriding the setVisible method)?
has answer: http://stackoverflow.com/a/25131409
accepted answer: http://stackoverflow.com/a/622839
type: AnsweredQuestion
tagged with: java
score: 16

http://stackoverflow.com/a/1158769
has comment: http://stackoverflow.com/comment/13910216
has comment: http://stackoverflow.com/comment/9750694
type: Answer
has body: I'm trying to do the same thing. I have a solution that works for me - yours may vary (and you might not love the solution... it's a bit low-level). I came across an article on the net where they were using a custom class loader to do something similar which served as inspiration. If anyone can see how to improve then suggestions would be welcome btw. For deployment I rely on container injection of the EntityManager but for testing I create it myself using this code: final Thread currentThread = Thread.currentThread(); final ClassLoader saveClassLoader = currentThread.getContextClassLoader(); currentThread.setContextClassLoader(new ClassLoaderProxy(saveClassLoader)); EntityManagerFactory emFactory = Persistence.createEntityManagerFactory("test"); em = emFactory.createEntityManager(); Then the ClassLoaderProxy is about as minimal as you can get and just redirects requests for META-INF/persistence.xml to META-INF/test-persist.xml: public class ClassLoaderProxy extends ClassLoader { public ClassLoaderProxy(final ClassLoader parent) { super(); } @Override public Enumeration&lt;URL&gt; getResources(final String name) throws IOException { if (!"META-INF/persistence.xml".equals(name)) { return super.getResources(name); } else { System.out.println("Redirecting persistence.xml to test-persist.xml"); return super.getResources("META-INF/test-persist.xml"); } } } Just to explain this a bit more: There are two persistence.xml files (one named persistence.xml that is used outside testing and one named test-persist.xml that is used for tests). The custom class loader is only active for unit tests (for deployment everything is normal) The custom class loader redirects requests for "META-INF/persistence.xml" to the test version ("META-INF/test-persist.xml"). I was originally hitting some problems because Hibernate will revert back (somehow) to the classloader that was used to load Hibernate (at least I think that is what was going on). I've found that putting the ClassLoader switchi…
score: 1
has comment: http://stackoverflow.com/comment/13961795
upvote count: 2
answers question: http://stackoverflow.com/q/385532
downvote count: 1

http://stackoverflow.com/q/449557
has answer: http://stackoverflow.com/a/1441580
tagged with: erlang
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/1441698
tagged with: key-value
score: 1
favorite count: 0
has body: Why wouldn't you use Scalaris?
has comment: http://stackoverflow.com/comment/276257
type: Question
upvote count: 2
has title: Scalaris: P2P key-value database - your opinion please
has answer: http://stackoverflow.com/a/471207
tagged with: java
has answer: http://stackoverflow.com/a/639766
downvote count: 1
answer count: 4
tagged with: database

http://stackoverflow.com/comment/376575
type: AnswerComment
comment on: http://stackoverflow.com/a/564718
has text: I'm struggling to get rid of that white space. The minimum response length after trimming is 10 (probably for good reason). My answer is actually No_______. I', thinking about posting a StackOverflow question to see if anyone can help me.
type: Comment
score: 2

http://stackoverflow.com/a/508686
has comment: http://stackoverflow.com/comment/3597225
has comment: http://stackoverflow.com/comment/123550713
downvote count: 0
has comment: http://stackoverflow.com/comment/323066
type: Answer
has comment: http://stackoverflow.com/comment/53226872
has comment: http://stackoverflow.com/comment/323021
upvote count: 90
has comment: http://stackoverflow.com/comment/323042
answers question: http://stackoverflow.com/q/508665
score: 90
has body: From this forum: parseInt() returns primitive integer type (int), whereby valueOf returns java.lang.Integer, which is the object representative of the integer. There are circumstances where you might want an Integer object, instead of primitive type. Of course, another obvious difference is that intValue is an instance method whereby parseInt is a static method.
has comment: http://stackoverflow.com/comment/51401291

http://stackoverflow.com/comment/644421
has text: Sorry, the "KeyStore" there was wrong; I fixed that. As for initializing the key stores, yes, there is a method that uses system properties, with default values for the important properties. I'll update my answer with that.
comment on: http://stackoverflow.com/a/387639
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/9419413
has text: @Nick - I think that's a fair comment but it does no harm to read between the lines occasionally and suggest alternatives.
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/483463

http://stackoverflow.com/comment/42753890
type: Comment
score: 13
has text: This, 1k times over. Don't take the state data from the object, change it somewhere else, and put it back in. Give it all the data it needs to do the work itself. That's like OOP 101.
type: AnswerComment
comment on: http://stackoverflow.com/a/565227

http://stackoverflow.com/comment/99213361
type: Comment
comment on: http://stackoverflow.com/a/9418812
has text: ImgScalr 4.2 supports rotating only in multiples of 90 degrees. It can't rotate at arbitrary angles.
score: 0
type: AnswerComment

http://stackoverflow.com/q/527017
has answer: http://stackoverflow.com/a/527029
tagged with: ssl
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/340711
type: Question
has comment: http://stackoverflow.com/comment/344957
answer count: 1
has title: web.xml <transport-guarantee> not able to work in certain environment
score: 0
tagged with: java
tagged with: web-applications
has body: I have added this transport-guarantee tag in the web.xml meaning that certain pages can only be accessed by https. But however this has an issue with environment that has web server and load balancer. Apparently it does not redirect to the application with ssl port. Seens like a firewall restriction. Any advise anyone?
tagged with: https

http://stackoverflow.com/q/628583
downvote count: 1
has body: I have not been able to write a regular expression, to use in a String.split (Java) expression such as to only split on comma which are not in parentheses. Example: (54654,4565):(45651,65423),4565:45651,(4565,4564):45651 Should yield the 3 strings: (54654,4565):(45651,65423) 4565:45651 (4565,4564):45651 Any help much appreciated.
tagged with: java
type: Question
score: 5
has answer: http://stackoverflow.com/a/628716
has answer: http://stackoverflow.com/a/628620
duplicate of: http://stackoverflow.com/q/26633452
favorite count: 0
has answer: http://stackoverflow.com/a/628670
has title: Regular expression to split on commas not enclosed in parenthesis
answer count: 3
tagged with: regex
upvote count: 6
linked to: http://stackoverflow.com/q/26633452
has comment: http://stackoverflow.com/comment/441328
type: UnansweredQuestion

http://stackoverflow.com/a/647134
type: Answer
has body: Be wary of microbenchmarks, but I found this blog entry where someone found that new was about twice as fast as newInstance with JDK 1.4. It sounds like there is a difference, and as expected, reflection is slower. However, it sounds like the difference may not be a dealbreaker, depending on the frequency of new object instances vs how much computation is being done.
score: 1
has comment: http://stackoverflow.com/comment/460521
upvote count: 1
has comment: http://stackoverflow.com/comment/460505
has comment: http://stackoverflow.com/comment/463459
downvote count: 0
answers question: http://stackoverflow.com/q/647111

http://stackoverflow.com/q/531353
accepted answer: http://stackoverflow.com/a/531366
score: 8
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/531366
upvote count: 8
has answer: http://stackoverflow.com/a/531459
type: Question
possible better answer: http://stackoverflow.com/a/531379
has answer: http://stackoverflow.com/a/57549623
has answer: http://stackoverflow.com/a/1706764
tagged with: java
has body: I am working on a GUI application and would rather distribute just one jar as opposed to multiple ones. Can you control this with the manifest.
has title: Can you add multiple jars in a jar file and then launch that jar file
tagged with: jar
favorite count: 0
has answer: http://stackoverflow.com/a/531379
answer count: 5

http://stackoverflow.com/q/395401
favorite count: 0
has title: Printing Java Collections Nicely (toString Doesn't Return Pretty Output)
has answer: http://stackoverflow.com/a/60501046
has answer: http://stackoverflow.com/a/395407
has answer: http://stackoverflow.com/a/395406
has answer: http://stackoverflow.com/a/395456
has answer: http://stackoverflow.com/a/59505079
has answer: http://stackoverflow.com/a/3670573
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/31764076
answer count: 20
has answer: http://stackoverflow.com/a/34089004
tagged with: java
has answer: http://stackoverflow.com/a/51891788
upvote count: 238
has answer: http://stackoverflow.com/a/395403
has body: I wish to print a Stack&lt;Integer&gt; object as nicely as the Eclipse debugger does (i.e. [1,2,3...]) but printing it with out = "output:" + stack doesn't return this nice result. Just to clarify, I'm talking about Java's built-in collection so I can't override its toString(). How can I get a nice printable version of the stack?
has answer: http://stackoverflow.com/a/28961292
has answer: http://stackoverflow.com/a/65973528
has comment: http://stackoverflow.com/comment/47086920
linked to: http://stackoverflow.com/q/2828252
has answer: http://stackoverflow.com/a/32533080
downvote count: 1
type: Question
tagged with: debugging
has answer: http://stackoverflow.com/a/34928115
has answer: http://stackoverflow.com/a/8144738
accepted answer: http://stackoverflow.com/a/395403
possible better answer: http://stackoverflow.com/a/28961292
score: 237
tagged with: pretty-print
has answer: http://stackoverflow.com/a/3669419
linked to: http://stackoverflow.com/q/9174268
has answer: http://stackoverflow.com/a/25278401
has comment: http://stackoverflow.com/comment/45888940
has answer: http://stackoverflow.com/a/12025075
has answer: http://stackoverflow.com/a/41165315
has answer: http://stackoverflow.com/a/22737771

http://stackoverflow.com/q/625726
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/627710
tagged with: java
tagged with: concurrency
has answer: http://stackoverflow.com/a/625747
type: Question
has answer: http://stackoverflow.com/a/625745
has answer: http://stackoverflow.com/a/625740
has answer: http://stackoverflow.com/a/3228542
has body: class A { public synchronized void myOneMethod() { // ... } } class B extends A { public synchronized void myOtherMethod() { // ... } } // ... B myObject; // ... myObject.myOneMethod(); // acquires lock myObject.myOtherMethod(); // same lock? How I understand the synchronization model, I'd say that yes, it does, because the lock / monitor is associated with the instance myObject, and it doesn't matter where the method was defined. But am I right? If not, why? If yes, why are you sure, and I'm not? :-)
answer count: 7
score: 22
favorite count: 0
linked to: http://stackoverflow.com/q/609963
has answer: http://stackoverflow.com/a/625741
accepted answer: http://stackoverflow.com/a/625741
has title: Java: A synchronized method in the superclass acquires the same lock as one in the subclass, right?
upvote count: 22
downvote count: 0
possible better answer: http://stackoverflow.com/a/625740
has answer: http://stackoverflow.com/a/29643234

http://stackoverflow.com/q/559880
downvote count: 0
answer count: 1
favorite count: 0
score: 1
has comment: http://stackoverflow.com/comment/371143
has title: how do you print a bag datatype?
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/559892
upvote count: 1
has body: Bag&lt;String&gt; wordFrequencies = getWordFrequencies(text); how do i see what this wordfrequencies bag contains.. i ve used org.apache.commons.collections15.Bag org.apache.commons.collections15.bag.HashBag packages
tagged with: java
type: Question

http://stackoverflow.com/comment/1814379
comment on: http://stackoverflow.com/a/646476
type: Comment
has text: Netbeans, though it is bit heavier and will be sluggish once you start using the inbuilt pre-processing modules, is far better compared to Eclipse MTJ in managing different configuration and screen resolutions in a single source.
score: 0
type: AnswerComment

http://stackoverflow.com/q/414583
has answer: http://stackoverflow.com/a/6466677
has answer: http://stackoverflow.com/a/4760522
has answer: http://stackoverflow.com/a/642926
tagged with: ruby-on-rails
downvote count: 1
has answer: http://stackoverflow.com/a/8068650
tagged with: crud
possible better answer: http://stackoverflow.com/a/414613
answer count: 22
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/18518157
tagged with: java
has answer: http://stackoverflow.com/a/7205219
has answer: http://stackoverflow.com/a/414929
has answer: http://stackoverflow.com/a/13256960
has answer: http://stackoverflow.com/a/16651858
accepted answer: http://stackoverflow.com/a/2026856
has answer: http://stackoverflow.com/a/414615
type: Question
has title: Is there a CRUD generator utility in Java(any framework) like Scaffolding in Rails?
has answer: http://stackoverflow.com/a/2026812
upvote count: 53
tagged with: scaffolding
has answer: http://stackoverflow.com/a/2026792
has answer: http://stackoverflow.com/a/28024372
has answer: http://stackoverflow.com/a/48742136
has answer: http://stackoverflow.com/a/2130785
has answer: http://stackoverflow.com/a/1745431
has answer: http://stackoverflow.com/a/414609
has answer: http://stackoverflow.com/a/20505808
has answer: http://stackoverflow.com/a/5988640
has answer: http://stackoverflow.com/a/5505468
has body: Is there a CRUD generator utility in Java like Scaffolding in Rails? Can be in any framework or even plain servlets. Must generate controllers + views in jsp, not just DAO code...
favorite count: 0
has answer: http://stackoverflow.com/a/2026856
score: 52
has answer: http://stackoverflow.com/a/414613

http://stackoverflow.com/q/538240
tagged with: java
has comment: http://stackoverflow.com/comment/350573
tagged with: swing
possible better answer: http://stackoverflow.com/a/538273
type: Question
has answer: http://stackoverflow.com/a/759514
has comment: http://stackoverflow.com/comment/350618
has body: I'm designing a really simple GUI but without any luck. Basically the outer layout has two columns which is a splitter pane (this is for an IRC client I'm writing). On the left-hand side is the server/channel/user tree and on the right is the chat pane. Now I break this down so on the right-hand side there's the output pane at the top, and a single-lined input box at the bottom. This is the code for creating the GUI on a whole (this is just a snippet) ChatModel cm = new ChatModel(); ChatView cv = new ChatView(cm); treeViewChatSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, serverTreeView, cv); treeViewChatSplitPane.setSize(500, 500); treeViewChatSplitPane.setBorder(null); treeViewChatSplitPane.setDividerSize(3); this.getContentPane().add(treeViewChatSplitPane); this.setSize(500, 500); The ChatView constructor has this in it (it extends java.awt.Container) this.model = model; this.setLayout(new BorderLayout()); mainTextArea = new JTextArea(); mainTextArea.setLineWrap(true); mainTextArea.setBackground(new Color(255, 255, 255)); inputField = new JTextField(); this.add(mainTextArea, BorderLayout.CENTER); this.add(inputField, BorderLayout.PAGE_END); Now it looks fine initially, but the problem I'm having with it is that you can move the splitter to the left, but not to the right. In fact, if you move it left, you can no longer move it right. I did have it working earlier, but the implementation wasn't as good and I've forgotten what I had done. Any ideas? I can't see why this wouldn't work.
has title: Java GUI Problems
downvote count: 0
has comment: http://stackoverflow.com/comment/350588
has answer: http://stackoverflow.com/a/538273
favorite count: 0
has answer: http://stackoverflow.com/a/538271
has answer: http://stackoverflow.com/a/538335
accepted answer: http://stackoverflow.com/a/538271
upvote count: 2
answer count: 5
has answer: http://stackoverflow.com/a/538306
score: 2
type: AnsweredQuestion

http://stackoverflow.com/a/21449373
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/585991
has body: You can do software releases without the downtime, kinda of situations in 24x7 running systems. You can write your own class loader call that from JMX and replace the class file at run time.
downvote count: 0
type: Answer

http://stackoverflow.com/comment/25929192
comment on: http://stackoverflow.com/a/5886596
has text: Doubles are fractional binary approximations of numbers and, as such, almost no fractional decimal numbers have an exact fractional binary representation. Unless the fractional part is some multiple of a negative power of 2, the representation in a double is an approximation. Decimal fractions that are multiples of negative powers of two are extremely rare compared to the total number of decimal fractions down to billionths. Sums of several thousand of these approximations will very quickly have issues that will start to show up in cents and make rounding/truncation solutions difficult.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/359993
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/362095
has title: Is there a tool or framework to Generate a CRUD UI in Swing?
tagged with: java
has answer: http://stackoverflow.com/a/362088
tagged with: swing
type: Question
has body: I am looking for a tool/framework to (automatically) generate a Swing user interface to perform CRUD operations on an underlying database. I would also like to configure the database fields that should be exposed. Something like django (via modelforms) or ruby on rails features, but in a Java desktop environment.
score: 11
tagged with: user-interface
downvote count: 0
possible better answer: http://stackoverflow.com/a/8068634
has answer: http://stackoverflow.com/a/362095
has answer: http://stackoverflow.com/a/58932786
has answer: http://stackoverflow.com/a/8068634
favorite count: 0
answer count: 4
tagged with: crud
upvote count: 11

http://stackoverflow.com/q/454294
has title: What are synchronizing strategies for Prevayler?
tagged with: java
has comment: http://stackoverflow.com/comment/274742
tagged with: concurrency
type: Question
answer count: 2
score: 5
upvote count: 5
downvote count: 0
tagged with: persistence
has answer: http://stackoverflow.com/a/479077
has answer: http://stackoverflow.com/a/475629
tagged with: prevayler
has body: Prevayler guarantees that all the writes ( through its transactions) are synchronized. But what about reads? Is it right that dirty reads are possible if no explicit synchronizing is used (in user code)? Are they possible if a business object is read as: // get the 3rd account Accont account = (Bank)prevayler.prevalentSystem().getAccounts().get(2); ? If so what synchronizing strategies are good for a user code? (Consider a business object A contains a collection of business objects Bs), using a synchronized collection (of Bs inside of A), for example from java.util.concurrent package? synchronize collection reads outside transactions with the collection writes inside transactions, for example using "synchronized( collection )" code around reads and writes?
favorite count: 0
tagged with: synchronization
possible better answer: http://stackoverflow.com/a/475629
has comment: http://stackoverflow.com/comment/275013
accepted answer: http://stackoverflow.com/a/479077
type: AnsweredQuestion

http://stackoverflow.com/a/531428
answers question: http://stackoverflow.com/q/531358
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/531358
upvote count: 1
type: AcceptedAnswer
has body: Was able to sort it out with help from this post: http://polygeek.com/302_flex_changing-font-colors-in-flex-buildereclipse
type: Answer

http://stackoverflow.com/a/610544
score: 0
has comment: http://stackoverflow.com/comment/422881
type: Answer
has body: Groovy and Grails. If you like MVC or even have a existing library written in Java/JVM, that are the tools you're looking for! Grails aims to bring the "coding by convention" paradigm to Groovy. It's an open-source web application framework that leverages the Groovy language and complements Java Web development. You can use Grails as a standalone development environment that hides all configuration details or integrate your Java business logic. Grails aims to make development as simple as possible and hence should appeal to a wide range of developers not just those from the Java community.
answers question: http://stackoverflow.com/q/610516

http://stackoverflow.com/q/597566
tagged with: java
has answer: http://stackoverflow.com/a/597603
type: Question
has answer: http://stackoverflow.com/a/597693
upvote count: 5
has body: I need to read a Word .doc file from Java that has text and images. I need to recognize the images &amp; text and separate them into 2 files. I've recently heard about "Apache POI." How I can use Apache POI to read Word .doc files?
has title: How do I use Apache POI to read a .DOC file in Java to separate images from text?
answer count: 2
score: 5
downvote count: 0
favorite count: 0
type: UnansweredQuestion
tagged with: ms-word
tagged with: apache-poi

http://stackoverflow.com/comment/35274536
has text: @ShivaKomuravelly Yes, but not in any situation it seems, so -1 from me as well.
comment on: http://stackoverflow.com/a/16895970
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/202477
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/374007
has text: suggestions added in response to your comment

http://stackoverflow.com/comment/340110
comment on: http://stackoverflow.com/q/526991
type: QuestionComment
type: Comment
has text: The examples are not well-chosen. Where is the method that modifies the input string? Like you say, collect doesn't modify its input, but println doesn't either.
score: 0

http://stackoverflow.com/comment/36974612
type: AnswerComment
comment on: http://stackoverflow.com/a/534679
type: Comment
has text: @Dan Can you explain to me why a Thread would be significant barrier to the portability of moving an EJB from one machine in a custer to another?
score: 1

http://stackoverflow.com/a/435568
has comment: http://stackoverflow.com/comment/262656
upvote count: 226
answers question: http://stackoverflow.com/q/435553
has comment: http://stackoverflow.com/comment/37497268
has comment: http://stackoverflow.com/comment/40549578
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/435553
has comment: http://stackoverflow.com/comment/4703328
has comment: http://stackoverflow.com/comment/6796084
has comment: http://stackoverflow.com/comment/13989860
has comment: http://stackoverflow.com/comment/6797036
has comment: http://stackoverflow.com/comment/18064964
type: Answer
score: 202
has comment: http://stackoverflow.com/comment/13994672
has comment: http://stackoverflow.com/comment/262705
has comment: http://stackoverflow.com/comment/263100
downvote count: 24
has body: Yes - absolutely. Looking up a class via reflection is, by magnitude, more expensive. Quoting Java's documentation on reflection: Because reflection involves types that are dynamically resolved, certain Java virtual machine optimizations can not be performed. Consequently, reflective operations have slower performance than their non-reflective counterparts, and should be avoided in sections of code which are called frequently in performance-sensitive applications. Here's a simple test I hacked up in 5 minutes on my machine, running Sun JRE 6u10: public class Main { public static void main(String[] args) throws Exception { doRegular(); doReflection(); } public static void doRegular() throws Exception { long start = System.currentTimeMillis(); for (int i=0; i&lt;1000000; i++) { A a = new A(); a.doSomeThing(); } System.out.println(System.currentTimeMillis() - start); } public static void doReflection() throws Exception { long start = System.currentTimeMillis(); for (int i=0; i&lt;1000000; i++) { A a = (A) Class.forName("misc.A").newInstance(); a.doSomeThing(); } System.out.println(System.currentTimeMillis() - start); } } With these results: 35 // no reflection 465 // using reflection Bear in mind the lookup and the instantiation are done together, and in some cases the lookup can be refactored away, but this is just a basic example. Even if you just instantiate, you still get a performance hit: 30 // no reflection 47 // reflection using one lookup, only instantiating Again, YMMV.
has comment: http://stackoverflow.com/comment/60345510
has comment: http://stackoverflow.com/comment/36489676
has comment: http://stackoverflow.com/comment/18064227

http://stackoverflow.com/a/364498
upvote count: 2
type: Answer
score: 2
downvote count: 0
has body: Previous answers already hit the main issues, but there's a minor detail that might be worth mentioning. You could have a factory that returns instances of (hidden) subclasses of the abstract class. The abstract class defines the contract on the resulting object, as well as providing default implementations, but the fact that the class is abstract both keeps it from being instantiated directly and also signals the fact that the identity of the "real" implementation class is not published.
answers question: http://stackoverflow.com/q/362446

http://stackoverflow.com/a/597581
has comment: http://stackoverflow.com/comment/89123810
answers question: http://stackoverflow.com/q/596958
type: AcceptedAnswer
upvote count: 9
type: Answer
has body: I think you want code-prettify Supports a bunch of different languages (including Java). Here are the docs/examples.
downvote count: 0
accepted answer of: http://stackoverflow.com/q/596958
score: 9

http://stackoverflow.com/a/371873
answers question: http://stackoverflow.com/q/371839
has body: For JTable in particular, I'd suggest subclassing AbstractTableModel like so: class MyTableModel extends AbstractTableModel { private List&lt;List&lt;String&gt;&gt; data; public MyTableModel(List&lt;List&lt;String&gt;&gt; data) { this.data = data; } @Override public int getRowCount() { return data.size(); } @Override public int getColumnCount() { return data.get(0).size(); } @Override public Object getValueAt(int row, int column) { return data.get(row).get(column); } // optional @Override public void setValueAt(Object aValue, int row, int column) { data.get(row).set(column, aValue); } } Note: this is the most basic implementation possible; error-checking is omitted for brevity. Using a model like this, you don't have to worry about pointless conversions to Object[][].
downvote count: 0
score: 8
upvote count: 8
type: Answer
has comment: http://stackoverflow.com/comment/200650
has comment: http://stackoverflow.com/comment/200656

http://stackoverflow.com/comment/58822220
type: Comment
has text: @PatrickCuff - Nice solution! `JAVA_HOME` is the parent directory of the directory that contains `java.exe` though, so you should traverse one directory up from the result found. `java.exe` is expected to be found at `%JAVA_HOME%\bin\java.exe`
comment on: http://stackoverflow.com/a/639293
score: 1
type: AnswerComment

http://stackoverflow.com/q/514478
has answer: http://stackoverflow.com/a/514738
favorite count: 0
has answer: http://stackoverflow.com/a/514486
has comment: http://stackoverflow.com/comment/328512
type: Question
has answer: http://stackoverflow.com/a/514519
has answer: http://stackoverflow.com/a/514762
tagged with: pass-by-value
possible better answer: http://stackoverflow.com/a/514486
has answer: http://stackoverflow.com/a/515169
score: 9
has answer: http://stackoverflow.com/a/516723
has answer: http://stackoverflow.com/a/514536
has answer: http://stackoverflow.com/a/514537
has answer: http://stackoverflow.com/a/514498
has answer: http://stackoverflow.com/a/514522
tagged with: pass-by-reference
has comment: http://stackoverflow.com/comment/328260
has answer: http://stackoverflow.com/a/516159
upvote count: 9
has answer: http://stackoverflow.com/a/514523
tagged with: java
has body: I'm fairly new to Java (been writing other stuff for many years) and unless I'm missing something (and I'm happy to be wrong here) the following is a fatal flaw... String foo = new String(); thisDoesntWork(foo); System.out.println(foo);//this prints nothing public static void thisDoesntWork(String foo){ foo = "howdy"; } Now, I'm well aware of the (fairly poorly worded) concept that in java everything is passed by "value" and not "reference", but String is an object and has all sorts of bells and whistles, so, one would expect that unlike an int a user would be able to operate on the thing that's passed into the method (and not be stuck with the value set by the overloaded =). Can someone explain to me what the reasoning behind this design choice was? As I said, I'm not looking to be right here, and perhaps I'm missing something obvious?
has answer: http://stackoverflow.com/a/515115
has title: Can someone explain to me what the reasoning behind passing by "value" and not by "reference" in Java is?
has comment: http://stackoverflow.com/comment/328340
has answer: http://stackoverflow.com/a/514491
has answer: http://stackoverflow.com/a/514499
answer count: 15
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/514498
has comment: http://stackoverflow.com/comment/328254
has comment: http://stackoverflow.com/comment/328480
downvote count: 0

http://stackoverflow.com/comment/32727033
type: Comment
has text: @JonSkeet: did you ever implement the `LinkedHashMap` into C#?
type: AnswerComment
comment on: http://stackoverflow.com/a/487006
score: 0

http://stackoverflow.com/a/560176
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/559779
downvote count: 0
has body: Yes, I believe that arrays should have an API defined beyond the one specified in the language itself. In particular, it's annoying that a Foo[] doesn't implement Iterable&lt;Foo&gt;. Yes, I know it's easy to wrap it - but it's annoying that you have to. .NET gets this mostly right, with the Array type which is mostly for non-generic access, and various generic interfaces which are deemed to be implemented by the actual arrays. For instance: IList&lt;int&gt; intList = new int[10]; (It helps that .NET generics cope with primitive types better than Java does.) The only downsides I've seen of this approach is that arrays can be covariant in .NET, but normal generics aren't, and that things get slightly confusing with non-zero-based arrays and rectangular arrays. As an aside, various people have referred to arrays as primitives in this thread. While they certainly have special handling, they're not defined to be primitives. From the language spec, section 4.2: A primitive type is predefined by the Java programming language and named by its reserved keyword (§3.9): PrimitiveType: NumericType boolean NumericType: IntegralType FloatingPointType IntegralType: one of byte short int long char FloatingPointType: one of float double
type: Answer

http://stackoverflow.com/a/525222
answers question: http://stackoverflow.com/q/525212
upvote count: 33
has comment: http://stackoverflow.com/comment/51538842
type: Answer
has comment: http://stackoverflow.com/comment/18481660
downvote count: 12
score: 21
has comment: http://stackoverflow.com/comment/65846409
has comment: http://stackoverflow.com/comment/338481
has comment: http://stackoverflow.com/comment/83501829
has body: I would say that it is not in the spirit of Java to run a shell script from Java. Java is meant to be cross platform, and running a shell script would limit its use to just UNIX. With that said, it's definitely possible to run a shell script from within Java. You'd use exactly the same syntax you listed (I haven't tried it myself, but try executing the shell script directly, and if that doesn't work, execute the shell itself, passing the script in as a command line parameter).
has comment: http://stackoverflow.com/comment/10037039

http://stackoverflow.com/a/670988
has comment: http://stackoverflow.com/comment/485011
has comment: http://stackoverflow.com/comment/498280
score: 0
has body: I would go with the Lift framework written in Scala. You will see a great productivity boost just by switching to Scala. Scala is also very stable and it's extremely easy to call Java code from your Scala code. Not only that but it's quite similar to Java but with some added features. For some examples you should refer to 5 Things a Java developer needs to know about Scala. Twitter will move part of it's codebase to Scala. You will never "get stuck" on a piece of code because you can just think about how you would do it in Java and write similar code. First class functions and actors will give you an even greater productivity boost and are both in Scala. Scala is of course statically typed and has a performance that is similar to Java. I will quote the author of the Lift framework for an description of it: Lift borrows from the best of existing frameworks, providing Seaside's highly granular sessions and security Rails fast flash-to-bang Django's "more than just CRUD is included" Wicket's designer-friendly templating style (see Lift View First) And because Lift applications are written in Scala, an elegant new JVM language, you can still use your favorite Java libraries and deploy to your favorite Servlet Container. Use the code you've already written and deploy to the container you've already configured!
type: Answer
answers question: http://stackoverflow.com/q/645746

http://stackoverflow.com/comment/1833736
has text: Here's a link to all of the JBoss DTDs: http://community.jboss.org/wiki/JBossDTDs
comment on: http://stackoverflow.com/a/534333
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/644719
answers question: http://stackoverflow.com/q/642897
upvote count: 279
has comment: http://stackoverflow.com/comment/34388169
score: 272
has comment: http://stackoverflow.com/comment/109461841
downvote count: 7
has comment: http://stackoverflow.com/comment/64942246
has comment: http://stackoverflow.com/comment/64939980
has comment: http://stackoverflow.com/comment/94270398
type: AcceptedAnswer
has body: You could use commons lang's ArrayUtils. array = ArrayUtils.removeElement(array, element) commons.apache.org library:Javadocs
has comment: http://stackoverflow.com/comment/84683298
accepted answer of: http://stackoverflow.com/q/642897
type: Answer
has comment: http://stackoverflow.com/comment/84648374
has comment: http://stackoverflow.com/comment/34357621

soa
type: Tag
tags question: http://stackoverflow.com/q/564153
tag name: soa
tags question: http://stackoverflow.com/q/432461

http://stackoverflow.com/comment/50631016
type: Comment
has text: @Hardcoded Sure, you can (and should) make it transient and get a slightly smaller serialized form.
type: AnswerComment
comment on: http://stackoverflow.com/a/390739
score: 0

http://stackoverflow.com/a/15139370
upvote count: 5
score: 5
downvote count: 0
has body: Here is a method to obtain the current file name (as a String). In your property change listener for JFileChooser.FILE_FILTER_CHANGED_PROPERTY, you make the following call: final JFileChooser fileChooser = new JFileChooser(); fileChooser.addPropertyChangeListener(JFileChooser.FILE_FILTER_CHANGED_PROPERTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { String currentName = ((BasicFileChooserUI)fileChooser.getUI()).getFileName(); MyFileFilter filter = (MyFileFilter) e.getNewValue(); // ... Transform currentName as you see fit using the newly selected filter. // Suppose the result is in newName ... fileChooser.setSelectedFile(new File(newName)); } }); The getFileName() method of javax.swing.plaf.basic.BasicFileChooserUI (the descendant of FileChooserUI returned by JFileChooser.getUI()) will return the contents of the dialog's text box that is used to type in the file name. It seems that this value is always set to a non-null String (it returns an empty string if the box is empty). On the other hand, getSelectedFile() returns null if the user has not selected an existing file yet. It seems that the dialog's design is governed by the 'file selection' concept; that is, while the dialog is visible getSelectedFile() only returns a meaningful value if the user has already selected an existing file or the program called setSelectedFile(). getSelectedFile() will return what the user typed in after the user clicks the approve (i.e. OK) button. The technique will only work for single-selection dialogs, however changing file extension based on selected filter should also make sense for single files only ("Save As..." dialogs or similar). This design was a subject of a debate at sun.com back in 2003, see the link for details.
type: Answer
answers question: http://stackoverflow.com/q/596429

http://stackoverflow.com/a/498532
score: 0
has body: If you go to http://www.stripclubcity.com/ or more specifically http://www.stripclubcity.com/new-jersey-strip-clubs they are using Red5 to stream their cams. I think I read that it's so much easier to use Red5 than it is to write your own AMF... Why reinvent the wheel?
type: Answer
answers question: http://stackoverflow.com/q/374445

http://stackoverflow.com/comment/50979503
has text: simple maths http://stackoverflow.com/a/5220597/185022 :)
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/493494

http://stackoverflow.com/a/461977
type: Answer
answers question: http://stackoverflow.com/q/461896
downvote count: 2
upvote count: 39
has comment: http://stackoverflow.com/comment/280620
score: 37
has body: Though probably not exactly what you are asking for, the most frequent concurrency-related problem I've encountered (probably because it comes up in normal single-threaded code) is a java.util.ConcurrentModificationException caused by things like: List&lt;String&gt; list = new ArrayList&lt;String&gt;(Arrays.asList("a", "b", "c")); for (String string : list) { list.remove(string); }

http://stackoverflow.com/a/505104
has body: This is the reason why Factory Patterns and other creational patterns are so popular in Java. You are correct that without them Java doesn't provide an out of the box mechanism for easy abstraction of instantiation. Still, you get abstraction everywhere where you don't create an object in your method, which should be most of your code. As an aside, I generally encourage people to not follow the "IRealname" mechanism for naming interfaces. That's a Windows/COM thing that puts one foot in the grave of Hungarian notation and really isn't necessary (Java is already strongly typed, and the whole point of having interfaces is to have them as largely indistinguishable from class types as possible).
upvote count: 3
answers question: http://stackoverflow.com/q/504904
type: Answer
score: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/324827

http://stackoverflow.com/a/7643781
type: Answer
upvote count: 6
has comment: http://stackoverflow.com/comment/25608500
downvote count: 1
has comment: http://stackoverflow.com/comment/15163045
has body: I'm the author of la4j (Linear Algebra for Java) library and here is my point. I've been working on la4j for 3 years (the latest release is 0.4.0 [01 Jun 2013]) and only now I can start doing performace analysis and optimizations since I've just covered the minimal required functional. So, la4j isn't as fast as I wanted but I'm spending loads of my time to change it. I'm currently in the middle of porting new version of la4j to JMatBench platform. I hope new version will show better performance then previous one since there are several improvement I made in la4j such as much faster internal matrix format, unsafe accessors and fast blocking algorithm for matrix multiplications.
score: 5
answers question: http://stackoverflow.com/q/529457

http://stackoverflow.com/a/388479
type: Answer
answers question: http://stackoverflow.com/q/388461
score: 22
has body: Besides Apache Commons, also see String.format which should be able to take care of simple padding (e.g. with spaces).
upvote count: 22
downvote count: 0

http://stackoverflow.com/comment/414586
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/601529
has text: That's not physics: no gravity, no elasticity, etc. Fun to do as a starter, but limited.

http://stackoverflow.com/q/643659
possible better answer: http://stackoverflow.com/a/5042831
has body: I am copying an example from XSLT Cookbook: 2nd Edition (O'Reilly: Mangano, 2006) where Mangano creates a tree diagram with SVG. As a way to quickly test this code, I am simply transforming the XML using JSTL's &lt;x:transform/&gt; tag, and running it in Jetty 6. The XSLT seems to be getting hung on calling java:java.lang.Math:max, saying: ERROR: 'Cannot find external method 'max' (must be public).' FATAL ERROR: 'Could not compile stylesheet' The code that gives me the error is contained in here where ...Math:max(... is called: &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xsl:stylesheet version="1.1" xmlns:emath="http://www.exslt.org/math" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tree="http://www.ora.com/XSLTCookboox/ns/tree" xmlns:xalan="http://xml.apache.org/xslt" xmlns:Math="xalan:java.lang.Math"&gt; ... &lt;!--Pass 1 copies input with added bookkeeping attributes --&gt; &lt;xsl:variable name="treeWithLayout"&gt; &lt;xsl:apply-templates mode="layout"/&gt; &lt;/xsl:variable&gt; &lt;xsl:variable name="maxPos" select="Math:max($treeWithLayout/*/@tree:WEIGHT * ($nodeWidth + $horzSpace), $treeWithLayout/*/@tree:MAXDEPTH * ($nodeHeight + $vertSpace))"/&gt; ...
has answer: http://stackoverflow.com/a/5042831
answer count: 2
tagged with: jstl
accepted answer: http://stackoverflow.com/a/643816
downvote count: 0
favorite count: 0
tagged with: http://stackoverflow.com/tag/xml
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/643816
upvote count: 1
has title: XSLT/Java: ERROR: 'Cannot find external method 'max' (must be public).'
type: Question
has comment: http://stackoverflow.com/comment/457989
tagged with: xslt
tagged with: transform
type: AnsweredQuestion

http://stackoverflow.com/comment/20855381
comment on: http://stackoverflow.com/a/501309
score: 3
type: AnswerComment
has text: They could just disallow using two catch blocks with the same type together. So that using SomeExc<Integer> alone would be legal, only using SomeExc<Integer> and SomeExc<String> together would be illegal. That would make no problems, or would it?
type: Comment

http://stackoverflow.com/comment/35675677
score: 0
type: Comment
has text: Things only get messy with types 32 bits or bigger. I see no reason Java shouldn't have had `byte` be signed as it was in Pascal.
comment on: http://stackoverflow.com/a/430389
type: AnswerComment

http://stackoverflow.com/q/427447
has answer: http://stackoverflow.com/a/517493
type: AnsweredQuestion
tagged with: orm
type: Question
accepted answer: http://stackoverflow.com/a/7308668
tagged with: java
has body: Let say there is a table: TableA:Field1, Field2, Field3 and associated JPA entity class @Entity @Table(name="TableA") public class TableA{ @Id @Column(name="Field1") private Long id; @Column(name="Field2") private Long field2; @Column(name="Field3") private Long field3; //... more associated getter and setter... } Is there any way to construct a JPQL statement that loosely translated to this SQL, ie how to translated the case expression to JPQL? select field1, case when field2 = 1 then 'One' when field2 = 2 then 'Two' else 'Other number' end, field3 from tableA;
answer count: 3
has title: Is there such thing CASE expression in JPQL?
tagged with: jpa
upvote count: 55
downvote count: 0
favorite count: 0
possible better answer: http://stackoverflow.com/a/2318281
score: 55
has answer: http://stackoverflow.com/a/2318281
tagged with: oracle-database
has answer: http://stackoverflow.com/a/7308668
linked to: http://stackoverflow.com/q/51565156

http://stackoverflow.com/a/5342096
type: Answer
has comment: http://stackoverflow.com/comment/58567430
has comment: http://stackoverflow.com/comment/47047096
has comment: http://stackoverflow.com/comment/58567599
has body: I have implemented another solution to the problem, I found it more efficient in counting rows: try ( FileReader input = new FileReader("input.txt"); LineNumberReader count = new LineNumberReader(input); ) { while (count.skip(Long.MAX_VALUE) &gt; 0) { // Loop just in case the file is &gt; Long.MAX_VALUE or skip() decides to not read the entire file } result = count.getLineNumber() + 1; // +1 because line index starts at 0 }
score: 201
downvote count: 5
has comment: http://stackoverflow.com/comment/58569307
answers question: http://stackoverflow.com/q/453018
upvote count: 206
has comment: http://stackoverflow.com/comment/71152738

permissions
tag name: permissions
type: Tag
tags question: http://stackoverflow.com/q/571783
tags question: http://stackoverflow.com/q/620153
tags question: http://stackoverflow.com/q/601294
tags question: http://stackoverflow.com/q/581655
tags question: http://stackoverflow.com/q/459622

http://stackoverflow.com/a/529499
answers question: http://stackoverflow.com/q/529474
upvote count: 2
type: Answer
downvote count: 1
score: 1
has body: When run from the command line, using a dot at the start of a script indicates that the script should be run in the current environment, instead of spawning a new subshell and using a new copy of the current environment. This allows you to export a new value of an environment variable to be used by commands run later from the same interactive shell. Obviously, this technique only works if you are running your batchstart.sh script from an actual shell. Java does not know how this mechanism works and so the dot means nothing to it. A script cannot modify the environment of the Java process it was called from. If your goal is to change the value of the DISPLAY environment variable for other commands run by your Java process, consider using the ProcessBuilder class to specify a new environment for the child process. Java does not contain a built-in way to modify variables in its own environment.

http://stackoverflow.com/a/9639416
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/406963
downvote count: 0
has body: I found this during research for a gwt app, and even though this is an old thread thought i would post a method to run an applet inside of gwt. First create two distinct projects, one for your applet and one for gwt. make your applet as normal. jar your applet. then SIGN your .jar with jarsigner. create your gwt modules as normal. to embed the applet I use a gwt HTML object with an applet tag like this: (applet MAYSCRIPT code = 'com.myapplet.MyApplet' id ='myApplet' jnlp_href = '/spplets/MyApplet.jnlp', width=500, height=400)(/applet) Simply add the HTML widget to a contentPanel and the gui part is done. The applet .jar will need to go in the /war for your gwt project. Along with the .jar you will need to write a .jnlp file to launch the applet. This will embed an applet in gwt and run it in hosted or production mode. The key is to SIGN your .JAR and launch it with .JNLP
type: Answer

http://stackoverflow.com/a/563362
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/374834
has comment: http://stackoverflow.com/comment/374900
answers question: http://stackoverflow.com/q/563237
has comment: http://stackoverflow.com/comment/374704
upvote count: 1
has body: If you are stroking (as it looks like you are from your snippet), you might want to also try: g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
has comment: http://stackoverflow.com/comment/375141
type: Answer

http://stackoverflow.com/comment/385929
score: 0
has text: I think I used a misleading title. I can see why you'd need this method (i.e. for cleanup), but I was more asking about this specific case.
comment on: http://stackoverflow.com/a/574084
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/60625114
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/454919
has text: This answer is exactly correct. One little suggestion would be that it might be helpful to add _why_ it gets rid of the empty lines for people that might not be as familiar with regex and how it behaves. For anybody that might be wondering, it's because the "+" is a greedy operator and will match at least one but will continue to match the '\r\n' characters until it no longer can match them. See here: http://www.regular-expressions.info/repeat.html#greedy

http://stackoverflow.com/a/517955
has comment: http://stackoverflow.com/comment/111251978
has comment: http://stackoverflow.com/comment/34205871
downvote count: 0
score: 72
has comment: http://stackoverflow.com/comment/95117565
upvote count: 72
type: Answer
answers question: http://stackoverflow.com/q/517915
has body: Actually, there's a good Wikipedia article about strictfp, with a link to the Java specification's section on Floating-Point Types, Formats, and Values. Reading between the lines, the implication is that if you don't specify strictfp, then the JVM and JIT compiler have license to compute your floating-point calculations however they want. In the interest of speed, they will most likely delegate the computation to your processor. With strictfp on, the computations have to conform to IEEE 754 arithmetic standards, which, in practice, probably means that the JVM will do the computation. So why would you want to use strictfp? One scenario I can see is in a distributed application (or multiplayer game) where all floating-point calculations need to be deterministic no matter what the underlying hardware or CPU is. What's the trade-off? Most likely execution time.

http://stackoverflow.com/a/639739
type: Answer
answers question: http://stackoverflow.com/q/639592
downvote count: 1
score: 7
has body: As devinb and others mention, it sounds like the interviewer shows their ignorance in not accepting your valid answers. However, the mention of JDBC might be a hint. In that case, perhaps they are asking for the benefits of a client coding against an interface instead of a class. So instead of perfectly valid answers such as "you only get one use of inheritance", which are relating to class design, they may be looking for an answer more like "decouples a client from a specific implementation".
upvote count: 8

http://stackoverflow.com/comment/6824305
comment on: http://stackoverflow.com/a/2889822
type: Comment
score: 21
has text: Hate to say this, but this is some of the worst C# code I've ever seen. `empty = !(full = false);` wtf? `begin = end = 0xA2;` magic number FTL. Write-only properties are a wtf in themselves, write-only properties called `write` are doubly-so because imagine using it like this `myqueue.write = someObj`. Why on earth is `read` a property instead of vanilla function? And the `queueSize` function is beyond convoluted. This would make a cute entry in an obfuscated C# competition, but would likely get you fired if used in production.
type: AnswerComment

http://stackoverflow.com/q/377865
downvote count: 0
tagged with: java
tagged with: jaxb
upvote count: 8
type: Question
has answer: http://stackoverflow.com/a/670410
tagged with: race-condition
has answer: http://stackoverflow.com/a/5081373
has answer: http://stackoverflow.com/a/8803691
tagged with: unmarshalling
has title: Intermittent ClassCastException from ElementNSImpl to own type during unmarshalling
favorite count: 0
score: 8
possible better answer: http://stackoverflow.com/a/670410
tagged with: exception
has answer: http://stackoverflow.com/a/1158738
accepted answer: http://stackoverflow.com/a/1158738
answer count: 4
has body: We are experiencing an exceedingly hard to track down issue where we are seeing ClassCastExceptions sometimes when trying to iterate over a list of unmarshalled objects. The important bit is sometimes, after a reboot the particular code works fine. This seems to point in the direction of concurrency/timing/race condition. I can confirm that neither the JAXBContext, nor the marshallers and unmarshallers are being used concurrently. We've gone as far as serializing access to them through locking. However, since we run on an OSGi platform where individual bundles are getting initialized asynchronously through Spring DM it can be that 2 different bundles are creating their JAXBContext at the same time. In any case I would appreciate any pointers towards an explanation for what could cause these intermittent ClassCastExceptions. The intermittent is important since they indicate that the code itself is normally working fine but that some external factor seems to influence the behaviour. Here's a specific example of the exception (note I removed the company specific stuff): Caused by: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to com.foobar.TunnelType at com.foobar.NetMonitorImpl.getVpnStatus(NetMonitorImpl.java:180) That method at line 180 is a for() construct looping over a Collection of TunnelType objects inside of an unmarshalled object (said unmarshalling works fine BTW). Given that the actual object unmarshalling went fine, is it even physically possible for JAXB to leave ElementNSImpl objects inside of nested collections? Runtime environment: JAXB 2.1 OSGi Spring DM The JAXBContext is initialised with the ClassLoader of the bundle containing the classes to be marshalled/unmarshalled
type: AnsweredQuestion

http://stackoverflow.com/comment/376208
has text: I see what you mean about "starting", but given that we assumed that download speeds were fast, how is this any different at all than "starting" a webpage by "clicking" on a link? It's the same thing, surely, i.e. a link on a page.
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/564985

http://stackoverflow.com/a/620543
downvote count: 0
answers question: http://stackoverflow.com/q/620509
has body: If you would like to pass in a variety of objects with testing() methods, have each object implement a Testable interface: public interface Testable { public void testing() } Then have myMethod() take a Testable. public static void myMethod(Testable testable) { testable.testing(); } Edit: To clarify, implementing an interface means that the class is guaranteed to have the method, but the method can do whatever it wants. So I could have two classes whose testing() methods do different things. public class AClass implements Testable { public void testing() { System.out.println("Hello world"); } } public class BClass implements Testable { public void testing() { System.out.println("Hello underworld"); } }
has comment: http://stackoverflow.com/comment/433467
accepted answer of: http://stackoverflow.com/q/620509
has comment: http://stackoverflow.com/comment/433483
has comment: http://stackoverflow.com/comment/433471
score: 20
has comment: http://stackoverflow.com/comment/433560
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/433530
upvote count: 20
type: Answer
has comment: http://stackoverflow.com/comment/433479

http://stackoverflow.com/a/565237
upvote count: 3
downvote count: 1
answers question: http://stackoverflow.com/q/564320
has body: Three points that completely fail to answer the question: null is evil. Don't write methods that return it. Your example problem would then disappear. I think you might be missing out on encapsulation. Instead of foo.getBar() could the interface of foo be made such that you perform a "tell don't ask" operation? Side-effects in expression tends to cause bad code. Prefer more, simpler lines to fewer, buggy lines. The usual exception if using ++ to increment an index when accessing a buffer, or similar iterator style algorithms.
type: Answer
score: 2

http://stackoverflow.com/a/449415
upvote count: 3
answers question: http://stackoverflow.com/q/448471
downvote count: 0
type: Answer
score: 3
has body: I struggled a bit with this exact issue. It's so abstract and simple I was always worried I was "doing it wrong". I've had been using it in the main project which has dependencies on other projects because the Guice module which sets the bindings was part of the main project. I finally realized the libraries should be supplying the Modules themselves. At that point you can depend only on an instance of a Module (not a specific one), and the interfaces that are bound by it. Taking it one step better, you can use the new ServiceLoader mechanism in Java 6 to automatically locate and install all Guice modules available on the classpath. Then you can swap in dependencies just by changing class path (db-real.jar vs. db-mock.jar).

http://stackoverflow.com/comment/290007
type: Comment
comment on: http://stackoverflow.com/q/472347
type: QuestionComment
has text: What are some of the stats of your current build process?
score: 0

http://stackoverflow.com/q/413214
type: Question
answer count: 8
tagged with: testing
has answer: http://stackoverflow.com/a/413331
has answer: http://stackoverflow.com/a/413282
score: 53
linked to: http://stackoverflow.com/q/1293880
has title: Is it possible to run JUnit tests from multiple packages in Eclipse?
upvote count: 53
tagged with: junit
downvote count: 0
has answer: http://stackoverflow.com/a/74900186
has answer: http://stackoverflow.com/a/13519526
favorite count: 0
has answer: http://stackoverflow.com/a/413289
has answer: http://stackoverflow.com/a/17450919
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/10880892
has answer: http://stackoverflow.com/a/413281
has body: Is it possible to run JUnit tests for multiple packages at the same time without manually creating test suites. For example if I have the hierarchy: code.branchone code.branchone.aaa code.branchone.bbb code.branchtwo code.branchtwo.aaa code.branchtwo.bbb Is it possible to: Run all tests in code.branchone and in descendent packages Run all tests in say code.branchone.aaa and code.branchtwo.bbb The problem I see with manually creating test suites is that when new tests come along you may forget to add them.
tagged with: java
has answer: http://stackoverflow.com/a/14923130
has comment: http://stackoverflow.com/comment/10880693
tagged with: eclipse
has comment: http://stackoverflow.com/comment/10880759

http://stackoverflow.com/a/579946
has comment: http://stackoverflow.com/comment/391914
has comment: http://stackoverflow.com/comment/412379
downvote count: 0
has comment: http://stackoverflow.com/comment/391957
answers question: http://stackoverflow.com/q/579925
has comment: http://stackoverflow.com/comment/392968
score: 9
has comment: http://stackoverflow.com/comment/391889
has comment: http://stackoverflow.com/comment/393302
has body: If you're not concerned about the randomness, you can just decrement a counter, like this: private final AtomicInteger ai=new AtomicInteger(0); public int nextID() { return ai.addAndGet(-1); } Edit: For random numbers, you can just use your solution and use eg. ConcurrentHashMap or ConcurrentSkipListSet instead of the synchronizedSet. You have to ensure that different threads use different instances of the random generator, and that these generators are not correlated.
has comment: http://stackoverflow.com/comment/391900
has comment: http://stackoverflow.com/comment/392092
upvote count: 9
type: Answer

http://stackoverflow.com/a/435162
downvote count: 0
answers question: http://stackoverflow.com/q/432461
upvote count: 2
type: Answer
score: 2
has body: For contract first I'd recommend using JAX-WS. Either CXF, JAX-WS RI or Metro (Metro = JAX-WS RI + WSIT) seem to be the best implementations around that can take any WSDL contract and generate the POJOs (or vice versa).

http://stackoverflow.com/comment/15119666
has text: @LicenseQ: I don't know if this statement was correct at the time you wrote it, but it's not correct for any recent release of Java. The implementation of String.substring is smarter than that: it does not copy the character buffer of the original string, it simply creates a new String object pointing to the same buffer and uses a nonzero "offset" field to indicate that the string doesn't start from the beginning of the buffer. Substring allocates a String object containing three ints (count, hash and offset) and a reference to the pre-existing buffer, nothing more.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/523881

http://stackoverflow.com/a/594756
upvote count: 5
downvote count: 0
answers question: http://stackoverflow.com/q/594722
type: Answer
score: 5
has body: First of all make it a well written application. In my experience most of the performance benefits will come not doing stupid things, rather than doing clever optimisations. When you have a well written application, then is the time to run a profiler and optimise only that which matters.

http://stackoverflow.com/comment/99210371
type: Comment
has text: Even text that is not part of the link can be clicked to follow the link.
score: 2
comment on: http://stackoverflow.com/a/527877
type: AnswerComment

http://stackoverflow.com/comment/387808
comment on: http://stackoverflow.com/q/567851
score: 0
type: QuestionComment
has text: Better build a real parser than this regex pseudo parser. At least when you want nested lists you will see that regular expressions are not the answer to every question.
type: Comment

http://stackoverflow.com/comment/15533923
score: 0
has text: Answer is no, see details here: http://tshikatshikaaa.blogspot.nl/2012/07/about-using-systemexit-in-try-catch.html
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/516049

http://stackoverflow.com/a/442773
downvote count: 4
answers question: http://stackoverflow.com/q/442747
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/22834889
has comment: http://stackoverflow.com/comment/420025
accepted answer of: http://stackoverflow.com/q/442747
upvote count: 212
score: 208
has comment: http://stackoverflow.com/comment/25452125
type: Answer
has comment: http://stackoverflow.com/comment/9926484
has body: Thread.currentThread().getStackTrace() will usually contain the method you’re calling it from but there are pitfalls (see Javadoc): Some virtual machines may, under some circumstances, omit one or more stack frames from the stack trace. In the extreme case, a virtual machine that has no stack trace information concerning this thread is permitted to return a zero-length array from this method.

http://stackoverflow.com/a/645852
has comment: http://stackoverflow.com/comment/79100625
type: Answer
has body: AFAIK, there isn't a native way. But check out the article Powerful Groovy on how you'd add a .zip(...) method to File, which would be very close to what you're looking for. You'd just need to make an .unzip(...) method.
upvote count: 6
accepted answer of: http://stackoverflow.com/q/645847
downvote count: 1
answers question: http://stackoverflow.com/q/645847
score: 5
type: AcceptedAnswer

http://stackoverflow.com/a/531298
upvote count: 4
downvote count: 0
has body: Take a look at this SO question. Even though the other one is for C++, the concepts are still very similar.
score: 4
answers question: http://stackoverflow.com/q/531282
type: Answer

persistence
tags question: http://stackoverflow.com/q/529729
tags question: http://stackoverflow.com/q/454294
tags question: http://stackoverflow.com/q/594613
tags question: http://stackoverflow.com/q/616012
tags question: http://stackoverflow.com/q/516364
tags question: http://stackoverflow.com/q/449336
tags question: http://stackoverflow.com/q/388206
tags question: http://stackoverflow.com/q/374886
tags question: http://stackoverflow.com/q/585454
tags question: http://stackoverflow.com/q/472377
tag name: persistence
type: Tag
tags question: http://stackoverflow.com/q/424341
tags question: http://stackoverflow.com/q/418146
tags question: http://stackoverflow.com/q/492096
tags question: http://stackoverflow.com/q/450864
tags question: http://stackoverflow.com/q/639077
tags question: http://stackoverflow.com/q/443558
tags question: http://stackoverflow.com/q/589732

http://stackoverflow.com/comment/25373255
type: AnswerComment
comment on: http://stackoverflow.com/a/386082
type: Comment
score: 1
has text: FYI: This answer is still correct for JUnit 4.0, but fortunately adding customized names is possible in JUnit 4.11. See http://stackoverflow.com/a/10143872/103814

http://stackoverflow.com/comment/5970781
has text: Sorry to bump a very old topic here, but I keep getting an `EXCEPTION_ACCESS_VIOLATION` in `jvm.dll` whenever I try to get the drawing surface (`GetDrawingSurface`) of a component (in my case a `java.awt.Cavas`). I made sure it is _not_ lightweight and it is already visible on the screen. Has anything changed in Java 1.6 or is there anything else you need to do before you can get the drawing surface?
type: Comment
comment on: http://stackoverflow.com/a/413895
score: 0
type: AnswerComment

http://stackoverflow.com/comment/3693991
comment on: http://stackoverflow.com/a/602923
has text: Link should be http://docs.jboss.org/hibernate/core/3.3/reference/en/html/mapping.html#mapping-declaration-compositeid
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/13254712
type: Comment
has text: See this thread http://stackoverflow.com/questions/174171/including-non-java-sources-in-a-maven-project
comment on: http://stackoverflow.com/q/606062
score: 0
type: QuestionComment

http://stackoverflow.com/comment/18186376
type: AnswerComment
has text: This helped me :) for MAC OSX
score: 0
type: Comment
comment on: http://stackoverflow.com/a/1619098

http://stackoverflow.com/comment/123885505
score: 2
comment on: http://stackoverflow.com/q/496928
has text: To counter what @JérômeVerstrynge suggested: *The instanceof construction is a preferred way to check whether a variable can be cast to some type statically* because a compile-time error will occur in case of incompatible types. The method isInstance() from java.lang.Class works differently and does type check at runtime only, incompatible types will therefore not be detected early in the development, potentially resulting in dead code. The isInstance() method should only be used in dynamic cases when the instanceof operator can’t be used.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/437841
comment on: http://stackoverflow.com/a/624976
score: 0
type: AnswerComment
type: Comment
has text: This is so true.. I remember when my internet connection was still an expensive dial-up (which gives away my age...) I copied the jdk's bin dir from a friend on 1.44 diskettes! And of course it worked perfectly =8-)

http://stackoverflow.com/a/491589
score: 4
type: Answer
upvote count: 4
answers question: http://stackoverflow.com/q/479855
downvote count: 0
has body: Found out that Spring Modules provide integration between Spring and Commons Configuration, which has a hierarchial XML configuration style. This ties straight into PropertyPlaceholderConfigurer, which is exactly what I wanted.

http://stackoverflow.com/q/554769
tagged with: sorting
has answer: http://stackoverflow.com/a/554804
has answer: http://stackoverflow.com/a/554820
has title: Alphabetically Sort a Java Collection based upon the 'toString' value of its member items
downvote count: 0
possible better answer: http://stackoverflow.com/a/554804
score: 28
favorite count: 0
accepted answer: http://stackoverflow.com/a/554777
upvote count: 28
has answer: http://stackoverflow.com/a/554793
has body: Assume I have a user defined Java class called Foo such as: public class Foo { private String aField; @Override public String toString() { return aField; } } And a Collection such as: List&lt;Foo&gt; aList; What I am looking to do is to sort the List alphabetically based upon each member's returned '.toString()' value. I have tried using the Collections.sort() method, but the result was not what I was attempting. What do I need to do inorder to accomplish this?
has answer: http://stackoverflow.com/a/554799
answer count: 10
has answer: http://stackoverflow.com/a/57933318
has answer: http://stackoverflow.com/a/1385758
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/554821
tagged with: collections
type: Question
has answer: http://stackoverflow.com/a/1387093
has answer: http://stackoverflow.com/a/554777
has answer: http://stackoverflow.com/a/41022218

http://stackoverflow.com/comment/211310
score: 9
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/383554
has text: Care to point to some docs? I find it hard to believe that the size of a boolean is machine dependant. That would mean that the binary representation of a class containing a boolean would have different sizes (and memory layouts) in different VM and that would imply that VMs would not be compatible.

http://stackoverflow.com/a/544431
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/544049
downvote count: 0
has comment: http://stackoverflow.com/comment/4178692
accepted answer of: http://stackoverflow.com/q/544049
has comment: http://stackoverflow.com/comment/2271989
type: Answer
upvote count: 29
has comment: http://stackoverflow.com/comment/135438270
has comment: http://stackoverflow.com/comment/359125
score: 29
has body: Advantages that often get touted in circles I frequent are: Your html can be fully xhtml compliant - there is a VERY nice separation of presentation and logic in that the only thing your presentation/html layer needs to know about wicket are wicketid attributes in standard html tags. This is wonderful for the html/css/javascript client side guy on your team who does little to no actual java work. No other java based web framework can claim this, afaik. No xml config for anything wicket specific - everything can be done in source and very little needs to be done to the standard web.xml for your .war component based development is pretty easy to grok - especially if you have a non web background (e.g. a swing programmer). it encourages reuse quite a bit more than mvc does, imo.

http://stackoverflow.com/a/539426
answers question: http://stackoverflow.com/q/538870
type: Answer
upvote count: 13
has body: One reason you might want to declare static helper methods is if you need to call them in the class constructor "before" this or super. For example: public class MyClass extends SomeOtherClass { public MyClass(String arg) { super(recoverInt(arg)); } private static int recoverInt(String arg) { return Integer.parseInt(arg.substring(arg.length() - 1)); } } This is a bit of a contrived example but clearly recoverInt cannot be an instance method in this case.
downvote count: 1
score: 12
has comment: http://stackoverflow.com/comment/352403

http://stackoverflow.com/q/479762
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/510457
has answer: http://stackoverflow.com/a/510489
tagged with: java
has answer: http://stackoverflow.com/a/479772
has answer: http://stackoverflow.com/a/515040
tagged with: filesystems
has body: I am writing a little program that creates an index of all files on my directories. It basically iterates over each file on the disk and stores it into a searchable database, much like Unix's locate. The problem is, that index generation is quite slow since I have about a million files. Once I have generated an index, is there a quick way to find out which files have been added or removed on the disk since the last run? EDIT: I do not want to monitor the file system events. I think the risk is too high to get out of sync, I would much prefer to have something like a quick re-scan that quickly finds where files have been added / removed. Maybe with directory last modified date or something? A Little Benchmark I just made a little benchmark. Running dir /b /s M:\tests\ &gt;c:\out.txt Takes 0.9 seconds and gives me all the information I need. When I use a Java implementation (much like this), it takes about 4.5 seconds. Any ideas how to improve at least this brute force approach? Related posts: How to see if a subfile of a directory has changed
downvote count: 0
has comment: http://stackoverflow.com/comment/325706
favorite count: 0
has answer: http://stackoverflow.com/a/494322
accepted answer: http://stackoverflow.com/a/510489
has comment: http://stackoverflow.com/comment/325787
has answer: http://stackoverflow.com/a/492266
answer count: 10
has answer: http://stackoverflow.com/a/510529
has answer: http://stackoverflow.com/a/492301
has comment: http://stackoverflow.com/comment/325696
upvote count: 11
has answer: http://stackoverflow.com/a/479823
possible better answer: http://stackoverflow.com/a/510529
has answer: http://stackoverflow.com/a/479861
tagged with: file
score: 11
has comment: http://stackoverflow.com/comment/309928
has title: How to quickly find added / removed files?
type: Question

http://stackoverflow.com/a/600214
score: 0
type: Answer
answers question: http://stackoverflow.com/q/596746
has body: mvn site:site should produce what you are after, in the target directory, there will be a site directory containing all reports linked with an index.html in that directory.

http://stackoverflow.com/comment/433560
score: 0
type: Comment
comment on: http://stackoverflow.com/a/620543
has text: No, that just makes them accessible to all other classes. Currently you have them set package-protected, which means they can't be accessed by classes outside their own package.
type: AnswerComment

http://stackoverflow.com/a/571425
upvote count: 9
downvote count: 0
answers question: http://stackoverflow.com/q/571388
score: 9
has body: You can create a sorted collection when iterating but it make more sense to have a sorted map in the first place. (As has already been suggested) All the same, here is how you do it. Map&lt;String, Object&gt; map; for(String key: new TreeSet&lt;String&gt;(map.keySet()) { // accessed in sorted order. }
type: Answer

http://stackoverflow.com/q/522202
type: UnansweredQuestion
has body: I need to serialise a javabean (with arbitrary nested beans) to plain text, and then later restore as an Object graph. For the purposes of this question I am not interested in XML, JSON, etc. but rather name/value pairs. The Spring DataBinder is great for turning a list of name/value pairs into a real Object. For example we can supply: values.addPropertyValue("id", "6789"); values.addPropertyValue("nestedBean[0].systemId", "FOO"); values.addPropertyValue("nestedBean[1].systemId", "BAR"); And use the DataBinder to produce a top level bean (with property id) containing a List of two nested beans. My question is, how can I easily serialise a bean into the format that DataBinder expects? I would expect something of the form: Map&lt;String,String&gt; reduceBeanToNameValuePairs(Object bean) but have had no luck finding anything of the sort.
tagged with: javabeans
tagged with: serialization
type: Question
tagged with: spring
tagged with: properties
score: 0
has answer: http://stackoverflow.com/a/679708
tagged with: java
answer count: 1
has title: How can I serialise a javabean to be loaded by Spring's DataBinder?

http://stackoverflow.com/a/725376
score: 0
answers question: http://stackoverflow.com/q/446694
has body: I use the Jboss Developer Studio (v2.0) and have my project set up to hot-deploy. This means that I don't have restart for any changes aside from Entities, EJBs and Message Bundles. Perfect for mostly POJO projects.
type: Answer

http://stackoverflow.com/comment/126719623
has text: Using generics here, adds no value. Change the method declaration to `public void print(Object data)` and it will still work exactly the same.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/61201924
score: 1

http://stackoverflow.com/a/62802024
answers question: http://stackoverflow.com/q/580085
has comment: http://stackoverflow.com/comment/120648815
type: Answer
has comment: http://stackoverflow.com/comment/119328400
has comment: http://stackoverflow.com/comment/139728856
score: 9
upvote count: 9
has body: @Snowbuilder's answer put me in the right track, however it was mysteriously not working with Oracle JDK 1.8.0_231 (he tested with minor version _144). Even though I was able to update the underlying Map (validated by printing out System.getenv() before and after adding a new property to the Map), the changes were not reflected when the new property was retrieved using System.getenv("property"). After some investigation I found out that's because System.getenv() and System.getenv("property") end up using different static attributes of java.lang.ProcessEnvironment, which are initialized in the class' static block. So it doesn't matter if new properties are added to the Map retrieved using System.getenv(); these properties will not be available in the other Map used by System.getenv("property"). So I changed the code from the other answer to deal with this scenario and came to the code below. Please note this will only work if you retrieve properties using System.getenv("property"); if you use System.getenv().get("property") then his answer is what you need. The usage is as follows: @SuppressWarnings("unchecked") private static Map<String, String> getModifiableEnvironment() throws Exception { Class<?> pe = Class.forName("java.lang.ProcessEnvironment"); Method getenv = pe.getDeclaredMethod("getenv", String.class); getenv.setAccessible(true); Field props = pe.getDeclaredField("theCaseInsensitiveEnvironment"); props.setAccessible(true); return (Map<String, String>) props.get(null); } This method should be used as follows: getModifiableEnvironment().put("propName", "propValue"); System.getenv("propName"); // this will return "propValue"
downvote count: 0

http://stackoverflow.com/comment/101903197
type: Comment
has text: Fun thing is that the `replaceAll` method implicitly does `Pattern.compile(regex).matcher(testString).replaceAll(regexReplacementString)`! So, if you re-use the pattern this way, redundant objects will be avoided. Further, as @MarcelValdezOrozco says, making it static will prevent unnecessary pattern compile invocations. :)
score: 3
type: AnswerComment
comment on: http://stackoverflow.com/a/20096812

http://stackoverflow.com/a/403016
answers question: http://stackoverflow.com/q/402969
has body: I think part of it is the complexity of the languages. C++ is incredibly mutable, with the ability to override pretty much any operator or piece of syntax (like overriding the () operator). This means the compiler has to do a lot more work just to determine what operations to actually run, even for simple things. Java and C# don't have this issue, as the syntax is fixed, and they're generally much simpler to parse.
upvote count: 1
type: Answer
downvote count: 0
score: 1

http://stackoverflow.com/q/456865
accepted answer: http://stackoverflow.com/a/464926
has body: I've created an app that interacts with a SOAP service using java WS. I generate classes and manage the WSDL using the built in netbeans functions. Every time I run the application, it has to download the WSDL and parse it again. The WSDL is frozen at each version so I don't think this is necessary. I've tried to reference it as a local file, but then my app complains it can't find the file when it's installed on another machine. Does anyone know how I can stop Java WS needing to re-parse the WSDL, or at least cache it locally?
type: AnsweredQuestion
tagged with: java
type: Question
upvote count: 4
has title: How to cache a WSDL with Java-WS
has answer: http://stackoverflow.com/a/464926
downvote count: 0
answer count: 1
score: 4
tagged with: java-ws
tagged with: wsdl
favorite count: 0
tagged with: netbeans

http://stackoverflow.com/a/506487
upvote count: 9
type: Answer
downvote count: 0
score: 9
accepted answer of: http://stackoverflow.com/q/407614
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/322780
has body: RMI Hello World looks nice for a start. Of course it's still a simple example, so maybe tips on RMI performance/scalability will be useful since you're already familiar with RMI.
answers question: http://stackoverflow.com/q/407614

http://stackoverflow.com/comment/224237
has text: The real problem we are trying to solve is that once the buffer flushes, we can no longer redirect. This means that 500 errors that occur after the first flush do not get redirected to our 500 page and are not reported as 500s in the access logs.
type: Comment
comment on: http://stackoverflow.com/a/388402
score: 0
type: AnswerComment

http://stackoverflow.com/a/622688
downvote count: 0
type: Answer
has body: You need to place the QWebView in a layout, that it will follow the change in its "container". For using layout with Qt Designer, refer to http://doc.trolltech.com/4.5/designer-layouts.html
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/541802

http://stackoverflow.com/q/468789
tagged with: validation
accepted answer: http://stackoverflow.com/a/468798
answer count: 7
has answer: http://stackoverflow.com/a/6697897
favorite count: 0
score: 95
has answer: http://stackoverflow.com/a/468798
has answer: http://stackoverflow.com/a/469105
has title: Is there a way in Java to determine if a path is valid without attempting to create a file?
has answer: http://stackoverflow.com/a/35452697
type: AnsweredQuestion
has body: I need to determine if a user-supplied string is a valid file path (i.e., if createNewFile() will succeed or throw an Exception) but I don't want to bloat the file system with useless files, created just for validation purposes. Is there a way to determine if the string I have is a valid file path without attempting to create the file? I know the definition of "valid file path" varies depending on the OS, but I was wondering if there was any quick way of accepting C:/foo or /foo and rejecting banana. A possible approach may be attempting to create the file and eventually deleting it if the creation succeeded, but I hope there is a more elegant way of achieving the same result.
tagged with: java
has answer: http://stackoverflow.com/a/55938716
type: Question
linked to: http://stackoverflow.com/q/13924808
has answer: http://stackoverflow.com/a/468845
tagged with: filesystems
has comment: http://stackoverflow.com/comment/58120199
downvote count: 0
has answer: http://stackoverflow.com/a/52823159
possible better answer: http://stackoverflow.com/a/35452697
upvote count: 95

http://stackoverflow.com/comment/95583588
type: Comment
comment on: http://stackoverflow.com/a/10117865
score: 1
has text: @JacobSchoen : The above link does not work anymore as GrepCode is down. Here is the alternative for equals Implementation : [Inline Link] (https://zgrepcode.com/java/openjdk/10.0.2/java.base/java/lang/string.java#L-1000)
type: AnswerComment

http://stackoverflow.com/comment/121364839
type: AnswerComment
comment on: http://stackoverflow.com/a/494921
type: Comment
has text: The option to compact is "compact once". You turn it on and the next blocking Gen2 collection will compact the LOH. Once compacted, the option reverts to off/default.
score: 0

http://stackoverflow.com/q/528917
possible better answer: http://stackoverflow.com/a/528955
type: Question
has body: I've noticed with Integer.parseInt() that you don't have to surround it with a try catch or declare that the method might throw an exception, despite the fact that it "throws" a NumberFormatException. Why don't I have to explicitly catch the NumberFormatException or state that my method throws it?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/528955
has answer: http://stackoverflow.com/a/528942
has title: Why don't you have to explicitly declare that you might throw some built in exceptions in Java?
accepted answer: http://stackoverflow.com/a/528942
has answer: http://stackoverflow.com/a/529305
downvote count: 0
has answer: http://stackoverflow.com/a/528934
favorite count: 0
tagged with: exception
answer count: 4
score: 7
tagged with: java
upvote count: 7

http://stackoverflow.com/a/434731
has comment: http://stackoverflow.com/comment/257702
has comment: http://stackoverflow.com/comment/257627
has comment: http://stackoverflow.com/comment/257628
upvote count: 41
has comment: http://stackoverflow.com/comment/699767
has comment: http://stackoverflow.com/comment/257697
type: Answer
has comment: http://stackoverflow.com/comment/127336614
has comment: http://stackoverflow.com/comment/6379068
downvote count: 3
has body: If you're not too concerned with performance, you could always try listening on a port using the ServerSocket class. If it throws an exception odds are it's being used. public static boolean isAvailable(int portNr) { boolean portFree; try (var ignored = new ServerSocket(portNr)) { portFree = true; } catch (IOException e) { portFree = false; } return portFree; } EDIT: If all you're trying to do is select a free port then new ServerSocket(0) will find one for you.
answers question: http://stackoverflow.com/q/434718
has comment: http://stackoverflow.com/comment/127299688
has comment: http://stackoverflow.com/comment/104304971
has comment: http://stackoverflow.com/comment/701004
score: 38
has comment: http://stackoverflow.com/comment/570009

http://stackoverflow.com/a/406040
accepted answer of: http://stackoverflow.com/q/403583
upvote count: 33
type: Answer
has body: There are two good uses for package level visibility (in my experience): 1) Defining "internal" classes in a public API. Commonly you would define your interfaces and core factories as public and the "internal" implementations as package level. Then the public factories can construct the package level implementation classes and return them as instances of the public interfaces. This nicely allows users to only access the stuff they should. The downside is that you have to have all this stuff in the same package, which almost never is a good idea for any reasonably-sized API. JSR 294/modules/Project Jigsaw in Java 7 will hopefully provide an alternative by specifying a new visibility modifier (module) that can be used to access classes within a module across packages without making them visible outside the module. You can find an example of how this would work in this article. 2) Unit testing is the other common use case. Frequently you'll see a src tree and a test tree and stuff that would otherwise be private is instead package level so that unit tests in the same (parallel) package are able to access otherwise hidden methods to check or manipulate state.
downvote count: 0
score: 33
answers question: http://stackoverflow.com/q/403583
has comment: http://stackoverflow.com/comment/131990553
type: AcceptedAnswer

http://stackoverflow.com/comment/389486
has text: I needed a Java only solution. I've tried this with Groovy as well and, while the code is much more compact, this isn't as nice. I'm a huge fan of Groovy but I feel that 1.x is still a little bit ... "incomplete".
comment on: http://stackoverflow.com/a/577007
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/257768
has text: Could you please improve your formatting and actually ask a question? It seems you already solved your problem.
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/434865

http://stackoverflow.com/comment/35356806
type: QuestionComment
comment on: http://stackoverflow.com/q/527703
score: 0
type: Comment
has text: Note that if your application is [for public consumption, using the Google Finance API is against Google's terms of service](https://groups.google.com/d/msg/google-finance-apis/O8fjsgnamHE/-ZKSjif4yDIJ). @timmyc: the `&client` parameter isn't necessary. http://finance.google.com/finance/info?q=NASDAQ%3aMSFT works.

http://stackoverflow.com/a/667272
type: Answer
upvote count: 0
score: -1
downvote count: 1
answers question: http://stackoverflow.com/q/600907
has body: Make sure you have the correct file name/path. Make sure you have file access to the file system.

http://stackoverflow.com/comment/49698312
has text: I used this lib but i don't understand how it is doing it. I get some unloaded classes and it don't load them either. just return classes without loading them. How it is possible?
type: Comment
comment on: http://stackoverflow.com/a/9571146
score: 0
type: AnswerComment

http://stackoverflow.com/a/417197
has body: I think your only option is to wrap java in a script that substitutes the environment variables into the command line
answers question: http://stackoverflow.com/q/417152
upvote count: 4
downvote count: 0
score: 4
type: Answer

http://stackoverflow.com/q/579600
tagged with: java
upvote count: 41
answer count: 1
has body: I need to put the contents of a java.nio.ByteBuffer into an java.io.OutputStream. (wish I had a Channel instead but I don't) What's the best way to do this? I can't use the ByteBuffer's array() method since it can be a read-only buffer. I also may be interspersing writes to the OutputStream between using this ByteBuffer and having a regular array of byte[] which I can with use OutputStream.write() directly.
has answer: http://stackoverflow.com/a/579616
accepted answer: http://stackoverflow.com/a/579616
has title: How to put the content of a ByteBuffer into an OutputStream?
tagged with: bytebuffer
favorite count: 0
tagged with: outputstream
type: AnsweredQuestion
score: 41
downvote count: 0
type: Question

http://stackoverflow.com/a/38319186
upvote count: 1
score: 1
has body: For the specific case where you know the data will not have nulls (always a good idea for strings) and the data is really large, you are still doing three comparisons before actually comparing the values, if you know for sure this is your case, you can optimize a tad bit. YMMV as readable code trumps minor optimization: if(o1.name != null &amp;&amp; o2.name != null){ return o1.name.compareToIgnoreCase(o2.name); } // at least one is null return (o1.name == o2.name) ? 0 : (o1.name != null ? 1 : -1);
answers question: http://stackoverflow.com/q/481813
downvote count: 0
type: Answer

http://stackoverflow.com/q/500637
tagged with: java
has answer: http://stackoverflow.com/a/500843
has answer: http://stackoverflow.com/a/5291597
upvote count: 42
type: Question
tagged with: dependency-injection
linked to: http://stackoverflow.com/q/420732
has answer: http://stackoverflow.com/a/3365417
downvote count: 0
linked to: http://stackoverflow.com/q/131975
has answer: http://stackoverflow.com/a/500641
has answer: http://stackoverflow.com/a/500715
score: 42
has answer: http://stackoverflow.com/a/501162
has answer: http://stackoverflow.com/a/501324
has answer: http://stackoverflow.com/a/501189
has answer: http://stackoverflow.com/a/500755
favorite count: 0
answer count: 12
has comment: http://stackoverflow.com/comment/38148414
type: UnansweredQuestion
has title: Understanding the need for a DI framework
has body: This might be a naive question. I'm currently learning the Spring framework and dependency injection. While the basic principle of DI is rather easy to grasp, it's not immediately obvious why you need an elaborate framework to implement it. Consider the following: public abstract class Saw { public abstract void cut(String wood); } public class HandSaw extends Saw { public void cut(String wood) { // chop it up } } public class ChainSaw extends Saw { public void cut(String wood) { // chop it a lot faster } } public class SawMill { private Saw saw; public void setSaw(Saw saw) { this.saw = saw; } public void run(String wood) { saw.cut("some wood"); } } Then you could simply do: Saw saw = new HandSaw(); SawMill sawMill = new SawMill(); sawMill.setSaw(saw); sawMill.run(); Which would be equivalent to: &lt;bean id="saw" class="HandSaw"/&gt; &lt;bean id="sawMill" class="SawMill"&gt; &lt;property name="saw" ref="saw"/&gt; &lt;/bean&gt; plus: ApplicationContext context = new ClassPathXmlApplicationContext("sawmill.xml"); SawMill springSawMill = (SawMill)context.getBean("sawMill"); springSawMill.run(); Granted, this is a contrieved example, and with more complex object relationships it might be more efficient to stash up an XML file than writing it programmatically, but surely there must be more to it than that? (I know the Spring framework is more than that, but I'm thinking of the need for a DI container.) In the first example it would also be trivial to change dependencies midstream: // gotta chop it faster saw = new ChainSaw(); sawMill.setSaw(saw); sawMill.run();
tagged with: spring
has answer: http://stackoverflow.com/a/525046
has comment: http://stackoverflow.com/comment/564865
has answer: http://stackoverflow.com/a/500820
has answer: http://stackoverflow.com/a/500645

http://stackoverflow.com/a/528959
upvote count: 1
has body: You need to read the Javadocs for the String.split() methods...you are calling the version of String.split() that takes a regular expression and a limit, but you are passing the string itself as the first parameter, which doesn't really make sense. As Aaron Digulla mentioned, use the other version.
downvote count: 0
answers question: http://stackoverflow.com/q/527595
type: Answer
score: 1

http://stackoverflow.com/comment/428977
comment on: http://stackoverflow.com/a/615189
has text: You indicate a filename variable - how does this get set?
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/231456
type: AnswerComment
score: 0
type: Comment
has text: If you just want to make sure that the appropriate library calls are being made, use mocking with expectations. If you can't mock the external library, create a wrapper around the library that can be mocked and mock that. Check out the JMock framework if you aren't familiar with mocking.
comment on: http://stackoverflow.com/a/406140

http://stackoverflow.com/a/64254818
downvote count: 0
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/450807
has body: As the question is based in hypothetical data here is a good exemple returning a generic that extends Comparable interface. public class MaximumTest { // find the max value using Comparable interface public static <T extends Comparable<T>> T maximum(T x, T y, T z) { T max = x; // assume that x is initially the largest if (y.compareTo(max) > 0){ max = y; // y is the large now } if (z.compareTo(max) > 0){ max = z; // z is the large now } return max; // returns the maximum value } //testing with an ordinary main method public static void main(String args[]) { System.out.printf("Maximum of %d, %d and %d is %d\n\n", 3, 4, 5, maximum(3, 4, 5)); System.out.printf("Maximum of %.1f, %.1f and %.1f is %.1f\n\n", 6.6, 8.8, 7.7, maximum(6.6, 8.8, 7.7)); System.out.printf("Maximum of %s, %s and %s is %s\n", "strawberry", "apple", "orange", maximum("strawberry", "apple", "orange")); } }

http://stackoverflow.com/a/40077772
downvote count: 0
answers question: http://stackoverflow.com/q/609262
type: Answer
score: 3
upvote count: 3
has body: Not sure if this still matters to you, 7 years later :-), but this works for me: private static long getWindowIdFromShell(Shell shell) { long handle = shell.handle; long topWidget = OS._gtk_widget_get_toplevel(handle); long topWindow = OS._gtk_widget_get_window(topWidget); long topXid = OS._gdk_x11_window_get_xid(topWindow); return topXid; } In particular, the "get_toplevel" step is what jumps to the root widget/window, and so means you don't need the "minus magic window offset" hack (which I was initially stuck doing as well).
has comment: http://stackoverflow.com/comment/67619038

http://stackoverflow.com/q/566582
has answer: http://stackoverflow.com/a/12011831
answer count: 1
has comment: http://stackoverflow.com/comment/6227506
favorite count: 0
type: UnansweredQuestion
tagged with: multithreading
has comment: http://stackoverflow.com/comment/1402369
tagged with: jmx
has body: Our application connects to several jmx agents (about 50) to poll jmx data in frequent interval. After some time (about a day) application becomes irresponsive. We looked at thread dump and seeing large number of threads stuck on ClientNotifForwarder.. Eg: "ClientNotifForwarder-50" daemon prio=3 tid=0x09aa3800 nid=0x330 runnable [0xd3a90000..0xd3a90c70] java.lang.Thread.State: RUNNABLE at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) at java.io.BufferedInputStream.read(BufferedInputStream.java:237) - locked &lt;0xe2538af0&gt; (a java.io.BufferedInputStream) at java.io.DataInputStream.readByte(DataInputStream.java:248) at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:195) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142) at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source) at javax.management.remote.rmi.RMIConnectionImpl_Stub.fetchNotifications(Unknown Source) at javax.management.remote.rmi.RMIConnector$RMINotifClient.fetchNotifs(RMIConnector.java:1291) at com.sun.jmx.remote.internal.ClientNotifForwarder$NotifFetcher.fetchNotifs(ClientNotifForwarder.java:503) at com.sun.jmx.remote.internal.ClientNotifForwarder$NotifFetcher.run(ClientNotifForwarder.java:395) at com.sun.jmx.remote.internal.ClientNotifForwarder$LinearExecutor$1.run(ClientNotifForwarder.java:83) Any help in identifying root cause is appreciated... Thanks, Raja
score: 3
downvote count: 0
tagged with: java
type: Question
has title: JMX Thread stuck on ClientNotifForwarder
upvote count: 3

http://stackoverflow.com/q/491199
has answer: http://stackoverflow.com/a/491227
has answer: http://stackoverflow.com/a/491341
accepted answer: http://stackoverflow.com/a/491341
has answer: http://stackoverflow.com/a/497372
has comment: http://stackoverflow.com/comment/307028
has answer: http://stackoverflow.com/a/3338972
downvote count: 2
has answer: http://stackoverflow.com/a/491268
tagged with: typing
has answer: http://stackoverflow.com/a/492362
has title: Why don't Java, C# and C++ have ranges?
has body: Ada, Pascal and many other languages support ranges, a way to subtype integers. A range is a signed integer value which ranges from a value (first) to another (last). It's easy to implement a class that does the same in OOP but I think that supporting the feature natively could let the compiler to do additional static checks. I know that it's impossible to verify statically that a variabile defined in a range is not going to "overflow" runtime, i.e. due to bad input, but I think that something could be done. I think about the Design by Contract approach (Eiffel) and the Spec# ( C# Contracts ), that give a more general solution. Is there a simpler solution that checks, at least, static out-of-bound assignment at compile time in C++, C# and Java? Some kind of static-assert? edit: I understand that "ranges" can be used for different purpose: iterators enumerators integer subtype I would focus on the latter, because the formers are easily mappable on C* language . I think about a closed set of values, something like the music volume, i.e. a range that goes from 1 up to 100. I would like to increment or decrement it by a value. I would like to have a compile error in case of static overflow, something like: volume=rangeInt(0,100); volume=101; // compile error! volume=getIntFromInput(); // possible runtime exception Thanks.
favorite count: 0
answer count: 12
has answer: http://stackoverflow.com/a/77657589
has answer: http://stackoverflow.com/a/492314
has answer: http://stackoverflow.com/a/497315
score: 11
tagged with: c++
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/491259
has comment: http://stackoverflow.com/comment/307373
tagged with: java
tagged with: spec#
has comment: http://stackoverflow.com/comment/307147
has answer: http://stackoverflow.com/a/497157
type: Question
tagged with: c#
possible better answer: http://stackoverflow.com/a/492249
upvote count: 13
has answer: http://stackoverflow.com/a/492249

http://stackoverflow.com/a/377788
upvote count: 5
downvote count: 0
score: 5
has comment: http://stackoverflow.com/comment/205697
has body: The first code is better as it restricts scope of o variable to the for block. From a performance perspective, it might not have any effects in Java, but it might have in lower level compilers. They might put the variable in a register if you do the first. In fact, some people might think that if the compiler is dumb, the second snippet is better in terms of performance. This is what some instructor told me at the college and I laughed at him for this suggestion! Basically, compilers allocate memory on the stack for the local variables of a method just once at the start of the method (by adjusting the stack pointer) and release it at the end of method (again by adjusting the stack pointer, assuming it's not C++ or it doesn't have any destructors to be called). So all stack-based local variables in a method are allocated at once, no matter where they are declared and how much memory they require. Actually, if the compiler is dumb, there is no difference in terms of performance, but if it's smart enough, the first code can actually be better as it'll help the compiler understand the scope and the lifetime of the variable! By the way, if it's really smart, there should no absolutely no difference in performance as it infers the actual scope. Construction of a object using new is totally different from just declaring it, of course. I think readability is more important that performance and from a readability standpoint, the first code is definitely better.
answers question: http://stackoverflow.com/q/377763
type: Answer
has comment: http://stackoverflow.com/comment/205931

http://stackoverflow.com/a/435304
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/435238
type: Answer
upvote count: 1
has body: Have a look at Freemarker I would suggest XML as the "hub" format, then separate out your styling information into an XSLT.

http://stackoverflow.com/a/4729893
type: Answer
upvote count: 3
has comment: http://stackoverflow.com/comment/48144820
downvote count: 0
answers question: http://stackoverflow.com/q/587357
has body: As my company recently found out, AES is not quite Rijndael. AES has the restriction that keys MUST be 128, 192, or 256 bit - however, Rijndael allows for keys that are 160 and 224 as well. As indicated by erickson above, BouncyCastle provides a Rijndael object that DOES support the additional key lengths: 128/160/192/224/256 bits. Specifically, take a look at the lightweight API. Gnu-crypto is another open source library - however, it also does NOT provide support for 160 and 224 bit keys. So, if you are specifically looking for full Rijndael support, then BouncyCastle is the only one I've found so far.
score: 3

owl
tags question: http://stackoverflow.com/q/553810
tag name: owl
type: Tag

http://stackoverflow.com/a/458736
answers question: http://stackoverflow.com/q/457655
type: Answer
score: 0
has body: The way it's supposed to work is, if someone gives you a file and says it's UTF-16, they expect you to examine the first two bytes (the BOM) to find out whether it's big-endian or little-endian. But if they tell you the encoding is UTF-16LE, it means there's no BOM; you don't need it because they've already told you the byte order is little-endian. Java follows these rules precisely, which is a real pisser because nobody else does. The native character encoding of modern Windows operating systems is UTF-16, little-endian. Unfortunately, individual programs don't seem to be consistent when it comes to byte-order marks. And you can't just use UTF-16LE all the time because, if the BOM is there, it will be passed through as a junk character. The only way to know ahead of time whether to use UTF-16 or UTF-16LE is to examine the first two bytes, as McDowell described.

http://stackoverflow.com/comment/260758
comment on: http://stackoverflow.com/a/437115
type: Comment
has text: Thank you Bernie. The problem with that is that you have ActiveMQ specific code, the ones I listed above works perfectly fine with other JMS implementations too, i.e. with OpenJms.
score: 0
type: AnswerComment

http://stackoverflow.com/q/624337
tagged with: java
downvote count: 2
tagged with: mysql
upvote count: 7
has answer: http://stackoverflow.com/a/624376
has body: I am trying to add an image to a BLOB field in a mysql database. The image is going to be less then 100kb in size. However I am running into problems and was wondering what would be a better way to add this data to the database? com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'Data' at row 1 PreparedStatement addImage = conn.prepareStatement("INSERT INTO Images (Width, Height, Data) VALUES (?,?,?)",Statement.RETURN_GENERATED_KEYS); Below is the method that I am using to add the image into the database. public int addImage(Image image) throws SQLException, IllegalArgumentException { this.addImage.clearParameters(); byte[] imageData = ImageConverter.convertToBytes(image); int width = image.getWidth(null); int height = image.getHeight(null); if (width == -1 || height == -1) { throw new IllegalArgumentException("You must load the image first."); } this.addImage.setInt(1, width); this.addImage.setInt(2, height); this.addImage.setBytes(3, imageData); this.addImage.executeUpdate(); ResultSet rs = this.addImage.getGeneratedKeys(); rs.next(); return rs.getInt(1); } SQL Definition for the table After Changing the datafield type to a Mediumblob and attempting to place a 140kb image file into the database i received a different error. com.mysql.jdbc.PacketTooBigException: Packet for query is too large Is the problem the way in which i am trying to add the data to the database. Should I take a different approach? If so which way?
type: Question
has comment: http://stackoverflow.com/comment/437232
has answer: http://stackoverflow.com/a/624373
has title: Adding Image to a database in Java
favorite count: 0
has answer: http://stackoverflow.com/a/624569
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/11320236
score: 5
tagged with: jdbc
answer count: 4
has answer: http://stackoverflow.com/a/11320462

http://stackoverflow.com/a/24849939
downvote count: 1
has comment: http://stackoverflow.com/comment/40770191
has body: Got the same error but probably for the other (yet unknown) reason. I was casting exported object to the type of my remote interface and then while binding to name I was getting NoSuchObjectException. Removing casting fixed the problem. Briefly: public interface MyRemoteInterface extedns Remote { ... } public class MyRemoteObject implements MyRemoteInterface { ... } public static MyRemoteObject obj = new MyRemoteObject(); public static void main(String[] args) { //removing cast to MyRemoteInterface fixes the problem this.obj = UnicastRemoteObject.exportObject((MyRemoteInterface) this.obj, 0); //unless the above cast is removed, this throws NoSuchObjectException occasionally LocateRegisry.getRegistry("127.0.0.1", 1099).bind("name", this.obj); }
type: Answer
upvote count: 0
answers question: http://stackoverflow.com/q/645208
score: -1

http://stackoverflow.com/a/425778
score: 0
type: Answer
has body: you can extend the ApplicactionContext that are using and override the method createBeanFactory() protected DefaultListableBeanFactory createBeanFactory(){ DefaultListableBeanFactory beanFactory = super.createBeanFactory(); // By default this is false; beanFactory.setAllowRawInjectionDespiteWrapping( true ); return beanFactory; } This works, but be careful because this allows circular references.
answers question: http://stackoverflow.com/q/425049

http://stackoverflow.com/comment/112579683
score: 0
has text: The original blog post (which is awesome!) is available via Internet Archive [here](https://web.archive.org/web/20170808205930/http://rgomes-info.blogspot.co.uk/2013/12/using-typetokens-to-retrieve-generic.html)
type: AnswerComment
comment on: http://stackoverflow.com/a/723728
type: Comment

http://stackoverflow.com/q/632793
has comment: http://stackoverflow.com/comment/446133
possible better answer: http://stackoverflow.com/a/632812
has answer: http://stackoverflow.com/a/7132376
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/449112
answer count: 3
tagged with: architecture
accepted answer: http://stackoverflow.com/a/632830
has comment: http://stackoverflow.com/comment/446076
has title: Server architecture for a multiplayer game?
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/632812
tagged with: multiplayer
score: 15
has body: I'm planning to build a small multiplayer game which could be run as a java applet or a flash file in the web browser. I haven't done any server programming before, so I'm wondering what sort of server architecture i should have. It'll be easy for me to create perl/php files on the server, which the java/flash code contacts to update the player position/actions, etc. But I'm considering whether i should get a dedicated web host, which OS to use, which database, etc. Also, the amount of bandwidth used and scalability is a consideration. Another option could be using a cloud hosting system (as opposed to a dedicated server), so they would take care of adding additional machines as the game grows. As long as each server ran the core perl/php files for updating the database, it should work fine. Yet another option could be using Google app engine. Any thoughts regarding the server architecture, OS/database choice, and whether my method of using perl/php/python scripts for server-side programing is a good one, will be appreciated!
has answer: http://stackoverflow.com/a/632830
type: Question
upvote count: 15

http://stackoverflow.com/a/414384
has comment: http://stackoverflow.com/comment/8437856
downvote count: 0
has body: Here is the obligatory google solves that answer: Google Charts. http://code.google.com/apis/chart/ However, these will not be hosted on your system. I'm also not sure they support post request types, so the amount of data you can send is limited to the size of a get request url.
score: 1
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/412695
has comment: http://stackoverflow.com/comment/35692795

http://stackoverflow.com/comment/12087271
type: Comment
has text: But I *LOVE* her (C++)! No one is going to get in the way of our marriage if I can help it!
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/537635

http://stackoverflow.com/comment/26910337
type: Comment
comment on: http://stackoverflow.com/a/607267
score: 0
type: AnswerComment
has text: @BlaiseDoughan, Metro is a JAXB implementation ?! Isn't Metro a WSIT implementation ?

http://stackoverflow.com/a/458780
answers question: http://stackoverflow.com/q/458756
has comment: http://stackoverflow.com/comment/1746849
downvote count: 2
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/278331
has comment: http://stackoverflow.com/comment/280569
type: Answer
upvote count: 15
has body: There is not, but in windows you can use this: jintellitype Unfortunately there is nothing I'm aware of for Linux and OSX, probably that's why it doesn't come with java out of the box. If you find for the other platforms post it here please :) Just for couriosity, what are you doing with that?
score: 13
accepted answer of: http://stackoverflow.com/q/458756

http://stackoverflow.com/q/465886
has title: Determining which submit button was used?
possible better answer: http://stackoverflow.com/a/465915
tagged with: java
score: 4
tagged with: forms
tagged with: servlets
upvote count: 4
has answer: http://stackoverflow.com/a/465908
downvote count: 0
has body: Is it possible to determine which submit button was used? I have a confirmation form with 2 submit buttons. The first would confirm the order, do some DB tasks, then redirect. The second, which is a Cancel button, will just redirect to the same page, without doing any DB tasks. Is it possible in the servlet, preferably via the request object, to determine which submit button was used? I'd prefer not to be dependent on Javascript, as that is pretty simple, but will resort to it if the only possibility. Thanks.
favorite count: 0
tagged with: http://stackoverflow.com/tag/html
has answer: http://stackoverflow.com/a/466043
answer count: 4
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/465908
has answer: http://stackoverflow.com/a/465915
tagged with: http
type: Question
has answer: http://stackoverflow.com/a/466685

http://stackoverflow.com/a/607982
has body: You can reference static members/methods via reflection, but there is not automatic way to find all subclasses of a class. Consider providing the subclasses/instance factories/metadata classes via some other mechanism, such as ServiceLoader services or some other plugin framework.
type: Answer
upvote count: 1
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/607934

http://stackoverflow.com/comment/291777
type: Comment
comment on: http://stackoverflow.com/a/473804
has text: Agree with all the architectural issues, more interested in creating motivation for refactoring. Unfortunately, the reason it was written this way was because the original authors didn't understand spring - I think someone wrote one instance of the above code, all else was just cut-n-paste. Sigh.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/38288955
type: AnswerComment
type: Comment
has text: This I like, barring the race
score: 0
comment on: http://stackoverflow.com/a/375925

http://stackoverflow.com/comment/11141891
has text: looking for that book! awesome!
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/640204

http://stackoverflow.com/a/3793504
answers question: http://stackoverflow.com/q/438594
score: 15
has comment: http://stackoverflow.com/comment/70820465
has body: Apologies for resurrecting the thread, but I think I have a better answer :-) You could also use Py4J which has two parts: a library that runs in CPython (or any Python interpreter for that matter) and a library that runs on the Java VM you want to call. There is an example on the frontpage and lots of documentation, but essentially, you just call Java methods from your python code as if they were python methods: &gt;&gt;&gt; from py4j.java_gateway import JavaGateway &gt;&gt;&gt; gateway = JavaGateway() # connect to the JVM &gt;&gt;&gt; java_object = gateway.jvm.mypackage.MyClass() # invoke constructor &gt;&gt;&gt; other_object = java_object.doThat() &gt;&gt;&gt; other_object.doThis(1,'abc') &gt;&gt;&gt; gateway.jvm.java.lang.System.out.println('Hello World!') # call a static method The communication is done through sockets instead of JNI. Disclaimer: I am the author of Py4J
type: Answer
upvote count: 15
downvote count: 0
has comment: http://stackoverflow.com/comment/70746629

http://stackoverflow.com/comment/74952575
comment on: http://stackoverflow.com/a/31394053
type: Comment
score: 9
type: AnswerComment
has text: strictfp was introduced in Java 1.2. This was much later than when oak was designed.

http://stackoverflow.com/q/434379
upvote count: 6
possible better answer: http://stackoverflow.com/a/435172
type: AnsweredQuestion
tagged with: java
tagged with: eclipse
type: Question
answer count: 2
accepted answer: http://stackoverflow.com/a/434795
downvote count: 0
has body: If I have a text field with SWT, how can I get the field to fill to 100% or some specified width. For example, this text field will only reach for so much horizontally. public class Tmp { public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); GridLayout gridLayout = new GridLayout (); shell.setLayout (gridLayout); Button button0 = new Button(shell, SWT.PUSH); button0.setText ("button0"); Text text = new Text(shell, SWT.BORDER | SWT.FILL); text.setText ("Text Field"); shell.setSize(500, 400); //shell.pack(); shell.open(); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); } }
favorite count: 0
has answer: http://stackoverflow.com/a/435172
has title: How to have text fields fill 100% horizontally
tagged with: swt
score: 6
has answer: http://stackoverflow.com/a/434795

http://stackoverflow.com/a/643826
has body: I started my career as a PowerBuilder developer, but quickly changed to java and python, as soon as I realized PB was almost a dead language. Also, even if there are tools that can be used to apply programming "good practices", they are not widely known and somewhat expensive, so I've had to work even without version control (!!), left aside automated testing or continuous integration. It is a language in which almost anyone can start to build usable apps in a short period of time and with little training, and the apps are built really fast, in contrast with java, that demands a period of learning until a developer can be productive, and even then, a webapp takes time to be developed. But the payback is with maintenance, that quickly becomes a nightmare. Even a minor change in the database like a type change in a database column can destroy every datawindow (the PB ubiquitous data-access component) that refers to it. It's pretty much similar to VB, in that as almost anyone can develop applications in it, with very little programming knowledge, the average quality of applications is very low, with unmanageable database coupling and plagued of bad coding practices. My advice is not to build a Developer career in such kind of language unless the money justifies it, and in that case, continue training yourself in alternative technologies as a "plan b" to not become obsolete along with the language. And always work to keep your coding and problem solving skills "in good shape" as this kind of language does not help in that.
answers question: http://stackoverflow.com/q/605619
score: 7
downvote count: 4
type: Answer
upvote count: 11

http://stackoverflow.com/comment/374699
comment on: http://stackoverflow.com/a/562906
score: 0
type: AnswerComment
has text: I think we'd have to see the code you actually wrote. The snippet in the answer isn't intended to compile as written, but what was written, should compile fine, provided you filled in the bits well.
type: Comment

http://stackoverflow.com/comment/360154
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/547622
score: 0
has text: Java doesn't have a Functor interface? LOL.

http://stackoverflow.com/q/589039
type: Question
score: 3
tagged with: java
has body: for example, in ant i would use something like fileset dir="src/tests" includes="${test.includes}" excludes="${test.excludes}"/> in the junit task. there is a Test Runner Parameters field in the Run Configurations in Intellij, but i cant seem to find how to pass that sort of information in. basic use case: i have abstract tests which have to extend TestCase, but are being run by intellij's test runner (and failing with "no tests found.."). if anyone knows how to do this.. it would be good :)
tagged with: intellij-idea
answer count: 1
has title: passing test.includes into intellij idea test runner parameters
favorite count: 0
upvote count: 3
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/645023
accepted answer: http://stackoverflow.com/a/645023
tagged with: unit-testing

http://stackoverflow.com/a/611424
score: 2
has comment: http://stackoverflow.com/comment/424464
answers question: http://stackoverflow.com/q/611417
upvote count: 3
has body: if you've got XML already, your best option is probably to continue using it.
downvote count: 1
has comment: http://stackoverflow.com/comment/424652
has comment: http://stackoverflow.com/comment/423864
type: Answer
has comment: http://stackoverflow.com/comment/423880
has comment: http://stackoverflow.com/comment/423899

oop
tags question: http://stackoverflow.com/q/622944
tags question: http://stackoverflow.com/q/405336
tags question: http://stackoverflow.com/q/416331
tags question: http://stackoverflow.com/q/628049
tags question: http://stackoverflow.com/q/533330
tags question: http://stackoverflow.com/q/477012
tags question: http://stackoverflow.com/q/369512
tags question: http://stackoverflow.com/q/413898
tags question: http://stackoverflow.com/q/510976
tags question: http://stackoverflow.com/q/500493
tags question: http://stackoverflow.com/q/516677
tags question: http://stackoverflow.com/q/558546
tag name: oop
tags question: http://stackoverflow.com/q/478804
tags question: http://stackoverflow.com/q/475843
tags question: http://stackoverflow.com/q/515133
tags question: http://stackoverflow.com/q/380046
tags question: http://stackoverflow.com/q/612095
tags question: http://stackoverflow.com/q/607106
tags question: http://stackoverflow.com/q/550919
tags question: http://stackoverflow.com/q/639592
tags question: http://stackoverflow.com/q/475097
tags question: http://stackoverflow.com/q/565095
tags question: http://stackoverflow.com/q/540293
tags question: http://stackoverflow.com/q/638421
tags question: http://stackoverflow.com/q/530923
tags question: http://stackoverflow.com/q/604188
tags question: http://stackoverflow.com/q/414001
tags question: http://stackoverflow.com/q/555283
tags question: http://stackoverflow.com/q/574569
tags question: http://stackoverflow.com/q/579454
tags question: http://stackoverflow.com/q/484301
tags question: http://stackoverflow.com/q/478918
type: Tag
tags question: http://stackoverflow.com/q/504904
tags question: http://stackoverflow.com/q/558839
tags question: http://stackoverflow.com/q/623978

http://stackoverflow.com/a/472066
type: Answer
score: 7
upvote count: 7
downvote count: 0
has comment: http://stackoverflow.com/comment/307719
answers question: http://stackoverflow.com/q/456140
has body: One of the biggest things you lose when you use dynamic languages, especially in a large codebase is the ability to use an IDE to re-factor. Languages that allow dynamically adding code to objects simply can't be parsed by today's IDEs to allow the kind of easy refactoring methods you can get from Eclipse, etc. for Java, C++, etc. It's not really a case of "Dynamic languages are better than Static". Use what's best for you. The really cool thing about Groovy in particular is you can mix and match Java and Groovy in the same project, and it all runs on the VM. Yes, Scala is another example.

http://stackoverflow.com/comment/373447
type: Comment
score: 0
has text: @Steve - DV has intraframe compression, but according to wikipedia (which, of course, is an unassailable bastion of truth ;-) it doesn't not have interframe compression. Thus each frame is compressed individually, and does not depend on any other frame for information.
type: AnswerComment
comment on: http://stackoverflow.com/a/561585

http://stackoverflow.com/comment/191220
has text: @Nemanja: Just put your cursor on bar(); and hit F9. Both VS2005 and VS2008 handle intra-line breakpoints, if they're separate "statements".
score: 11
comment on: http://stackoverflow.com/a/359787
type: AnswerComment
type: Comment

http://stackoverflow.com/q/624422
accepted answer: http://stackoverflow.com/a/624474
has answer: http://stackoverflow.com/a/624473
type: AnsweredQuestion
tagged with: java
tagged with: javadoc
has body: In the Java APIs I can see Javadoc comments for packages. How/where do I place Javadoc comments to document a package?
score: 214
type: Question
upvote count: 214
has answer: http://stackoverflow.com/a/624474
answer count: 3
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/624423
tagged with: package
has title: How Do I Document Packages in Java?
possible better answer: http://stackoverflow.com/a/624473

http://stackoverflow.com/comment/92976198
has text: And because collisions must always be accounted for (to reduce the risk or collisions or the risk of long loops to lookup other positions) you need to increase the internal size of the hash table, keeping a minimum number of slots unused, but then you waste space. As well once you get a position in the hash index, you need to compare the effective keys (not just their hashed value). Globally it takes hundreds CPU cycles (thousands in worst cases, when there's a high level of collision as the hash table is almost full) instead of only 2 table indirects with a Trie for all reads and most writes!
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/22409507

http://stackoverflow.com/comment/67254276
type: AnswerComment
type: Comment
score: 1
comment on: http://stackoverflow.com/a/26687649
has text: I was getting errors in Android Studio as well. I changed from 1.4.1 to 1.5.1 and it works!

http://stackoverflow.com/comment/55845649
type: Comment
score: 2
type: AnswerComment
has text: Sun could have picked a reasonable default that programmers could override. This is no excuse. The same problem exists for Strings when it comes to empty strings or null references. Is a null reference greater than or less than the string "foo"? Sun picked an ordering that makes sense.
comment on: http://stackoverflow.com/a/480661

jakarta-ee
tags question: http://stackoverflow.com/q/555129
tags question: http://stackoverflow.com/q/634255
tags question: http://stackoverflow.com/q/539298
tags question: http://stackoverflow.com/q/585595
tags question: http://stackoverflow.com/q/399924
tags question: http://stackoverflow.com/q/402056
tags question: http://stackoverflow.com/q/553031
tags question: http://stackoverflow.com/q/431107
tags question: http://stackoverflow.com/q/631596
tags question: http://stackoverflow.com/q/538550
tags question: http://stackoverflow.com/q/525711
tags question: http://stackoverflow.com/q/368792
type: Tag
tags question: http://stackoverflow.com/q/643055
tags question: http://stackoverflow.com/q/487826
tags question: http://stackoverflow.com/q/571910
tags question: http://stackoverflow.com/q/442582
tags question: http://stackoverflow.com/q/416208
tags question: http://stackoverflow.com/q/399286
tags question: http://stackoverflow.com/q/573194
tags question: http://stackoverflow.com/q/463543
tags question: http://stackoverflow.com/q/531593
tags question: http://stackoverflow.com/q/638896
tags question: http://stackoverflow.com/q/584742
tags question: http://stackoverflow.com/q/580682
tags question: http://stackoverflow.com/q/368350
tags question: http://stackoverflow.com/q/473068
tags question: http://stackoverflow.com/q/529573
tags question: http://stackoverflow.com/q/536073
tags question: http://stackoverflow.com/q/497830
tags question: http://stackoverflow.com/q/546365
tags question: http://stackoverflow.com/q/491773
tags question: http://stackoverflow.com/q/427452
tags question: http://stackoverflow.com/q/497552
tags question: http://stackoverflow.com/q/541241
tags question: http://stackoverflow.com/q/634598
tags question: http://stackoverflow.com/q/636450
tags question: http://stackoverflow.com/q/586592
tag name: jakarta-ee
tags question: http://stackoverflow.com/q/639275
tags question: http://stackoverflow.com/q/512595
tags question: http://stackoverflow.com/q/545496
tags question: http://stackoverflow.com/q/466858
tags question: http://stackoverflow.com/q/616598
tags question: http://stackoverflow.com/q/530735
tags question: http://stackoverflow.com/q/582248
tags question: http://stackoverflow.com/q/566892
tags question: http://stackoverflow.com/q/520467
tags question: http://stackoverflow.com/q/381071
tags question: http://stackoverflow.com/q/644205
tags question: http://stackoverflow.com/q/645746
tags question: http://stackoverflow.com/q/584252
tags question: http://stackoverflow.com/q/533783
tags question: http://stackoverflow.com/q/515397
tags question: http://stackoverflow.com/q/472176
tags question: http://stackoverflow.com/q/450965
tags question: http://stackoverflow.com/q/605589
tags question: http://stackoverflow.com/q/359147
tags question: http://stackoverflow.com/q/568134
tags question: http://stackoverflow.com/q/511523
tags question: http://stackoverflow.com/q/491503
tags question: http://stackoverflow.com/q/474159
tags question: http://stackoverflow.com/q/520348
tags question: http://stackoverflow.com/q/509049
tags question: http://stackoverflow.com/q/464346
tags question: http://stackoverflow.com/q/362665
tags question: http://stackoverflow.com/q/531463
tags question: http://stackoverflow.com/q/495792
tags question: http://stackoverflow.com/q/535821
tags question: http://stackoverflow.com/q/536821
tags question: http://stackoverflow.com/q/536228
tags question: http://stackoverflow.com/q/545831
tags question: http://stackoverflow.com/q/467235
tags question: http://stackoverflow.com/q/359548
tags question: http://stackoverflow.com/q/416116
tags question: http://stackoverflow.com/q/448254
tags question: http://stackoverflow.com/q/461886
tags question: http://stackoverflow.com/q/540764
tags question: http://stackoverflow.com/q/567482
tags question: http://stackoverflow.com/q/456556

http://stackoverflow.com/q/381966
answer count: 2
downvote count: 0
favorite count: 0
possible better answer: http://stackoverflow.com/a/382028
has title: java Best Debugging Options
has answer: http://stackoverflow.com/a/382028
has body: I am trying to analyze a JVM crash that is occuring inconsistently. I get a hs_err_pid312.log file when it happens. i've added Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler(), but i'm not sure that will catch the error. What other things can i do so the next time this occurs, i can get as much information as possible? thanks
has answer: http://stackoverflow.com/a/382715
upvote count: 2
score: 2
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/382715
has comment: http://stackoverflow.com/comment/209594
type: Question
tagged with: debugging

http://stackoverflow.com/q/535227
has comment: http://stackoverflow.com/comment/348030
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/535235
has title: Take string "asdxyz\n" and replace \n with the ascii value
has body: I dont want to replace it with /u000A, do NOT want it to look like "asdxyz/u000A" I want to replace it with the actual newline CHARACTER.
possible better answer: http://stackoverflow.com/a/535239
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/535322
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/535322
has answer: http://stackoverflow.com/a/535239
tagged with: string

http://stackoverflow.com/a/1260467
type: Answer
upvote count: 4
downvote count: 0
has body: Tomcat will be doing the compression. However because you are using mod_jk I guess you are getting you requests via Apache on port 80 rather than tomcat on port 8080. As an experiment try getting your page via port 8080 and then checking yslow you should see the correct headers. I think what is happening is that apache is unzipping the content that it is getting from tomcat via mod_jk and then passing the deflated content on to the browser. If you wish to use mod_jk then you will need to set up your compression on Apache rather than Tomcat.
answers question: http://stackoverflow.com/q/550024
score: 4
has comment: http://stackoverflow.com/comment/2519970

http://stackoverflow.com/comment/22522586
has text: Wouldn't this also return true for `John Doe <john.doe@example.com>`? This is a valid address to use in the email API, but might not be valid in other use cases.
comment on: http://stackoverflow.com/a/5931718
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/551668
has answer: http://stackoverflow.com/a/34396972
upvote count: 54
has answer: http://stackoverflow.com/a/551760
has answer: http://stackoverflow.com/a/48448348
has title: How do I set the default Java installation/runtime (Windows)?
answer count: 9
has comment: http://stackoverflow.com/comment/11886218
tagged with: java
has body: I'm in the situation where I've installed the JDK, but I can't run applets in browsers (I may not have installed the JRE). However, when I install the JRE, it clobbers my JDK as the default runtime. This breaks pretty much everything (Eclipse, Ant) - as they require a server JVM. There's no JAVA_HOME environment variable these days - it just seems to use some registry magic (setting the system path is of no use either). Previously, I've just uninstalled the JRE after I've used it to restore the JDK. This time I want to fix it properly. This also manifests itself with the jre autoupdater - once upon a time, I had a working setup with the JDK and JRE, but it updated and bust everything.
has comment: http://stackoverflow.com/comment/126666572
has answer: http://stackoverflow.com/a/8875165
downvote count: 0
tagged with: runtime
linked to: http://stackoverflow.com/q/27996603
has answer: http://stackoverflow.com/a/63958009
score: 54
has answer: http://stackoverflow.com/a/64534644
possible better answer: http://stackoverflow.com/a/8875165
has answer: http://stackoverflow.com/a/551709
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/48690194
tagged with: windows
linked to: http://stackoverflow.com/q/69066139
favorite count: 0
accepted answer: http://stackoverflow.com/a/551709
tagged with: installation
type: Question
has answer: http://stackoverflow.com/a/52771816

http://stackoverflow.com/comment/110826592
comment on: http://stackoverflow.com/a/29252884
type: Comment
has text: Then how can we return our expected cause exception?
score: 2
type: AnswerComment

http://stackoverflow.com/comment/78294793
has text: Not exactly. `final byte a = (byte) (new Random().nextInt(4));` and `Incompatible types` rears it's ugly head again. It's not just finality, it's being able to compile it away to a value that fits the type.
type: Comment
comment on: http://stackoverflow.com/a/41750719
score: 0
type: AnswerComment

http://stackoverflow.com/comment/55399607
comment on: http://stackoverflow.com/a/33816920
has text: if needed, one can use the `toMap` signature including a map supplier to specify the type of map.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/419196
type: Answer
score: -2
answers question: http://stackoverflow.com/q/419181
downvote count: 2
has body: You can use Team Foundation Server 2008 and Microsoft Studio Team System to accomplish your source control, branching, and releases.
upvote count: 0
has comment: http://stackoverflow.com/comment/243384

http://stackoverflow.com/a/631705
answers question: http://stackoverflow.com/q/631682
downvote count: 0
has body: Yes, this is a classpath issue. You need to tell the compiler and runtime that the directory where your .class files live is part of the CLASSPATH. The directory that you need to add is the parent of the "com" directory at the start of your package structure. You do this using the -classpath argument for both javac.exe and java.exe. Should also ask how the 3rd party classes you're using are packaged. If they're in a JAR, and I'd recommend that you have them in one, you add the .jar file to the classpath: java -classpath .;company.jar foo.bar.baz.YourClass Google for "Java classpath". It'll find links like this. One more thing: "import" isn't loading classes. All it does it save you typing. When you include an import statement, you don't have to use the fully-resolved class name in your code - you can type "Foo" instead of "com.company.thing.Foo". That's all it's doing.
type: Answer
upvote count: 11
score: 11

http://stackoverflow.com/comment/267435
comment on: http://stackoverflow.com/a/446012
type: AnswerComment
type: Comment
score: 1
has text: Perhaps I was not clear. I know why it happens as in the source code that makes it happen that way, I had read the code before posting. My question was why was it decided that it should be this way?

http://stackoverflow.com/q/412380
has comment: http://stackoverflow.com/comment/23069841
has answer: http://stackoverflow.com/a/413039
type: Question
has answer: http://stackoverflow.com/a/45593876
has answer: http://stackoverflow.com/a/79432071
has answer: http://stackoverflow.com/a/58239271
has answer: http://stackoverflow.com/a/67887723
score: 464
has answer: http://stackoverflow.com/a/4380310
favorite count: 0
answer count: 14
has title: How to combine paths in Java?
has answer: http://stackoverflow.com/a/54648481
has answer: http://stackoverflow.com/a/78666911
has answer: http://stackoverflow.com/a/9148215
has answer: http://stackoverflow.com/a/4177678
has body: Is there a Java equivalent for System.IO.Path.Combine() in C#/.NET? Or any code to accomplish this? This static method combines one or more strings into a path.
has answer: http://stackoverflow.com/a/43185019
linked to: http://stackoverflow.com/q/204784
downvote count: 0
type: UnansweredQuestion
tagged with: path
has answer: http://stackoverflow.com/a/20069477
upvote count: 464
has answer: http://stackoverflow.com/a/412495
has answer: http://stackoverflow.com/a/56615614
tagged with: java

http://stackoverflow.com/comment/260725
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/437870
has text: Thanks, but the inheritance option doesn't always make sense (A and B could be totally unrelated. I don't really like the second option either, because it means that 1) I might have to make 'C interfaces' for every possible combination of interfaces and 2) classes should all implement these...

migration
tags question: http://stackoverflow.com/q/479461
type: Tag
tags question: http://stackoverflow.com/q/570031
tags question: http://stackoverflow.com/q/531284
tag name: migration

http://stackoverflow.com/a/457552
has body: This page might help you, although it seems you are restricted to having the same combobox in all the cells in a column.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/457463

http://stackoverflow.com/q/610962
upvote count: 1
tagged with: swing
type: AnsweredQuestion
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/611031
has body: In java swing I can insert panels into panels and so on, and not have to build a brand new window for every view of my applicaiton, or mess around removing and adding controls. Theres a panel clas sin C# however I cant see any way of creating a 'panel form' or basically just a form in form designer thats a panel and its contents. How do I do this then and work the way I did with java swing?
type: Question
tagged with: c#
tagged with: jpanel
possible better answer: http://stackoverflow.com/a/611025
answer count: 3
has answer: http://stackoverflow.com/a/950645
accepted answer: http://stackoverflow.com/a/611031
has answer: http://stackoverflow.com/a/611025
downvote count: 0
favorite count: 0
tagged with: winforms
has title: winforms panels vs java swing panels

http://stackoverflow.com/q/451886
has answer: http://stackoverflow.com/a/451907
downvote count: 0
tagged with: java
has body: I was looking over this code to calculate math.sqrt in Java. Why did they use hex values in some of the loops and normal values for variables? What benefits are there to use hex?
type: Question
upvote count: 6
tagged with: http://stackoverflow.com/tag/c
has answer: http://stackoverflow.com/a/451912
accepted answer: http://stackoverflow.com/a/451912
tagged with: math.sqrt
answer count: 3
favorite count: 0
tagged with: hex
has title: Why use hex values instead of normal base 10 numbers?
has answer: http://stackoverflow.com/a/451931
score: 6
possible better answer: http://stackoverflow.com/a/451907
type: AnsweredQuestion

http://stackoverflow.com/a/477059
accepted answer of: http://stackoverflow.com/q/472984
answers question: http://stackoverflow.com/q/472984
type: Answer
score: 2
downvote count: 0
upvote count: 2
type: AcceptedAnswer
has body: I hate to ask the obvious, but have you looked at all the stuff for configuring OS4J and CXF together from the CXF web site? http://cwiki.apache.org/CXF20DOC/appserverguide.html#AppServerGuide-OC4J
has comment: http://stackoverflow.com/comment/298015

http://stackoverflow.com/a/606218
has body: There's no reason why using a static variable wouldn't work. I'm not saying it's particularly good practice, but it will work. What should happen is: The first call is made. The class is initialised, started is false. doSomething is called. The if fails and the code bypasses it. started is set to true and the other code runs. doSomething is called again. The if passes and execution stops. The one thing to note is that there is no synchronization here, so if doSomething() was called on separate threads incredibly close together, each thread could read started as false, bypass the if statement and do the work i.e. there is a race condition.
type: Answer
upvote count: 6
score: 6
answers question: http://stackoverflow.com/q/606196
downvote count: 0

http://stackoverflow.com/q/524617
tagged with: css
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
type: Question
tagged with: gwt
has answer: http://stackoverflow.com/a/525122
accepted answer: http://stackoverflow.com/a/526495
answer count: 2
upvote count: 1
has answer: http://stackoverflow.com/a/526495
has body: I see that it uses png images for the rendering, so I am assuming that means I need to provide my own version of these images, with colors changed appropriately. Where do I put these images, and how do I apply them in the CSS?
favorite count: 0
possible better answer: http://stackoverflow.com/a/525122
has title: How can I change the color of a DecoratorPanel in GWT?

http://stackoverflow.com/comment/284776
has text: @saua: absurd or not, still a question and a real life problem ( unfortunately :( ) See this: http://stackoverflow.com/questions/318503
comment on: http://stackoverflow.com/q/466589
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/a/364140
downvote count: 0
type: Answer
score: 2
upvote count: 2
has body: I said this in the PHP Optimization Tips question and I'll say it again here: If you're running PHP from a static environment (web server module or FastCGI), use an opcode cache, such as APC. Otherwise, PHP is reinterpreting/recompiling your code on every request!
answers question: http://stackoverflow.com/q/363805

http://stackoverflow.com/a/513637
answers question: http://stackoverflow.com/q/513600
type: Answer
has body: In your example, performance probalby isn't too different but there are other issues to consider: namely memory fragmentation. Even concatenate operation is creating a new string, even if its temporary (it takes time to GC it and it's more work). String.format() is just more readable and it involves less fragmentation. Also, if you're using a particular format a lot, don't forget you can use the Formatter() class directly (all String.format() does is instantiate a one use Formatter instance). Also, something else you should be aware of: be careful of using substring(). For example: String getSmallString() { String largeString = // load from file; say 2M in size return largeString.substring(100, 300); } That large string is still in memory because that's just how Java substrings work. A better version is: return new String(largeString.substring(100, 300)); or return String.format("%s", largeString.substring(100, 300)); The second form is probably more useful if you're doing other stuff at the same time.
score: 7
has comment: http://stackoverflow.com/comment/49795606
has comment: http://stackoverflow.com/comment/67483043
downvote count: 2
has comment: http://stackoverflow.com/comment/345922
upvote count: 9

http://stackoverflow.com/q/484355
has title: Does it make sense to rewrite Perl and shell scripts in java?
type: Question
has answer: http://stackoverflow.com/a/484549
has body: I have a bunch of scripts - some in perl and some in bash - which are used for: Creating a database (tables, indexes, constraints, views) Parsing spreadsheets and loading the data into the database Getting info about a bunch of files and loading that into the database. These scripts are used in conjunction with a much larger application that is written in java, and my manager has requested that I rewrite the scripts in java. His reasoning is that it is easier to work with, port, manage, understand, and support if it's all in one language, and that too many separate pieces is a design issue. My initial reaction is that this is a bad idea. The scripts are beautifully concise and fast, and tasks that are trivial in the scripts - such as using regexs to find and replace invalid values - will be so much more verbose and very likely slower when done in java. The one drawback of the scripts is that when they run on windows they require cygwin in order to run. Therefore I would like to give a counter proposition that I port all the bash scripts to perl so that they can run on windows without cygwin, and that I spend time organizing and documenting the scripts. The problem is that a "gut reaction" type of response is not going to be enough to convince my manager. I come from a linux background, he from Windows, and we have some of the classic linux vs. windows differences in approaches. So I have two questions: Is my "gut reaction" correct? Is java slower, more verbose, and harder to maintain for database management, spreadsheet parsing, &amp; file processing tasks? If the answer to the first question is yes, what is the best way to present my case? EDIT: Thanks everyone for the insights. I'd like to make one clarification: the scripts are not full-blown apps hidden away in obfuscated scripts. They are, for the most part, tasks that had been done manually that I automated via scripts and later embellished as the requirements developed. And the reason I used a scripting langu…
has comment: http://stackoverflow.com/comment/77497718
has answer: http://stackoverflow.com/a/484579
has answer: http://stackoverflow.com/a/484611
has answer: http://stackoverflow.com/a/491964
tagged with: java
has answer: http://stackoverflow.com/a/3819347
has answer: http://stackoverflow.com/a/4260068
accepted answer: http://stackoverflow.com/a/484382
has answer: http://stackoverflow.com/a/485805
has answer: http://stackoverflow.com/a/484412
has answer: http://stackoverflow.com/a/486908
has answer: http://stackoverflow.com/a/484406
has answer: http://stackoverflow.com/a/484374
tagged with: perl
has answer: http://stackoverflow.com/a/484454
downvote count: 0
has answer: http://stackoverflow.com/a/484382
tagged with: shell
possible better answer: http://stackoverflow.com/a/484703
has answer: http://stackoverflow.com/a/488495
favorite count: 0
answer count: 20
has answer: http://stackoverflow.com/a/484657
has answer: http://stackoverflow.com/a/484439
has answer: http://stackoverflow.com/a/45255573
upvote count: 16
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2396276
has answer: http://stackoverflow.com/a/484421
score: 16
has answer: http://stackoverflow.com/a/484703

http://stackoverflow.com/a/18390826
answers question: http://stackoverflow.com/q/422181
has body: If you have concurrency needs, don't try to solve this problem yourself. Guava's CacheBuilder has a .maximumSize() method that allows you to limit the size of a map, although it's my understanding that old entries may be cleaned out before you actually reach the limit. There's an interesting page on the data structure's design, which should impress on the reader how difficult it would be to do any better than Google's implementation. :)
score: 0
type: Answer

http://stackoverflow.com/q/494180
accepted answer: http://stackoverflow.com/a/494200
has title: How do I check if a date is within a certain range?
has answer: http://stackoverflow.com/a/72024355
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/45297429
has comment: http://stackoverflow.com/comment/79049703
has answer: http://stackoverflow.com/a/38246482
has body: I have a series of ranges with start dates and end dates. I want to check to see if a date is within that range. Date.before() and Date.after() seem to be a little awkward to use. What I really need is something like this pseudocode: boolean isWithinRange(Date testDate) { return testDate &gt;= startDate &amp;&amp; testDate &lt;= endDate; } Not sure if it's relevant, but the dates I'm pulling from the database have timestamps.
tagged with: java
has answer: http://stackoverflow.com/a/494200
has answer: http://stackoverflow.com/a/41661785
has answer: http://stackoverflow.com/a/494203
linked to: http://stackoverflow.com/q/23335970
type: Question
has answer: http://stackoverflow.com/a/63211304
has answer: http://stackoverflow.com/a/46044878
possible better answer: http://stackoverflow.com/a/35300229
has answer: http://stackoverflow.com/a/50813531
has answer: http://stackoverflow.com/a/65628146
linked to: http://stackoverflow.com/q/38922754
has answer: http://stackoverflow.com/a/62698189
has answer: http://stackoverflow.com/a/72315844
has answer: http://stackoverflow.com/a/494216
tagged with: date
linked to: http://stackoverflow.com/q/883060
has comment: http://stackoverflow.com/comment/58309766
has answer: http://stackoverflow.com/a/494201
score: 129
downvote count: 0
has answer: http://stackoverflow.com/a/71939524
upvote count: 129
answer count: 17
favorite count: 0
has answer: http://stackoverflow.com/a/35300229
has answer: http://stackoverflow.com/a/70659447

http://stackoverflow.com/a/427101
has comment: http://stackoverflow.com/comment/60806618
answers question: http://stackoverflow.com/q/426878
downvote count: 0
has comment: http://stackoverflow.com/comment/60790355
type: Answer
upvote count: 3
score: 3
has comment: http://stackoverflow.com/comment/36958761
has body: The essential idea behind nesting loops is multiplication. Expanding on Michael Burr's answer, if the outer for loops are doing nothing but controlling a count, then your nested for loops over n counts are simply a more complicated way of iterating over the product of the counts with a single for loop. Now, let's extend this idea to Lists. If you're iterating over three lists in nested loops, this is simply a more complicated way of iterating over the product of the lists with a single loop. But how do you express the product of three lists? First, we need a way of expressing the product of types. The product of two types X and Y can be expressed as a generic type like P2&lt;X, Y&gt;. This is just a value that consists of two values, one of type X, the other of type Y. It looks like this: public abstract class P2&lt;A, B&gt; { public abstract A _p1(); public abstract B _p2(); } For a product of three types, we just have P3&lt;A, B, C&gt;, with the obvious third method. A product of three lists, then, is achieved by distributing the List functor over the product type. So the product of List&lt;X&gt;, List&lt;Y&gt;, and List&lt;Z&gt; is simply List&lt;P3&lt;X, Y, Z&gt;&gt;. You can then iterate over this list with a single loop. The Functional Java library has a List type that supports multiplying lists together using first-class functions and product types (P2, P3, etc. which are also included in the library). For example: for (String x : xs) { for (String y : ys) { for (String z : zs) { doSomething(x, y, z); } } } Is equivalent to: for (P3&lt;String, String, String&gt; p : xs.map(P.p3()).apply(ys).apply(zs)) { doSomething(p._1(), p._2(), p._3()); } Going further with Functional Java, you can make doSomething first-class, as follows. Let's say doSomething returns a String: public static final F&lt;P3&lt;String, String, String&gt;, String&gt; doSomething = new F&lt;P3&lt;String, String, String&gt;, String&gt;() { public String f(final P3&lt;String, String, String&gt; …

http://stackoverflow.com/comment/1916273
has text: SwingWiki does no longer exist.
comment on: http://stackoverflow.com/a/532259
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/422696
type: AnswerComment
has text: some of them depend on some of the others. Lets say we have packages A, B, and C. A dn c and B an c might relate. (in my opinion id deploy A B and C whether they wanted A or B
type: Comment
comment on: http://stackoverflow.com/a/610381
score: 0

http://stackoverflow.com/comment/424438
has text: Do you think it is too heavy or complicated. That is the only thing that is holding me back from using Antlr. But it is popular and seems to be very stable.
comment on: http://stackoverflow.com/a/611844
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/521205
has body: You could write a generic Pair&lt;A, B&gt; class and use this in an array or list. Yes, you have to write a class, but you can reuse the same class for all types, so you only have to do it once.
answers question: http://stackoverflow.com/q/521171
upvote count: 12
has comment: http://stackoverflow.com/comment/334619
has comment: http://stackoverflow.com/comment/334759
type: Answer
has comment: http://stackoverflow.com/comment/334817
downvote count: 2
has comment: http://stackoverflow.com/comment/334834
has comment: http://stackoverflow.com/comment/334645
score: 10
has comment: http://stackoverflow.com/comment/334711

http://stackoverflow.com/comment/203812
has text: Arial is sufficiently different from Helvetica to be an unacceptable substitute for those who care about such things. And it certainly wouldn't be selected automatically when you search for "Helvetica".
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/375607

http://stackoverflow.com/comment/340738
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/527595
has text: its not readable... many unreadable characters in your description.

http://stackoverflow.com/comment/284629
type: Comment
type: QuestionComment
has text: Make sure you take into consideration encoded chars if your going to implement it yourself.
score: 0
comment on: http://stackoverflow.com/q/463482

http://stackoverflow.com/a/603819
type: Answer
has body: It is not possible to modify the default screen of a device with J2ME. You need a native application (Symbian, Windows Mobile) to do so. J2ME lays in a sandboxed environment and has many restrictions on what you can access. An application can only be started by the user and can't run as a service. It is also not possible to register an application to run at the start-up of the phone. It has been discussed that MIDP 3.0 may address many of the above issues, but I don't think it will ever be available.
upvote count: 1
accepted answer of: http://stackoverflow.com/q/603652
score: 1
answers question: http://stackoverflow.com/q/603652
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/20906602
type: Answer
has comment: http://stackoverflow.com/comment/59743327
answers question: http://stackoverflow.com/q/428918
has comment: http://stackoverflow.com/comment/59738328
downvote count: 1
has body: java.time On Java 8 and later, the java.time package makes this pretty much automatic. (Tutorial) Assuming String input and output: import java.time.LocalDate; public class DateIncrementer { static public String addOneDay(String date) { return LocalDate.parse(date).plusDays(1).toString(); } }
upvote count: 106
has comment: http://stackoverflow.com/comment/59732761
score: 105

http://stackoverflow.com/q/459441
upvote count: 3
has answer: http://stackoverflow.com/a/459496
tagged with: java
tagged with: servlets
type: Question
has answer: http://stackoverflow.com/a/459481
has answer: http://stackoverflow.com/a/459507
downvote count: 0
has body: When you get a doGet or doPost call in a servlet you can use getparameterxxx() to get either the query string or the post data in one easy place. If the call was a GET, you get data from the url/query string. If the call was a POST, you get the post data all parsed out for you. Except as it turns out, if you don't put an 'action' attribute in your form call. If you specify a fully qualified or partially qualified url for the action param everything works great, if you don't, the browser will call the same url as it did on the previous page submit, and if there happens to be query string data there, you'll get that as well as POST data, and there's no way to tell them apart. Or is there? I'm looking through the request object, I see where the post data comes from, I'm just trying to figure out where the GET data comes from, so I can erase the GET data on a post call and erase the post data on a GET call before it parses it out if possible. Any idea what the safe way to do this is? And lemme guess: you never tried to not put an action field in a form tag. :-)
tagged with: http-post
tagged with: http-get
has title: How do I separate out query string params from POST data in a java servlet
has answer: http://stackoverflow.com/a/459485
favorite count: 0
accepted answer: http://stackoverflow.com/a/459507
possible better answer: http://stackoverflow.com/a/459485
answer count: 4
type: AnsweredQuestion
score: 3

http://stackoverflow.com/q/641462
answer count: 5
upvote count: 51
tagged with: memory-leaks
has answer: http://stackoverflow.com/a/641480
type: AnsweredQuestion
has body: If my application has too many static variables or methods, then as per definition they will be stored in heap. Please correct me if I am wrong 1) Will these variables be on heap until application is closed? 2) Will they be available for GC at any time? If not can I say it is a memory leak?
tagged with: memory-management
has answer: http://stackoverflow.com/a/641491
possible better answer: http://stackoverflow.com/a/660874
type: Question
has answer: http://stackoverflow.com/a/642513
tagged with: java
has answer: http://stackoverflow.com/a/641473
accepted answer: http://stackoverflow.com/a/641473
has answer: http://stackoverflow.com/a/660874
has title: Can using too many static variables cause a memory leak in Java?
downvote count: 0
favorite count: 0
score: 51

http://stackoverflow.com/comment/215856
type: QuestionComment
has text: The answer to this question (as given by Skeet and libt) just raises further questions, such as why doesn't Cloneable contain the clone method?
comment on: http://stackoverflow.com/q/388439
score: 0
type: Comment

http://stackoverflow.com/q/565095
tagged with: oop
tagged with: accessor
has answer: http://stackoverflow.com/a/565117
linked to: http://stackoverflow.com/q/601721
tagged with: java
has title: Are getters and setters poor design? Contradictory advice seen
tagged with: setter
has answer: http://stackoverflow.com/a/565130
has answer: http://stackoverflow.com/a/565204
has answer: http://stackoverflow.com/a/8715204
type: Question
score: 241
has answer: http://stackoverflow.com/a/565158
has answer: http://stackoverflow.com/a/565222
has comment: http://stackoverflow.com/comment/4383535
tagged with: getter
has answer: http://stackoverflow.com/a/565212
answer count: 16
has answer: http://stackoverflow.com/a/565287
duplicate of: http://stackoverflow.com/q/1568091
linked to: http://stackoverflow.com/q/996179
possible better answer: http://stackoverflow.com/a/565117
has answer: http://stackoverflow.com/a/565196
downvote count: 7
accepted answer: http://stackoverflow.com/a/565227
has answer: http://stackoverflow.com/a/565124
favorite count: 0
has answer: http://stackoverflow.com/a/565121
has answer: http://stackoverflow.com/a/7696363
has body: I'm currently working on a simple game in Java with several different modes. I've extended a main Game class to put the main logic within the other classes. Despite this, the main game class is still pretty hefty. After taking a quick look at my code the majority of it was Getters and Setters (60%) compared to the rest that is truly needed for the logic of the game. A couple of Google searches have claimed that Getters and Setters are evil, whilst others have claimed that they are necessary for good OO practice and great programs. So what should I do? Which should it be? Should I be changing my Getters and Setters for my private variables, or should I stick with them?
upvote count: 248
has answer: http://stackoverflow.com/a/565344
has answer: http://stackoverflow.com/a/565155
linked to: http://stackoverflow.com/q/1568091
has answer: http://stackoverflow.com/a/565227
has answer: http://stackoverflow.com/a/565290
type: AnsweredQuestion

http://stackoverflow.com/comment/36560406
type: AnswerComment
comment on: http://stackoverflow.com/a/7873389
type: Comment
has text: I think it's important to say greenDAO has a better compatibility with ProGuard than ORMLite.
score: 0

http://stackoverflow.com/comment/336879
type: Comment
has text: Just my opinion but shouldn't C#'s Windows.Forms and WPF be compared to Java AWT instead of Swing?
comment on: http://stackoverflow.com/a/521337
type: AnswerComment
score: 0

http://stackoverflow.com/comment/106290544
type: Comment
has text: @wwadge the content of jolbox.com has been completely altered... (new owner or new new owner...?)
comment on: http://stackoverflow.com/a/1662916
score: 0
type: AnswerComment

http://stackoverflow.com/comment/435356
type: QuestionComment
has text: Well, XmlNode/XmlDocument have direct equivalents to Java's Document and Node objects. Returning XmlNode/XmlDocuments from WS is a MS-suggested method of returning complex data. This appears to come across correctly in the WSDL as "any" data, I'm just not sure how I pick it up on the Java side.
comment on: http://stackoverflow.com/q/620943
score: 0
type: Comment

http://stackoverflow.com/comment/366805
type: Comment
score: 1
has text: This is exactly why I said "was (is?)", and particularly the term "slower". Nowhere did I say that Ruby is in itself slow.
type: AnswerComment
comment on: http://stackoverflow.com/a/441926

http://stackoverflow.com/a/37885135
answers question: http://stackoverflow.com/q/522395
score: 0
has body: if you have the client code then you just need to add the following two lines to get the XML request/response. Here _call is org.apache.axis.client.Call String request = _call.getMessageContext().getRequestMessage().getSOAPPartAsString(); String response = _call.getMessageContext().getResponseMessage().getSOAPPartAsString();
type: Answer

http://stackoverflow.com/q/435890
linked to: http://stackoverflow.com/q/68078584
tagged with: java
has title: Find Java classes implementing an interface
has answer: http://stackoverflow.com/a/435958
duplicate of: http://stackoverflow.com/q/347248
linked to: http://stackoverflow.com/q/1816730
has answer: http://stackoverflow.com/a/9891313
type: Question
has answer: http://stackoverflow.com/a/10125367
has answer: http://stackoverflow.com/a/5831808
has answer: http://stackoverflow.com/a/436178
has answer: http://stackoverflow.com/a/435930
has answer: http://stackoverflow.com/a/435967
upvote count: 143
has comment: http://stackoverflow.com/comment/6695258
has comment: http://stackoverflow.com/comment/258934
has comment: http://stackoverflow.com/comment/40384552
score: 142
possible better answer: http://stackoverflow.com/a/8166959
linked to: http://stackoverflow.com/q/54719780
has body: Some time ago, I came across a piece of code, that used some piece of standard Java functionality to locate the classes that implemented a given interface. I know the functions were hidden in some non-logical place, but they could be used for other classes as the package name implied. Back then I did not need it, so I forgot about it, but now I do, and I can't seem to find the functions again. Where can these functions be found? Edit: I'm not looking for any IDE functions or anything, but rather something that can be executed within the Java application.
favorite count: 0
has answer: http://stackoverflow.com/a/8166959
linked to: http://stackoverflow.com/q/8735737
accepted answer: http://stackoverflow.com/a/435930
linked to: http://stackoverflow.com/q/251336
answer count: 9
tagged with: interface
linked to: http://stackoverflow.com/q/205573
downvote count: 1
has answer: http://stackoverflow.com/a/436188
linked to: http://stackoverflow.com/q/347248
type: AnsweredQuestion

http://stackoverflow.com/comment/25022370
type: QuestionComment
comment on: http://stackoverflow.com/q/464098
has text: @Hele I wouldn't want to give the game away, but you can google it.
score: 6
type: Comment

http://stackoverflow.com/q/633299
has answer: http://stackoverflow.com/a/633828
tagged with: optimization
has answer: http://stackoverflow.com/a/633598
has comment: http://stackoverflow.com/comment/446870
has answer: http://stackoverflow.com/a/635927
downvote count: 0
has answer: http://stackoverflow.com/a/636079
possible better answer: http://stackoverflow.com/a/633598
has answer: http://stackoverflow.com/a/633544
favorite count: 0
score: 8
upvote count: 8
accepted answer: http://stackoverflow.com/a/635927
answer count: 10
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/633469
has comment: http://stackoverflow.com/comment/2883131
has answer: http://stackoverflow.com/a/636987
has answer: http://stackoverflow.com/a/633926
tagged with: java
has title: Anyone know of a java.util.Map implementation optimized for low memory use?
has body: I've looked in the usual places (apache commons, google) and not been able to find one ... It should be opensource. Pretty much looking for one based on a linked list. The use case is 10'000's of maps, with not necessarily many values in. It does not need to scale up, as i can convert it when it gets too big. Some numbers, sizes using some calculated jvm values (8bytes/java.lang.Object, 4bytes/ref) the HashMap is about 100+32n bytes, the theoretical best is 12+20*n. &lt;-- I want that, for small n.
has answer: http://stackoverflow.com/a/24517459
tagged with: collections
type: Question
has answer: http://stackoverflow.com/a/633364

http://stackoverflow.com/q/537040
score: 20
answer count: 8
has answer: http://stackoverflow.com/a/1586015
upvote count: 20
has answer: http://stackoverflow.com/a/537344
downvote count: 0
accepted answer: http://stackoverflow.com/a/573468
has comment: http://stackoverflow.com/comment/353913
has comment: http://stackoverflow.com/comment/353975
has answer: http://stackoverflow.com/a/17525653
favorite count: 0
has title: How to connect to a secure website using SSL in Java with a pkcs12 file?
has answer: http://stackoverflow.com/a/1761472
has answer: http://stackoverflow.com/a/10817635
has answer: http://stackoverflow.com/a/992426
has answer: http://stackoverflow.com/a/573468
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/10817635
tagged with: ssl
has body: I have a pkcs12 file. I need to use this to connect to a webpage using https protocol. I came across some code where in order to connect to a secure web page i need to set the following system properties: System.setProperty("javax.net.ssl.trustStore", "myTrustStore"); System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); System.setProperty("javax.net.ssl.keyStoreType", "pkcs12"); System.setProperty("javax.net.ssl.keyStore", "new_cert.p12"); System.setProperty("javax.net.ssl.keyStorePassword", "newpass"); I have the p12(pkcs12) file. All I need is a truststore file. I extracted the certificates using: openssl.exe pkcs12 -in c:/mykey.p12 -out c:/cert.txt -nokeys -clcerts Now converted the cert PEM file to der openssl.exe x509 -in c:/cert.txt -outform DER -out c:/CAcert.der Now adding the der file to a keystore keytool -import -file C:/Cacert.der -keystore mytruststore Now I have the truststore, but when I use it, I get the following error Exception in thread "main" java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl) Update: After removing certain properties and setting only the "trustStore", "trustStorePassword" and "trustStoreType" property, I got the following exception java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty Please Help.
has answer: http://stackoverflow.com/a/15183924
type: Question

http://stackoverflow.com/comment/320620
has text: This is exactly the same thing that tweakt says with a code sample.
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/505979

http://stackoverflow.com/q/490824
has body: trying to do some Android development, which means Eclipse, however, most of my experience is Microsoft tools (e.g. Visual Studio). My java experience is mostly either Blackberry dev in the JDE and some miscellaneous stuff back in the Java 1.0 days. My question is this. In VS200x, there is a .sln (solution), .csproj(project), etc... What are the equivalent file extensions for Eclipse? Do they even exist? I am having trouble with the basics, like how does one load a project into a workspace. Is there a tutorial for Microsoft refugees somewhere?
answer count: 4
score: 8
has answer: http://stackoverflow.com/a/490846
has answer: http://stackoverflow.com/a/490857
type: AnsweredQuestion
downvote count: 0
possible better answer: http://stackoverflow.com/a/490840
accepted answer: http://stackoverflow.com/a/490838
has answer: http://stackoverflow.com/a/490840
favorite count: 0
upvote count: 8
type: Question
tagged with: android
has title: Eclipse eye for a Visual Studio guy
tagged with: visual-studio
tagged with: java
tagged with: eclipse
has answer: http://stackoverflow.com/a/490838

http://stackoverflow.com/comment/376925
score: 0
type: Comment
comment on: http://stackoverflow.com/a/565555
type: AnswerComment
has text: Hmm, yes this is true. As I said above, it's that we have quite draconian coverage standards, and I would need to except the wrapper from our coverage. But this is the initial solution we came up with and I guess it makes sense. Thanks!

http://stackoverflow.com/q/454992
has answer: http://stackoverflow.com/a/455032
has title: What interfaces are programmable in the Nokia N73?
type: Question
accepted answer: http://stackoverflow.com/a/455032
tagged with: nokia
tagged with: n73
answer count: 1
tagged with: hardware-interface
has body: I have a Nokia N73 and I'd like to program it to interface with external hardware using any available interface. (POP Port?) Using any of the available platforms: Open C++ Symbian C++ Java Flash Lite Python
type: AnsweredQuestion
score: 0
tagged with: java

waveform
tag name: waveform
type: Tag
tags question: http://stackoverflow.com/q/523419

http://stackoverflow.com/comment/227613
score: 0
type: Comment
comment on: http://stackoverflow.com/a/402067
has text: I've liked JSTL. : -S For me scriplets are just fine as long as they are used in a healthy way, that's what I do. I remember there was something in between since JSP2.0.. it has something like JSP-EL or something like that. I never got too deep in to that though.
type: AnswerComment

http://stackoverflow.com/comment/349556
type: Comment
comment on: http://stackoverflow.com/a/534826
score: 1
type: AnswerComment
has text: @Jon Skeet Let's separate *feelings* from facts even if the former belong to Jon Skeet :) It does not matter whether I think it is faster (I never said that, only that it's not slower) or whether you think it's slower. What matters is the *fact* how fast/slow it is

http://stackoverflow.com/a/376275
upvote count: 12
type: Answer
downvote count: 0
score: 12
accepted answer of: http://stackoverflow.com/q/376093
has body: Here is a possible workaround: if you name it dateofbirth the column in the DB would be named like that, but the attribute name should be the same. Hibernate takes the camel case format to create/read database columns. I've had this problem before. I worked with a legacy columns where there was no space in the column names "employeename", "employeerole", "departmentlocation". I hate it because all my beans properties had to be without camel case. Database columns separated by "_" will be used to properly camelCase as you have just seen.
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/376093

http://stackoverflow.com/comment/436932
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/623733
has text: Say you got a panel with 50+ elements, put into several layers of layout managers, sub widgets, tabs etc. And you need to move an element from one layout manager to another. You never had problems finding the right layout manager? Oh and you didn't code this panel. Somebody else did.

http://stackoverflow.com/a/476723
downvote count: 0
upvote count: 2
has body: I am using RapidMiner (formerly YALE from Univ. of Dortmund). Its a Java-based open source tool and implements most of the popular classifier/clustering methods. And it also ships with algorithms implemented for the Weka toolkit, so there are more options there. Comes with a GUI which is quite easy to use, and a Java-based API.
type: Answer
answers question: http://stackoverflow.com/q/419524
score: 2

http://stackoverflow.com/comment/356218
type: Comment
has text: We're creating the web application. So I shouldn't have to worry about reading the card at all correct? The browser should pass the certificate to my web app and as long as the user enters the correct PIN, Tomcat would allow them access. Wrong PIN, Tomcat would deny access right?
comment on: http://stackoverflow.com/a/544212
type: AnswerComment
score: 0

http://stackoverflow.com/a/3534505
answers question: http://stackoverflow.com/q/517353
upvote count: 2
type: Answer
score: 2
downvote count: 0
has body: I already did this. You need to create one DAO each class, and in the scope of your DAO you need to pass the DATASOURCE and finally one class CONTROLLER where you do dynamic calling to DAO.

http://stackoverflow.com/a/462344
score: 0
answers question: http://stackoverflow.com/q/462198
type: Answer
has body: If you want the subclass to define specific methods, using an interface will do the trick. As others have said, it's not so much about how the subclass does it, just the fact that it will do it.

http://stackoverflow.com/a/46575084
has comment: http://stackoverflow.com/comment/119251765
answers question: http://stackoverflow.com/q/520328
downvote count: 1
type: Answer
upvote count: 0
has body: If you are merely looking to load a group of related classes, then Spring can help you. Spring can instantiate a list or map of all classes that implement a given interface in one line of code. The list or map will contain instances of all the classes that implement that interface. That being said, as an alternative to loading the list of classes out of the file system, instead just implement the same interface in all the classes you want to load, regardless of package and use Spring to provide you instances of all of them. That way, you can load (and instantiate) all the classes you desire regardless of what package they are in. On the other hand, if having them all in a package is what you want, then simply have all the classes in that package implement a given interface. Note that the interface itself doesn't have to declare any methods - it can be completely empty. To inject a list of classes implementing a given interface, use the following lines of code... @Autowired private List&lt;ISomeInterface&gt; implementationList; It is also possible to inject a Map of classes using Spring. Read the docs if interested to see how. Finally, I will offer one other solution that is a bit more elegant than searching the entire file system tree. Create a custom annotation that builds a catalog of the classes to which it is applied - something like @ClassCatalog.
score: -1

http://stackoverflow.com/comment/354340
type: AnswerComment
comment on: http://stackoverflow.com/a/542262
type: Comment
score: 0
has text: I guess by "multiple platforms" you mean non-desktop platforms.

http://stackoverflow.com/a/463355
upvote count: 63
downvote count: 0
answers question: http://stackoverflow.com/q/462923
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/462923
score: 63
type: Answer
has body: Either HSQLDB - Used by OpenOffice, tested and stable. It's easy to use. If you want to edit your db-data, you can just open the file and edit the insert statements. or H2 - Said to be faster (by the developer, who originally designed hsqldb, too) Which one you use is up to you, depending how much performance and how much stability you need. The developer of H2 has put up a nice performance evaluation: http://www.h2database.com/html/performance.html

http://stackoverflow.com/q/395630
has answer: http://stackoverflow.com/a/395664
answer count: 3
has answer: http://stackoverflow.com/a/395643
favorite count: 0
accepted answer: http://stackoverflow.com/a/395643
has body: I'm looking for a sequence of steps to add java code formatting to my blogspot blog. I'm really looking for a dummies guide - something so simple a cleaner could follow it if they found it on a piece of paper on the floor.
has title: What are the steps I need to take to add nice java code formatting to my blogger/blogspot blog?
tagged with: http://stackoverflow.com/tag/html
type: AnsweredQuestion
score: 2
tagged with: java
downvote count: 3
tagged with: blogger
linked to: http://stackoverflow.com/q/384101
tagged with: formatting
tagged with: blogspot
type: Question
has answer: http://stackoverflow.com/a/3489389
upvote count: 5
possible better answer: http://stackoverflow.com/a/395664

http://stackoverflow.com/a/510395
score: 0
answers question: http://stackoverflow.com/q/510305
has comment: http://stackoverflow.com/comment/324487
type: Answer
has body: Not sure if I have understood your question correctly. Assuming you will query based on A's id, how about writing a query in ibatis that joins the two tables? select * from a, a_to_b_map where a.id = #id# and a.id = a_to_b_map.a_id You can then use a 'queryForMap' to return a hashmap of a_id vs (collection of records from the query). Use a custom method to convert this data structure into an object of 'A'

http://stackoverflow.com/comment/245295
has text: Also agree that re-design is necessary. See my answer below.
comment on: http://stackoverflow.com/q/421280
type: Comment
type: QuestionComment
score: 1

http://stackoverflow.com/a/489866
has body: No. Your best option, if you truly need to do this, is to define your fourth parameter as a long[], and have your JNI code update the array element. Actually, your best option would be to consider why you can't return the long from the method.
has comment: http://stackoverflow.com/comment/305851
type: Answer
accepted answer of: http://stackoverflow.com/q/489853
answers question: http://stackoverflow.com/q/489853
upvote count: 2
downvote count: 1
score: 1
type: AcceptedAnswer

http://stackoverflow.com/q/619560
tagged with: eclipse
has answer: http://stackoverflow.com/a/620028
answer count: 2
upvote count: 1
downvote count: 0
favorite count: 0
has body: Is there a way to build my app using one version of the JRE but have my source conform to another version? I would like to debug my app locally using 1.6 because OS X's 1.6 is much better than 1.4.2, but because of backwards compatibility reasons we actually ship using 1.4.2.
has title: Eclipse: Build and conform to different JRE versions
possible better answer: http://stackoverflow.com/a/620028
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/619601
accepted answer: http://stackoverflow.com/a/619601
score: 1
tagged with: java

http://stackoverflow.com/a/439270
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/436488
downvote count: 0
score: 1
has body: McDowell's answer did it. Just for completeness, here's the two methods I added. public Object saveState(FacesContext context) { Object[] rtrn = new Object[2]; rtrn[0] = super.saveState(context); rtrn[1] = msg; return rtrn; } public void restoreState(FacesContext context, Object state) { Object[] values = (Object[]) state; super.restoreState(context, values[0]); msg = (String) values[1]; }

http://stackoverflow.com/comment/5876125
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/458279
has text: Err, he asked about a JComboBox, not JCheckBox. How did this answer even get accepted?
score: 20

http://stackoverflow.com/a/606077
has comment: http://stackoverflow.com/comment/80114561
has comment: http://stackoverflow.com/comment/80132659
downvote count: 1
upvote count: 23
accepted answer of: http://stackoverflow.com/q/606062
type: AcceptedAnswer
has body: In a Java/Maven setting we use as project hierarchy: project/src/main/java/Package/Class.java project/src/test/java/Package/ClassTest.java project/src/main/resources/Package/resource.properties project/src/test/resources/Package/test_resource.properties And in order to answer your question: I would put the SQL-files along with the resources under src/main/resources. You may want to have a look at this thread.
score: 22
answers question: http://stackoverflow.com/q/606062
type: Answer

http://stackoverflow.com/a/531385
has body: If I understood you correctly, you want to know, what the annotation @Before means. The annotation marks a method as to be executed before each test will be executed. There you can implement the old setup() procedure. The @Test annotation marks the following method as a JUnit test. The testrunner will identify every method annotated with @Test and executes it. Example: import org.junit.*; public class IntroductionTests { @Test public void testSum() { Assert.assertEquals(8, 6 + 2); } } How can i use it with Netbeans? In Netbeans, a testrunner for JUnit tests is included. You can choose it in your Execute Dialog.
score: 22
type: Answer
upvote count: 22
has comment: http://stackoverflow.com/comment/344380
downvote count: 0
answers question: http://stackoverflow.com/q/531371

http://stackoverflow.com/q/621117
type: AnsweredQuestion
score: 3
possible better answer: http://stackoverflow.com/a/1229240
tagged with: bounded-wildcard
has answer: http://stackoverflow.com/a/1229240
tagged with: java
accepted answer: http://stackoverflow.com/a/621204
type: Question
answer count: 2
downvote count: 0
has title: How do I fix this Java generics wildcard error?
favorite count: 0
linked to: http://stackoverflow.com/q/620934
tagged with: generics
tagged with: foreach
has answer: http://stackoverflow.com/a/621204
upvote count: 3
has body: In this question, TofuBeer was having problems creating a genericized IterableEnumeration. The answer came from jcrossley3 pointing to this link http://www.javaspecialists.eu/archive/Issue107.html which pretty much solved the problem. There is still one thing I don't get. The real problem, as effectively pointed out by erickson, was that: You cannot specify a wildcard when constructing a parameterized type But removing the wildcard in the declaration didn't work either: final IterableEnumeration&lt;ZipEntry&gt; iteratable = new IterableEnumeration&lt;ZipEntry&gt;(zipFile.entries()); Results in the following error: Main.java:19: cannot find symbol symbol : constructor IterableEnumeration(java.util.Enumeration&lt;capture#469 of ? extends java.util.zip.ZipEntry&gt;) location: class IterableEnumeration&lt;java.util.zip.ZipEntry&gt; final IterableEnumeration&lt;ZipEntry&gt; iteratable = new IterableEnumeration&lt;ZipEntry&gt;( zipFile.entries()); ^ 1 error But the samples in the JavaSpecialist do work: IterableEnumeration&lt;String&gt; ie = new IterableEnumeration&lt;String&gt;(sv.elements()); The only difference I can spot is that in the JavaSpecialists blog, the Enumeration comes from a Vector whose signature is: public Enumeration&lt;E&gt; elements() while the one that fails comes from ZipFile whose signature is: public Enumeration&lt;? extends ZipEntry&gt; entries() Finally, all of this is absorbed by the for-each construct and the static make method suggested in the link for(final ZipEntry entry : IterableEnumeration.make( zipFile.entries() )) { if(!(entry.isDirectory())) { names.add(entry.getName()); } } But!! the point in that newsletter was not to solve this problem, but to avoid the need to specify a generic type, just because the syntax looks ugly!! So.. my questions is: What is happening? Why doesn't creating an instance of IterableEnumeration work when the parameter is an Enumeration whose type is &lt;? extends SomeClass&gt; ? And why does the make for-each c…

http://stackoverflow.com/comment/40815359
score: 4
type: AnswerComment
type: Comment
has text: @ars-longa-vita-brevis, If you are using Comparable then sorting logic must be in the same class whose objects are being sorted so this is called natural ordering of objects. With the use of Comparator you can write custom sorting logic outside the Person class. If you want to compare Person objects only by its first name or last name, you cant use this logic. You have to write it again,
comment on: http://stackoverflow.com/a/369867

http://stackoverflow.com/comment/243630
type: Comment
has text: ...another way to show pride in our work is to see ourselves as businesspeople too, not just as engineers. We can show pride by seeing our engineering activities in their proper business context and behaving accordingly.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/419459

http://stackoverflow.com/q/475842
linked to: http://stackoverflow.com/q/869033
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/475852
has answer: http://stackoverflow.com/a/44298628
has answer: http://stackoverflow.com/a/476223
upvote count: 21
has body: I have an object that I need to copy in Java. I need to create a copy and run some tests on it without changing the original object itself. I assumed that I needed to use the clone() method, but this is protected. Having done some research on the net, I can see that this can be overriden with a public method in my class. But I cannot find an explanation on how to do this. How could this be done? Also, is this the best way of achieving what I need?
type: Question
tagged with: object
has title: Copy an object in Java
tagged with: clone
score: 21
has answer: http://stackoverflow.com/a/475859
tagged with: java
has comment: http://stackoverflow.com/comment/4378625
tagged with: copy
has answer: http://stackoverflow.com/a/9835618
has answer: http://stackoverflow.com/a/476040
downvote count: 0
answer count: 7
favorite count: 0
has answer: http://stackoverflow.com/a/475865

http://stackoverflow.com/comment/106101465
has text: This is what's wrong with Stack Overflow. Someone has a pissy fit because they are called out and expresses it with downvotes.
type: Comment
comment on: http://stackoverflow.com/a/49241488
score: 0
type: AnswerComment

http://stackoverflow.com/comment/321485
has text: "dead" == "I'm not aware of anybody in my small world talking or thinking about or using Jini." Admittedly my world is limited.
comment on: http://stackoverflow.com/a/506989
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/415841
answer count: 3
tagged with: enterprise
downvote count: 0
favorite count: 0
possible better answer: http://stackoverflow.com/a/415846
has answer: http://stackoverflow.com/a/415846
accepted answer: http://stackoverflow.com/a/415877
tagged with: remoting
type: AnsweredQuestion
score: 1
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/415857
tagged with: java
has answer: http://stackoverflow.com/a/415877
has title: Are application servers (with EJBs) the only way for Java EE client/server communication?
has body: Imagine a Java client/server ERP application serving up to 100 concurrent users, both web and swing clients. For persistence we can use Persistence API and Hibernate. But when it comes to client/server communication, do we really have an alternative to using an AS with EJBs to keep down the programming costs of remote communication? It seems a very heavyweight solution to throw in EJBs and an application server, just for remoting stuff. There is also the standard way using RMI, but who wants nowadays to code everything on his own... I know that you'll get a lot of features for free with an AS in addition to the remoting part. And, maybe it's the way to go. But, are there really any other (low programming cost) alternatives to an AS for doing client/server communication for an enterprise application?
tagged with: client-server

http://stackoverflow.com/comment/325249
comment on: http://stackoverflow.com/a/511434
type: Comment
has text: where should not doesn't mean must not! +1 I have a couple of cases where I do handle UnsatisfiedLinkError
type: AnswerComment
score: 4

testing
tags question: http://stackoverflow.com/q/530203
tags question: http://stackoverflow.com/q/609405
tag name: testing
tags question: http://stackoverflow.com/q/400250
tags question: http://stackoverflow.com/q/375656
tags question: http://stackoverflow.com/q/511578
tags question: http://stackoverflow.com/q/624137
type: Tag
tags question: http://stackoverflow.com/q/406129
tags question: http://stackoverflow.com/q/583756
tags question: http://stackoverflow.com/q/626389
tags question: http://stackoverflow.com/q/486381
tags question: http://stackoverflow.com/q/545194
tags question: http://stackoverflow.com/q/413214
tags question: http://stackoverflow.com/q/433065
tags question: http://stackoverflow.com/q/412409
tags question: http://stackoverflow.com/q/385532
tags question: http://stackoverflow.com/q/604449
tags question: http://stackoverflow.com/q/440786
tags question: http://stackoverflow.com/q/576901
tags question: http://stackoverflow.com/q/487901

http://stackoverflow.com/q/565060
answer count: 1
type: UnansweredQuestion
tagged with: python
has comment: http://stackoverflow.com/comment/576466
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/565185
has title: Using jep.invoke() method
score: 0
has body: I need to call a function from a python script and pass in parameters into it. I have a test python script which I can call and run from java using Jepp - this then adds the person. Eg Test.py import Finding from Finding import * f = Finding() f.addFinding("John", "Doe", 27) Within my Finding class I have addFinding(firstname, lastName, age) However, I wish to be able to do this from within java. Should I be using the jep.invoke() method. Does anyone have a hello world example of such a thing being done or forward me to some good examples? Does anyone have any suggestions please? Thanks in advance

windows-xp
tags question: http://stackoverflow.com/q/361609
type: Tag
tag name: windows-xp
tags question: http://stackoverflow.com/q/486938

http://stackoverflow.com/comment/5313606
has text: @oxbow. I want to learn Spring. Where do I start?
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/530406

http://stackoverflow.com/a/579506
answers question: http://stackoverflow.com/q/579445
upvote count: 37
accepted answer of: http://stackoverflow.com/q/579445
score: 37
has comment: http://stackoverflow.com/comment/107808358
has body: The constructors can appear anywhere in the code for the class. However, by convention, most people put them before any other functions that aren't constructors. As for the variable names, all 6 are actually variable names, but the scope is differnet. The ones specified as parameters to the constructor (startCadence, startSpeed, startGear) are only available within the constructor. The other 3 (gear, cadence, speed) are probably class-wide variables, available to all methods. However the definition isn't shown in your code snippet. The full class would look mroe like: class Bicycle { // class-level variables private int gear; private int cadence; private int speed; // constructor public Bicycle(int startCadence, int startSpeed, int startGear) { gear = startGear; cadence = startCadence; speed = startSpeed; } // another method (not a constructor) public void ShiftUp() { gear = gear + 1; // notice the 'gear' variable is available here too. } } Hope that helps!
type: AcceptedAnswer
downvote count: 0
type: Answer

http://stackoverflow.com/q/400477
has answer: http://stackoverflow.com/a/401399
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/400498
has title: On a 64-bit machine is the size of an int in Java 32 bits or 64 bits?
tagged with: java
has answer: http://stackoverflow.com/a/400483
type: Question
has answer: http://stackoverflow.com/a/400481
score: 70
upvote count: 70
has answer: http://stackoverflow.com/a/400490
has answer: http://stackoverflow.com/a/400988
has answer: http://stackoverflow.com/a/11856042
downvote count: 0
answer count: 7
favorite count: 0
accepted answer: http://stackoverflow.com/a/400481
has body: On a 64-bit machine is the size of an int in Java 32 bits or 64 bits?
possible better answer: http://stackoverflow.com/a/401399

http://stackoverflow.com/a/11110781
score: 13
upvote count: 13
has body: Everyone here seems to think that implementing Runnable is the way to go and I don't really disagree with them but there is also a case for extending Thread in my opinion, in fact you have sort of demonstrated it in your code. If you implement Runnable then the class that implements Runnable has no control over the thread name, it is the calling code that can set the thread name, like so: new Thread(myRunnable,"WhateverNameiFeelLike"); but if you extend Thread then you get to manage this within the class itself (just like in your example you name the thread 'ThreadB'). In this case you: A) might give it a more useful name for debugging purposes B) are forcing that that name be used for all instances of that class (unless you ignore the fact that it is a thread and do the above with it as if it is a Runnable but we are talking about convention here in any case so can ignore that possibility I feel). You might even for example take a stack trace of its creation and use that as the thread name. This might seem odd but depending on how your code is structured it can be very useful for debugging purposes. This might seem like a small thing but where you have a very complex application with a lot of threads and all of a sudden things 'have stopped' (either for reasons of deadlock or possibly because of a flaw in a network protocol which would be less obvious - or other endless reasons) then getting a stack dump from Java where all the threads are called 'Thread-1','Thread-2','Thread-3' is not always very useful (it depends on how your threads are structured and whether you can usefully tell which is which just by their stack trace - not always possible if you are using groups of multiple threads all running the same code). Having said that you could of course also do the above in a generic way by creating an extension of the thread class which sets its name to a stack trace of its creation call and then use that with your Runnable implementations instead of the standard j…
answers question: http://stackoverflow.com/q/541487
has comment: http://stackoverflow.com/comment/17964970
downvote count: 0
has comment: http://stackoverflow.com/comment/17964784
has comment: http://stackoverflow.com/comment/38847674
type: Answer

http://stackoverflow.com/a/449165
answers question: http://stackoverflow.com/q/449103
score: 0
type: Answer
upvote count: 1
downvote count: 1
has body: It is failing because of erasure. You can read more about it in these Java Tutorials

parameter-spoofing
tag name: parameter-spoofing
type: Tag
tags question: http://stackoverflow.com/q/437663

http://stackoverflow.com/comment/283345
comment on: http://stackoverflow.com/a/464833
type: AnswerComment
has text: In fact the JDK implementation does keep track of who locked the readlock to some extent; getReadHoldCount() returns the count for the current thread only (via a ThreadLocal) so exactly the right number of unlocks() can be called in this situation. The code I put in my own answer does in fact work.
score: 0
type: Comment

http://stackoverflow.com/q/453610
upvote count: 157
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/485775
tagged with: java
has answer: http://stackoverflow.com/a/453706
has body: As a sort of follow up to the question called Differences between MSIL and Java bytecode?, what is the (major) differences or similarity in how the Java Virtual Machine works versus how the .NET Framework Common Language Runtime (CLR) works? Also, is the .NET framework CLR a "virtual machine" or does it not have the attributes of a virtual machine?
downvote count: 1
tagged with: cil
type: Question
has answer: http://stackoverflow.com/a/480362
has answer: http://stackoverflow.com/a/453617
possible better answer: http://stackoverflow.com/a/453706
tagged with: bytecode
has title: Java's Virtual Machine and CLR
score: 156
tagged with: .net
has comment: http://stackoverflow.com/comment/274013
accepted answer: http://stackoverflow.com/a/480362
favorite count: 0
linked to: http://stackoverflow.com/q/30458195
tagged with: vm-implementation
answer count: 5
has answer: http://stackoverflow.com/a/453638

http://stackoverflow.com/comment/312641
type: AnswerComment
has text: Assuming that the field is not a primitive. You didn't say if it was an object or a double, so I thought the reference would be worth having. You also didn't mention overriding equals, and you should.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/496808

http://stackoverflow.com/q/477550
has answer: http://stackoverflow.com/a/1491331
has answer: http://stackoverflow.com/a/22881463
has answer: http://stackoverflow.com/a/477563
type: Question
tagged with: for-loop
has answer: http://stackoverflow.com/a/54756663
answer count: 16
has answer: http://stackoverflow.com/a/477608
has answer: http://stackoverflow.com/a/54122689
has body: Is there a way in Java's for-each loop for(String s : stringArray) { doSomethingWith(s); } to find out how often the loop has already been processed? Aside from using the old and well-known for(int i=0; i &lt; boundary; i++) - loop, is the construct int i = 0; for(String s : stringArray) { doSomethingWith(s); i++; } the only way to have such a counter available in a for-each loop?
downvote count: 0
has answer: http://stackoverflow.com/a/44551063
has answer: http://stackoverflow.com/a/477654
possible better answer: http://stackoverflow.com/a/1491331
has answer: http://stackoverflow.com/a/46722062
has answer: http://stackoverflow.com/a/40116095
favorite count: 0
linked to: http://stackoverflow.com/q/3431529
has answer: http://stackoverflow.com/a/3149547
has answer: http://stackoverflow.com/a/477569
upvote count: 342
has answer: http://stackoverflow.com/a/59594774
has comment: http://stackoverflow.com/comment/27437381
has comment: http://stackoverflow.com/comment/67503679
has answer: http://stackoverflow.com/a/75100977
has title: Is there a way to access an iteration-counter in Java's for-each loop?
type: AnsweredQuestion
tagged with: foreach
has answer: http://stackoverflow.com/a/477592
score: 342
accepted answer: http://stackoverflow.com/a/477592
tagged with: java
has answer: http://stackoverflow.com/a/5200217
tagged with: loops

http://stackoverflow.com/q/434803
type: Question
has answer: http://stackoverflow.com/a/504872
accepted answer: http://stackoverflow.com/a/504872
has body: I realised this might be relatively niche, but maybe that's why this is good to ask anyway. I'm looking at a hardware multiple input recording console (such as the Alesis IO 26) to take in an Adat lightpipe 8 channel input to do signal processing. As I have yet to acquire the device and need to work out whether this is feasible (budgetary concerns), I'd like to ask if anyone has any experience tapping all these 8 inputs for data in Java? I've seen tons of examples of recording sound using the Javax.sound.sampled libraries but I couldn't find any information on multichannel that is more than 2. What I'm interested in is sampling the 8 channels individual as mono source to perform some simple DSP on them. Would the hardware device be treated as one mixer? And the 8 channels be represented as 8 lines? I hope I got my terminology right. I would appreciate if someone can point me to any relevant information. Thanks!
has answer: http://stackoverflow.com/a/12255119
favorite count: 0
has title: How to sample multi-channel sound input in Java
answer count: 4
score: 8
possible better answer: http://stackoverflow.com/a/495005
downvote count: 0
tagged with: javasound
has answer: http://stackoverflow.com/a/495005
tagged with: audio-recording
has answer: http://stackoverflow.com/a/487861
type: AnsweredQuestion
tagged with: java
upvote count: 8

http://stackoverflow.com/a/616564
has comment: http://stackoverflow.com/comment/83972278
has comment: http://stackoverflow.com/comment/84103396
upvote count: 2
score: 1
answers question: http://stackoverflow.com/q/616487
downvote count: 1
has body: DISCLAIMER: I don't know these Java classes, I'm taking a stab in the dark here. In C#, you have a lock statement (I think this is something like Java's synchronized statement) which can lock on any object. I suppose using that statement, or Monitor.Enter(obj) and Monitor.Exit(obj) would be a bit like ReentrantLock. There are two class called ManualResetEvent and AutoResetEvent. These classes have a Wait method, and a Set method, which I suppose is like Condition's signal and await. The difference between these two classes is that a ManualResetEvent stays set (no longer blocking anyone) and must be Reset. And AutoResetEvent is - like its name suggests - reset automatically.
type: Answer

http://stackoverflow.com/q/631550
type: AnsweredQuestion
score: 3
tagged with: java
type: Question
possible better answer: http://stackoverflow.com/a/631594
accepted answer: http://stackoverflow.com/a/631560
downvote count: 0
has answer: http://stackoverflow.com/a/631553
favorite count: 0
has body: Which is better? @SuppressWarnings("unchecked") @SuppressWarnings(AnnotationConstants.UNCHECKED) Where AnnotationConstants is a typical constants class... public final class AnnotationConstants { private AnnotationConstants() { } public static final String UNCHECKED = "unchecked"; ... } I know that there are a lot of general arguments for and against constants classes--and that's exactly what I'm not interested in. I want to know if a constants class specifically for annotations is a good idea or a bad idea.
has answer: http://stackoverflow.com/a/632017
has answer: http://stackoverflow.com/a/631560
answer count: 4
tagged with: constants
has answer: http://stackoverflow.com/a/631594
upvote count: 3
tagged with: annotations
has title: Should I make a constants class for my annotations?

http://stackoverflow.com/comment/245224
comment on: http://stackoverflow.com/a/420082
score: 1
has text: actually 'support moving' is a misnomer. It recognizes that some files are absent, and some files are new, but it doesn't know anything about _moving_ files per se...
type: AnswerComment
type: Comment

http://stackoverflow.com/q/431107
tagged with: java
has answer: http://stackoverflow.com/a/431132
has title: Spring context files organization and best practices
type: Question
tagged with: jakarta-ee
upvote count: 22
has answer: http://stackoverflow.com/a/11130632
downvote count: 0
has answer: http://stackoverflow.com/a/431352
score: 22
has answer: http://stackoverflow.com/a/431754
answer count: 7
possible better answer: http://stackoverflow.com/a/431754
has body: We have started using Spring framework in my project. After becoming acquainted with the basic features (IoC) we have started using spring aop and spring security as well. The problem is that we now have more than 8 different context files and I feel we didn't give enough thought for the organization of those files and their roles. New files were introduced as the project evolved. We have different context files for: metadata, aop, authorization, services, web resources (it's a RESTful application). So when a developer wants to add a new bean it's not always clear in which file he should add it. We need methodology. The question: Is there a best practice for spring files organization? Should the context files encapsulate layers (DAL , Business Logic, Web) or use cases ? or Flows?
favorite count: 0
accepted answer: http://stackoverflow.com/a/431352
has answer: http://stackoverflow.com/a/1005220
tagged with: spring
has answer: http://stackoverflow.com/a/431422
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/431337

http://stackoverflow.com/a/579221
score: 137
has comment: http://stackoverflow.com/comment/391941
has body: By using synchronized on a static method lock you will synchronize the class methods and attributes ( as opposed to instance methods and attributes ) So your assumption is correct. I am wondering if making the method synchronized is the right approach to ensure thread-safety. Not really. You should let your RDBMS do that work instead. They are good at this kind of stuff. The only thing you will get by synchronizing the access to the database is to make your application terribly slow. Further more, in the code you posted you're building a Session Factory each time, that way, your application will spend more time accessing the DB than performing the actual job. Imagine the following scenario: Client A and B attempt to insert different information into record X of table T. With your approach the only thing you're getting is to make sure one is called after the other, when this would happen anyway in the DB, because the RDBMS will prevent them from inserting half information from A and half from B at the same time. The result will be the same but only 5 times ( or more ) slower. Probably it could be better to take a look at the "Transactions and Concurrency" chapter in the Hibernate documentation. Most of the times the problems you're trying to solve, have been solved already and a much better way.
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/22554204
has comment: http://stackoverflow.com/comment/22541263
type: Answer
has comment: http://stackoverflow.com/comment/391972
answers question: http://stackoverflow.com/q/578904
accepted answer of: http://stackoverflow.com/q/578904
downvote count: 0
has comment: http://stackoverflow.com/comment/22498149
upvote count: 137
has comment: http://stackoverflow.com/comment/391960

http://stackoverflow.com/a/443024
has body: Even if there is such a tool, I'd highly recommend you to do the conversion by hand. Automatic converters will often faithfully reproduce the code, but ignore idioms - because they'd be really, really hard to get right. Furthermore, the differences between generics in .NET and Java could lead to some very different decisions in the two codebases. Really, you'll be better off doing it by hand.
answers question: http://stackoverflow.com/q/443010
has comment: http://stackoverflow.com/comment/265127
has comment: http://stackoverflow.com/comment/264806
downvote count: 3
type: Answer
upvote count: 33
score: 30

http://stackoverflow.com/comment/60806618
type: Comment
comment on: http://stackoverflow.com/a/427101
score: 0
type: AnswerComment
has text: @joel.neely That is totally true, and you've articulated the difference between applicative functors (used in this answer) and monads.

http://stackoverflow.com/a/494937
downvote count: 0
has comment: http://stackoverflow.com/comment/24653067
type: Answer
has body: There is a lib called jnotify that wraps inotify on linux and has also support for windows. Never used it and I don't know how good it is, but it's worth a try I'd say.
score: 27
answers question: http://stackoverflow.com/q/494869
upvote count: 27

http://stackoverflow.com/comment/136189526
type: Comment
has text: To avoid a circular call (which will result in a stack overflow eventually), check if the SecurityManager itself appears twice in the call stack. You can add this as first line inside the for-each loop: `if (clasS == this.getClass() && ++visitedThis >= 2) return; `. (And declare a variable `int visitedThis = 0` before the loop.)
comment on: http://stackoverflow.com/a/24225075
score: 0
type: AnswerComment

http://stackoverflow.com/comment/12782553
has text: I've stopped by this thread so many times when I needed to study how someone accomplished something for a Bukkit plugin... That comment always leaves me with a smile. I wish I could upvote it every time I stop by.
type: Comment
comment on: http://stackoverflow.com/q/647116
type: QuestionComment
score: 10

http://stackoverflow.com/q/525855
downvote count: 0
answer count: 1
favorite count: 0
has title: Moving focus from JTextArea using tab key
upvote count: 32
has comment: http://stackoverflow.com/comment/6574976
tagged with: netbeans
linked to: http://stackoverflow.com/q/5042429
has answer: http://stackoverflow.com/a/525867
score: 32
tagged with: swing
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/525867
tagged with: java
has body: As stated, I want to change the default TAB behaviour within a JTextArea (so that it acts like a JTextField or similar component) Here's the event action private void diagInputKeyPressed(java.awt.event.KeyEvent evt) { if(evt.KEY_PRESSED == java.awt.event.KeyEvent.VK_TAB) { actionInput.transferFocus(); } } And here's the listener diagInput.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { diagInputKeyPressed(evt); } }); I've tried evt.KEY_TYPED as well with no joy. Any ideas? quick edit: I've also tried requestFocus() in place of transferFocus()
type: Question

http://stackoverflow.com/comment/464354
type: Comment
has text: By the way Matt, please use the url in the original comment ( http://www.terracotta.org/download/reflector/maven2/ ) and not the one you put in the comment. The original is the official link and will redirect to actual (which will likely change today in fact).
comment on: http://stackoverflow.com/a/641478
score: 0
type: AnswerComment

http://stackoverflow.com/a/1687044
has comment: http://stackoverflow.com/comment/15511404
type: Answer
has comment: http://stackoverflow.com/comment/35070584
has body: The JDK logging facilities have always done what I need them to do - never had a problem with it. To me, third party logging tools are neither necessary nor desirable.
upvote count: 7
score: 7
answers question: http://stackoverflow.com/q/607863
downvote count: 0

http://stackoverflow.com/a/471614
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/450807
has body: Based on the same idea as Super Type Tokens, you could create a typed id to use instead of a string: public abstract class TypedID&lt;T extends Animal&gt; { public final Type type; public final String id; protected TypedID(String id) { this.id = id; Type superclass = getClass().getGenericSuperclass(); if (superclass instanceof Class) { throw new RuntimeException("Missing type parameter."); } this.type = ((ParameterizedType) superclass).getActualTypeArguments()[0]; } } But I think this may defeat the purpose, since you now need to create new id objects for each string and hold on to them (or reconstruct them with the correct type information). Mouse jerry = new Mouse(); TypedID&lt;Dog&gt; spike = new TypedID&lt;Dog&gt;("spike") {}; TypedID&lt;Duck&gt; quacker = new TypedID&lt;Duck&gt;("quacker") {}; jerry.addFriend(spike, new Dog()); jerry.addFriend(quacker, new Duck()); But you can now use the class in the way you originally wanted, without the casts. jerry.callFriend(spike).bark(); jerry.callFriend(quacker).quack(); This is just hiding the type parameter inside the id, although it does mean you can retrieve the type from the identifier later if you wish. You'd need to implement the comparison and hashing methods of TypedID too if you want to be able to compare two identical instances of an id.
score: 10
upvote count: 10

http://stackoverflow.com/q/379594
type: Question
tagged with: blob
tagged with: java
has title: Why I cannot cast oracle BLOB from native java Blob
has answer: http://stackoverflow.com/a/379606
downvote count: 0
score: 4
favorite count: 0
answer count: 3
tagged with: oracle-database
tagged with: classcastexception
upvote count: 4
possible better answer: http://stackoverflow.com/a/379605
accepted answer: http://stackoverflow.com/a/1168936
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/379605
has answer: http://stackoverflow.com/a/1168936
has body: I am reading file from ResultSet and it's required to save file into Oracle Database. ... ResultSet rs = ... java.sql.Blob myfile = rs.getBlob("field") java.io.OutputStream os = ((oracle.sql.BLOB) myfile).getBinaryOutputStream(); I get get this error message java.lang.ClassCastException Any one have solution to this? Thanks!

http://stackoverflow.com/comment/79142887
has text: I really like this syntax. I think in C# it's `jerry.CallFriend<Dog>(...` which I think looks better.
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/450852
type: Comment

http://stackoverflow.com/comment/40121254
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/4382138
has text: @andreas-h I've added the RGB values to the answer.

http://stackoverflow.com/a/626354
answers question: http://stackoverflow.com/q/579109
upvote count: 1
type: Answer
downvote count: 0
score: 1
has body: Of course it all depends on the kind of applications and services you want to provide, and the target environment. But I can also recommend OSGi as a development and deployment platform. The underlying architecture and specifications are very well developed and proven. Besides of the Eclipse RCP you should have a look at Apache Felix (http://felix.apache.org) and Knopflerfish (http://www.knopflerfish.org), which are (smaller) open source OSGi framework implementations.

http://stackoverflow.com/q/515133
has answer: http://stackoverflow.com/a/515302
accepted answer: http://stackoverflow.com/a/515142
possible better answer: http://stackoverflow.com/a/515302
score: 1
upvote count: 1
type: Question
type: AnsweredQuestion
tagged with: oop
has body: I have written a program with both a Advanced Mode and a Beginner Mode to allow the user to get the hang of my program before it is actually used. The Advanced Mode is almost identical to the Beginner Mode apart from one or two methods needing to be replaced by another, so I have decided to create a general Mode class for both Advanced Mode and Beginner Mode classes to use instead of just coping code: Here is the class structure if my explanation isn't very clear: GUI Class General Mode Class Beginner Mode Advanced Mode Let's say that the General Mode class has the following code: public class GeneralMode { private int range; private String id; public GeneralMode() { } public int getRange() { return range; } public String getID() { return id; } public void doStuff() { } } The GeneralMode class is where all the work gets done for the program. Now, I would like to make it so that the Advanced Mode class can take the input from the GUI class and use it in the same way as the GeneralMode class does. Thank you for all your help!
has comment: http://stackoverflow.com/comment/328802
tagged with: java
has title: Java: Basic OOP Question
has answer: http://stackoverflow.com/a/515332
has answer: http://stackoverflow.com/a/515387
downvote count: 0
has answer: http://stackoverflow.com/a/515142
favorite count: 0
has answer: http://stackoverflow.com/a/515301
answer count: 5
has comment: http://stackoverflow.com/comment/328976

http://stackoverflow.com/comment/29953910
type: AnswerComment
type: Comment
has text: The former suggestion won't work, either. The docs say: `The Class-Path header points to classes or JAR files on the local network, not JAR files within the JAR file or classes accessible over internet protocols. To load classes in JAR files within a JAR file into the class path, you must write custom code to load those classes.`
comment on: http://stackoverflow.com/a/502988
score: 0

http://stackoverflow.com/q/567482
type: Question
tagged with: jakarta-ee
upvote count: 5
tagged with: java
has title: LDAP Best Practices
has answer: http://stackoverflow.com/a/572023
has body: I'm interested in the best practices of using LDAP authentication in a Java-based web application. In my app I don't want to store username\password, only some ids. But I want to retrieve addition information (Name, Last name) if any exists in an LDAP catalog.
possible better answer: http://stackoverflow.com/a/7977560
score: 5
downvote count: 0
accepted answer: http://stackoverflow.com/a/567662
favorite count: 0
tagged with: ldap
has answer: http://stackoverflow.com/a/567718
has answer: http://stackoverflow.com/a/567662
has answer: http://stackoverflow.com/a/7977560
answer count: 4
type: AnsweredQuestion

http://stackoverflow.com/comment/41425425
type: Comment
has text: While a helpful comment, it's not really an answer to the question. Recommend changing it to a comment.
comment on: http://stackoverflow.com/a/530505
score: 0
type: AnswerComment

linux
tags question: http://stackoverflow.com/q/624137
tags question: http://stackoverflow.com/q/602651
tags question: http://stackoverflow.com/q/376279
tags question: http://stackoverflow.com/q/538886
tags question: http://stackoverflow.com/q/609888
tags question: http://stackoverflow.com/q/458382
tags question: http://stackoverflow.com/q/573982
tags question: http://stackoverflow.com/q/554641
tags question: http://stackoverflow.com/q/638553
tags question: http://stackoverflow.com/q/491877
tags question: http://stackoverflow.com/q/494442
tags question: http://stackoverflow.com/q/447298
tags question: http://stackoverflow.com/q/609528
tags question: http://stackoverflow.com/q/623990
tags question: http://stackoverflow.com/q/564154
tags question: http://stackoverflow.com/q/490970
tags question: http://stackoverflow.com/q/597927
type: Tag
tags question: http://stackoverflow.com/q/578073
tags question: http://stackoverflow.com/q/481379
tags question: http://stackoverflow.com/q/580860
tags question: http://stackoverflow.com/q/641866
tags question: http://stackoverflow.com/q/559433
tag name: linux
tags question: http://stackoverflow.com/q/472825
tags question: http://stackoverflow.com/q/590797
tags question: http://stackoverflow.com/q/444731
tags question: http://stackoverflow.com/q/561245
tags question: http://stackoverflow.com/q/450676
tags question: http://stackoverflow.com/q/625516
tags question: http://stackoverflow.com/q/375332
tags question: http://stackoverflow.com/q/429762
tags question: http://stackoverflow.com/q/426397

http://stackoverflow.com/a/542447
has comment: http://stackoverflow.com/comment/354656
score: 0
answers question: http://stackoverflow.com/q/542127
type: Answer
has body: Jar file manipulation can be very expensive, and the Java class library already implements this kind of resource loading (probably as efficiently as possible.) Plus, once you're in webstart, your jar file names will get mangled, so you'll likely end up having to explore every jar file on the classpath to load your resources (I've done it! Ugly!) Instead, use Class.getResourceAsStream(String resourceName). I haven't profiled it, but I haven't noticed it being noticeably slower than direct file access.

http://stackoverflow.com/a/3189373
upvote count: 1
has body: I am answering this question a year+ after it was asked but I do have some info to add for those happening by at a later time. I answered a similar question about getting the image dimensions from an image on a remote server without downloading the whole image. See that discussion at the following URL: Get image dimensions with Curl You could definitely use the same technique to pull info out of the ID3 tags without downloading the whole MP3 from a remote server. I hope that helps for future passers-by.
downvote count: 0
answers question: http://stackoverflow.com/q/624741
type: Answer
score: 1

http://stackoverflow.com/comment/414032
type: Comment
comment on: http://stackoverflow.com/a/601810
type: AnswerComment
has text: We use POI as well in our shop, it's quirky, but it gets the job done.
score: 0

http://stackoverflow.com/comment/310260
type: AnswerComment
score: 0
type: Comment
has text: Also, OCUnit is not really there in the iPhone version of the SDK so you may want to look at this more leightweight unit testing framework for iPhone stuff: http://code.google.com/p/google-toolbox-for-mac/wiki/iPhoneUnitTesting
comment on: http://stackoverflow.com/a/487980

http://stackoverflow.com/a/617257
accepted answer of: http://stackoverflow.com/q/617165
has comment: http://stackoverflow.com/comment/432571
has body: Heres my code that tofubeer updated that I updated again. His didn't compile. missing InvalidGroupException class. Also, no package was specified. Switched EMPTY_LIST to emptyList() to avoid lack of parameterization. package fileutils; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; public class GroupReader2 { public static class InvalidGroupException extends Exception { private static final long serialVersionUID = 1L; public InvalidGroupException(String string) { super(string); } } public static GroupReader2 parseGroup(final String groupLine) throws InvalidGroupException { final String line; final String[] parts; if (groupLine == null) { throw new IllegalArgumentException("groupLine cannot be null"); } line = groupLine.trim(); if (line.startsWith("#") || line.isEmpty()) { return null; } parts = line.split(":"); if (parts.length &lt; 3) { throw new InvalidGroupException(groupLine + "must be in the format of name:passwd:gid[:userlist]"); } try { final GroupReader2 group; final String name; final String passwd; final int gid; final List&lt;String&gt; userList; name = parts[0]; passwd = parts[1]; gid = Integer.parseInt(parts[2]); if (parts.length == 4) { userList = Arrays.asList(parts[3].split(",")); } else { userList = Collections.emptyList(); } group = new GroupReader2(name, passwd, gid, userList); return group; } catch (final NumberFormatException ex) { throw new InvalidGroupException(groupLine + " gid must be a number"); } } private final int gid; private final String name; private final String passwd; private final List&lt;String&gt; userList; public GroupReader2(final String nm, final String pw, final int id, final List&lt;String&gt; users) { name = nm; passwd = pw; gid = id; userList = Collections.unmodifiableList(new ArrayList&lt;String&gt;(users)); } public int getGid() { return (gid); } public String getName() { return (name); } public String getPasswd() { return (passwd); } public List&lt;String&gt; g…
has comment: http://stackoverflow.com/comment/430486
has comment: http://stackoverflow.com/comment/430189
has comment: http://stackoverflow.com/comment/430280
has comment: http://stackoverflow.com/comment/433412
upvote count: 4
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/433217
score: 4
has comment: http://stackoverflow.com/comment/430272
answers question: http://stackoverflow.com/q/617165
has comment: http://stackoverflow.com/comment/430248
has comment: http://stackoverflow.com/comment/430258
type: Answer

http://stackoverflow.com/comment/107743305
has text: How did you find that out?
score: 0
comment on: http://stackoverflow.com/a/33601400
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/372715
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/561588
has text: Vote for close as exact duplicate. http://stackoverflow.com/questions/24901/ ... http://stackoverflow.com/questions/53455/ ... http://stackoverflow.com/questions/484462/ ... etc
score: 0

http://stackoverflow.com/q/381680
has answer: http://stackoverflow.com/a/381710
tagged with: java
tagged with: http://stackoverflow.com/tag/c
score: 0
has answer: http://stackoverflow.com/a/10574245
has answer: http://stackoverflow.com/a/382849
has answer: http://stackoverflow.com/a/381692
has answer: http://stackoverflow.com/a/381855
tagged with: ide
favorite count: 0
has answer: http://stackoverflow.com/a/382868
answer count: 9
has answer: http://stackoverflow.com/a/390711
tagged with: objective-c
tagged with: c++
type: UnansweredQuestion
has title: C/objC/C++/Java compilers
upvote count: 1
has answer: http://stackoverflow.com/a/381900
downvote count: 1
has answer: http://stackoverflow.com/a/381727
type: Question
has body: I downloaded NetBeans (for first time) to use Java and found that it can handle C/C++ etc too. Wanted to know following -- 01- Is there any better C++ tool (IDE) other than NetBeans and MS Visual Studio? Better means very mature and popular (and free). 02- What is the difference between GNU Java and Sun Java compilers? 02- Is there any other popular C/ObjC/C++ complier out which is free, mature and popular? Thank you for the reply.

http://stackoverflow.com/comment/50697868
type: AnswerComment
comment on: http://stackoverflow.com/a/6452833
has text: Anonymous inner classes don't generate synthetic classes on Oracle JDK 1.8.0_45, they generate separate non-synthetic classes with names of type `Outer$1.class`.
score: 0
type: Comment

http://stackoverflow.com/q/613097
type: UnansweredQuestion
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/427302
has answer: http://stackoverflow.com/a/622653
tagged with: java
has answer: http://stackoverflow.com/a/618605
tagged with: eclipse
has body: I am creating an eclipse plugin, and I need Class object of selected file, not IType. Is it possible, and how is the best way to do it? Edit: when I think about it, the best way is to add it like run as (like junit, profiler, or other plugins are doing). I suppose they must have access to Class (if X is class in question), because they are running it's functions. So how to create plugin that has "run as " action, and get live object?
type: Question
score: 0
tagged with: eclipse-plugin
favorite count: 0
has comment: http://stackoverflow.com/comment/426636
answer count: 3
has answer: http://stackoverflow.com/a/613639
has title: Eclipse plugin - Class object

http://stackoverflow.com/comment/381702
type: Comment
comment on: http://stackoverflow.com/a/570246
has text: if i could have accepted more than one answer i'd accept this one too
type: AnswerComment
score: 0

http://stackoverflow.com/comment/21807626
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/461031
type: Comment
has text: That doesn´t seem to get the env variables setup in .bashrc or .profile. Does it only load the system environment variables?

http://stackoverflow.com/comment/12804785
score: 70
type: Comment
comment on: http://stackoverflow.com/a/502252
has text: btw you will see warning "The assignment to variable test has no effect" anyway
type: AnswerComment

http://stackoverflow.com/comment/61285594
comment on: http://stackoverflow.com/a/621749
type: Comment
score: 2
type: AnswerComment
has text: I do agree with you that Java is not the best option to build websites with. I use Laravel(PHP) to build web products. Lately, I've facing a lot of problem in switching jobs as almost 90% of the recruiters are asking that do I know any JSP thing or not. I only know core java. Java(pays well) and PHP(does not) here in India.

http://stackoverflow.com/a/607285
has comment: http://stackoverflow.com/comment/422390
has body: The Sun JVM requires a lot of memory for HotSpot and it maps in the runtime libraries in shared memory. If memory is an issue consider using another JVM suitable for embedding. IBM has j9, and there is the Open Source "jamvm" which uses GNU classpath libraries. Also Sun has the Squeak JVM running on the SunSPOTS so there are alternatives.
score: 8
type: Answer
answers question: http://stackoverflow.com/q/561245
downvote count: 0
has comment: http://stackoverflow.com/comment/422428
upvote count: 8

http://stackoverflow.com/a/481836
has comment: http://stackoverflow.com/comment/55519087
has comment: http://stackoverflow.com/comment/298587
has comment: http://stackoverflow.com/comment/316264
has comment: http://stackoverflow.com/comment/298567
type: Answer
answers question: http://stackoverflow.com/q/481813
has comment: http://stackoverflow.com/comment/63821371
downvote count: 2
has comment: http://stackoverflow.com/comment/38833317
upvote count: 98
score: 96
has comment: http://stackoverflow.com/comment/15146616
has comment: http://stackoverflow.com/comment/298597
has comment: http://stackoverflow.com/comment/316086
has body: I would implement a null safe comparator. There may be an implementation out there, but this is so straightforward to implement that I've always rolled my own. Note: Your comparator above, if both names are null, won't even compare the value fields. I don't think this is what you want. I would implement this with something like the following: // primarily by name, secondarily by value; null-safe; case-insensitive public int compareTo(final Metadata other) { if (other == null) { throw new NullPointerException(); } int result = nullSafeStringComparator(this.name, other.name); if (result != 0) { return result; } return nullSafeStringComparator(this.value, other.value); } public static int nullSafeStringComparator(final String one, final String two) { if (one == null ^ two == null) { return (one == null) ? -1 : 1; } if (one == null &amp;&amp; two == null) { return 0; } return one.compareToIgnoreCase(two); } EDIT: Fixed typos in code sample. That's what I get for not testing it first! EDIT: Promoted nullSafeStringComparator to static.
has comment: http://stackoverflow.com/comment/62415195

http://stackoverflow.com/comment/284596
type: Comment
comment on: http://stackoverflow.com/a/466338
has text: Thanks for the help, but it's the "DrawGLScene" part of the code that won't work. However I seem to have fixed this.
type: AnswerComment
score: 0

http://stackoverflow.com/a/370917
score: 1
downvote count: 0
type: Answer
has body: Normally, you should be able to set a break point. Especially if the 3rd party library is open source. But if your 3rd party lib is from a commercial vendor, they may have compiled the source with the debug flag turned off. This will make it impossible for you to debug into it. Your vendor might have done this as part of an obfuscation process to make it impossible to reverse engineer the library, or just simply because the final compiled classes will be smaller.
answers question: http://stackoverflow.com/q/370814
has comment: http://stackoverflow.com/comment/199739
upvote count: 1

http://stackoverflow.com/a/531825
has comment: http://stackoverflow.com/comment/40547206
downvote count: 1
has comment: http://stackoverflow.com/comment/29942698
upvote count: 83
has body: s1 == "" is not reliable as it tests reference equality not object equality (and String isn't strictly canonical). s1.equals("") is better but can suffer from null pointer exceptions. Better yet is: "".equals(s1) No null pointer exceptions. EDIT: Ok, the point was asked about canonical form. This article defines it as: Suppose we have some set S of objects, with an equivalence relation. A canonical form is given by designating some objects of S to be "in canonical form", such that every object under consideration is equivalent to exactly one object in canonical form. To give you a practical example: take the set of rational numbers (or "fractions" are they're commonly called). A rational number consists of a numerator and a denomoinator (divisor), both of which are integers. These rational numbers are equivalent: 3/2, 6/4, 24/16 Rational nubmers are typically written such that the gcd (greatest common divisor) is 1. So all of them will be simplified to 3/2. 3/2 can be viewed as the canonical form of this set of rational numbers. So what does it mean in programming when the term "canonical form" is used? It can mean a couple of things. Take for example this imaginary class: public class MyInt { private final int number; public MyInt(int number) { this.number = number; } public int hashCode() { return number; } } The hash code of the class MyInt is a canonical form of that class because for the set of all instances of MyInt, you can take any two elements m1 and m2 and they will obey the following relation: m1.equals(m2) == (m1.hashCode() == m2.hashCode()) That relation is the essence of canonical form. A more common way this crops up is when you use factory methods on classes such as: public class MyClass { private MyClass() { } public MyClass getInstance(...) { ... } } Instances cannot be directly instantiated because the constructor is private. This is just a factory method. What a factory method allows you to do is things like: Always return the same instance (abst…
has comment: http://stackoverflow.com/comment/347883
has comment: http://stackoverflow.com/comment/102230961
has comment: http://stackoverflow.com/comment/346393
has comment: http://stackoverflow.com/comment/12317879
has comment: http://stackoverflow.com/comment/102230865
type: Answer
score: 82
answers question: http://stackoverflow.com/q/531779

jprogressbar
tags question: http://stackoverflow.com/q/531831
type: Tag
tag name: jprogressbar
tags question: http://stackoverflow.com/q/447481

http://stackoverflow.com/a/637336
has body: If all of the writes are done before any of the reads then you could use the Collectons.unmodifiableMap method. If that isn't the case then writing code to do what you want isn't terribly hard (wanders off to find the post that has the basic code in it...) Hmm... just to be sure that the question is what I am thinking... is the read only aspect the important part or is trying to access the data fast the most important part? Edit: (based on comment) Have you checked to see, with a profiler if the code is slow? If not then you should not be worrying about it yet.
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/504558
has comment: http://stackoverflow.com/comment/450604
downvote count: 0
answers question: http://stackoverflow.com/q/637324
has comment: http://stackoverflow.com/comment/504516
upvote count: 2

http://stackoverflow.com/a/19125208
upvote count: 3
has body: package in.javadomain; public class JavaSplit { public static void main(String[] args) { String input = "chennai\nvellore\ncoimbatore\nbangalore\narcot"; System.out.println("Before split:\n"); System.out.println(input); String[] inputSplitNewLine = input.split("\\n"); System.out.println("\n After split:\n"); for(int i=0; i&lt;inputSplitNewLine.length; i++){ System.out.println(inputSplitNewLine[i]); } } }
has comment: http://stackoverflow.com/comment/36472854
score: -1
downvote count: 4
answers question: http://stackoverflow.com/q/454908
has comment: http://stackoverflow.com/comment/43280355
type: Answer

http://stackoverflow.com/q/580085
has answer: http://stackoverflow.com/a/580145
answer count: 6
score: 63
has title: Is it possible to set an environment variable at runtime from Java?
upvote count: 63
tagged with: environment-variables
downvote count: 0
has answer: http://stackoverflow.com/a/583536
favorite count: 0
has comment: http://stackoverflow.com/comment/392160
has answer: http://stackoverflow.com/a/580089
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/580097
has comment: http://stackoverflow.com/comment/462071
has answer: http://stackoverflow.com/a/46436871
has comment: http://stackoverflow.com/comment/392153
has comment: http://stackoverflow.com/comment/392054
has comment: http://stackoverflow.com/comment/392159
tagged with: java
has body: Is it possible to set an environment variable at runtime from a Java application? In Java 1.5 java.lang.System class there is the getenv() method, I would only need a setenv() method... Is it possible to modify the environment variables in the java process itself; not in the child process. Is it possible to achieve it through JNI? And how would that work? Thanks. EDIT: Ok let me put it this way - Can we do the following with Java. Please answer. Can we modify the environment of the current process? Can we modify the environment of the parent process? Can we modify the environment of the child process? Hemal Pandya has answered that "You can modify the environment of current and child processes but not of the parent process that spawned this process." Do you agree with this ?
has comment: http://stackoverflow.com/comment/38828478
type: Question
has answer: http://stackoverflow.com/a/62802024

http://stackoverflow.com/a/16306269
answers question: http://stackoverflow.com/q/556238
downvote count: 0
has body: Old post, I know, but I found all of these solutions lacking. In the hibernate mapping, you have: &lt;many-to-one name="corpus" class="xxx.entities.Corpus" column="idCorpus" insert="false" update="false" /&gt; You should change the second line to: &lt;many-to-one name="corpus" class="xxx.entities.Corpus" column="idCorpus" cascade="save-update" not-null="true" insert="true" /&gt;
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/comment/254788
type: AnswerComment
type: Comment
has text: Thanks ;) If someone asks I think I should be able to show that you can get started with annotations easily and with little pain. It's really a joy to work with. Blows some life into java and spring.
comment on: http://stackoverflow.com/a/431352
score: 0

http://stackoverflow.com/comment/92388789
has text: The static in-project repository solution is what I needed. Make sure to add the <repositories> tags around it. I put mine above the <build> tag and below the </parent> tag.
type: Comment
score: 1
comment on: http://stackoverflow.com/a/7623805
type: AnswerComment

http://stackoverflow.com/comment/61205570
type: Comment
comment on: http://stackoverflow.com/a/2553995
score: 0
type: AnswerComment
has text: See http://stackoverflow.com/questions/4128436/query-string-manipulation-in-java/ for several manual decoding examples.

http://stackoverflow.com/a/1227727
score: 0
has body: you can override a method,that is all right but what do you mean by overriding a variable? if you want to use a variable at any other place rather than super class u can use super. as in super(variable names); why do you want to override a variable? i mean is there any need?
type: Answer
answers question: http://stackoverflow.com/q/427756

integrity
type: Tag
tags question: http://stackoverflow.com/q/462696
tag name: integrity

http://stackoverflow.com/a/1161861
answers question: http://stackoverflow.com/q/407405
downvote count: 0
has body: You can use the following JVM arguments to startup Tomcat with MBean enabled -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=4444 (could be anything) -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/a/517339
has comment: http://stackoverflow.com/comment/864941
answers question: http://stackoverflow.com/q/500484
upvote count: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/500484
type: Answer
has comment: http://stackoverflow.com/comment/344325
downvote count: 0
has body: As far as I know, getSubimage(...) shouldn't have any significant effect to the rendering. Converting image data is slow and usually it is better to try to avoid doing it on the fly. With images slowness can be divided to two categories: Disk I/O Data processing And disk I/O can easily be the slowest part. If you are going to use only part of the image, it would be best to be able to load only part of the image from disk. My experience is that JAI is better at doing only what is really needed than the standard library stuff.
score: 1

http://stackoverflow.com/comment/2511154
comment on: http://stackoverflow.com/a/573468
type: Comment
has text: @Fredrik - seems perfectly reasonable to me. I think there's probably something about in the FAQ though.
score: 33
type: AnswerComment

http://stackoverflow.com/comment/20527171
comment on: http://stackoverflow.com/a/9418812
has text: imgscalr is great, except is doesn't have it's own IO routines (if I'm wrong here please please correct me). It depends on IOImage or JAI to create a BufferedImage. But IOImage doesn't support JPEG images with certain metadata, and JAI doesn't support JPEG images with a CMYK color scheme. So if you're working with uncontrolled images the technoglogies that imagscalr depend on are all buggy. :(
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/404804
has body: public class CovariantTest { public A getObj() { return new A(); } public static void main(String[] args) { CovariantTest c = new SubCovariantTest(); System.out.println(c.getObj().x); } } class SubCovariantTest extends CovariantTest { public B getObj() { return new B(); } } class A { int x = 5; } class B extends A { int x = 6; } The above code prints 5 when compiled and run. It uses the covariant return for the over-ridden method. Why does it prints 5 instead of 6, as it executes the over ridden method getObj in class SubCovariantTest. Can some one throw some light on this. Thanks.
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/404813
downvote count: 0
has title: Java Covariants
possible better answer: http://stackoverflow.com/a/404812
type: Question
score: 14
has answer: http://stackoverflow.com/a/9546925
has answer: http://stackoverflow.com/a/406018
has answer: http://stackoverflow.com/a/404812
tagged with: java
upvote count: 14
has answer: http://stackoverflow.com/a/404817
answer count: 7
favorite count: 0
has answer: http://stackoverflow.com/a/404819
has answer: http://stackoverflow.com/a/404829
accepted answer: http://stackoverflow.com/a/404829

http://stackoverflow.com/comment/205603
type: AnswerComment
has text: I don't think that's the case: the JLS specifies that compile-time constants are always inlined. Moreover, in the case of String compile-time constants, they are interned and all uses refer to the same instance.
type: Comment
comment on: http://stackoverflow.com/a/377860
score: 0

http://stackoverflow.com/comment/411481
has text: THe compiler will optimize the string concatenation but you will be creating a new StringBuilder object each time the loop is executed.
score: 6
type: Comment
comment on: http://stackoverflow.com/a/599181
type: AnswerComment

http://stackoverflow.com/comment/202695
type: Comment
comment on: http://stackoverflow.com/a/374350
type: AnswerComment
has text: Yeah, it isn't nice, for a simple structure like ArrayList with only one class generic, if can be handy when you get something complex like a Graph data structure with Nodes and Edges, all typed with each other! Yes, wrapping it would be nicer, but that's a nitpick against the question.
score: 0

http://stackoverflow.com/a/8557078
answers question: http://stackoverflow.com/q/530208
upvote count: 3
downvote count: 0
type: Answer
score: 3
has body: A nice approach for resolving poker hands in general is to assign each card a bit value with bit ((rank-2)*2) bit set as well as bit (suit+28) set, (so 2=1, 3=4, 4=16, etc. up to A=0x1000000). Then add together all the cards (call that result 'Sum'. Compute V1=(Sum &amp; 0x2AAAAAA)>>1, V0=(Sum &amp; 0x1555555), and V2=V1 &amp; V0. Also OR together the values for the five cards, and compute V3=OrValue &amp; 0xF0000000; For a pair, V1 will have a single bit set, V0 will have multiple bits set, and V2 will be zero. For two-pair, V1 will have two bits set and V2 will equal zero. For a three-of-a-kind, V1 will have a single bit set, and V2 will equal V1. For a straight, V0 will either be 0x1000055 or else a power-of-two multiple of 0x155. For a flush, V2 will have precisely one bit set. For a full house, V1 will have two bits set, and V2 will be non-zero. For four-of-a-kind, either V1 will be twice v0, with both having one bit set, or V0 will have precisely two bits set and V1 will be zero. For a straight flush, conditions for straight and flush will be met. This tests required for this approach should be implementable quickly with a minimal amount of branching.

jboss
tags question: http://stackoverflow.com/q/509049
tags question: http://stackoverflow.com/q/396569
tags question: http://stackoverflow.com/q/545831
tags question: http://stackoverflow.com/q/467235
tags question: http://stackoverflow.com/q/415863
tags question: http://stackoverflow.com/q/552968
tags question: http://stackoverflow.com/q/459644
tag name: jboss
tags question: http://stackoverflow.com/q/528891
tags question: http://stackoverflow.com/q/643055
tags question: http://stackoverflow.com/q/639908
type: Tag
tags question: http://stackoverflow.com/q/516196
tags question: http://stackoverflow.com/q/636941
tags question: http://stackoverflow.com/q/614812
tags question: http://stackoverflow.com/q/494171
tags question: http://stackoverflow.com/q/587899
tags question: http://stackoverflow.com/q/407405
tags question: http://stackoverflow.com/q/605408
tags question: http://stackoverflow.com/q/510000
tags question: http://stackoverflow.com/q/513786
tags question: http://stackoverflow.com/q/473068
tags question: http://stackoverflow.com/q/644205
tags question: http://stackoverflow.com/q/636450
tags question: http://stackoverflow.com/q/586592
tags question: http://stackoverflow.com/q/565317
tags question: http://stackoverflow.com/q/542979
tags question: http://stackoverflow.com/q/538261
tags question: http://stackoverflow.com/q/483963
tags question: http://stackoverflow.com/q/507391
tags question: http://stackoverflow.com/q/641387
tags question: http://stackoverflow.com/q/483379
tags question: http://stackoverflow.com/q/530735
tags question: http://stackoverflow.com/q/541242
tags question: http://stackoverflow.com/q/472739
tags question: http://stackoverflow.com/q/566892

http://stackoverflow.com/comment/391568
has text: Ya, sure can, reduces the cost of creating the channel every time :)
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/579616
type: Comment

http://stackoverflow.com/a/648181
upvote count: 2
has body: Horizontal scaling a message driven app is easy... most of the time. You can certainly add another message listener operating on the same queue. Watch out, though, because you might have subtle dependencies on the ordering of messages. They might not be a problem now, with just one processor, but with more than one you are guaranteed that the messages will be processed "out of order" at some point. EJB MDPs don't offer anything beyond Spring MDBs. Stick with what's working. Horizontally scaling the processors is a start, but this one requires a bit more discussion. For HA, you need to clarify the requirements. "High availability" is an interesting question for a queue-based app. If your app goes down for a few minutes, messages pile up in the queue. As long as you can get your app back up and running, those messages will still get processed, just with a bit more latency. It's probably worth asking, "What is the maximum acceptable latency for a message?" There's probably some component of concern about hardware failures, loss of a datacenter, etc. These won't be addressed by horizontal scaling in the same location. You'll need to replicate all components at every layer: the queue itself, the processors, the backend database, and all network hardware connecting them. It's an expensive proposition, so it's also worth asking, "What's the delta in annualized loss expectancy of downtime between an HA scenario and a non-HA scenario?" ALE incorporates both direct losses and regulatory or legal costs, so it's a good way to capture the cost of downtime.
type: Answer
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/561188

http://stackoverflow.com/q/466808
tagged with: java
has body: Is there a tool to take a GUI designed in C# or other languages that can take the screen layout and export that to an XML file such that you end up with a template of the screen in XML terms? As well as take an XML file and display the resulting screen?
has answer: http://stackoverflow.com/a/466847
answer count: 3
downvote count: 0
has answer: http://stackoverflow.com/a/466896
has answer: http://stackoverflow.com/a/466902
favorite count: 0
has title: Exporting a GUI to XML?
type: UnansweredQuestion
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/284938
tagged with: wpf
tagged with: xaml
type: Question
tagged with: c#

http://stackoverflow.com/a/506107
answers question: http://stackoverflow.com/q/506105
has comment: http://stackoverflow.com/comment/72279040
has body: You can use string.indexOf('a'). If the char a is present in string : it returns the the index of the first occurrence of the character in the character sequence represented by this object, or -1 if the character does not occur.
accepted answer of: http://stackoverflow.com/q/506105
type: Answer
downvote count: 6
has comment: http://stackoverflow.com/comment/117347919
has comment: http://stackoverflow.com/comment/101997080
has comment: http://stackoverflow.com/comment/79812663
has comment: http://stackoverflow.com/comment/320764
score: 367
has comment: http://stackoverflow.com/comment/320745
has comment: http://stackoverflow.com/comment/81441373
has comment: http://stackoverflow.com/comment/328147
upvote count: 373
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/62348082

http://stackoverflow.com/a/516240
upvote count: 14
type: Answer
has body: If you set up a JBoss server using the Eclipse WebTools, you can simply start the server in debug mode (debug button in the servers view). This will allow you to set breakpoints in the application that is running inside the JBoss.
downvote count: 0
score: 14
answers question: http://stackoverflow.com/q/516196
has comment: http://stackoverflow.com/comment/329909

http://stackoverflow.com/a/2266365
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/562652
downvote count: 0
has body: A year later and I find myself having to something very similar. Googling around, I found this link which describes getting access to the application context from within a scheduled job through the JobExecutionContext. I think I will be creating an abstract type job that can do some of the actual job creation and use a prototype to actual inject required services when the job needs to run.

http://stackoverflow.com/a/450874
has comment: http://stackoverflow.com/comment/271702
type: Answer
upvote count: 1041
has body: You could define callFriend this way: public &lt;T extends Animal&gt; T callFriend(String name, Class&lt;T&gt; type) { return type.cast(friends.get(name)); } Then call it as such: jerry.callFriend("spike", Dog.class).bark(); jerry.callFriend("quacker", Duck.class).quack(); This code has the benefit of not generating any compiler warnings. Of course this is really just an updated version of casting from the pre-generic days and doesn't add any additional safety.
accepted answer of: http://stackoverflow.com/q/450807
answers question: http://stackoverflow.com/q/450807
score: 1036
type: AcceptedAnswer
downvote count: 5
has comment: http://stackoverflow.com/comment/271812

http://stackoverflow.com/comment/312801
comment on: http://stackoverflow.com/a/495829
type: AnswerComment
score: 0
type: Comment
has text: Is it possible to use that library to just format a String though?

http://stackoverflow.com/a/4468289
downvote count: 0
has body: I think when we use reference variable in java and by using this variable we can assign a object of any class type. most of the cases we create a reference variable of Interface and abstract class because we can't create the object of interface and abstract class so assign the object of class in reference variable of Interface or abstract class. Ex- Interface X { public abstract void xx(); public abstract void yy(); } Class XXX implements X { ........... } Class XY extends XXX { X xy = new XXX(); } here xy is a reference of Interface X and assign the object of Class XXX in the reference of Interface. so according to my point of view by using reference variable we can also use interface to participate in Object creation.
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/497772

http://stackoverflow.com/comment/321634
score: 0
type: AnswerComment
type: Comment
has text: I don't think the : was meant to be construed as part of the output.
comment on: http://stackoverflow.com/a/507278

http://stackoverflow.com/a/444924
score: 2
upvote count: 3
downvote count: 1
answers question: http://stackoverflow.com/q/444909
has body: Why not modify the serialVersionUID in your current version instead as described in the Serialization documentation?
has comment: http://stackoverflow.com/comment/266540
has comment: http://stackoverflow.com/comment/266567
has comment: http://stackoverflow.com/comment/266537
type: Answer
has comment: http://stackoverflow.com/comment/274751
has comment: http://stackoverflow.com/comment/274994

http://stackoverflow.com/a/6403880
type: Answer
has body: The Google Guava library has a ton of helpful utilities. One of note here is the Files class. It has a bunch of useful methods including: File myTempDir = Files.createTempDir(); This does exactly what you asked for in one line. If you read the documentation here you'll see that the proposed adaptation of File.createTempFile("install", "dir") typically introduces security vulnerabilities.
has comment: http://stackoverflow.com/comment/122477800
has comment: http://stackoverflow.com/comment/20413312
upvote count: 185
has comment: http://stackoverflow.com/comment/18698081
answers question: http://stackoverflow.com/q/617414
has comment: http://stackoverflow.com/comment/8134876
has comment: http://stackoverflow.com/comment/8461002
downvote count: 1
score: 184

http://stackoverflow.com/comment/49535356
comment on: http://stackoverflow.com/a/462375
type: Comment
score: 1
has text: For those wondering, to use a label you write the label name followed by ':' before a loop.
type: AnswerComment

http://stackoverflow.com/a/4700241
answers question: http://stackoverflow.com/q/409483
type: Answer
score: 1
upvote count: 1
has body: The Peter Norton's Guide to Java Programming, "Making the Transition from C/C++ to Java".
downvote count: 0

http://stackoverflow.com/q/584576
accepted answer: http://stackoverflow.com/a/588189
type: Question
has title: What is the preferred way to do site templates and themes with Wicket?
downvote count: 0
tagged with: themes
answer count: 1
tagged with: templates
has answer: http://stackoverflow.com/a/588189
favorite count: 0
tagged with: wicket
score: 6
upvote count: 6
type: AnsweredQuestion
has body: I'm just learning Wicket, and Googling yields different results about how to theme/template a site using Wicket. It appears that the common methods are: Markup Inheritance (description) Borders (description) Reusable Panels (description) Fragments (description) What is the best practices / "right" way to do this in Wicket? Or do these different methods each have specific kinds of uses?
tagged with: java

http://stackoverflow.com/q/471870
favorite count: 0
answer count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/471877
duplicate of: http://stackoverflow.com/q/13707519
has answer: http://stackoverflow.com/a/471873
has answer: http://stackoverflow.com/a/471888
has answer: http://stackoverflow.com/a/472098
score: 1
tagged with: java
linked to: http://stackoverflow.com/q/13707519
has title: How to invoke a unix script from java?
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/472149
has body: I want to delete the old log files in log directory. To delete the log files which are more than 6 months, I have written the script like find /dnbusr1/ghmil/BDELogs/import -type f -mtime +120 -exec rm -f {} \; By using this script i am able to delete the old files, but how do I invoke this script by using java?
downvote count: 0
tagged with: exec
tagged with: unix

http://stackoverflow.com/q/585268
has answer: http://stackoverflow.com/a/585277
tagged with: size
has body: Okay, so if I had a project that used: import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Dimension; import java.awt.Font; import java.awt.Color; import java.awt.Polygon; Would it make the Class file smaller to use: import java.awt.* I'm thinking against it because I'm importing a lot of things I don't need. I'm thinking for it cause it makes the file have a lot less characters.
answer count: 10
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/585364
duplicate of: http://stackoverflow.com/q/147454
tagged with: java
has title: Which would make a Class file bigger? import java.awt.*, or a bunch or single import statements?
has answer: http://stackoverflow.com/a/585289
tagged with: import
type: Question
possible better answer: http://stackoverflow.com/a/585307
score: 5
has answer: http://stackoverflow.com/a/588117
has answer: http://stackoverflow.com/a/585275
accepted answer: http://stackoverflow.com/a/585284
has answer: http://stackoverflow.com/a/585444
has answer: http://stackoverflow.com/a/585328
has comment: http://stackoverflow.com/comment/400034
tagged with: class
has answer: http://stackoverflow.com/a/585284
has answer: http://stackoverflow.com/a/585294
favorite count: 0
has answer: http://stackoverflow.com/a/585307
upvote count: 5

http://stackoverflow.com/q/584742
has body: I have a collection of states, that I want to cache for the life of the application, preferably after it is called for the first time. I'm using EclipseLink as my persistence provider. In my EJB3 entity I have the following code: @Cache @NamedQueries({ @NamedQuery( name = "State.findAll", query = "SELECT s FROM State s", hints = { @QueryHint(name=QueryHints.CACHE_USAGE, value=CacheUsage.CheckCacheThenDatabase), @QueryHint(name=QueryHints.READ_ONLY, value=HintValues.TRUE) } ) }) This doesn't seem to do anything though, if I monitor the SQL queries going to MySQL it still does a select each time my Session Bean uses this NamedQuery. What is the correct way to configure this query so that it is only ever read once from the database, preferably across all sessions? Edit: I am calling the query like this: Query query = em.createNamedQuery("State.findAll"); List&lt;State&gt; states = query.getResultList();
type: Question
tagged with: eclipselink
favorite count: 0
has answer: http://stackoverflow.com/a/672675
tagged with: ejb-3.0
upvote count: 8
has comment: http://stackoverflow.com/comment/124861235
answer count: 3
has comment: http://stackoverflow.com/comment/396719
tagged with: java
has title: How To Configure Query Cacheing in EclipseLink
tagged with: jakarta-ee
has answer: http://stackoverflow.com/a/3336095
score: 8
tagged with: jpa
downvote count: 0
has answer: http://stackoverflow.com/a/584833
type: UnansweredQuestion

http://stackoverflow.com/a/762900
answers question: http://stackoverflow.com/q/521117
score: 0
has body: I have to add to these one solution that I find I can't live without ... its called Hudson. It only takes a few seconds to setup and you can usually get away with most of whatever your existing ANT files are already doing. Additionally, Hudson provides a great way to "cron" builds, execute test cases, and generate "artifacts" (e.g. build products) in a way that anyone can download. It is hard to capture all that it can do for you ... so just try it out ... you will no be disappointed.
type: Answer

http://stackoverflow.com/a/532229
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/345446
answers question: http://stackoverflow.com/q/532201
has comment: http://stackoverflow.com/comment/345154
has body: Not that I know of. I decided to avoid using swing app framework until it matures (or dies). I decided to use jgoodies libraries instead to wait for Sun to do something for swing developers.
has comment: http://stackoverflow.com/comment/345086

http://stackoverflow.com/q/556864
has comment: http://stackoverflow.com/comment/371728
tagged with: openoffice.org
score: 1
tagged with: java
upvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/371730
answer count: 1
downvote count: 0
has title: How to find true cause of com.sun.star.uno.RuntimeException?
favorite count: 0
has comment: http://stackoverflow.com/comment/371072
type: UnansweredQuestion
has body: I'm trying to replace a field in an OpenOffice document using the OpenOffice Java API. I'm using the insertString method: xText.insertString(((XTextField) fieldMaster).getAnchor(), value.toString(), false); The stacktrace is as follows: [junit] com.sun.star.uno.RuntimeException: [junit] at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:182) [junit] at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:148) [junit] at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:344) [junit] at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:313) [junit] at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:101) [junit] at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:652) [junit] at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:154) [junit] at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:136) [junit] at $Proxy14.insertString(Unknown Source) ... If I interpret this correctly, it's telling me that it connected to a different proces from Java, something in the other proces failed, but it's not telling me what the problem is. I found that there are some environment variables (PROT_REMOTE...) that would let me log messages from these remote (different process, same computer, btw) processes, but only if I run an OpenOffice version with debugging enabled? I'm using an OpenOffice version from an deb repository on Ubuntu, and have to interest in compiling my own OpenOffice version. Is there any way I can get some useful error messages from the remote process to help me understand why my code is failing?
has answer: http://stackoverflow.com/a/580714

http://stackoverflow.com/comment/433479
type: AnswerComment
type: Comment
has text: Different in what it does. The 'tests' that are applied to that object type will be different inside of each class.testing() method.
comment on: http://stackoverflow.com/a/620543
score: 0

http://stackoverflow.com/comment/41755282
type: Comment
score: 3
has text: @Pacerier On what theoretical grounds is static the "default"? It sounds like you just made that up. Perhaps in procedural programming; in OOP actually I would argue instance methods are the default. Anyway, *why*? If you are calling on an instance, why are you so concerned that it be static? How does that make any practical difference?
comment on: http://stackoverflow.com/a/370967
type: AnswerComment

http://stackoverflow.com/q/430089
has answer: http://stackoverflow.com/a/430093
has answer: http://stackoverflow.com/a/430494
has answer: http://stackoverflow.com/a/430092
upvote count: 6
favorite count: 0
has title: In Java, can Class.forName ever return null?
has body: In Java, can Class.forName ever return null, or will it always throw a ClassNotFoundException or NoClassDefFoundError if the class can't be located?
answer count: 4
downvote count: 0
tagged with: classloader
possible better answer: http://stackoverflow.com/a/430092
score: 6
has answer: http://stackoverflow.com/a/430253
type: Question
accepted answer: http://stackoverflow.com/a/430093
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/a/11130632
upvote count: 1
score: 1
has body: I would follow spring's recommendations and place the context files in META-INF/spring as described in the Spring Roo documentation. In general, I would recommend trying out roo and following their project structure and layout. Example src/ +-- main/ | +-- java/ | \-- resources/ | +-- META-INF/ | | \-- spring/ ‹ normal spring context files | | +-- context.xml | | \-- context-services.xml | \-- other files | +-- test/ | +-- java/ | \-- resources/ | +-- META-INF/ | | \-- spring/ ‹ context files for testing | | +-- context-test.xml | | \-- context-dao-test.xml | \-- other files | \-- pom.xml Spring XML vs annotations There are many good articles on the topic, but I would like to break up a common misconception, because both approaches have their merits: If you want to separate the configuration from the actual implementation, it is easier with XML, but you can achieve the same thing with annotations, as krosenvold said. However, when using XML configuration files, bean names are only required, if the bean has to be referenced directly. You can always use auto-wiring by name or by type. The only important thing is that you should stay consistent throughout the project, or, where possible, across your company's projects.
downvote count: 0
answers question: http://stackoverflow.com/q/431107
type: Answer

http://stackoverflow.com/comment/12250450
type: AnswerComment
type: Comment
score: 1
has text: This worked for me, but note that openssl wants PEM formatted certs and not DER (which is what keytool seems to use by default)
comment on: http://stackoverflow.com/a/473884

http://stackoverflow.com/comment/46597559
type: Comment
has text: @ArchimedesTrajano https://stackoverflow.com/questions/16251273/can-i-watch-for-single-file-change-with-watchservice-not-the-whole-directory
comment on: http://stackoverflow.com/a/494957
type: AnswerComment
score: 0

http://stackoverflow.com/q/400895
type: Question
tagged with: casting
has title: How does a Java compiler parse typecasts?
answer count: 2
accepted answer: http://stackoverflow.com/a/401035
has answer: http://stackoverflow.com/a/400934
downvote count: 0
favorite count: 0
tagged with: parsing
possible better answer: http://stackoverflow.com/a/400934
score: 11
tagged with: compiler-construction
upvote count: 11
type: AnsweredQuestion
has body: A simple expression like (x) - y is interpreted differently depending on whether x is a type name or not. If x is not a type name, (x) - y just subtracts y from x. But if x is a type name, (x) - y computes the negative of y and casts the resulting value to type x. In a typical C or C++ compiler, the question of whether x is a type or not is answerable because the parser communicates such information to the lexer as soon as it processes a typedef or struct declaration. (I think that such required violation of levels was the nastiest part of the design of C.) But in Java, x may not be defined until later in the source code. How does a Java compiler disambiguate such an expression? It's clear that a Java compiler needs multiple passes, since Java doesn't require declaration-before-use. But that seems to imply that the first pass has to do a very sloppy job on parsing expressions, and then in a later pass do another, more accurate, parse of expressions. That seems wasteful. Is there a better way?
tagged with: java
has answer: http://stackoverflow.com/a/401035

http://stackoverflow.com/comment/74390774
has text: [java.time](http://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html)!!!!!!
score: 0
type: Comment
comment on: http://stackoverflow.com/q/643402
type: QuestionComment

http://stackoverflow.com/a/531289
has body: As little as is needed to complete the initialization of the object. If you can talk about a portion (5 or so lines is my guideline) of your constructor as a chunk of logic or a specific process, it's probably best to split it into a separate method for clarity and organizational purposes. But to each his own.
type: Answer
answers question: http://stackoverflow.com/q/531282
score: 2
downvote count: 0
upvote count: 2

http://stackoverflow.com/comment/363092
type: AnswerComment
score: 0
type: Comment
has text: @eljenso: I'm more inclined to call it a inconvenient overloading of terminology. "Type" can, but does not always, refer to something analogous to an OO class. The Lizard is right on the money.
comment on: http://stackoverflow.com/a/551115

http://stackoverflow.com/a/523908
score: 7
downvote count: 2
upvote count: 9
answers question: http://stackoverflow.com/q/523871
type: Answer
has body: Have you seen this Coding Horror blog entry? The Sad Tragedy of Micro-Optimization Theater I am not shure whether or not it is "neater", but from a performance-standpoint it probably won't matter much.

http://stackoverflow.com/comment/89137675
type: Comment
comment on: http://stackoverflow.com/a/41563212
has text: I suppose long is more appropriate for this function as System.currentTimeMillis() returns a long value.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/351731
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/538768
has text: Right. As I explained in my comment, a register can be used. The point I'm making is that every volatile read or write must include a trip out to main memory. Operations on a non-volatile members (or local variable) don't incur that expense.

http://stackoverflow.com/a/499598
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/499528
has body: Thanks Brian, however, it seems Telephony is used by code posted on this site. In this excerpt from Apress (ISBN: 978-1-43021-064-1) by Chris Haseman, it is used too: Telephony class is used for sms messaging, (Context context, Intent intent) { SmsMessage msg[] = Telephony.Sms.Intents.getMessagesFromIntent(intent); ...
downvote count: 0
type: Answer

http://stackoverflow.com/comment/228059
type: AnswerComment
comment on: http://stackoverflow.com/a/401785
type: Comment
has text: Anything ending in -Stream deals exclusively with bytes, i.e. does not even have a concept of lines, and will not transform the input in any text-related way.
score: 0

http://stackoverflow.com/q/539288
has answer: http://stackoverflow.com/a/541138
tagged with: sqlite
tagged with: embedded-database
accepted answer: http://stackoverflow.com/a/539717
has body: Has anybody done any benchmarking/evaluation of the popular open-source embedded SQL DBs for performance, particularly write performance? I've some 1:1 comparisons for sqlite, Firebird Embedded, Derby and HSQLDB (others I am missing?) but no across the board comparisons... Also, I'd be interested in the overall developer experience for any of these (for a Java app).
type: AnsweredQuestion
upvote count: 5
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/539717
tagged with: firebird
answer count: 2
score: 5
has title: Best Embedded SQL DB for write performance?
downvote count: 0
tagged with: database
favorite count: 0
possible better answer: http://stackoverflow.com/a/541138

http://stackoverflow.com/comment/288905
score: 0
has text: @Simucal: on your "Resolved" believe me or not, I always thought that was the problem see my comment: "Start with empty canvas, then add the preffered size, then etc. etc. Chances are, the bug is on the paint method", I have been there before :(
type: QuestionComment
comment on: http://stackoverflow.com/q/468059
type: Comment

http://stackoverflow.com/q/552402
has answer: http://stackoverflow.com/a/552454
accepted answer: http://stackoverflow.com/a/552454
has body: I want to compile multiple java files in my Application without restarting Weblogic and Tomcat. Otherwise, this takes a lot of time. For this I got one Hotswap plugin in Eclipse, but this is not working in all the cases. It says it works for single file compile. Even if I use that it is not working in all the cases. Is there any other way that I can do this or is there any other plugin/script/software which can help me in this? If there are some open source ones, it will be very helpful. Thanks in Advance.
downvote count: 0
possible better answer: http://stackoverflow.com/a/553483
tagged with: eclipse-plugin
favorite count: 0
has title: How to compile single/multiple java files without server restart? Is there any Eclipse plugin for the same?
score: 6
has answer: http://stackoverflow.com/a/553393
has answer: http://stackoverflow.com/a/553483
has answer: http://stackoverflow.com/a/552425
upvote count: 6
has answer: http://stackoverflow.com/a/552865
type: AnsweredQuestion
tagged with: java
type: Question
tagged with: compilation
answer count: 6
has answer: http://stackoverflow.com/a/1693366

http://stackoverflow.com/comment/439066
comment on: http://stackoverflow.com/q/626389
type: Comment
score: 0
type: QuestionComment
has text: By Java console do you mean the window opened when running a webstart application or applet?

http://stackoverflow.com/q/490219
tagged with: java
has answer: http://stackoverflow.com/a/560117
tagged with: portal
tagged with: websphere
has answer: http://stackoverflow.com/a/14945794
downvote count: 0
answer count: 7
accepted answer: http://stackoverflow.com/a/3935671
has title: Lightweight portal server for WebSphere Portal development?
favorite count: 0
has answer: http://stackoverflow.com/a/490261
has answer: http://stackoverflow.com/a/490224
has answer: http://stackoverflow.com/a/11201884
upvote count: 6
possible better answer: http://stackoverflow.com/a/490261
score: 6
has answer: http://stackoverflow.com/a/490287
has answer: http://stackoverflow.com/a/3935671
tagged with: websphere-portal
type: Question
has comment: http://stackoverflow.com/comment/400351
type: AnsweredQuestion
has body: I'm doing some portlet development for IBM WebSphere Portal 6.1. However, the deployment process is painfully slow. As this is my first time doing portlet development, I'm not too familiar with the various portal servers out there. I'd like some recommendations for a lightweight portal server on which I can deploy quickly for development.

http://stackoverflow.com/a/7264268
upvote count: 3
answers question: http://stackoverflow.com/q/439298
downvote count: 0
score: 3
type: Answer
has body: To escape XML characters, the easiest way is to use the Apache Commons Lang project, JAR downloadable from: http://commons.apache.org/lang/ The class is this: org.apache.commons.lang3.StringEscapeUtils; It has a method named "escapeXml", that will return an appropriately escaped String.
has comment: http://stackoverflow.com/comment/77817836

relative-path
type: Tag
tags question: http://stackoverflow.com/q/437382
tags question: http://stackoverflow.com/q/623977
tag name: relative-path

http://stackoverflow.com/a/20761900
has comment: http://stackoverflow.com/comment/118123214
has comment: http://stackoverflow.com/comment/76266284
has body: Just use the Random class: Random ran = new Random(); // Assumes max and min are non-negative. int randomInt = min + ran.nextInt(max - min + 1);
score: 21
downvote count: 5
upvote count: 26
answers question: http://stackoverflow.com/q/363681
type: Answer
has comment: http://stackoverflow.com/comment/118123040

http://stackoverflow.com/a/644060
type: Answer
has comment: http://stackoverflow.com/comment/92641963
has body: Void has become convention for a generic argument that you are not interested in. There is no reason why you should use any other non-instantiable type, such as System. It is also often used in for example Map values (although Collections.newSetFromMap uses Boolean as maps don't have to accept null values) and java.security.PrivilegedAction.
downvote count: 0
has comment: http://stackoverflow.com/comment/45265959
score: 127
answers question: http://stackoverflow.com/q/643906
has comment: http://stackoverflow.com/comment/45333351
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/643906
upvote count: 127

http://stackoverflow.com/q/457276
accepted answer: http://stackoverflow.com/a/457299
has comment: http://stackoverflow.com/comment/132849208
answer count: 5
downvote count: 2
has body: How do I create test suites with JUnit 4? All the documentation I've seen doesn't seem to be working for me. And if I use the Eclipse wizard it doesn't give me an option to select any of the test classes I have created.
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/457291
possible better answer: http://stackoverflow.com/a/4952225
type: Question
tagged with: test-suite
has answer: http://stackoverflow.com/a/46395484
upvote count: 106
score: 104
tagged with: junit
has title: JUnit 4 Test Suites
has answer: http://stackoverflow.com/a/457293
has answer: http://stackoverflow.com/a/4952225
has comment: http://stackoverflow.com/comment/7658134
favorite count: 0
linked to: http://stackoverflow.com/q/3627392
has answer: http://stackoverflow.com/a/457299

http://stackoverflow.com/comment/1300708
score: 1
has text: Thanks for the example. There is a bug in it though(and in all other examples here), getNetworkInterfaces() can return null for some strange reason(please tell me why) if no network interfaces are found: 'Returns all the interfaces on this machine. Returns null if no network interfaces could be found on this machine. NOTE: can use getNetworkInterfaces()+getInetAddresses() to obtain all IP addresses for this node '
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/494480

http://stackoverflow.com/q/417648
tagged with: c#
answer count: 2
has answer: http://stackoverflow.com/a/417749
accepted answer: http://stackoverflow.com/a/417749
downvote count: 0
tagged with: monitoring
possible better answer: http://stackoverflow.com/a/417752
has title: Track used applications
favorite count: 0
has comment: http://stackoverflow.com/comment/242107
has comment: http://stackoverflow.com/comment/241995
score: 2
has comment: http://stackoverflow.com/comment/242058
tagged with: task-tracking
tagged with: process
has comment: http://stackoverflow.com/comment/242070
has answer: http://stackoverflow.com/a/417752
has comment: http://stackoverflow.com/comment/242028
type: AnsweredQuestion
tagged with: java
has body: I've been using Wakoopa recently, and I find it quite amusing. I had no idea ( well I had an idea but never got real data about it ) on how much time I spend in SO until this: alt text http://img396.imageshack.us/img396/4699/wakoopaim1.png So my programming question is: How can I programmatically track the applications being used? My initial though was to use something like "tasklist" command and "netstat" and pool every 15 minutes or something like that, but I don't think this is the way they're doing this. Is there a library in .NET ( in C# I guess ) to do this? Does windows provides some kind of service like this? What about java? I usually have at least some vague idea on how some programming task could be performed, but for this I don't have a clue. The wakoopa app tracker works on OSX and Linux too, but it is clear to me they are three different apps, one per platform BTW, how much do you used SO? :)
type: Question
upvote count: 2

http://stackoverflow.com/a/560042
answers question: http://stackoverflow.com/q/547169
has body: I'm stuck in websphere at the moment, and don't see what I'm looking for. But I do remember eclipse having a run configuration option related to launching the application in the same VM. Is it possible your launching your java application in the same VM as the eclipse VM? But the option slips my mind.
score: 0
type: Answer

http://stackoverflow.com/a/622638
has body: I won't return null because int is a primitive type. It will return the default int value, which is 0. There is no way of knowing if any element has been set, short of keeping a separate boolean array.
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/435502
score: 3
answers question: http://stackoverflow.com/q/622628
upvote count: 3

http://stackoverflow.com/a/438630
type: Answer
upvote count: 16
answers question: http://stackoverflow.com/q/438628
score: 16
type: AcceptedAnswer
downvote count: 0
has body: I haven't used Eclipse for a while, but from what I remember this was possible in the Callisto release at least. If you set a breakpoint on the line containing the declaration, and then go into the advanced properties for that breakpoint, I believe you can set options for modification and access of that variable. Edit: I just checked with Eclipse Europa. It does work broadly as I thought; the breakpoint is called a watchpoint when you set it on a variable; and in the "Breakpoint Properties" page (accessible by right-clicking on the breakpoint's bauble in the margin, and possibly in other ways) you can determine whether the debugger should stop on "Field access" and "Field Modification". In your case, you want the first one selected.
accepted answer of: http://stackoverflow.com/q/438628

http://stackoverflow.com/q/630296
has title: Is there any reasonable SSDP or DIDL Lib for java/groovy/python?
tagged with: groovy
has answer: http://stackoverflow.com/a/3255815
downvote count: 0
answer count: 1
favorite count: 0
tagged with: python
tagged with: upnp
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/3255815
upvote count: 3
has body: For a future project I am looking for a library to handle SSDP communication and messages in DIDL-Lite xml dialect. Is there any reasonable implementation of java, groovy or python? I don't like to use implementations of existing UPnP stacks like cybergarage or the frauenhofer UPnP stack because they are highly depending on these stacks.
type: Question
score: 3
tagged with: java

http://stackoverflow.com/q/381502
tagged with: java
has answer: http://stackoverflow.com/a/699302
answer count: 7
upvote count: 17
has body: I'm writing small and very DRY framework, which heavily relies on metadata. I'd like to know if there is a way to obtain method parameter names, i.e. given some method public void a(int myIntParam, String theString) { ... } get the strings "myIntParam" and "theString". I know I could annotate parameters, but that wouldn't be nice... public void a( @Param("myIntParam") int myIntParam, @Param("theString") String theString ) { ... }
has comment: http://stackoverflow.com/comment/70132255
has title: Is there a way to obtain names of method parameters in Java?
has comment: http://stackoverflow.com/comment/209561
has comment: http://stackoverflow.com/comment/121229582
accepted answer: http://stackoverflow.com/a/699302
has answer: http://stackoverflow.com/a/384929
has answer: http://stackoverflow.com/a/384837
possible better answer: http://stackoverflow.com/a/384929
has answer: http://stackoverflow.com/a/381543
type: AnsweredQuestion
downvote count: 0
linked to: http://stackoverflow.com/q/2237803
has answer: http://stackoverflow.com/a/3621204
favorite count: 0
score: 17
has answer: http://stackoverflow.com/a/384628
has comment: http://stackoverflow.com/comment/121229584
type: Question
duplicate of: http://stackoverflow.com/q/2237803
has comment: http://stackoverflow.com/comment/33943754
has comment: http://stackoverflow.com/comment/121229583
has answer: http://stackoverflow.com/a/381519
tagged with: reflection

http://stackoverflow.com/a/43672804
downvote count: 0
answers question: http://stackoverflow.com/q/642241
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/642241
score: 1
type: Answer
upvote count: 1
has body: The Answer by Sacre is correct but outdated. The modern way is with the java.time classes. tl;dr StringBuild sql = new StringBuilder() sql.append( "SELECT id_, datum_ " ); sql.append( "FROM appointments_ " ); sql.append( "WHERE datum_ &gt;= ? " ); // Start is *inclusive*… sql.append( "AND datum_ &lt; ? ; " ); // …while end is *exclusive*. (Half-Open approach) And pass a pair of Instant objects. pstmt.setObject( 1 , start ) ; // Pass `java.time.Instant` object directly via `PreparedStatement::setObject` method. pstmt.setObject( 2 , stop ) ; Use objects not strings Avoid using strings for fetching/storing date-time values in your database. Use date-time objects for date-time values. Java and JDBC have rich support for date-time objects. Using java.time The java.sql.Date class is intended to represent a date-only value without a time-of-day and without a time zone. Actually it carries both those extras, but pretends not too. The modern replacement is LocalDate. The LocalDate class represents a date-only value without time-of-day and without time zone. But java.sql.Date (and LocalDate too) is the wrong class to use as your column seems to be defined not as a date-only type but as a date-time type. The critical issue here is being ignored by your Question: time zone. A time zone is crucial in determining a date. For any given moment, the date varies around the globe by zone. For example, a few minutes after midnight in Paris France is a new day while still “yesterday” in Montréal Québec. Specify a proper time zone name in the format of continent/region, such as America/Montreal, Africa/Casablanca, or Pacific/Auckland. Never use the 3-4 letter abbreviation such as EST or IST as they are not true time zones, not standardized, and not even unique(!). ZoneId z = ZoneId.of( "America/Montreal" ); LocalDate today = LocalDate.now( z ); Regarding time zone in your database… Your database almost certainly stores date-time values carrying time zone or offset-from-UTC info as UTC va…

http://stackoverflow.com/q/419770
has comment: http://stackoverflow.com/comment/244735
type: UnansweredQuestion
has title: increase clarity of a graph
score: 1
tagged with: java
upvote count: 1
tagged with: jfreechart
type: Question
has answer: http://stackoverflow.com/a/419901
has body: I am using jfreechart for plotting graphs. The problem is that if have more entries on the X-axis, then the X-axis parameters are not visible. How should I solve that?
answer count: 1
downvote count: 0
favorite count: 0

lcdui
type: Tag
tag name: lcdui
tags question: http://stackoverflow.com/q/589141

http://stackoverflow.com/comment/19055014
has text: I assume the non-subtle bug is the "guot" which was corrected - I also get a warning on the appending concatenated strings in the StringBuilder. What is the subtle bug? I honestly like a stand-alone solution like this for my current implementation, embedded where we can't import apache libraries.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/10035382
score: 0

http://stackoverflow.com/q/474283
has title: Command to give a list of JREs installed on the system
favorite count: 0
has body: Is there any command which would list down all the JRE versions and releases installed on a system?
answer count: 5
has answer: http://stackoverflow.com/a/474340
type: UnansweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/474544
has answer: http://stackoverflow.com/a/474371
score: 4
type: Question
upvote count: 4
has answer: http://stackoverflow.com/a/474303
downvote count: 0
has answer: http://stackoverflow.com/a/474292

http://stackoverflow.com/q/435091
type: Question
has answer: http://stackoverflow.com/a/435132
tagged with: java
tagged with: gssapi
tagged with: kerberos
score: 2
answer count: 1
downvote count: 0
has title: Is a service principal name (SPN) bound to a specific machine?
accepted answer: http://stackoverflow.com/a/435132
favorite count: 0
type: AnsweredQuestion
has body: At the moment I am getting a KrbException: Integrity check on decrypted field failed (31) with my GSS demo application (on the server side). Now I am looking for the reason for this. I have the suspicion, that it comes from the fact that the client and the server application run on the same machine (localhost) and/or the SPN was generated for another machine (computer) The second means that the service principal was generated for a machine xxx0815.domain.net, so the SPN is HTTP/xxx0815.domain.net@DOMAIN.NET. And my machine is not that one, but I have got the keytab file so that the server's login method succeeds. Do I suspect correctly or am I making another mistake? Server configuration and source code: server.conf Server { com.sun.security.auth.module.Krb5LoginModule required isInitiator=false doNotPrompt=true useKeyTab=true keyTab="gssdemo.keytab" storeKey=true principal="HTTP/xxx0815.domain.net@DOMAIN.NET" debug=true; }; GSSServer.java (omitted the boilerplate stuff) GSSManager manager = GSSManager.getInstance(); GSSName serverName = manager.createName(getServerName(), null); GSSCredential serverCred = manager.createCredential(serverName, GSSCredential.INDEFINITE_LIFETIME, createKerberosOid(), GSSCredential.ACCEPT_ONLY); GSSContext context = manager.createContext(serverCred); System.out.println("Context created successfully. Now incoming tokens could be accepted."); ServerSocket serverSocket = new ServerSocket(55555); SocketAdapter ca = new SocketAdapter(serverSocket.accept()); while (!context.isEstablished()) { byte[] inToken = ca.readToken(); byte[] outToken = context.acceptSecContext(inToken, 0, inToken.length); if (outToken != null) { ca.sendToken(outToken); } } System.out.println("Context established"); System.out.println("Connected user is: " + context.getSrcName()); context.dispose(); Client configuration and source code: client.conf Client { com.sun.security.auth.module.Krb5LoginModule required useTicketCache=true debug=true; }; GssClient.java (boilerpla…
upvote count: 2

http://stackoverflow.com/a/46871451
answers question: http://stackoverflow.com/q/541487
type: Answer
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/84614819
has body: Thread class defines several methods that can be overriden by the the extending class. But to create a thread we must override the run() method. Same applies to Runnable as well. However Runnable is a preferred method of creating a thread. The primary reasons are: Since Runnable is an interface, you can extend other classes. But if you extend Thread then that option is gone. If you are not modifying or enhancing a whole lot of Thread functionalities and extending the Thread class is not a preferred way.
downvote count: 0

http://stackoverflow.com/comment/211599
type: AnswerComment
has text: Can you give a specific example of using this tool?
comment on: http://stackoverflow.com/a/382906
type: Comment
score: 0

http://stackoverflow.com/q/368736
has answer: http://stackoverflow.com/a/368845
has title: Tips on Speeding up JDBC writes?
upvote count: 14
has answer: http://stackoverflow.com/a/370294
has comment: http://stackoverflow.com/comment/198173
has answer: http://stackoverflow.com/a/370162
accepted answer: http://stackoverflow.com/a/370162
favorite count: 0
tagged with: postgresql
tagged with: jdbc
has body: I am writing a program that does a lot of writes to a Postgres database. In a typical scenario I would be writing say 100,000 rows to a table that's well normalized (three foreign integer keys, the combination of which is the primary key and the index of the table). I am using PreparedStatements and executeBatch(), yet I can only manage to push in say 100k rows in about 70 seconds on my laptop, when the embedded database we're replacing (which has the same foreign key constraints and indices) does it in 10. I am new at JDBC and I don't expect it to beat a custom embedded DB, but I was hoping it to be only 2-3x slower, not 7x. Anything obvious that I maybe missing? does the order of the writes matter? (i.e. say if it's not the order of the index?). Things to look at to squeeze out a bit more speed?
answer count: 4
score: 14
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/198544
possible better answer: http://stackoverflow.com/a/370294
tagged with: java
has answer: http://stackoverflow.com/a/368876
type: Question
tagged with: performance
downvote count: 0

http://stackoverflow.com/q/593996
has answer: http://stackoverflow.com/a/6959010
downvote count: 0
favorite count: 0
score: 30
has comment: http://stackoverflow.com/comment/405784
upvote count: 30
has answer: http://stackoverflow.com/a/37208995
answer count: 5
linked to: http://stackoverflow.com/q/1205995
has body: We are always taught to make sure we use a break in switch statements to avoid fall-through. The Java compiler warns about these situations to help us not make trivial (but drastic) errors. I have, however, used case fall-through as a feature (we don't have to get into it here, but it provides a very elegant solution). However the compiler spits out massive amounts of warnings that may obscure warnings that I need to know about. I know how I can change the compiler to ignore ALL fall-through warnings, but I would like to implement this on a method-by-method basis to avoid missing a place where I did not intend for fall-through to happen. Any Ideas?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/594023
tagged with: java
tagged with: warnings
has answer: http://stackoverflow.com/a/594012
type: Question
accepted answer: http://stackoverflow.com/a/594011
has comment: http://stackoverflow.com/comment/405835
has title: How to suppress Java compiler warnings for specific functions
tagged with: compiler-warnings
tagged with: suppress-warnings
has comment: http://stackoverflow.com/comment/405788
has answer: http://stackoverflow.com/a/594011
possible better answer: http://stackoverflow.com/a/594023

http://stackoverflow.com/a/620185
score: 4
upvote count: 4
answers question: http://stackoverflow.com/q/620041
type: Answer
has comment: http://stackoverflow.com/comment/433162
has body: One way to deal with this is to create a Hibernate UserType. There are instructions in the link at hibernate.org with some already-made classes for String escaping. I realize this doesn't directly answer 'how do I tell hibernate not to convert 9 spaces to empty string', but it will solve the storage problem on the database side. There are 2 implementations on that page - one that escapes all strings (may handle your 9 spaces case in your desired manner), and one that only escapes the value ''. It sounds like the former may be a better fit for you. For the record - I am utilizing this method myself. All you need to do is have the class in your classpath, and set the 'type' attribute in your HBM.xml to the fully qualified classname (i.e add type="my.fully.qualified.HibernateUserType" to your property element). On the Java side your classes will still deal directly with java.lang.String and the values you expect to see, but on the hibernate side, they will use the UserType class.
downvote count: 0
has comment: http://stackoverflow.com/comment/433118
has comment: http://stackoverflow.com/comment/433180

http://stackoverflow.com/comment/320573
type: AnswerComment
comment on: http://stackoverflow.com/a/505935
score: 0
type: Comment
has text: My point being, bags are a better answer to the specific question.

http://stackoverflow.com/q/420945
score: 9
has answer: http://stackoverflow.com/a/420975
has answer: http://stackoverflow.com/a/421198
favorite count: 0
upvote count: 9
has comment: http://stackoverflow.com/comment/244998
possible better answer: http://stackoverflow.com/a/420971
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/421384
has answer: http://stackoverflow.com/a/421033
accepted answer: http://stackoverflow.com/a/421384
has title: java package name convention failure
downvote count: 0
has answer: http://stackoverflow.com/a/420971
type: Question
tagged with: naming-conventions
has body: I'm just coming up the learning curve for Java SE &amp; have no problem with the usual Java convention for package names, e.g. com.example.library_name_here.package_name_here Except. I've been noticing a failure to abide by this in some fairly well-known packages. JLine: jline.* JACOB: com.jacob.* (there is no jacob.com) JNA: com.sun.jna.* (disclaimer on the site says NOTE: Sun is not sponsoring this project, even though the package name (com.sun.jna) might imply otherwise.) So I'm wondering, are there instances where the usual reverse-domain-name convention breaks down, and there are good ways to get around it? The only cases I can think of revolve around domain-name ownership issues (e.g. you change the project hosting/domain name, or there's already a well-known package that has "squatter's rights" to your domain, or your ownership of the domain runs out &amp; someone else snaps it up). edit: if I use my company's domain name, and we are bought out or have a spin-off, what should we do with package names? keep them the same or rename? (I suppose renaming is bad from the point of view that compiled classes referring to the package then lose)
tagged with: java
has answer: http://stackoverflow.com/a/420966
answer count: 6

http://stackoverflow.com/comment/41096282
type: AnswerComment
has text: **-1** and no fix 2 year later :(
type: Comment
comment on: http://stackoverflow.com/a/476761
score: 2

http://stackoverflow.com/a/516013
downvote count: 0
has body: Get an IDE: IntelliJ (my preference), Eclipse, Netbeans; Get an application server: Glassfish (my preference; either v2 or v3 Prelude), JBoss or, if you're feeling adventurous, SpringSource dm server; Get a JDK eg 6u11; Get a copy of Spring 2.5.6 (or 3.0M2 if you're feeling adventurous); Get a copy of the Spring reference documentation; Put the pieces together.
upvote count: 8
type: Answer
accepted answer of: http://stackoverflow.com/q/515996
answers question: http://stackoverflow.com/q/515996
score: 8
has comment: http://stackoverflow.com/comment/329853
type: AcceptedAnswer

http://stackoverflow.com/q/495741
downvote count: 0
has answer: http://stackoverflow.com/a/44291163
favorite count: 0
has answer: http://stackoverflow.com/a/1223263
answer count: 9
has answer: http://stackoverflow.com/a/496007
has comment: http://stackoverflow.com/comment/312202
has body: I'm writing some Scala code which uses the Apache POI API. I would like to iterate over the rows contained in the java.util.Iterator that I get from the Sheet class. I would like to use the iterator in a for each style loop, so I have been trying to convert it to a native Scala collection but will no luck. I have looked at the Scala wrapper classes/traits, but I can not see how to use them correctly. How do I iterate over a Java collection in Scala without using the verbose while(hasNext()) getNext() style of loop? Here's the code I wrote based on the correct answer: class IteratorWrapper[A](iter:java.util.Iterator[A]) { def foreach(f: A =&gt; Unit): Unit = { while(iter.hasNext){ f(iter.next) } } } object SpreadsheetParser extends Application { implicit def iteratorToWrapper[T](iter:java.util.Iterator[T]):IteratorWrapper[T] = new IteratorWrapper[T](iter) override def main(args:Array[String]):Unit = { val ios = new FileInputStream("assets/data.xls") val workbook = new HSSFWorkbook(ios) var sheet = workbook.getSheetAt(0) var rows = sheet.rowIterator() for (val row &lt;- rows){ println(row) } } }
has answer: http://stackoverflow.com/a/15009179
possible better answer: http://stackoverflow.com/a/1625252
has answer: http://stackoverflow.com/a/1625252
has answer: http://stackoverflow.com/a/495974
has answer: http://stackoverflow.com/a/30280247
tagged with: scala-java-interop
tagged with: scala
tagged with: collections
has title: Iterating over Java collections in Scala
accepted answer: http://stackoverflow.com/a/1223263
type: Question
has answer: http://stackoverflow.com/a/31871499
linked to: http://stackoverflow.com/q/2708990
has comment: http://stackoverflow.com/comment/312016
type: AnsweredQuestion
upvote count: 116
tagged with: java
has answer: http://stackoverflow.com/a/34552742
score: 116

http://stackoverflow.com/comment/44019446
comment on: http://stackoverflow.com/a/396770
type: AnswerComment
score: 0
type: Comment
has text: This answer should get all the likes! I've used this to successfully add dependencies for my maven projects on both Google App Engine and Heroku.

http://stackoverflow.com/comment/56191989
comment on: http://stackoverflow.com/a/402331
has text: For the switch case, I am not sure if this happens for every switch, but I've observed this for switch with enums; the compiler generates anonymous class with single static field that provides a mapping Enum.ordinal() -> 1, 2, 3... (so a sequence without gaps), and then a lookupswitch instruction runs the switch on this sequence, not directly on ordinals.
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/q/415967
has answer: http://stackoverflow.com/a/416042
downvote count: 0
has answer: http://stackoverflow.com/a/416661
has answer: http://stackoverflow.com/a/45059225
favorite count: 0
accepted answer: http://stackoverflow.com/a/416042
type: AnsweredQuestion
tagged with: unmodifiable
tagged with: java
has title: How to create a deep unmodifiable collection?
type: Question
has answer: http://stackoverflow.com/a/9793645
upvote count: 15
has answer: http://stackoverflow.com/a/415976
has body: I often make a collection field unmodifiable before returning it from a getter method: private List&lt;X&gt; _xs; .... List&lt;X&gt; getXs(){ return Collections.unmodifiableList(_xs); } But I can't think of a convenient way of doing that if the X above is itself a List: private List&lt;List&lt;Y&gt;&gt; _yLists; ..... List&lt;List&lt;Y&gt;&gt; getYLists() { return Collections.unmodifiableList(_yLists); } The problem in the above is of course that though the client cannot modify the List of lists, it can add/delete Y objects from the embedded lists. Any thoughts?
has answer: http://stackoverflow.com/a/416018
answer count: 6
score: 15
possible better answer: http://stackoverflow.com/a/415976

http://stackoverflow.com/a/397842
downvote count: 0
has body: I think i would do it this way str being the input string pos being the lengths of the parts after which we should put a comma Code: public static String partition(String str, int[] pos) { int oldPos = 0; StringBuilder builder = new StringBuilder(str.length() + pos.length); for(int len : pos) { builder.append(str.substring(oldPos, oldPos+len)).append(','); oldPos += len; } builder.append(str.substring(oldPos)).append(','); return builder.toString(); }
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/397667

http://stackoverflow.com/comment/338991
type: Comment
has text: enums... of course they gave themselves plenty of versions to mull over that particular problem didn't they? :)
comment on: http://stackoverflow.com/a/525732
type: AnswerComment
score: 0

http://stackoverflow.com/a/412606
type: Answer
has comment: http://stackoverflow.com/comment/237433
answers question: http://stackoverflow.com/q/411631
accepted answer of: http://stackoverflow.com/q/411631
score: 3
has body: Jon's answer should work, but you can also use the appendCodePoint method in StringBuilder or StringBuffer. StringBuilder sb = new StringBuilder(); sb.appendCodePoint(0x1f000); Both techniques do the conversion to surrogate pairs for you. It sounds like your problem now is getting the characters to display properly. If you're trying to display them on the console, forget it; the console on most machines is way too limited. I suggest you either write your output to a file and use a good text editor to read it, or display the output in a Swing component like a JTextPane.
type: AcceptedAnswer
downvote count: 0
upvote count: 3

http://stackoverflow.com/q/374964
answer count: 2
score: 3
downvote count: 0
has body: I'm using a third-party library which accesses fonts through the GraphicsEnvironment: getAllFonts() call. This includes fonts in font registries belonging to both the JRE and the operating system. But on client machines that connect to our server I will likely not be able to install fonts into either of these locations. So how can I make other fonts available to the JRE so that this call will pick them up? Is there a way to expand its search path? I can access a font from an arbitrary file with the Font.createFont() call. But then it still doesn't show up in GraphicsEnvironment.getAllFonts(). Is there a method I can pass that Font to that will add it to the list of fonts available? I'm reading that there are calls that access fonts from a system property, but I'm still not understanding, yet, and I think that just translates a font property I set up into a font name from the available list. asalamon has provided the correct answer, but I'm stuck on an earlier version of Java that doesn't support it, at least until next year. So more answers are still very welcome! I'm probably going to try to use reflection to hack the library we are using and insert fonts directly into its cache.
favorite count: 0
has answer: http://stackoverflow.com/a/375205
type: AnsweredQuestion
upvote count: 3
tagged with: fonts
tagged with: java
accepted answer: http://stackoverflow.com/a/375205
has title: How can I make arbitrary font files available to Java?
type: Question
possible better answer: http://stackoverflow.com/a/374998
has answer: http://stackoverflow.com/a/374998

http://stackoverflow.com/a/596788
type: Answer
answers question: http://stackoverflow.com/q/383833
has body: If you suspect you have a memory leak I suggest you use a memory profiler to see how objects are being retained over time. A fast memory leak will be obvious with such a tool so if you create a test for something you suspect leaks and repeat it many times you will be able to see the leak and why the objects are being retained.
score: 0

http://stackoverflow.com/comment/438573
type: Comment
score: 2
has text: cadrian, now it will only work for durations less than a day. The number of hours will always be between 0 and 23, inclusive.
comment on: http://stackoverflow.com/a/625444
type: AnswerComment

http://stackoverflow.com/q/380813
has comment: http://stackoverflow.com/comment/208258
has comment: http://stackoverflow.com/comment/208262
answer count: 12
has answer: http://stackoverflow.com/a/24103148
has comment: http://stackoverflow.com/comment/208245
upvote count: 203
has title: Downcasting in Java
has answer: http://stackoverflow.com/a/17398348
has answer: http://stackoverflow.com/a/381330
has answer: http://stackoverflow.com/a/380830
has answer: http://stackoverflow.com/a/2453875
type: AnsweredQuestion
score: 203
tagged with: java
type: Question
possible better answer: http://stackoverflow.com/a/380915
has answer: http://stackoverflow.com/a/380828
tagged with: casting
has answer: http://stackoverflow.com/a/380915
downvote count: 0
has answer: http://stackoverflow.com/a/72295327
has body: Upcasting is allowed in Java, however downcasting gives a compile error. The compile error can be removed by adding a cast but would anyway break at the runtime. In this case why Java allows downcasting if it cannot be executed at the runtime? Is there any practical use for this concept? public class demo { public static void main(String a[]) { B b = (B) new A(); // compiles with the cast, // but runtime exception - java.lang.ClassCastException } } class A { public void draw() { System.out.println("1"); } public void draw1() { System.out.println("2"); } } class B extends A { public void draw() { System.out.println("3"); } public void draw2() { System.out.println("4"); } }
has answer: http://stackoverflow.com/a/57268394
has comment: http://stackoverflow.com/comment/16282847
has answer: http://stackoverflow.com/a/19342011
has answer: http://stackoverflow.com/a/57820719
has comment: http://stackoverflow.com/comment/208209
accepted answer: http://stackoverflow.com/a/380828
has answer: http://stackoverflow.com/a/381073
favorite count: 0

http://stackoverflow.com/a/495350
score: 0
type: Answer
has body: Do you mean a way to get a GIF or JPEG? Actuate e.Spreadsheet can create images from Excel charts and ranges, but it's expensive (I worked there until 2002 but have no affiliation now).
answers question: http://stackoverflow.com/q/495199

http://stackoverflow.com/comment/333317
comment on: http://stackoverflow.com/a/519878
score: 0
type: AnswerComment
type: Comment
has text: My bad, I guess I've forgotten my network programming as well

http://stackoverflow.com/a/495923
score: 1
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/495674
has body: In your loop: while ((displayText = br.readLine()) != null) { if (textArea.length() &gt; 0) textArea.append("\n"); textArea.append(displayText); } i.e. if there is already some text in your textarea, insert a newline.
upvote count: 1

http://stackoverflow.com/a/567534
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/384002
upvote count: 2
has body: Would serialization of the model (if you are into MVC) not be another way? I'd prefer to use things in the language (or standard libraries) rather then roll my own if possible. The only issue I can see with that is that the file size may be larger than you want.
has comment: http://stackoverflow.com/comment/385600
answers question: http://stackoverflow.com/q/567516
type: Answer

http://stackoverflow.com/comment/70857727
type: AnswerComment
has text: This answer makes the most sense to me out of all the answers.
comment on: http://stackoverflow.com/a/540550
type: Comment
score: 0

http://stackoverflow.com/comment/75640841
score: 1
type: AnswerComment
has text: You can use `"RSA/ECB/PKCS1Padding"` for both providers.
type: Comment
comment on: http://stackoverflow.com/a/34271871

http://stackoverflow.com/comment/270669
has text: you might also want to null references inside methods that may use a large amount of memory or take a long time to execute, or in code in a Swing application that may run a long time. In short methods or short lived objects, its not worth the extra confusing code.
type: Comment
comment on: http://stackoverflow.com/a/449425
score: 8
type: AnswerComment

http://stackoverflow.com/comment/269159
score: 0
type: AnswerComment
has text: Thanks! Can you explain why that fixes it?
comment on: http://stackoverflow.com/a/448140
type: Comment

http://stackoverflow.com/a/381837
has comment: http://stackoverflow.com/comment/13828871
type: Answer
score: 6
answers question: http://stackoverflow.com/q/381733
has body: I've also developed in both Java and C# the last few years, and find C# a superior language with regards to expressiveness and powerful language constructs. The Java language does not undergo the same degree of changes and updates as C#, atleast not at the same pace. I still don't necessarily mean that Java should be drastically updated, but we need a powerful and expressive statically typed language on the Java platform. I think Scala is going to develop into this replacement language, which we Java developers can switch to when ordinary Java does not cut it. C# is an absolutely fantastic language; probably the "best" statically typed language these days, but Java is still in my opinion a superior platform. I like Java the platform, and I like C# the language.
has comment: http://stackoverflow.com/comment/20615888
upvote count: 7
downvote count: 1

http://stackoverflow.com/comment/411921
type: Comment
type: AnswerComment
has text: That won't start a terminal emulator, only a shell. You should also use '/bin/sh' instead of '/usr/bin/sh' as the first is a POSIX requirement (i.e. guaranteed to be there for every Unix system).
comment on: http://stackoverflow.com/a/599049
score: 0

http://stackoverflow.com/comment/2449934
comment on: http://stackoverflow.com/a/646382
score: 0
type: AnswerComment
type: Comment
has text: Yes `createScreenCapture()` does allocate a `BufferedImage`, and converts all pixels to `INT_RGBA` format, which is what takes most of the time.

http://stackoverflow.com/comment/335205
type: QuestionComment
comment on: http://stackoverflow.com/q/521407
has text: object is to class as *value* is to enum, not the other way around.
score: 0
type: Comment

http://stackoverflow.com/a/509131
has comment: http://stackoverflow.com/comment/325929
has comment: http://stackoverflow.com/comment/327292
has comment: http://stackoverflow.com/comment/327631
has comment: http://stackoverflow.com/comment/325845
score: 0
has body: It looks like your design is wrong for Java, and you can't directly do what you are asking for. Perhaps you need to reshape your code to use the visitor pattern? Failing that, you need to explain your requirement instead of the solution that you want to use. In that way, we can tell you the proper Java solutions to your requirement.
answers question: http://stackoverflow.com/q/509042
type: Answer

http://stackoverflow.com/a/428550
downvote count: 0
type: Answer
has body: Depending on your application and the scope of the cfg file, a properties file might be the easiest. Sure it isn't as elegant as xml but it certainly easier.
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/428073

http://stackoverflow.com/comment/338352
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/522750
score: 0
has text: I've never had problems using Eclipse's auto getter/setter code generation with Spring. Actually I exclusively use it and all of my code is Spring injected.

http://stackoverflow.com/a/540828
upvote count: 1
has comment: http://stackoverflow.com/comment/353008
type: Answer
answers question: http://stackoverflow.com/q/540729
downvote count: 0
score: 1
has body: If I got it right ExampleBean2 isn't loaded when Spring tries to instantiate the beans. Is this correct? In that case I don't thing you could do much with Spring's built in capabilities. Perhaps you could create a container class that will always be present. This class will check if ExampleBean2 is loaded and if yes, it will instantiate an instance of it. The container class will have an Object property that could either be null or the instance of the ExampleBean2.

http://stackoverflow.com/comment/78645054
score: 0
comment on: http://stackoverflow.com/a/439505
type: AnswerComment
type: Comment
has text: For me, apostrophes literal automatically casted to `int` in such contexts. So it doesn't need to be `char`. Deservin' some downvotes... simplistic.

http://stackoverflow.com/q/458756
upvote count: 31
downvote count: 2
linked to: http://stackoverflow.com/q/16179923
has answer: http://stackoverflow.com/a/40266737
answer count: 7
tagged with: keyboard
has answer: http://stackoverflow.com/a/62899371
favorite count: 0
tagged with: system
tagged with: shortcut
has body: Is there any way or a library to get a system-wide (global) keyboard shortcut to perform an action in a Java application?
possible better answer: http://stackoverflow.com/a/4190315
score: 29
has answer: http://stackoverflow.com/a/4190315
has answer: http://stackoverflow.com/a/515110
has answer: http://stackoverflow.com/a/458780
accepted answer: http://stackoverflow.com/a/458780
type: AnsweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/991177
has title: Java System-Wide Keyboard Shortcut
has answer: http://stackoverflow.com/a/458776

http://stackoverflow.com/q/541242
tagged with: jboss
score: 0
answer count: 1
accepted answer: http://stackoverflow.com/a/599482
type: AnsweredQuestion
tagged with: java
has body: I've got an application that is trying to call a method on an EJB running on JBoss 4.2.3 GA. The application is a legacy app; it works when it accesses the original server which ran on JBoss 4.0.1. Its RMI code is in jbossall-client.jar from JBoss 4.0.1. It is trying to call a method which will give it new code to allow it to update itself. So I've got to get it working as is; the only changes I can make are on the server side. At worst, I might have to set up a 4.0.1 JBoss server which can process these requests from older versions. In the meantime though, I'd like to understand why it is failing and if there is anything I can do to fix it. Right now it fails in new InitialContext(). This is the stack trace: javax.naming.NamingException: Failed to retrieve Naming interface [Root exception is java.lang.NullPointerException] at org.jboss.naming.HttpNamingContextFactory.getInitialContext(HttpNamingContextFactory.java:69) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247) at javax.naming.InitialContext.init(InitialContext.java:223) at javax.naming.InitialContext.&lt;init&gt;(InitialContext.java:197) at Main.main Caused by: java.lang.NullPointerException at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1820) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1908) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1832) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348) at org.jboss.proxy.ClientContainer.readExternal(ClientContainer.java:148) at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1755)…
has answer: http://stackoverflow.com/a/599482
type: Question
tagged with: ejb
tagged with: rmi
has title: NamingException when trying RMI/HTTP from JBoss 4.0.1 to 4.2.3

http://stackoverflow.com/comment/410163
comment on: http://stackoverflow.com/a/597990
has text: I didn't think of using $TERM. In any case, I know that it isn't always accurate. Both gnome-terminal and konsole set it to xterm (according to your link).
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/120524174
comment on: http://stackoverflow.com/a/10380512
type: AnswerComment
score: 0
type: Comment
has text: @BasilBourque I am confused why are arguing for final in method args when you state in your post that you only use it for specific cases. It has no use as I am in a project right now with finals everywhere. I can easily track the param and see where it is used and set by just putting my cursor on it. All light up. I don't need finals everywhere for some wierd case where the original author of the method decided you should not overwrite this param. If I now want to do just that, such as reassigning it, because say it was null, i can not. It makes no use in Java other than for very specific...

http://stackoverflow.com/a/15231008
answers question: http://stackoverflow.com/q/566877
type: Answer
has body: One way is to attach the SWT source jar (for example org.eclipse.swt.gtk.linux.x86_64.source_3.7.0.v3735b.jar) from the eclipse/plugins directory to the referenced library. You'll be able to view both the source and the Javadoc. Found on Eclipse Community Forums: Standard Widget Toolkit (SWT) » JavaDocs.
upvote count: 1
downvote count: 0
score: 1

http://stackoverflow.com/q/562160
possible better answer: http://stackoverflow.com/a/562172
downvote count: 1
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/562163
accepted answer: http://stackoverflow.com/a/562207
tagged with: java
has body: I have the following code: DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(xmlFile); How can I get it to parse XML contained within a String instead of a file?
answer count: 7
tagged with: string
favorite count: 0
upvote count: 281
score: 280
has answer: http://stackoverflow.com/a/562207
has comment: http://stackoverflow.com/comment/61775819
linked to: http://stackoverflow.com/q/33262
has title: In Java, how do I parse XML as a String instead of a file?
has answer: http://stackoverflow.com/a/562172
tagged with: parsing
tagged with: http://stackoverflow.com/tag/xml
has answer: http://stackoverflow.com/a/562184
has answer: http://stackoverflow.com/a/77459465
has answer: http://stackoverflow.com/a/39366585
has answer: http://stackoverflow.com/a/39953161
tagged with: file

http://stackoverflow.com/q/507556
has answer: http://stackoverflow.com/a/507568
has title: Is Spring too complex for JDBC operations?
favorite count: 0
answer count: 5
has comment: http://stackoverflow.com/comment/322032
has answer: http://stackoverflow.com/a/507608
tagged with: jdbc
tagged with: spring
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/507639
has comment: http://stackoverflow.com/comment/321898
has answer: http://stackoverflow.com/a/507639
tagged with: java
has answer: http://stackoverflow.com/a/507625
downvote count: 1
type: Question
has body: Just been looking at the Spring framework for JDBC - it looks like there is a bit of a learning curve - and I'm still not able to find a nice up to date quick start Spring/JDBC tutorial of any quality! Is there something lighter than Spring for basic JDBC operations - or has anyone got any good links for tutorials Many thanks
score: 3
accepted answer: http://stackoverflow.com/a/507608
has answer: http://stackoverflow.com/a/508259
upvote count: 4

http://stackoverflow.com/comment/102495099
type: AnswerComment
type: Comment
has text: I find the usage of `TransferHandler` highly complicated and unnecessary... I would propose the solution that makes use of Mouse(Motion)Listeners: https://stackoverflow.com/questions/58043707/java-how-to-drag-jtable-rows-without-usage-of-transferhandler
comment on: http://stackoverflow.com/a/4769575
score: 1

http://stackoverflow.com/q/424341
tagged with: persistence
upvote count: 19
has answer: http://stackoverflow.com/a/424758
favorite count: 0
has answer: http://stackoverflow.com/a/634176
has answer: http://stackoverflow.com/a/636057
possible better answer: http://stackoverflow.com/a/629645
has answer: http://stackoverflow.com/a/624640
downvote count: 1
has answer: http://stackoverflow.com/a/626534
accepted answer: http://stackoverflow.com/a/425024
tagged with: virtual-machine
type: Question
has answer: http://stackoverflow.com/a/425024
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/629645
has answer: http://stackoverflow.com/a/620451
has answer: http://stackoverflow.com/a/622382
tagged with: java
has body: Are there any Java VMs which can save their state to a file and then reload that state? If so, which ones?
has answer: http://stackoverflow.com/a/620414
answer count: 11
has answer: http://stackoverflow.com/a/424926
score: 18
has title: Are there any Java VMs which can save their state to a file and then reload that state?

http://stackoverflow.com/comment/310290
score: 1
type: AnswerComment
type: Comment
has text: The NetworkInterface class is present since 1.4, but the getInterfaceAddresses() and isUp() methods are both @since 1.6 (according to http://java.sun.com/javase/6/docs/api/java/net/NetworkInterface.html). 1.6 made the NetworkInterface class MUCH richer than it was in 1.5.
comment on: http://stackoverflow.com/a/494497

http://stackoverflow.com/q/395675
has answer: http://stackoverflow.com/a/403589
type: UnansweredQuestion
upvote count: 4
downvote count: 0
has answer: http://stackoverflow.com/a/21468035
has body: How can I reference a Groovy domain class from Java class using Eclipse? I've put my domain class in package: package com.me.myproject public class Person { String name int age } Then in my Java class I attempt to reference com.me.myproject.Person. This works for grails run-app (command line) but not Eclipse. Eclipse can't resolve the Groovy domain class. I'm running Eclipse 3.4.1 with the latest Groovy and Grails Eclipse plugins: Grails Eclipse Feature 0.1.0 20081120_2330 GroovyFeature 1.5.7.20081120_2330 I've tried setting the Eclipse default output folder to the same as Groovy compiler output location. I've also tried both enabling and disabling the “Disable Groovy Compiler Generating Class Files” setting. I've also tried not putting any of my classes in a package. None of these work.
type: Question
has answer: http://stackoverflow.com/a/1147672
tagged with: java
has answer: http://stackoverflow.com/a/7325155
has title: Reference Groovy domain class from Java class using Eclipse?
score: 4
tagged with: eclipse
tagged with: grails
tagged with: groovy
has answer: http://stackoverflow.com/a/1414110
has answer: http://stackoverflow.com/a/432467
answer count: 7
favorite count: 0
has answer: http://stackoverflow.com/a/407567

http://stackoverflow.com/comment/53203313
type: AnswerComment
type: Comment
has text: Is this still maintained? I see that the readme has been updated but the code hasn't changed for 2 years.
comment on: http://stackoverflow.com/a/18785300
score: 0

http://stackoverflow.com/a/4135494
upvote count: 1
downvote count: 1
type: Answer
has body: You may also want to check for the length - emails are a maximum of 254 chars long. I use the apache commons validator and it doesn't check for this.
answers question: http://stackoverflow.com/q/624581
has comment: http://stackoverflow.com/comment/10134164
score: 0

http://stackoverflow.com/comment/20839741
score: 1
has text: `DocumentListener` is better option for auto-complete `JTextField`.
type: AnswerComment
comment on: http://stackoverflow.com/a/485559
type: Comment

http://stackoverflow.com/comment/313544
comment on: http://stackoverflow.com/a/497315
type: AnswerComment
type: Comment
score: 1
has text: As far as I can see it's a flexibility that you can experience only at runtime. Why can't you have a compile error in the example you showed?

http://stackoverflow.com/q/616896
tagged with: java
has answer: http://stackoverflow.com/a/27541123
has answer: http://stackoverflow.com/a/617348
type: Question
has answer: http://stackoverflow.com/a/644658
tagged with: client-server
has answer: http://stackoverflow.com/a/638593
tagged with: network-programming
has comment: http://stackoverflow.com/comment/451828
downvote count: 0
has body: The aim of the test is to check the shape of the network response time between two hosts (client and server). Network response = the round trip time it takes to send a packet of data and receive it back. I am using the UDP protocol. How could I compute the response time ? I could just subtract TimeOfClientRequest - TimeOfClientResponseRecieved. But I'm not sure if this is the best approach. I can't do this only from inside the code and I'm thinking that the OS and computer load might interfere in the measuring process initiated by the client. By the way, I'm using Java. I would like to listen to your ideas.
tagged with: udp
has answer: http://stackoverflow.com/a/618552
answer count: 7
favorite count: 0
has answer: http://stackoverflow.com/a/616905
upvote count: 2
has title: How to measure the response time between a server and a client that communicate using the UDP protocol?
type: UnansweredQuestion
score: 2
has answer: http://stackoverflow.com/a/34768464

http://stackoverflow.com/a/583459
has body: I agree in that it doesn't really sound like you need a new format, or a binary one. If you truly want a binary format, why not consider one of these first: Binary XML (fast infoset, Bnux) Hessian google packet buffers But besides that, many textual formats should work just fine (or perhaps better) too; easier to debug, extensive tool support, compresses to about same size as binary (binary compresses poorly, and information theory suggests that for same effective information, same compression rate is achieved -- and this has been true in my testing). So perhaps also consider: Json works well; binary support via base64 (with, say, http://jackson.codehaus.org/) XML not too bad either; efficient streaming parsers, some with base64 support (http://woodstox.codehaus.org/, "typed access API" under 'org.codehaus.stax2.typed.TypedXMLStreamReader'). So it kind of sounds like you just want to build something of your own. Nothing wrong with that, as a hobby, but if so you need to consider it as such. It likely is not a requirement for the system you are building.
upvote count: 1
answers question: http://stackoverflow.com/q/567516
type: Answer
downvote count: 0
score: 1

http://stackoverflow.com/a/2293806
answers question: http://stackoverflow.com/q/442099
upvote count: 56
type: Answer
has comment: http://stackoverflow.com/comment/3741281
downvote count: 0
score: 56
has body: I had the same question, but then I messed around with it until I figured it out. Now, bear with me; this is the first time I have ever posted a response to an answer. Since I figured it out I thought I should transfer my brain’s data into your brain (eww.. we’re interfacing). Now to business... You can actually make up your own package and data types. What I did was I went to the Model Explorer tab on the left. Then, I right-clicked on IDL Data Types, and then I clicked Duplicate (since I didn’t want to make my own from scratch and it pretty much has what I want). It will then make a new package called "Package 1". Right-click on it and select Rename; I renamed mine to “Java Data Types” since that is what I am making, but you can name it “Underpants” if you want. Then, I opened my new package and right-clicked each data type, one at a time, and selected Properties. Then it will open up the UML Property Editor. From there, click on Name, then remove the word “idl” from inside the brackets, so “boolean(idl)” now says ”boolean()”. Now, one other thing: There is no int data type, so you need to make one. It is pretty easy; just right-click on your newly created folder, click New, then click Data Type. It should open the UML Datatypes Properties window. Now, click inside the Name tab, type in “int()”, then click OK. And you’re all done. See, that wasn’t so bad. Heck if I can do it, you definitely should be able to do it. I hope this was understandable and helpful. If not, well I guess I have failed you and I should now fall on my sword to save my honor.
has comment: http://stackoverflow.com/comment/9446097
has comment: http://stackoverflow.com/comment/9446500

http://stackoverflow.com/q/509318
accepted answer: http://stackoverflow.com/a/509437
tagged with: java
has answer: http://stackoverflow.com/a/33318630
type: Question
has title: can't run swing from the command line
has comment: http://stackoverflow.com/comment/323654
possible better answer: http://stackoverflow.com/a/509336
has answer: http://stackoverflow.com/a/8280818
has answer: http://stackoverflow.com/a/509336
downvote count: 0
answer count: 7
score: 8
has answer: http://stackoverflow.com/a/509330
favorite count: 0
has answer: http://stackoverflow.com/a/509367
upvote count: 8
has answer: http://stackoverflow.com/a/509437
has body: i use the command line in windows to compile and then execute my java programs. i've gone to http://java.sun.com/docs/books/tutorial/uiswing/start/compile.html and tried compiling the HelloWorldSwing.java class. it worked, but when i try "java HelloWorldSwing" it gives me a bunch of erros and says something along the lines of Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldSwing (wrong name: start/HelloWorldSwing) i try running with java start/HelloWorldSwing and it says noClassDefFoundError. i get no errors with javac either. here's the code from the tutorial: import javax.swing.*; public class HelloWorldSwing { /** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread. */ private static void createAndShowGUI() { //Create and set up the window. JFrame frame = new JFrame("HelloWorldSwing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Add the ubiquitous "Hello World" label. JLabel label = new JLabel("Hello World"); frame.getContentPane().add(label); //Display the window. frame.pack(); frame.setVisible(true); } public static void main(String[] args) { //Schedule a job for the event-dispatching thread: //creating and showing this application's GUI. javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } } EDIT: used javaw window pops up "a java exception has occurred" another window "error: could not find the main class. error: a jni error has occurred, please check your installation and try again." never had any problems running any java programs, am i missing something? is there a way to know what it is? i'm also running the command in the same path where the .java and .class are. there is no folder start in the path where i compiled the program. EDIT2 I tried both start/HelloWorldSwing and HelloWorldSwing with java. I don't get any errors with javac also. I get 2 pop up windows with the messages I've typed previously when I …
tagged with: swing
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/509335

http://stackoverflow.com/a/1799193
has body: I would recommend using MyBatis. It is a thin layer on top of JDBC, it is very easy to map objects to tables and still use plain SQL, everything is under your control.
type: Answer
upvote count: 36
score: 34
has comment: http://stackoverflow.com/comment/3727353
answers question: http://stackoverflow.com/q/452385
downvote count: 2

heap-memory
tag name: heap-memory
tags question: http://stackoverflow.com/q/632716
tags question: http://stackoverflow.com/q/477871
tags question: http://stackoverflow.com/q/417152
type: Tag
tags question: http://stackoverflow.com/q/371495
tags question: http://stackoverflow.com/q/542979
tags question: http://stackoverflow.com/q/462677

http://stackoverflow.com/comment/281720
type: Comment
comment on: http://stackoverflow.com/a/462985
has text: Thanks. DB4O looks good for such a small project, but I believe the ability to browse and edit data outside the application is very important. Also would it be easy to handle newer versions of classes? (e.g. added/removed fields)
score: 0
type: AnswerComment

http://stackoverflow.com/comment/51809960
comment on: http://stackoverflow.com/a/520339
score: 0
type: AnswerComment
has text: Be aware that the class (MyParentClass.class) you use as argument of reflections.getSubTypesOf(MyParentClass.class) also needs to be on the scanners you provided. I was getting an empty list trying to get subclasses of a class that was outside the packages being scanned.
type: Comment

http://stackoverflow.com/comment/78717273
comment on: http://stackoverflow.com/a/644730
has text: @Luckylukee you could create your own version of the class but generally you shouldn't alter built in classes.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/65930894
score: 1
type: Comment
comment on: http://stackoverflow.com/a/513001
has text: Does any of this discussion address that the Java 8 inclusion of static interfaces does not address the "enforcing a convention" concept that the OP wanted? Or did I misunderstand both this conversation and the OP? I would love a code enforcement version of static methods, even if it [grotesquely] required a new keyword. Something akin to `interface ClassReset{musthave public static void RESET();}`
type: AnswerComment

http://stackoverflow.com/comment/138427243
has text: A question about the convention itself: *[Are there any widespread, modern Java coding conventions?](https://stackoverflow.com/questions/1365210)*
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/414023
type: Comment

http://stackoverflow.com/comment/311590
score: 0
type: AnswerComment
type: Comment
has text: I believe he's using IceFaces.
comment on: http://stackoverflow.com/a/495777

http://stackoverflow.com/comment/107619787
type: Comment
has text: I like JCommander. Is it possible to have just a class-level annotation (specify a CLI style), so as to avoid all annotations on each fields, like lombok does?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/3337023

http://stackoverflow.com/q/367645
accepted answer: http://stackoverflow.com/a/367674
answer count: 2
upvote count: 1
possible better answer: http://stackoverflow.com/a/575019
has answer: http://stackoverflow.com/a/575019
favorite count: 0
has title: Disable character echo on Java network connection
has body: I have a Solaris daemon written in Java6. Clients can connect to it using a telnet style interface. They telnet to a particular port, and I read lines of input and act on them. At one point in I need to prompt the user to enter a password, and while they're entering that I want to disable the echoing of characters back to the telnet client. The code has a Socket object and creates an InputStream from the socket's getInputStream() result, then reads and buffers characters from the InputStream, breaking them up on cr/lf boundaries. I can't see any attributes on either the InputStream or the Socket to disable the echoing of characters back to the client. Can someone nudge me in the right direction?
tagged with: telnet
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
type: Question
tagged with: echo
tagged with: network-programming
tagged with: solaris
has answer: http://stackoverflow.com/a/367674

http://stackoverflow.com/a/501309
has comment: http://stackoverflow.com/comment/20855568
has comment: http://stackoverflow.com/comment/1116944
has comment: http://stackoverflow.com/comment/51250999
upvote count: 188
has comment: http://stackoverflow.com/comment/1116971
type: Answer
has comment: http://stackoverflow.com/comment/71829529
has comment: http://stackoverflow.com/comment/6540058
downvote count: 0
has comment: http://stackoverflow.com/comment/83590414
has comment: http://stackoverflow.com/comment/20855381
has comment: http://stackoverflow.com/comment/83211405
has comment: http://stackoverflow.com/comment/83475737
has comment: http://stackoverflow.com/comment/124358036
accepted answer of: http://stackoverflow.com/q/501277
has comment: http://stackoverflow.com/comment/31947651
has comment: http://stackoverflow.com/comment/83590751
score: 188
answers question: http://stackoverflow.com/q/501277
has comment: http://stackoverflow.com/comment/83544689
has body: As mark said, the types are not reifiable, which is a problem in the following case: try { doSomeStuff(); } catch (SomeException&lt;Integer&gt; e) { // ignore that } catch (SomeException&lt;String&gt; e) { crashAndBurn() } Both SomeException&lt;Integer&gt; and SomeException&lt;String&gt; are erased to the same type, there is no way for the JVM to distinguish the exception instances, and therefore no way to tell which catch block should be executed.
type: AcceptedAnswer

http://stackoverflow.com/a/12053269
downvote count: 2
answers question: http://stackoverflow.com/q/576918
score: 1
has body: I just developed a small framework for this purpose. You can check it out at: http://code.google.com/p/java-interceptor/ (use svn to check out).
type: Answer
has comment: http://stackoverflow.com/comment/35361223
upvote count: 3

http://stackoverflow.com/a/555091
score: 3
has comment: http://stackoverflow.com/comment/366989
upvote count: 3
has comment: http://stackoverflow.com/comment/367022
has comment: http://stackoverflow.com/comment/368670
has comment: http://stackoverflow.com/comment/366933
answers question: http://stackoverflow.com/q/554963
has body: From the error message, it sounds like Spring is attempting to instantiate the object with this constructor: public M2000AlarmChannel(String host, int port, String username, String password, MDDComponent componenet) Looks like Spring is confused on which constructor to use, possibly because both constructors have a MDDComponent parameter (in a way, both constructors have this as their last parameter, I'm curious if that has something to do with the logic that Spring uses in determining which constructor to use. Anyway...). According to the Spring manual, there are parameters you can add to the &lt;constructor-arg&gt; element to help the container resolve which constructor to use: You can add "type": &lt;bean id="exampleBean" class="examples.ExampleBean"&gt; &lt;constructor-arg type="int" value="7500000"/&gt; &lt;constructor-arg type="java.lang.String" value="42"/&gt; &lt;/bean&gt; or you can add an index: &lt;bean id="exampleBean" class="examples.ExampleBean"&gt; &lt;constructor-arg index="0" value="7500000"/&gt; &lt;constructor-arg index="1" value="42"/&gt; &lt;/bean&gt; (You can probably specify both, if you really want to) Adding one or both of these should help Spring resolve which constructor to use. As a corollary, if this doesn't help, can you simply change the XML definition to pass in the parameters required for the other constructor, the one Spring is attempting to use? BTW, it might make your question a lot more readable to use the quote tags within WMD.
downvote count: 0
has comment: http://stackoverflow.com/comment/370232
has comment: http://stackoverflow.com/comment/366911
type: Answer
has comment: http://stackoverflow.com/comment/366830
has comment: http://stackoverflow.com/comment/370238

wav
tags question: http://stackoverflow.com/q/577724
tag name: wav
type: Tag

http://stackoverflow.com/a/381811
has body: "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis. Epigrams on Programming.
has comment: http://stackoverflow.com/comment/209868
score: 17
answers question: http://stackoverflow.com/q/381733
has comment: http://stackoverflow.com/comment/210740
downvote count: 2
type: Answer
upvote count: 19

http://stackoverflow.com/q/644577
has title: Does JPA support mapping to sql views?
has comment: http://stackoverflow.com/comment/2223139
type: Question
upvote count: 41
has answer: http://stackoverflow.com/a/69174864
has body: I'm currently using Eclipselink, but I know now days most JPA implementations have been pretty standardized. Is there a native way to map a JPA entity to a view? I am not looking to insert/update, but the question is really how to handle the @Id annotation. Every entity in the JPA world must have an ID field, but many of the views I have created do not conform to this. Is there native support for this in the JPA or do I need to use hacks to get it to work? I've searched a lot and found very little information about doing this.
accepted answer: http://stackoverflow.com/a/644777
tagged with: sql
tagged with: jpa
favorite count: 0
possible better answer: http://stackoverflow.com/a/2203865
has answer: http://stackoverflow.com/a/34135295
has answer: http://stackoverflow.com/a/644777
has answer: http://stackoverflow.com/a/2203865
answer count: 4
type: AnsweredQuestion
score: 41
tagged with: view
downvote count: 0
tagged with: java
tagged with: orm

http://stackoverflow.com/comment/89846690
has text: @Johnbot Thanks for comment, you are right. But, the main reason was to show an API (of course, the smart path is to measure performance before using `parallel` processing). By the way, for array of `1_000_000` elements, the `parallel` version was 2 times faster on my machine in comparison with sequential.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/49784982

http://stackoverflow.com/q/624888
has answer: http://stackoverflow.com/a/624938
tagged with: java
has answer: http://stackoverflow.com/a/1183070
upvote count: 3
has answer: http://stackoverflow.com/a/806960
has answer: http://stackoverflow.com/a/1333349
answer count: 7
favorite count: 0
has answer: http://stackoverflow.com/a/662493
has title: What are the (gotchas and) limitations when using POI to create Excel workbooks?
type: UnansweredQuestion
has body: Just saw a crash as we exceeded 255 columns. Maybe this question should go directly to POI, but lets say I do not want to disturb them in their effort to further develop the increadibly useful API it already is. ;-) The limitations page is not increadibly detailed. So: What are your experience of actual limitations assuming the output shall be readable in Excel? Has anyone used POI to benchmark &amp; explore soft &amp; hard limitations of POI-generated Excel files? The only limitations I can quickly find in the POI interface is the below. Microsoft lists further limitations for Excel that do not seem to be covered in POI. EDIT: Oops. Just realized we have not refreshed POI in the last 5 years, so the code below may have been replaced 100 times over since then. EDIT: The code below has not changed since then and ver 3.2 of Oct 19, 2008. /** * @throws RuntimeException if the bounds are exceeded. */ private void checkBounds(int cellNum) { if (cellNum &gt; 255) { throw new RuntimeException("You cannot have more than 255 columns "+ "in a given row (IV). Because Excel can't handle it"); } else if (cellNum &lt; 0) { throw new RuntimeException("You cannot reference columns with an index of less then 0."); } }
has answer: http://stackoverflow.com/a/1187298
tagged with: apache-poi
downvote count: 0
tagged with: excel
type: Question
has answer: http://stackoverflow.com/a/4859302
score: 3

http://stackoverflow.com/a/449468
answers question: http://stackoverflow.com/q/449445
downvote count: 0
score: 6
has body: Static class variables can be thought of as a global class. No matter how many instances of the class you have, there is just one instance of each static variable. Static methods don't use any non-static class variables and they can be called directly from outside of the class without having to instantiate the class itself.
type: Answer
upvote count: 6

http://stackoverflow.com/a/377780
upvote count: 2
has comment: http://stackoverflow.com/comment/205524
has body: The first makes far more sense. It keeps the variable in the scope that it is used in. and prevents values assigned in one iteration being used in a later iteration, this is more defensive. The former is sometimes said to be more efficient but any reasonable compiler should be able to optimise it to be exactly the same as the latter.
score: 0
answers question: http://stackoverflow.com/q/377763
type: Answer
has comment: http://stackoverflow.com/comment/205689
downvote count: 2
has comment: http://stackoverflow.com/comment/205523

http://stackoverflow.com/a/380054
upvote count: 2
has body: use a MVC framework that handles all the hard organization work for you. there's a ton of MVC framework topics on SO. using high quality stuff written by others will probably teach you faster - you will get further and see more patterns with less headache.
has comment: http://stackoverflow.com/comment/207649
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/380046
score: 2

http://stackoverflow.com/comment/1429475
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/454498
score: 0
has text: Duplicate? http://stackoverflow.com/questions/876142

http://stackoverflow.com/comment/430143
type: Comment
score: 1
has text: That exception is easy to fix with a simple if which checks if builder length is greater than 0.
comment on: http://stackoverflow.com/a/450548
type: AnswerComment

http://stackoverflow.com/comment/97195089
has text: From a *compiler design* perspective, I disagree with this decision. The user should be allowed to design things poorly and shoot themselves in the foot. If you try to restrict that, then they'll find new, even *more* grotesque and convoluted ways to shoot themselves in the foot. Like forking a library to hack one of the classes to bypass said restriction (or worse--forking the compiler to remove the restriction altogether). And then as the official library gets updated over the years, maybe 64-bit support is added, some huge...
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/586397
type: Comment

http://stackoverflow.com/a/551024
has comment: http://stackoverflow.com/comment/362573
answers question: http://stackoverflow.com/q/551009
has comment: http://stackoverflow.com/comment/362740
has comment: http://stackoverflow.com/comment/363312
has comment: http://stackoverflow.com/comment/362609
score: 0
has comment: http://stackoverflow.com/comment/363277
has body: I've seen this practice before too, in fact once I was on a project where I had to search for a constants file which led me to an XML file which would finally give me the property name that I was looking for. And then I had to look at the property file too, since the value was what I really wanted. I think this an example of the stuff that Jeff and Joel were talking about on the last podcasts, where developers are blindly following a practice that they've heard about (in this case, the practice to never have a string literal in your code) without thinking about whether or not it's really appropriate given the matter at hand.
upvote count: 2
has comment: http://stackoverflow.com/comment/363131
downvote count: 2
has comment: http://stackoverflow.com/comment/363299
has comment: http://stackoverflow.com/comment/363146
type: Answer

http://stackoverflow.com/a/609879
downvote count: 7
has comment: http://stackoverflow.com/comment/1593297
has comment: http://stackoverflow.com/comment/25585646
score: 146
has comment: http://stackoverflow.com/comment/51180431
has body: This is almost certainly a bad idea. Certainly if the ordinal is de-facto persisted (e.g. because someone has bookmarked the URL) - it means that you must always preserve the enum ordering in future, which may not be obvious to code maintainers down the line. Why not encode the enum using myEnumValue.name() (and decode via ReportTypeEnum.valueOf(s)) instead?
answers question: http://stackoverflow.com/q/609860
has comment: http://stackoverflow.com/comment/7484446
has comment: http://stackoverflow.com/comment/139256916
has comment: http://stackoverflow.com/comment/422720
has comment: http://stackoverflow.com/comment/46724906
upvote count: 153
has comment: http://stackoverflow.com/comment/132554951
type: Answer
has comment: http://stackoverflow.com/comment/63665685
has comment: http://stackoverflow.com/comment/9409154
has comment: http://stackoverflow.com/comment/1593515
has comment: http://stackoverflow.com/comment/119207370

http://stackoverflow.com/a/29821752
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/60309342
type: Answer
has body: Please have a look on JOOQ. http://www.jooq.org/ Open Source is available .....
score: 0
answers question: http://stackoverflow.com/q/452627

http://stackoverflow.com/a/490755
has comment: http://stackoverflow.com/comment/3674663
has comment: http://stackoverflow.com/comment/1648313
downvote count: 0
score: 1
upvote count: 1
type: AcceptedAnswer
has body: For rewriting URLs within your application you can use UrlRewrite. However, in this case it looks like you want to remove your web application's context path, in which case you have two options: deploy your application to the context path / (how is application server-specific) run Apache on port 80 and use mod_proxy to proxy certain URLs to your application server running on a different port, using configuration something like the following. Apache config: &lt;Proxy http://localhost:8080/*&gt; Order Allow,Deny Allow From All &lt;/Proxy&gt; ProxyPreserveHost On ProxyPass / http://localhost:8080/WebApplication/ ProxyPassReverse / http://localhost:8080/WebApplication/
accepted answer of: http://stackoverflow.com/q/490124
type: Answer
answers question: http://stackoverflow.com/q/490124

http://stackoverflow.com/q/601804
accepted answer: http://stackoverflow.com/a/601813
has answer: http://stackoverflow.com/a/601817
answer count: 8
type: AnsweredQuestion
tagged with: performance
tagged with: java
has answer: http://stackoverflow.com/a/601815
possible better answer: http://stackoverflow.com/a/601824
type: Question
tagged with: c#
has answer: http://stackoverflow.com/a/601824
downvote count: 0
tagged with: string
tagged with: compiler-optimization
has answer: http://stackoverflow.com/a/601809
favorite count: 0
has answer: http://stackoverflow.com/a/604193
has title: What is the performance cost of assigning a single string value using +'s
has answer: http://stackoverflow.com/a/601813
upvote count: 11
has answer: http://stackoverflow.com/a/601958
has body: I have often wondered this, is there a performance cost of splitting a string over multiple lines to increase readability when initially assigning a value to a string. I know that strings are immutable and therefore a new string needs to be created every time. Also, the performance cost is actually irrelevant thanks to today's really fast hardware (unless you are in some diabolical loop). So for example: String newString = "This is a really long long long long long" + " long long long long long long long long long long long long " + " long long long long long long long long long string for example."; How does the JVM or .Net's compiler and other optimizations handle this. Will it create a single string? Or will it create 1 string then a new concatenating the value and then another one concatenating the values again? This is for my own curiosity.
score: 11
has answer: http://stackoverflow.com/a/601831

http://stackoverflow.com/a/628747
answers question: http://stackoverflow.com/q/628730
type: Answer
has body: 1) Why don't you use Generics: LinkedList&lt;DependencyDataCollection&gt; lList; 2) That is the downside of LinkedList, you might as well use HashMap or other data structures
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/441506
downvote count: 0
has comment: http://stackoverflow.com/comment/441457

http://stackoverflow.com/q/529309
has answer: http://stackoverflow.com/a/24131600
tagged with: xslt-2.0
type: Question
downvote count: 0
has comment: http://stackoverflow.com/comment/32928393
favorite count: 0
possible better answer: http://stackoverflow.com/a/6695906
accepted answer: http://stackoverflow.com/a/24131600
has answer: http://stackoverflow.com/a/6695906
has body: I'm currently looking into using XSLT 2.0, but I cannot find any open-source java implementations (Saxon-B seems to fit the bill, but isn't schema-aware). Am I missing something?
linked to: http://stackoverflow.com/q/23130587
has comment: http://stackoverflow.com/comment/53248529
has answer: http://stackoverflow.com/a/530122
score: 21
answer count: 4
has answer: http://stackoverflow.com/a/698636
tagged with: http://stackoverflow.com/tag/xml
has title: Open-source java XSLT 2.0 implementation?
upvote count: 21
tagged with: xslt
tagged with: open-source
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/a/534134
upvote count: 163
has comment: http://stackoverflow.com/comment/347224
type: AcceptedAnswer
downvote count: 1
score: 162
has body: Just my 2 cents: Here is the code for Enum.java, as published by Sun, and part of the JDK: public abstract class Enum&lt;E extends Enum&lt;E&gt;&gt; implements Comparable&lt;E&gt;, Serializable { // [...] /** * Returns true if the specified object is equal to this * enum constant. * * @param other the object to be compared for equality with this object. * @return true if the specified object is equal to this * enum constant. */ public final boolean equals(Object other) { return this==other; } }
type: Answer
accepted answer of: http://stackoverflow.com/q/533922
answers question: http://stackoverflow.com/q/533922

http://stackoverflow.com/comment/342486
has text: I decided that maybe trying to shoehorn this functionality into the existing class wasn't worth it, so I create a separate method and just used String.format as suggested here. Thanks!
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/529488

http://stackoverflow.com/comment/261292
has text: To expand in the comment, which is really good. Use something that extends JFrame instead of something that extends JDialog to get something flashing in the task bar when you invoke bring to front
type: Comment
comment on: http://stackoverflow.com/a/438815
score: 0
type: AnswerComment

http://stackoverflow.com/q/374478
has title: Out Of Memory using Postgres in Java
has comment: http://stackoverflow.com/comment/17195099
favorite count: 0
has comment: http://stackoverflow.com/comment/202974
has comment: http://stackoverflow.com/comment/203013
has body: Well, we have a web app, running over JBoss and we're having an "OutOfMemory" error when trying to insert a lot of rows in several tables of a postgres DB. This is the complete environment for this error: * JBoss 4.3.x GA * Java 1.6.0 * Hibernate 3.0 * postgreSQL-8.3 (driver) About actual code-work environment: * The heavy part about this is that we're parsing huge amounts of xml documents each one downloaded separately from a specific URL (1 URL = 1 XML). We accomplish that by having an EJB that distributes the generated URLs to a queue, then a pool of MDBs connect using streams and generates the documents (note that we've actually had to raise stack memory due to XML documents size, and we're stuck with having to get all the document in one stream), once the document is generated it goes to another queue where another MDB pool listens. Those MDBs parse the doc, storing information in several entities (5 at least) that then are persisted in the DB (note that the transaction management is set to "BEAN" and is begun and commited during each MDBs work). Processing URLs sequentially is not an option because of the amount of URLs to be processed, it would take like 2 months or so... lol Trouble is... that we parse and store like 200 URLs or so and start getting out of memory error for postgreSQL. Any ideas?? Thanks in advance!! ALSO: It may be of use knowing that this error wasn't coming out before (I did parse a few thousands of that XML befor), only generating documents and parsing some of it into some entities didn't seem to bring trouble. Troubles started when we started to parse more and more of the doc into it's correspondent entities. (Like one entity having a list of "features" [other entity parsed from the same xml])
has answer: http://stackoverflow.com/a/374513
upvote count: 2
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/202842
score: 2
has comment: http://stackoverflow.com/comment/202848
tagged with: java
has comment: http://stackoverflow.com/comment/202833
has comment: http://stackoverflow.com/comment/203005
tagged with: memory
has comment: http://stackoverflow.com/comment/202823
type: Question
has comment: http://stackoverflow.com/comment/202843
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/374505
tagged with: postgresql

http://stackoverflow.com/q/602614
has comment: http://stackoverflow.com/comment/415115
has comment: http://stackoverflow.com/comment/415389
has answer: http://stackoverflow.com/a/747563
answer count: 4
type: AnsweredQuestion
tagged with: java-2d
has body: I'm looking to do some physics simulations and I need fast rendering in Java. I've run into performance issues with Java2d in the past, so what are the fast alternatives? Is JOGL significantly faster than Java2d?
tagged with: jogl
accepted answer: http://stackoverflow.com/a/603342
upvote count: 17
type: Question
tagged with: performance
tagged with: rendering
tagged with: java
has answer: http://stackoverflow.com/a/603342
possible better answer: http://stackoverflow.com/a/747563
has comment: http://stackoverflow.com/comment/415111
score: 17
downvote count: 0
has answer: http://stackoverflow.com/a/603127
has answer: http://stackoverflow.com/a/932558
has title: What are some faster alternatives to Java2d?
favorite count: 0

http://stackoverflow.com/comment/289556
type: Comment
score: 0
type: AnswerComment
has text: Mind you, I will say that for Windows programmers using Java, that article is indeed very useful and should be recommended. So, my comments about its inapplicability to Unix should not in any way be seen to disparage the article in general.
comment on: http://stackoverflow.com/a/471873

http://stackoverflow.com/a/474480
has comment: http://stackoverflow.com/comment/291959
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/291973
type: Answer
answers question: http://stackoverflow.com/q/474451
accepted answer of: http://stackoverflow.com/q/474451
has comment: http://stackoverflow.com/comment/291987
score: 31
has comment: http://stackoverflow.com/comment/291942
upvote count: 31
has body: You can iterate with either for loops or enhanced for loops: for (int row=0; row &lt; grid.length; row++) { for (int col=0; col &lt; grid[row].length; col++) { int value = grid[row][col]; // Do stuff } } or // Note the different use of "row" as a variable name! This // is the *whole* row, not the row *number*. for (int[] row : grid) { for (int value : row) { // Do stuff } } The first version would be the easiest solution to the "find the co-ordinates" question - just check whether the value in the inner loop is correct.
has comment: http://stackoverflow.com/comment/291997

http://stackoverflow.com/comment/324735
comment on: http://stackoverflow.com/a/510747
type: Comment
score: 2
has text: It probably wont happen all the time, but due to the way nanotime() is implemented the possibility is always there.
type: AnswerComment

http://stackoverflow.com/comment/22483619
type: AnswerComment
has text: @TofuBeer Isn't being forced to update your code after the interface of an underlaying API changed a good thing? If you had had only unchecked exceptions there, you'd have ended up with a broken/incomplete program without knowing it.
type: Comment
comment on: http://stackoverflow.com/a/703944
score: 3

http://stackoverflow.com/q/491059
possible better answer: http://stackoverflow.com/a/491600
has body: I have to build a rather large form with many controls. The controls are divided in basic controls/settings and extended controls/settings. The user can decide if he wants to see only the basic or both basic and extended controls. I've dropped all extended controls onto their own JPanel so that I can easily switch between the two views by showing or hiding this panel. Currently I'm using GroupLayout and what happens is that the controls on different panels are not aligned: Label aaa: Text field Label a: Text field Label aaaaaa: Text field ---------------------------- Label b: Text field Label bbb: Text field Label bb: Text field Unfortunatly I found now way to "synchronize" the layouts of the two panels (except using AbsoluteLayout and fixed control coordinates) Is there any way to achive this? Is my whole design flawed? EDIT: If it is possible I would like to keep the GroupLayout manager.
has answer: http://stackoverflow.com/a/491818
has answer: http://stackoverflow.com/a/491064
has answer: http://stackoverflow.com/a/491600
has title: Can a layout manager spawn several JPanels?
type: Question
answer count: 6
has answer: http://stackoverflow.com/a/492291
downvote count: 0
accepted answer: http://stackoverflow.com/a/491818
tagged with: layout-manager
tagged with: netbeans6.5
favorite count: 0
tagged with: netbeans
tagged with: swing
type: AnsweredQuestion
score: 3
has answer: http://stackoverflow.com/a/491076
has answer: http://stackoverflow.com/a/492776
upvote count: 3
tagged with: java

http://stackoverflow.com/a/490857
upvote count: 2
type: Answer
has body: Are you doing it for fun or for commercial purposes? Because if money is involved, if I were you, I would really consider investing in IntelliJ, which is arguably the best IDE Java IDE out there, but unfortunately it is not exactly free. The Android SDK has some support for IntelliJ out of the box so it's not like you had to write all the makefiles yourself manually. If you liked Visual Studio, you would like IntelliJ, so why don't you download the trial version and have a look at it. Just my 2 cents.
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/490824

http://stackoverflow.com/comment/417572
comment on: http://stackoverflow.com/a/603028
score: 0
has text: ok, now I get what you want to do. However, I don't think Maven will allow that...
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/84668314
has text: Why the downvote? It's the same class used by Hibernate Validator.
type: Comment
comment on: http://stackoverflow.com/a/47875421
score: 0
type: AnswerComment

http://stackoverflow.com/comment/16195661
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/617438
has text: No, you misunderstand what I said (I think). Make a directory like ~/.tmp. Give it user only permissions. Then use the createTempFile method that allows you to specify the temp directory, passing in ~/.tmp. The number of times this method is called has no bearing on it (the odds of collisions are low, and can be handled via looping).

http://stackoverflow.com/q/431635
score: 12
answer count: 2
accepted answer: http://stackoverflow.com/a/431828
possible better answer: http://stackoverflow.com/a/1635134
has body: I'm using Grails 1.1 beta2. I need to import a large amount of data into my Grails application. If I repeatedly instantiate a grails domain class and then save it, the performance is unacceptably slow. Take for example importing people from a phone book: for (each person in legacy phone book) { // Construct new Grails domain class from legacy phone book person Person person = new Person(...) person.save() } This turns out be painfully slow. Someone on the Grails mailing list suggest batching up saves in a transaction. So now I have: List batch = new ArrayList() for (each person in legacy phone book) { // Construct new Grails domain class from legacy phone book person Person person = new Person(...) batch.add(person) if (batch.size() &gt; 500) { Person.withTransaction { for (Person p: batch) p.save() batch.clear() } } } // Save any remaining for (Person p: batch) p.save() This works must faster, at least initially. Each transaction saves 500 records. As time goes on, the transactions take longer and longer. The first few transactions takes about 5 seconds, then it just creeps from there. After about 100 transactions, each one takes over a minute, which is once again unacceptable. Worse is that eventually Grails will eventually run out of Java heap memory. I can increase the JVM heap size, but that just delays the OutOfMemoryError exception. Any ideas why this is? It's like there some internal resource not being released. The performance gets worse, memory is being held on to, and then eventually the system runs out of memory. According to the Grails documentation, withTransaction passes the closure to Spring's TransactionStatus object. I couldn't find anything in TransactionStatus to close/end the transaction. Edit: I'm running this from Grails' Console (grails console) Edit: Here's the out of memory exception: Exception thrown: Java heap space java.lang.OutOfMemoryError: Java heap space at org.hibernate.util.IdentityMap.entryArray(IdentityMap.java:194) at org.hibern…
tagged with: spring
tagged with: transactions
tagged with: java
tagged with: hibernate
has title: Grails, Inserting lots of data using withTransaction results in OutOfMemoryError
upvote count: 12
has comment: http://stackoverflow.com/comment/255049
has answer: http://stackoverflow.com/a/431828
tagged with: grails
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/1635134
favorite count: 0
type: Question

http://stackoverflow.com/comment/30202488
score: 0
type: AnswerComment
type: Comment
has text: -1 this doesn't include the answer for how to get jyaml to not include the class names. That's what I came here for.
comment on: http://stackoverflow.com/a/566084

http://stackoverflow.com/comment/21773922
has text: @Les - Flex runs on iOS and pretty much anywhere else, using Adobe AIR. Flex runs on Flash, AIR, and Apache Flex 5 will soon also target HTML5. Flex wins in the platform options category, it's not even close.
type: AnswerComment
comment on: http://stackoverflow.com/a/535071
score: 0
type: Comment

http://stackoverflow.com/q/395056
answer count: 2
score: 5
upvote count: 5
downvote count: 0
has title: Best way to separate Business from Presentation Logic?
accepted answer: http://stackoverflow.com/a/395128
has answer: http://stackoverflow.com/a/395179
favorite count: 0
tagged with: business-logic-layer
possible better answer: http://stackoverflow.com/a/395179
has answer: http://stackoverflow.com/a/395128
tagged with: presentation-layer
type: AnsweredQuestion
has body: I want to create a game that will work both locally and online. My first thought was to create an interface that would have all the methods that will be needed by the GUI for the business logic and then have a network implementation and a local implementation. This works fine for request-response messages. But what about messages that the server sends, where I have to update some GUI components (i.e. JLabels)? My first solution to this was to implement listeners, where each change in the implementation will fire an event. The GUI would register and change it's components appropriately. However, calls to fire events in the business logic looks a little wrong. Am I in the right track? Because I think I'm not. Any suggestions? Thank you. NOTE: The client is a simple Java Swing GUI.
tagged with: java
type: Question

http://stackoverflow.com/comment/448719
type: Comment
has text: See @basszero's comment for a neater solution. We considered multiple .classpaths but decided that it would lead to a lot of potential to break, as someone on one platform may add something to their classpath leaving the other ones out of date.
comment on: http://stackoverflow.com/a/632238
score: 0
type: AnswerComment

http://stackoverflow.com/a/370967
has comment: http://stackoverflow.com/comment/27163305
type: Answer
has comment: http://stackoverflow.com/comment/41757381
has comment: http://stackoverflow.com/comment/40935877
downvote count: 141
has comment: http://stackoverflow.com/comment/139633144
has comment: http://stackoverflow.com/comment/29697169
upvote count: 744
has body: Because "abstract" means: "Implements no functionality", and "static" means: "There is functionality even if you don't have an object instance". And that's a logical contradiction.
has comment: http://stackoverflow.com/comment/2880310
has comment: http://stackoverflow.com/comment/6212310
has comment: http://stackoverflow.com/comment/34458484
has comment: http://stackoverflow.com/comment/3060431
has comment: http://stackoverflow.com/comment/41743119
has comment: http://stackoverflow.com/comment/41738833
has comment: http://stackoverflow.com/comment/6348255
answers question: http://stackoverflow.com/q/370962
has comment: http://stackoverflow.com/comment/2884171
has comment: http://stackoverflow.com/comment/41757728
has comment: http://stackoverflow.com/comment/5321160
has comment: http://stackoverflow.com/comment/27163226
score: 603
has comment: http://stackoverflow.com/comment/5323117
has comment: http://stackoverflow.com/comment/36005076
has comment: http://stackoverflow.com/comment/12439685
has comment: http://stackoverflow.com/comment/41743128
has comment: http://stackoverflow.com/comment/40304586
has comment: http://stackoverflow.com/comment/3059554
has comment: http://stackoverflow.com/comment/2882559
has comment: http://stackoverflow.com/comment/40304607
has comment: http://stackoverflow.com/comment/40304633
has comment: http://stackoverflow.com/comment/41755282
has comment: http://stackoverflow.com/comment/50293061
has comment: http://stackoverflow.com/comment/41757210

http://stackoverflow.com/comment/220794
type: Comment
comment on: http://stackoverflow.com/q/393853
score: 0
type: QuestionComment
has text: It seems like you're implementing some kind of collection. Maybe you could study the other collection classes source code to get an idea how to attain your goal?

http://stackoverflow.com/q/442494
type: Question
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/442531
has comment: http://stackoverflow.com/comment/272194
has comment: http://stackoverflow.com/comment/4392006
type: UnansweredQuestion
has title: How to install JDK 1.5 for Solaris 10
has body: I been trying to install but keep on getting file is corrupted when unpacking the file after accepting the license agreement. Anyone have any advice. http://java.sun.com/javase/downloads/index_jdk5.jsp I installing this jdk-1_5_0_17-solaris-sparc.sh
tagged with: java

http://stackoverflow.com/comment/128064118
type: Comment
has text: 100% it seems like after java8 anytime I put a forloop into a PR, everyone wants to remind me that there are a zillion alternatives. But this is readible, canonical and not susceptible to the problem in the first place
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/477569

http://stackoverflow.com/comment/378848
score: 0
type: AnswerComment
type: Comment
has text: I'm thinking of how to keep it small. If the name is in a consistent place then all you really need convert and show on your web site is the name page as a thumbnail. You can then put the PDF behind a link for download. Would that work?
comment on: http://stackoverflow.com/a/564462

http://stackoverflow.com/q/638807
answer count: 5
has comment: http://stackoverflow.com/comment/463661
tagged with: swing
accepted answer: http://stackoverflow.com/a/645011
tagged with: mouse
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/649660
tagged with: java
has answer: http://stackoverflow.com/a/26765460
type: Question
has body: How do you setup a JTable to be able to drag a row to a different index in the table. For example if I have 5 rows and I want to drag the 4th row to the 2nd position?
downvote count: 0
has title: How do I drag and drop a row in a JTable?
linked to: http://stackoverflow.com/q/58043707
has answer: http://stackoverflow.com/a/645011
has answer: http://stackoverflow.com/a/56716436
tagged with: jtable
score: 35
upvote count: 35
possible better answer: http://stackoverflow.com/a/4769575
has answer: http://stackoverflow.com/a/4769575
favorite count: 0
tagged with: drag-and-drop

http://stackoverflow.com/comment/5850705
comment on: http://stackoverflow.com/a/1483378
type: AnswerComment
score: 32
type: Comment
has text: I agree. I've been using ORM over 3 years now, and i cannot tell how much time was wasted (still is) to resolve persistence related issues. We have no control whatsoever about what is happening "under the hood", configurations are too many to be managed efficiently and there are behaviors that could drive one crazy. On the other hand i have support for major databases and never have to worry about their differences.

http://stackoverflow.com/a/382381
has comment: http://stackoverflow.com/comment/210011
answers question: http://stackoverflow.com/q/382361
has comment: http://stackoverflow.com/comment/17087875
has body: I guess the first question is, what are you supposed to do with it? If it's not broken, quietly close it up and pretend you've never seen it. Otherwise, refactor like mad - hopefully there's some exit condition somewhere that looks something like a contract.
type: Answer
has comment: http://stackoverflow.com/comment/210013
downvote count: 1
score: 3
has comment: http://stackoverflow.com/comment/209977
upvote count: 4

http://stackoverflow.com/comment/136683549
has text: In Python PEP8 recommend to use `single_trailing_underscore_` to avoid name clashes with keywords.
type: Comment
score: 2
comment on: http://stackoverflow.com/a/424009
type: AnswerComment

http://stackoverflow.com/a/620601
has comment: http://stackoverflow.com/comment/433730
upvote count: 2
has comment: http://stackoverflow.com/comment/433891
type: Answer
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/619945
has body: For C#, something worth knowing is that Enum.IsDefined() is dangerous. You can't rely on it like you are. Getting something not of the expected values is a good case for throwing an exception and dying loudly. In Java, it's different because enums are classes not integers so you really can't get unexpected values (unless the enum is updated and your switch statement isn't), which is one big reason why I much prefer Java enums. You also have to cater for null values. But getting a non-null case you don't recognize is a good case for throwing an exception too.

http://stackoverflow.com/a/362430
downvote count: 3
answers question: http://stackoverflow.com/q/362384
upvote count: 76
has comment: http://stackoverflow.com/comment/194226
type: AcceptedAnswer
has body: Use the network byte order (big endian), which is the same as Java uses anyway. See man htons for the different translators in C.
has comment: http://stackoverflow.com/comment/192654
has comment: http://stackoverflow.com/comment/194227
has comment: http://stackoverflow.com/comment/55117376
has comment: http://stackoverflow.com/comment/192658
has comment: http://stackoverflow.com/comment/192673
type: Answer
score: 73
has comment: http://stackoverflow.com/comment/192681
accepted answer of: http://stackoverflow.com/q/362384

http://stackoverflow.com/a/372384
has comment: http://stackoverflow.com/comment/78389813
has comment: http://stackoverflow.com/comment/201373
upvote count: 51
answers question: http://stackoverflow.com/q/360520
accepted answer of: http://stackoverflow.com/q/360520
has comment: http://stackoverflow.com/comment/201118
has comment: http://stackoverflow.com/comment/201121
type: AcceptedAnswer
score: 51
type: Answer
has body: The problem is that Spring Security does not make the Authentication object available as a bean in the container, so there is no way to easily inject or autowire it out of the box. Before we started to use Spring Security, we would create a session-scoped bean in the container to store the Principal, inject this into an "AuthenticationService" (singleton) and then inject this bean into other services that needed knowledge of the current Principal. If you are implementing your own authentication service, you could basically do the same thing: create a session-scoped bean with a "principal" property, inject this into your authentication service, have the auth service set the property on successful auth, and then make the auth service available to other beans as you need it. I wouldn't feel too bad about using SecurityContextHolder. though. I know that it's a static / Singleton and that Spring discourages using such things but their implementation takes care to behave appropriately depending on the environment: session-scoped in a Servlet container, thread-scoped in a JUnit test, etc. The real limiting factor of a Singleton is when it provides an implementation that is inflexible to different environments.
downvote count: 0

http://stackoverflow.com/a/736519
upvote count: 2
answers question: http://stackoverflow.com/q/548229
has body: Since others have brought up RTSJ, I'll comment that synchronization between real-time and non-real-time code has a number of solutions. RTSJ provides wait-free queues for such communication. It is also possible to build upon these or other queues and make use of RTSJ's AsyncEvent and AsyncEventHandler abstractions to manage the communication. This is appropriate for situations where you really, truly have a need for deterministic behavior for the "real-time" thread. If you can accept best-effort behavior (try really hard to hit your deadlines, but the world doesn't fall apart if you miss) I suggest building carefully on the executor framework provided by the Java concurrency utilities. A careful selection of task boundaries, a suitable queuing policy (here, "suitable" would depend on more detail about your application than you've given), and threadpool policy will get what you need.
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/comment/123362346
score: 0
type: AnswerComment
type: Comment
has text: I don't know but for float eclipse say that this is correct...WHY?: `float[] ave = new float[] {(float) 1.2, (float) 4.3, (float) 10.2}`
comment on: http://stackoverflow.com/a/576870

http://stackoverflow.com/comment/18854120
type: Comment
type: QuestionComment
has text: This is not completely true. There are definitely more operations that can cause the value to not be exact when using floating point calculations. For instance 0.3-0.2-0.1 will not evaluate to exactly 0, but rather to -0.000000000000000027755575615628914 which in turn is != 0
comment on: http://stackoverflow.com/q/434657
score: 0

http://stackoverflow.com/comment/213766
score: 0
type: Comment
has text: That's an interesting viewpoint. It's a shame Sun didn't anticipate the empty catch block though!
type: AnswerComment
comment on: http://stackoverflow.com/a/386023

http://stackoverflow.com/a/624753
has body: You probably don't want to invoke the java app directly from the website. Like you said, if the java process takes 30 seconds to run, your web server is going to get way bogged down, especially if your site is getting pounded. You may want to look into web-services (and possibly a message queue) for dispatching back-end processing requests. The PHP page could call the web-service on the server, which could then put a processing request on a queue, or just kick off the java app in an asynchronous fashion. You don't want the HTTP request to wait for the java app to finish, because, while it's processing, the user will just have a hung browser, and the HTTP request might timeout. Once the java app finishes, it could update a database table, which the user could then access from the website.
type: Answer
answers question: http://stackoverflow.com/q/624749
score: 0

http://stackoverflow.com/q/567068
has answer: http://stackoverflow.com/a/567097
upvote count: 88
has title: Java synchronized block vs. Collections.synchronizedMap
answer count: 7
has answer: http://stackoverflow.com/a/32608663
has body: Is the following code set up to correctly synchronize the calls on synchronizedMap? public class MyClass { private static Map&lt;String, List&lt;String&gt;&gt; synchronizedMap = Collections.synchronizedMap(new HashMap&lt;String, List&lt;String&gt;&gt;()); public void doWork(String key) { List&lt;String&gt; values = null; while ((values = synchronizedMap.remove(key)) != null) { //do something with values } } public static void addToMap(String key, String value) { synchronized (synchronizedMap) { if (synchronizedMap.containsKey(key)) { synchronizedMap.get(key).add(value); } else { List&lt;String&gt; valuesList = new ArrayList&lt;String&gt;(); valuesList.add(value); synchronizedMap.put(key, valuesList); } } } } From my understanding, I need the synchronized block in addToMap() to prevent another thread from calling remove() or containsKey() before I get through the call to put() but I do not need a synchronized block in doWork() because another thread cannot enter the synchronized block in addToMap() before remove() returns because I created the Map originally with Collections.synchronizedMap(). Is that correct? Is there a better way to do this?
tagged with: synchronization
favorite count: 0
possible better answer: http://stackoverflow.com/a/567093
has answer: http://stackoverflow.com/a/567093
has answer: http://stackoverflow.com/a/567099
type: AnsweredQuestion
downvote count: 0
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/39276270
score: 88
has answer: http://stackoverflow.com/a/567101
accepted answer: http://stackoverflow.com/a/567101
has answer: http://stackoverflow.com/a/567246

http://stackoverflow.com/q/443558
has body: Do you know of an "easy" way to store and retrieve objects in Java without using a relational DB / ORM like Hibernate? [Note that I am not considering serialization as-is for this purpose, as it won't allow to retrieve arbitrary objects in the middle of an object graph. Neither am I considering DB4O because of its restrictive license. Thanks.] "Easy" meaning: not having to handle low-level details such as key/value pairs to rebuild an object graph (as with BerkeleyDB or traditional caches). The same applies for rebuilding objects from a document- or column-oriented DB (CouchDB, HBase, ..., even Lucene). Perhaps there are interesting projects out there that provide a layer of integration between the mentioned storage systems and the object model (like ORM would be for RDBMSs) that I am not aware of. Anyone successfully using those in production, or experimenting with persistence strategies other than relational DBs? How about RDF stores? Update: I came across a very interesting article: A list of distributed key-value stores
answer count: 9
has title: Easy way to store and retrieve objects in Java without using a relational DB?
has answer: http://stackoverflow.com/a/443755
has answer: http://stackoverflow.com/a/443644
has answer: http://stackoverflow.com/a/443933
has comment: http://stackoverflow.com/comment/265232
score: 11
has answer: http://stackoverflow.com/a/443633
accepted answer: http://stackoverflow.com/a/600744
upvote count: 11
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/443601
tagged with: java
has answer: http://stackoverflow.com/a/443790
has answer: http://stackoverflow.com/a/443601
has comment: http://stackoverflow.com/comment/265250
has answer: http://stackoverflow.com/a/555901
tagged with: relational
type: Question
has comment: http://stackoverflow.com/comment/265255
has comment: http://stackoverflow.com/comment/265256
has answer: http://stackoverflow.com/a/443669
has answer: http://stackoverflow.com/a/600744
downvote count: 0
has comment: http://stackoverflow.com/comment/265540
tagged with: persistence
favorite count: 0

http://stackoverflow.com/comment/19737147
has text: Guava 14 is still a release candidate, but this still gets my upvote -- by the time it reaches any decent position it should be golden :-)
type: Comment
comment on: http://stackoverflow.com/a/13920568
score: 1
type: AnswerComment

http://stackoverflow.com/q/428308
has title: How to programmatically change urls of images in word documents
downvote count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/428338
type: Question
has answer: http://stackoverflow.com/a/430717
has comment: http://stackoverflow.com/comment/252293
score: 1
tagged with: java
has body: I have a set of word documents that contains a lot of non-embedded images in them. The url that the images point to no longer exist. I would like to programmatically change the domain name of the url to something else. How can I go about doing this in Java or Python ?
tagged with: image
has answer: http://stackoverflow.com/a/428525
has comment: http://stackoverflow.com/comment/1482418
upvote count: 1
favorite count: 0
tagged with: python
has answer: http://stackoverflow.com/a/1615775
answer count: 4
tagged with: ms-word

http://stackoverflow.com/a/420251
has body: The methods do not have to give the same answers. That depends on which objects/classes you call them. If you are implementing your own classes which you know you want to compare at some stage, you may have them implement the Comparable interface and implement the compareTo() method accordingly. If you are using some classes from an API which do not implement the Comparable interface, but you still want to compare them. I.e. for sorting. You may create your own class which implements the Comparator interface and in its compare() method you implement the logic.
upvote count: 10
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/420223
score: 10

http://stackoverflow.com/q/478985
type: Question
answer count: 2
accepted answer: http://stackoverflow.com/a/479078
tagged with: apache
tagged with: ant
upvote count: 13
favorite count: 0
has body: The files residing in .settings in a Dynamic Web Project are: .settings/ |-- org.eclipse.jdt.core.prefs |-- org.eclipse.jst.common.project.facet.core.prefs |-- org.eclipse.jst.j2ee.ejb.annotations.xdoclet.prefs |-- org.eclipse.wst.common.component |-- org.eclipse.wst.common.project.facet.core.xml |-- org.eclipse.wst.jsdt.ui.superType.container |-- org.eclipse.wst.jsdt.ui.superType.name `-- org.eclipse.wst.validation.prefs The above file list is pretty much a clean new Dynamic Web Project, except that I'm using the IvyDE plug in, but I think it only affects the .classpath file. How do I learn more about these files? I'm wondering if I can get rid of any of them without loosing something important? Finding this information at Eclipse.org was not very easy, a link or an explanation would be very welcome. I'm trying to learn more about these files as I want to slim down the Eclipse files as much as possible before I check them into version control. In case it helps I list the above files and their contents: org.eclipse.jdt.core.prefs: #Mon Jan 26 03:01:22 CET 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.source=1.5 org.eclipse.jst.common.project.facet.core.prefs: #Mon Jan 26 03:01:22 CET 2009 classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER\:\:org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType\:\:java-6-sun-1.6.0.07/owners=jst.java\:5.0 eclipse.preferences.version=1 org.eclipse.jst.j2ee.ejb.annotations.xdoclet.prefs: #Mon Jan 26 03:23:25 CET 2009 XDOCLETBUILDERACTIVE=false XDOCLETHOME= XDOCLETUSEGLOBAL=false XDOCLETVERSION=1.2.1 eclipse.preferences.version=1 org.eclipse.wst.common.component: &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;project-modules id="moduleCoreId" project-version="1.5.0"&gt; &lt;wb-module depl…
has answer: http://stackoverflow.com/a/479078
has title: Slim down and/or understand the Eclipse files in a Dynamic Web Project
has answer: http://stackoverflow.com/a/479055
score: 13
possible better answer: http://stackoverflow.com/a/479055
type: AnsweredQuestion
downvote count: 0
tagged with: java
tagged with: eclipse

http://stackoverflow.com/a/4518090
upvote count: 2
has body: Threads are prohibited in Java EE containers according to the blueprints. Please refer to the blueprints for more information.
score: 2
answers question: http://stackoverflow.com/q/533783
downvote count: 0
type: Answer

http://stackoverflow.com/a/547452
has body: To retrieve and upload your images from the database you will need the Derby JDBC driver. Read the Derby wiki for more info. Blob stands for binary large object, and would be good to store an image in. JDBC tutoiral Using Derby on Java ME platforms wiki page. Good Luck.
downvote count: 0
answers question: http://stackoverflow.com/q/546867
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/comment/386633
score: 1
comment on: http://stackoverflow.com/a/574814
type: AnswerComment
has text: Agree. Whenever you cannot say with 100% certainty that you will deal with physical single files (java web start for one) you should always code with streams.
type: Comment

http://stackoverflow.com/a/9311087
upvote count: 97
has comment: http://stackoverflow.com/comment/12751547
score: 94
has comment: http://stackoverflow.com/comment/60408095
has comment: http://stackoverflow.com/comment/62170082
type: Answer
has comment: http://stackoverflow.com/comment/12749557
has comment: http://stackoverflow.com/comment/50668005
has comment: http://stackoverflow.com/comment/22995813
downvote count: 3
answers question: http://stackoverflow.com/q/625433
has body: long time = 1536259; return (new SimpleDateFormat("mm:ss:SSS")).format(new Date(time)); Prints: 25:36:259

http://stackoverflow.com/a/392672
answers question: http://stackoverflow.com/q/392624
upvote count: 12
has comment: http://stackoverflow.com/comment/220014
score: 10
has comment: http://stackoverflow.com/comment/219907
has comment: http://stackoverflow.com/comment/219860
downvote count: 2
has comment: http://stackoverflow.com/comment/219882
has body: Speaking of pure performance, if you can run Java 6 you get about 1:1 performance when compared to optimized C++ (special cases notwithstanding, sometimes Java is faster, sometimes C++), the only problem you will have is of course stuff like database libraries, interconnectivity, scalability and such. I believe there's a variety of good to great solutions available to each of these problems but you won't find one language which would solve everything for you so I have to give you the age old advice: Choose the language you like and use that one. Oh, you're still reading this? :) Well, here's some extra pointers. EVE Online uses Python for its client and server side code and it's both bug-ridden and laggy as something I don't think I should write here so that'd be an example of how Python can be extended to (poorly) serve vast amounts of users. While Java has some good to great solutions to various related problems, it's really not the best language out there for vast amount of users; it doesn't scale well to extremes without tuning. However there's multi-VM solutions to this which somewhat fix the issue, for example Terracotta is said to do the job well. While C++ is rather cumbersome, it allows for such a low-level interaction with the system that you may actually find yourself doing things you thought you couldn't do. I'm thinking of something like dynamic per-core microclustering of runtime code blocks for "filling" every possible clock cycle of the processor as efficiently as possible for maximum performance and things like that. Mono is far behind the .NET VM/equivalent on Windows platforms so you wouldn't be able to use the latest and fanciest features of C#. However Windows XP (x64) OEM licenses are so laughably cheap at the moment that with small investment you could get a bunch of those and you could then run your code on the platform it was meant to be. And don't fall into the Linux hype, Linux is your saviour only if you really know how to use it and espe…
type: Answer
has comment: http://stackoverflow.com/comment/220021

http://stackoverflow.com/a/573482
answers question: http://stackoverflow.com/q/573384
type: Answer
upvote count: 1
has body: You must be using 1.5. So here's one more way to get it right: if (a &gt;= '0' &amp;&amp; a &lt;= '9') { operands.push(a); } char c = operands.peek(); int op1 = (int) c; //check Character.isDigit(c), if there is other stuff in the stack
score: 1
downvote count: 0

http://stackoverflow.com/q/526866
has title: Compilation error on Zxing
tagged with: compiler-errors
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/528141
tagged with: java
type: Question
has body: Since I don't own a G1 for development purposes, I am doing my best with the emulator. This said, I am trying to scan a JPEG image or a PNG image in my sdCard, with the ZXing (Zebra Zrossing) library. I tried to change the code in the Android project, so it would scan from an image in the sdCard, instead from the camera, without any luck. What I did next is probably the root of my problem. I tried to use the JAVASE code, within a new Android Project, to provide an image to the "modified" CommandLineRunner, and here is the thing: Eclipse would build the project, but won't run it. The VM log throuws me this message among others: **02-08 20:47:45.916: WARN/dalvikvm(619): VFY: unable to resolve static method 939: Ljavax/imageio/ImageIO;.read (Ljava/io/File;)Ljava/awt/image/BufferedImage; 02-08 20:47:45.926: WARN/dalvikvm(619): VFY: rejecting opcode 0x71 at 0x0004 02-08 20:47:45.926: WARN/dalvikvm(619): VFY: rejected Lcom/magoco/fread/FRead;.decode2 (Ljava/io/File;Ljava/util/Hashtable;Ljava/lang/String;)Ljava/lang/String; 02-08 20:47:45.926: WARN/dalvikvm(619): Verifier rejected class Lcom/magoco/fread/FRead; 02-08 20:47:45.926: WARN/dalvikvm(619): Class init failed in newInstance call (Lcom/magoco/fread/FRead;) 02-08 20:47:45.926: DEBUG/AndroidRuntime(619): Shutting down VM 02-08 20:47:45.926: WARN/dalvikvm(619): threadid=3: thread exiting with uncaught exception (group=0x40010e28) 02-08 20:47:45.937: ERROR/AndroidRuntime(619): Uncaught handler: thread main exiting due to uncaught exception 02-08 20:47:45.946: ERROR/AndroidRuntime(619): java.lang.VerifyError: com.magoco.fread.FRead ** I searched the web for an answer and I got someone saying that this is common error on the Dalvikvm due to the fact that there is might be a class or library that was precompiled (true, outside Eclipse) and the VM wouldn't be able to use it. I am posting my code in the main Activity: package com.magoco.fread; import java.awt.image.BufferedImage; import java.io.BufferedInputStream; import j…
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/1287131
tagged with: g1gc

http://stackoverflow.com/comment/366643
score: 0
type: AnswerComment
has text: Python does have a convention where "private" members have a common prefix "_". The idea is that you don't use those unless you know what you're doing.
comment on: http://stackoverflow.com/a/554801
type: Comment

http://stackoverflow.com/a/520058
has comment: http://stackoverflow.com/comment/15299255
has comment: http://stackoverflow.com/comment/15331061
has comment: http://stackoverflow.com/comment/333661
accepted answer of: http://stackoverflow.com/q/520041
has comment: http://stackoverflow.com/comment/333602
answers question: http://stackoverflow.com/q/520041
type: AcceptedAnswer
downvote count: 0
score: 8
upvote count: 8
has comment: http://stackoverflow.com/comment/333642
type: Answer
has body: There are a few ways of doing this and it depends on what your environment is. If you're using Spring there's a fair chance you're deploying a Web application or you're otherwise in a J2EE environment. If this is the case (and arguably even if it isn't) you probably want to configure a DataSource. This is a fairly minimal solution: &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt; &lt;property name="driverClassName" value="${jdbc.driverClassName}"/&gt; &lt;property name="url" value="${jdbc.url}"/&gt; &lt;property name="username" value="${jdbc.username}"/&gt; &lt;property name="password" value="${jdbc.password}"/&gt; &lt;/bean&gt; The above is using the Apache (Jakarta Commons) database connection pooling but your appserver probably has an alternative you may want to use instead. Also, different database vendors have their own data source implementations too (eg OracleDataSource and OracleXADataSource for Oracle). Note the use of properties like jdbc.username. This is a typical configuration because database configurations typically vary between environment. You can activate a property configurator with something like: &lt;bean id="jdbcConfiguration" class="org.springframework.beans.factory.config.PropertiesPlaceholderConfigurer"&gt; &lt;property name="location" value="classpath:jdbc.properties"/&gt; &lt;/bean&gt; Now you probably want transactions too I would imagine. The easiest way is to use a platform transaction manager but, like with most things Spring, there are multiple ways of doing it. &lt;bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt; &lt;property name="dataSource" ref="dataSource"/&gt; &lt;/bean&gt; After this you can use this bean directly or (arguably more common) you can use declarative transactions with AOP (annotations). More on these subjects in the (superb) Spring reference documentation.

http://stackoverflow.com/a/1368142
downvote count: 0
score: 4
type: Answer
answers question: http://stackoverflow.com/q/425017
has body: I like the six page ref card at DZone which can be found here. There's a lot of information packed on it. You can read it online, or have a download link emailed to you. Good luck!
upvote count: 4

http://stackoverflow.com/comment/392779
comment on: http://stackoverflow.com/a/580886
type: AnswerComment
type: Comment
score: 0
has text: when i used the command echo $CLASSPATH nothing is displayed except empty line

http://stackoverflow.com/comment/14459132
has text: What about if my List contains custom Class? Like If I've List<PatientDetails>, where PatientDetails is my bean class which solely contains getters and setters. I tried the above logic but getting classCastException as well as I've to cast it in compile time with (List). What according you to be the best possible solution?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/7779427
type: Comment

http://stackoverflow.com/tag/xml
tags question: http://stackoverflow.com/q/501325
tags question: http://stackoverflow.com/q/638326
tags question: http://stackoverflow.com/q/483281
tags question: http://stackoverflow.com/q/632567
tags question: http://stackoverflow.com/q/589732
tags question: http://stackoverflow.com/q/593995
tags question: http://stackoverflow.com/q/508428
tags question: http://stackoverflow.com/q/570216
tags question: http://stackoverflow.com/q/512337
tags question: http://stackoverflow.com/q/535649
tags question: http://stackoverflow.com/q/373833
tags question: http://stackoverflow.com/q/596043
tags question: http://stackoverflow.com/q/380639
tags question: http://stackoverflow.com/q/424051
type: Tag
tags question: http://stackoverflow.com/q/489169
tags question: http://stackoverflow.com/q/479855
tags question: http://stackoverflow.com/q/452669
tags question: http://stackoverflow.com/q/539781
tags question: http://stackoverflow.com/q/591463
tags question: http://stackoverflow.com/q/621903
tags question: http://stackoverflow.com/q/363325
tags question: http://stackoverflow.com/q/622997
tags question: http://stackoverflow.com/q/529309
tags question: http://stackoverflow.com/q/425745
tags question: http://stackoverflow.com/q/428073
tags question: http://stackoverflow.com/q/643659
tags question: http://stackoverflow.com/q/361570
tags question: http://stackoverflow.com/q/619761
tags question: http://stackoverflow.com/q/543049
tags question: http://stackoverflow.com/q/536228
tags question: http://stackoverflow.com/q/431338
tags question: http://stackoverflow.com/q/475764
tags question: http://stackoverflow.com/q/368442
tags question: http://stackoverflow.com/q/632043
tags question: http://stackoverflow.com/q/392268
tags question: http://stackoverflow.com/q/633964
tags question: http://stackoverflow.com/q/561286
tags question: http://stackoverflow.com/q/443310
tags question: http://stackoverflow.com/q/592494
tags question: http://stackoverflow.com/q/442498
tags question: http://stackoverflow.com/q/547599
tags question: http://stackoverflow.com/q/430001
tag name: xml
tags question: http://stackoverflow.com/q/544153
tags question: http://stackoverflow.com/q/534807
tags question: http://stackoverflow.com/q/369760
tags question: http://stackoverflow.com/q/594537
tags question: http://stackoverflow.com/q/582352
tags question: http://stackoverflow.com/q/441990
tags question: http://stackoverflow.com/q/584804
tags question: http://stackoverflow.com/q/484995
tags question: http://stackoverflow.com/q/472326
tags question: http://stackoverflow.com/q/404141
tags question: http://stackoverflow.com/q/508878
tags question: http://stackoverflow.com/q/562160
tags question: http://stackoverflow.com/q/528312
tags question: http://stackoverflow.com/q/636360
tags question: http://stackoverflow.com/q/359675
tags question: http://stackoverflow.com/q/567525
tags question: http://stackoverflow.com/q/559296
tags question: http://stackoverflow.com/q/588883
tags question: http://stackoverflow.com/q/606145
tags question: http://stackoverflow.com/q/371607
tags question: http://stackoverflow.com/q/581939
tags question: http://stackoverflow.com/q/620943
tags question: http://stackoverflow.com/q/496369
tags question: http://stackoverflow.com/q/443305
tags question: http://stackoverflow.com/q/545705
tags question: http://stackoverflow.com/q/619982
tags question: http://stackoverflow.com/q/533508
tags question: http://stackoverflow.com/q/606325
tags question: http://stackoverflow.com/q/506317
tags question: http://stackoverflow.com/q/562241
tags question: http://stackoverflow.com/q/548050
tags question: http://stackoverflow.com/q/620250
tags question: http://stackoverflow.com/q/495779
tags question: http://stackoverflow.com/q/432347
tags question: http://stackoverflow.com/q/504689
tags question: http://stackoverflow.com/q/424119

http://stackoverflow.com/q/404141
possible better answer: http://stackoverflow.com/a/534117
has answer: http://stackoverflow.com/a/404355
accepted answer: http://stackoverflow.com/a/404355
downvote count: 0
has body: First, how do I format the XML processing instruction, is it: &lt;?processingInstructionName attribute="value" attribute2="value2"?&gt; Using StAX, I then want to read it by handling the XMLStreamConstants.PROCESSING_INSTRUCTION (javadoc) event, but it only provides two methods to then retrieve information about the processing instruction from the XMLStreamReader: getPITarget() getPIData() The javadoc for these two methods isn't very helpful. Is the XML formatting correct? Is this the proper way to go about parsing processing instructions using the StAX XMLStreamReader APIs? How do I use getPITarget() and getPIData() to return multiple arguments?
answer count: 3
tagged with: http://stackoverflow.com/tag/xml
favorite count: 0
has answer: http://stackoverflow.com/a/534117
has title: How do I format and read XML processing instructions using Java StAX?
upvote count: 2
tagged with: stax
type: AnsweredQuestion
score: 2
has answer: http://stackoverflow.com/a/41202788
tagged with: java
type: Question

http://stackoverflow.com/a/562172
type: Answer
downvote count: 0
has body: One way is to use the version of parse that takes an InputSource rather than a file A SAX InputSource can be constructed from a Reader object. One Reader object is the StringReader So something like parse(new InputSource(new StringReader(myString))) may work.
score: 20
answers question: http://stackoverflow.com/q/562160
upvote count: 20

http://stackoverflow.com/a/457673
has comment: http://stackoverflow.com/comment/8424676
downvote count: 0
has comment: http://stackoverflow.com/comment/284091
has comment: http://stackoverflow.com/comment/24457860
upvote count: 75
has body: If you know you are going to return two objects, you can also use a generic pair: public class Pair&lt;A,B&gt; { public final A a; public final B b; public Pair(A a, B b) { this.a = a; this.b = b; } }; Edit A more fully formed implementation of the above: package util; public class Pair&lt;A,B&gt; { public static &lt;P, Q&gt; Pair&lt;P, Q&gt; makePair(P p, Q q) { return new Pair&lt;P, Q&gt;(p, q); } public final A a; public final B b; public Pair(A a, B b) { this.a = a; this.b = b; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((a == null) ? 0 : a.hashCode()); result = prime * result + ((b == null) ? 0 : b.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } @SuppressWarnings("rawtypes") Pair other = (Pair) obj; if (a == null) { if (other.a != null) { return false; } } else if (!a.equals(other.a)) { return false; } if (b == null) { if (other.b != null) { return false; } } else if (!b.equals(other.b)) { return false; } return true; } public boolean isInstance(Class&lt;?&gt; classA, Class&lt;?&gt; classB) { return classA.isInstance(a) &amp;&amp; classB.isInstance(b); } @SuppressWarnings("unchecked") public static &lt;P, Q&gt; Pair&lt;P, Q&gt; cast(Pair&lt;?, ?&gt; pair, Class&lt;P&gt; pClass, Class&lt;Q&gt; qClass) { if (pair.isInstance(pClass, qClass)) { return (Pair&lt;P, Q&gt;) pair; } throw new ClassCastException(); } } Notes, mainly around rustiness with Java &amp; generics: both a and b are immutable. makePair static method helps you with boiler plate typing, which the diamond operator in Java 7 will make less annoying. There's some work to make this really nice re: generics, but it should be ok-ish now. (c.f. PECS) hashcode and equals are generated by eclipse. the compile time casting in the cast method is ok, but doesn't seem quite right. I'm not sure if the wildcar…
has comment: http://stackoverflow.com/comment/49694463
has comment: http://stackoverflow.com/comment/283610
has comment: http://stackoverflow.com/comment/8461080
answers question: http://stackoverflow.com/q/457629
has comment: http://stackoverflow.com/comment/8461663
score: 75
type: Answer

http://stackoverflow.com/a/438654
upvote count: 2
has body: Yes. You can put a breakpoint at the expression private String propString; The breakpoint gets another symbol and shows the tool tip "Watchpoint [Acess and modification] " Whith Shift+Ctrl+I you can watch the value of a selected variable name when the debugger is in step mode. You also can change variable values at runtime when the debugger is in step mode. The eclipse debugger is a very useful and powerful tool.
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/438628
score: 2

http://stackoverflow.com/comment/13793048
has text: I just created dll from my jar but I can see no functions using depwalker. Is this normal behavior?
comment on: http://stackoverflow.com/a/512247
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/333609
type: QuestionComment
type: Comment
has text: probably because it would've taken less time to google the answer than to ask it. The second google result has the answer in the summary, you wouldn't even have to click the link.
score: 4
comment on: http://stackoverflow.com/q/519631

http://stackoverflow.com/comment/2238820
type: QuestionComment
score: 2
has text: FYI the solution Amit links to works, although it has a bug if the class path has a space character in it (and probably for other non-alphanumeric characters too). if you're using it in any kind of production code, see my comment to his answer for a workaround.
comment on: http://stackoverflow.com/q/520328
type: Comment

http://stackoverflow.com/a/396225
has comment: http://stackoverflow.com/comment/222598
has body: This is not answering any of the questions. But for game develop/Simulation Engines learning if u need a reference: http://www.cs.chalmers.se/idc/ituniv/kurser/08/simul/ It's a link for the class lectures of Simulation Engines at Chalmers Univ in Gotembourg. The teacher as a game company and gave quite good lectures. Check the slides we had in the classes, maybe they'll help you a bit.
type: Answer
answers question: http://stackoverflow.com/q/395923
upvote count: 1
downvote count: 0
score: 1

http://stackoverflow.com/a/508642
type: AcceptedAnswer
has body: I don't believe so. Once you want to go bigger than a signed long, I think BigInteger is the only (out of the box) way to go.
has comment: http://stackoverflow.com/comment/44427649
type: Answer
answers question: http://stackoverflow.com/q/508630
score: 61
upvote count: 65
accepted answer of: http://stackoverflow.com/q/508630
downvote count: 4

http://stackoverflow.com/comment/37425800
type: Comment
has text: To add on Osacars point, without factory this can be created without factory `Cipher C =null; if (file.size() <= 2048) { C = new InMemoryCipherStrategy(); } else { c= SwaptToDiskCipher (); }`
score: 1
comment on: http://stackoverflow.com/a/370270
type: AnswerComment

http://stackoverflow.com/q/636072
has title: Class Loading problem in Java Enterprise application
favorite count: 0
has answer: http://stackoverflow.com/a/636272
tagged with: ejb-3.0
has answer: http://stackoverflow.com/a/636168
accepted answer: http://stackoverflow.com/a/636168
type: AnsweredQuestion
score: 3
tagged with: java
has body: I have Enterprise Application with EJB3 and JSF on Glassfish server. After running this application for more than 2 weeks I realized that I have problem with Class Loading. I don't think this is a problem with permgen. The classes loaded every time when I open a page but then they never erased from the memory. Here is the snapshot of or my server's memory: Snapshot So, i just need some pointers of how I can debug this problem.
type: Question
possible better answer: http://stackoverflow.com/a/636196
tagged with: glassfish
upvote count: 3
has answer: http://stackoverflow.com/a/636196
answer count: 3
tagged with: memory-leaks
downvote count: 0

http://stackoverflow.com/comment/22277503
has text: @Jon is there any specific technical name for this idiom of creating an non-static inner class instance?
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/633602

http://stackoverflow.com/q/624604
type: Question
tagged with: java
tagged with: hibernate
has title: Case-insensitive equals using Hibernate Criteria
score: 62
answer count: 7
has answer: http://stackoverflow.com/a/19993112
possible better answer: http://stackoverflow.com/a/12836812
favorite count: 0
has answer: http://stackoverflow.com/a/12836812
upvote count: 62
has body: I've seen Restrictions.ilike('property', '%value%'), but would like to generate SQL like: lower(property) = 'value'. Any ideas? I used: Restrictions.eq("email", email).ignoreCase() since Expression is deprecated. The SimpleExpression will call toLowerCase() on the value, so it is not necessary to do it beforehand. See: SimpleExpression source
has answer: http://stackoverflow.com/a/64556553
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/61366388
downvote count: 0
has answer: http://stackoverflow.com/a/624856
accepted answer: http://stackoverflow.com/a/624856
has answer: http://stackoverflow.com/a/624628
has answer: http://stackoverflow.com/a/23930706

http://stackoverflow.com/comment/44714452
score: 6
comment on: http://stackoverflow.com/q/428918
type: Comment
type: QuestionComment
has text: new DateTime().plusDays(1).toDate() ???

http://stackoverflow.com/q/366861
answer count: 8
possible better answer: http://stackoverflow.com/a/5576462
has answer: http://stackoverflow.com/a/5576462
score: 3
has answer: http://stackoverflow.com/a/367537
tagged with: jdbc
has answer: http://stackoverflow.com/a/17288741
favorite count: 0
has body: Pretty straightforward stuff, here -- I'm just not good enough with mysql to understand what it wants from me. I've got a short java test-case that opens a connection on mysql on my dev system but, when I try to put it to my server, it fails. Any help in tracking this down would be most appreciated. Thanks! Test Code import java.util.*; import java.sql.*; public class mysqltest { static public void getDBConnection() { System.out.println ("Start of getDBConnection."); Connection conn = null; String url = "jdbc:mysql://localhost:3306/"; String dbName = "magnets_development"; String driver = "com.mysql.jdbc.Driver"; String userName = "*****"; // blanked for publication String password = "*****"; try { Class.forName (driver).newInstance(); System.out.println ("driver.newInstance gotten."); conn = DriverManager.getConnection (url+dbName, userName, password); System.out.println ("Connection gotten: " + conn + "."); Statement sql = conn.createStatement (); ResultSet results = sql.executeQuery ("use " + dbName + ";"); } catch (Exception ex) { System.out.println ("*** Got exception."); ex.printStackTrace(); } } public static void main(String args[]) { System.out.println ("Main started."); mysqltest.getDBConnection(); } } Dev System Output (Expected/correct response) olie$ java mysqltest Main started. Start of getDBConnection. Properties set. driver.newInstance gotten. Connection gotten: com.mysql.jdbc.Connection@c980c9. olie$ Server Output (Error I'm trying to track-down) (Some blank lines removed.) mini$ java mysqltest Main started. Start of getDBConnection. Properties set. driver.newInstance gotten. *** Got exception. com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.net.ConnectException MESSAGE: Connection refused STACKTRACE: java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at…
downvote count: 1
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/366953
has title: Java Driver.getConnection() yields "Connection Refused" from mysql on live system, not dev
accepted answer: http://stackoverflow.com/a/367537
has answer: http://stackoverflow.com/a/366947
tagged with: java
tagged with: mysql
has answer: http://stackoverflow.com/a/366869
type: Question
upvote count: 4
has answer: http://stackoverflow.com/a/367455
has answer: http://stackoverflow.com/a/366999

http://stackoverflow.com/a/606150
has body: From an application lifecycle point of view, there are ways to approximate what you are trying to do but they almost unvariably require handset manufacturer support. If you have a choice, the Sony Ericsson JP8 platform has non-standard extensions to JavaME that can help. Accessing telephony information, however will be a major issue. Look for a handset that implements the cbs protocol of JSR-120, it could prove useful. Accessing the phone idle/standby/main screen on Series60 (Symbian) phones will require nokia support too, BTW.
score: 0
answers question: http://stackoverflow.com/q/603652
type: Answer

http://stackoverflow.com/comment/15241364
type: Comment
comment on: http://stackoverflow.com/a/10773333
type: AnswerComment
score: 0
has text: I am very interested in the joni option mentioned by Ryan above -- do you have any code snippets using named capture groups - I have managed to get basic matching and searching to work correctly - but I don't see which method I would use to get access to the groupNames or to get a capture's value using the group name.

http://stackoverflow.com/q/520860
has answer: http://stackoverflow.com/a/520885
upvote count: 5
downvote count: 0
has answer: http://stackoverflow.com/a/520934
has title: Passing a work item between threads (Java)
possible better answer: http://stackoverflow.com/a/520934
favorite count: 0
has answer: http://stackoverflow.com/a/520901
tagged with: multithreading
answer count: 4
type: AnsweredQuestion
tagged with: java
has body: I have two threads. The producer is producing pieces of data (String objects), where the consumer processes these strings. The catch is that my application only needs the most recent data object to be processed. In other words, if the producer managed to produce two strings "s1" and then "s2" then I want the consumer to process only "s2". "s1" can be safely discarded. Of course there's no problem implementing a class that realizes this behavior, but I want to use a standard mechanism from java.util.concurrent (if such a mechanism exists). Note that SynchronousQueue is not a good solution: the consumer will block when enqueueing "s1" and will not get the chance to produce "s2". (In short, I am looking for a single-element collection with a blocking remove operation and a non-blocking set operation) Any ideas?
type: Question
accepted answer: http://stackoverflow.com/a/520901
has answer: http://stackoverflow.com/a/522944
score: 5

http://stackoverflow.com/a/361761
score: 4
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/361723
type: Answer
has body: Split the readline by a comma and be done with it. I'd also create an object for the model, length,width,etc... and then have 1 arraylist of that object. while((outputline = fin.readLine()) != null) { String[] tokens = outputline.split(","); if(tokens.length == 7){ SObj o = new SObj; //Some Object o.model = tokens[0]; o.length = tokens[1]; //and so on oList.add(o); } }

http://stackoverflow.com/comment/754171
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/464784
has text: Does your problem come from trying to do an unknowable number of read locks on the same thread you're doing the writing. Couldn't you do the writing on another thread?

http://stackoverflow.com/comment/238517
comment on: http://stackoverflow.com/a/413743
score: 0
type: AnswerComment
type: Comment
has text: Name 5 great coders that use text editors exclusively. Serious coders use IDEs to work faster. Shallow elitists say they use text editors to boost their gigantic, undeserved egos.

http://stackoverflow.com/a/577226
answers question: http://stackoverflow.com/q/577205
has comment: http://stackoverflow.com/comment/1233082
has body: This is just a sketch to get you started, and could be improved a lot. But your basic members could be as follows: public class WeightedTree { private double weight; private List&lt;WeightedTree&gt; children; } I don't want to write more in case it's a homework question, but if you have specific follow up feel free to comment.
score: 3
upvote count: 3
downvote count: 0
type: Answer

http://stackoverflow.com/q/440209
accepted answer: http://stackoverflow.com/a/440536
has answer: http://stackoverflow.com/a/441748
favorite count: 0
has answer: http://stackoverflow.com/a/32587498
tagged with: events
possible better answer: http://stackoverflow.com/a/440445
upvote count: 12
downvote count: 0
tagged with: java
tagged with: swing
has title: How do I assign Enter as the trigger key of all JButtons in my Java application?
tagged with: jbutton
type: AnsweredQuestion
answer count: 6
has answer: http://stackoverflow.com/a/440445
type: Question
has body: I'm writing a Java Swing application using the Metal look-and-feel. Every time there is a JButton in my application the user uses the Tab key to move the focus to the button and then hits the Enter key. Nothing happens! If he hits the Space key the button events are fired. How do I assign the Enter key to trigger the same events as the Space key? Thank you for your help.
score: 12
has answer: http://stackoverflow.com/a/440369
has answer: http://stackoverflow.com/a/440273
has answer: http://stackoverflow.com/a/440536

http://stackoverflow.com/a/457745
downvote count: 0
answers question: http://stackoverflow.com/q/457629
upvote count: 6
has comment: http://stackoverflow.com/comment/14198569
type: Answer
has body: Alternatively, in situations where I want to return a number of things from a method I will sometimes use a callback mechanism instead of a container. This works very well in situations where I cannot specify ahead of time just how many objects will be generated. With your particular problem, it would look something like this: public class ResultsConsumer implements ResultsGenerator.ResultsCallback { public void handleResult( String name, Object value ) { ... } } public class ResultsGenerator { public interface ResultsCallback { void handleResult( String aName, Object aValue ); } public void generateResults( ResultsGenerator.ResultsCallback aCallback ) { Object value = null; String name = null; ... aCallback.handleResult( name, value ); } }
score: 6

http://stackoverflow.com/a/446671
has comment: http://stackoverflow.com/comment/93378277
has comment: http://stackoverflow.com/comment/66931461
answers question: http://stackoverflow.com/q/446663
score: 190
has body: Well there's certainly a better implementation of the enum solution (which is generally quite nice): public enum Error { DATABASE(0, "A database error has occurred."), DUPLICATE_USER(1, "This user already exists."); private final int code; private final String description; private Error(int code, String description) { this.code = code; this.description = description; } public String getDescription() { return description; } public int getCode() { return code; } @Override public String toString() { return code + ": " + description; } } You may want to override toString() to just return the description instead - not sure. Anyway, the main point is that you don't need to override separately for each error code. Also note that I've explicitly specified the code instead of using the ordinal value - this makes it easier to change the order and add/remove errors later. Don't forget that this isn't internationalised at all - but unless your web service client sends you a locale description, you can't easily internationalise it yourself anyway. At least they'll have the error code to use for i18n at the client side...
upvote count: 190
has comment: http://stackoverflow.com/comment/93365907
has comment: http://stackoverflow.com/comment/81629547
has comment: http://stackoverflow.com/comment/93377904
has comment: http://stackoverflow.com/comment/93370336
has comment: http://stackoverflow.com/comment/267968
has comment: http://stackoverflow.com/comment/66920536
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/9780206
has comment: http://stackoverflow.com/comment/66920398
type: Answer
has comment: http://stackoverflow.com/comment/74060071
has comment: http://stackoverflow.com/comment/267985
accepted answer of: http://stackoverflow.com/q/446663

http://stackoverflow.com/a/590932
downvote count: 0
has body: You shouldn't need to call connection.close() on application shut-down, since all open files will be closed automatically by the operating system. Also, the Connection's finalize() method should be run before application shut-down automatically (if the shut-down is normal, not ABORTed), and that should close the connection. In any case, you can register shutdown-hooks, to do any clean-up you require (again, will be run in normal shutdown cases, not ABORTs).
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/590899
has comment: http://stackoverflow.com/comment/402610

http://stackoverflow.com/a/15525059
answers question: http://stackoverflow.com/q/575685
score: 10
upvote count: 11
has comment: http://stackoverflow.com/comment/51794525
downvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/88801338
has comment: http://stackoverflow.com/comment/69517297
has body: Try this: import java.util.*; public class SimpleCacheManager { private static SimpleCacheManager instance; private static Object monitor = new Object(); private Map&lt;String, Object&gt; cache = Collections.synchronizedMap(new HashMap&lt;String, Object&gt;()); private SimpleCacheManager() { } public void put(String cacheKey, Object value) { cache.put(cacheKey, value); } public Object get(String cacheKey) { return cache.get(cacheKey); } public void clear(String cacheKey) { cache.put(cacheKey, null); } public void clear() { cache.clear(); } public static SimpleCacheManager getInstance() { if (instance == null) { synchronized (monitor) { if (instance == null) { instance = new SimpleCacheManager(); } } } return instance; } }
has comment: http://stackoverflow.com/comment/22154786

http://stackoverflow.com/q/461255
has comment: http://stackoverflow.com/comment/280087
has answer: http://stackoverflow.com/a/463293
has answer: http://stackoverflow.com/a/465299
has answer: http://stackoverflow.com/a/7848199
has answer: http://stackoverflow.com/a/461273
tagged with: java
has answer: http://stackoverflow.com/a/4859794
upvote count: 62
has answer: http://stackoverflow.com/a/462506
has answer: http://stackoverflow.com/a/478622
has comment: http://stackoverflow.com/comment/25419296
has comment: http://stackoverflow.com/comment/2142242
has answer: http://stackoverflow.com/a/463331
tagged with: eclipse
has title: Things possible in Eclipse that aren’t possible in IntelliJ?
linked to: http://stackoverflow.com/q/3707316
has comment: http://stackoverflow.com/comment/44307070
type: Question
tagged with: intellij-idea
has answer: http://stackoverflow.com/a/16624189
tagged with: ide
has answer: http://stackoverflow.com/a/516472
answer count: 16
has answer: http://stackoverflow.com/a/462386
has answer: http://stackoverflow.com/a/461653
has body: I have heard from people who swear by one or the other. Both are full-featured, excellent IDEs. But each has slightly different strengths. This is not meant to turn into a holy IDE war. Please downvote any flamebait answers. Thanks. This is the analog of this question.
has answer: http://stackoverflow.com/a/4143314
has comment: http://stackoverflow.com/comment/3844177
linked to: http://stackoverflow.com/q/239732
score: 61
favorite count: 0
has comment: http://stackoverflow.com/comment/4904773
has comment: http://stackoverflow.com/comment/131314315
has answer: http://stackoverflow.com/a/8753704
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/3857482
has answer: http://stackoverflow.com/a/461699
downvote count: 1
has comment: http://stackoverflow.com/comment/280553
has answer: http://stackoverflow.com/a/461473

http://stackoverflow.com/comment/376429
comment on: http://stackoverflow.com/a/565158
score: 1
type: AnswerComment
has text: Exactly - if those values are always set together, it's better to convery this information by having only one setter. It would be even better to put them together in a class, if there are more than two, or if there are methods that operate only on them and which could also be put into that class.
type: Comment

http://stackoverflow.com/q/639397
upvote count: 5
tagged with: jtable
accepted answer: http://stackoverflow.com/a/642920
answer count: 2
downvote count: 0
favorite count: 0
has body: Is there an easy way to manipulate the controls on a JTable to give different functionality when there is a keyboard button pressed (ie. CTRL button) and a row is selected? I've been asked to create a table where the CTRL + Click (mouse click) on a row will only deselect a selected row, never select a row. If the user CTRL + Clicks an unselected row, nothing will happen. I've been able to create a table, and disable functions like CTRL + A (select all), and i've been able to check if the control button is pressed when a MouseEvent is generated, but I can't seem to figure out how the CTRL + Click can be adjusted. Here's some code: package nicky; import javax.swing.*; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.*; public class TableTester extends JPanel { public TableTester() { super(new GridLayout(1,0)); final String[] columnNames = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"}; final Object[][] data = { {"Tom", "Roberts","Athletic", new Integer(5), new Boolean(false)}, {"Sarah", "Watt", "Football", new Integer(3), new Boolean(true)}, {"Laura", "Brown", "Swimming", new Integer(2), new Boolean(false)}, {"Simon", "Smith", "Tennis", new Integer(20), new Boolean(true)}, {"Paul", "Jones", "Rugby", new Integer(10), new Boolean(false)} }; JTable table = new JTable(data, columnNames); table.setPreferredScrollableViewportSize(new Dimension(500, 100)); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.addMouseListener(new MouseListener(){ public void mouseEntered(MouseEvent me){} public void mouseExited(MouseEvent me){} public void mouseReleased(MouseEvent me){} public void mouseClicked(MouseEvent me){} public void mousePressed(MouseEvent me){ if (me.isControlDown()){ System.out.println("This is working "); } } }); InputMap inputMap = table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK); inputMap.put(keyStrok…
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/642920
tagged with: java
tagged with: swing
type: Question
possible better answer: http://stackoverflow.com/a/639777
score: 5
has title: Change the Ctrl + click behaviour on a JTable
has answer: http://stackoverflow.com/a/639777

http://stackoverflow.com/a/464635
downvote count: 0
answers question: http://stackoverflow.com/q/463460
score: 1
has body: Text processing is going to always be bounded if you dont shift your paradigm. I dont know how flexible your domain is, so not sure if this is applicable, but here goes: try creating an index into where your text substitution is - this is especially good if the template doesnt change often, because it becomes part of the "compile" of the template, into a binary object that can take in the value required for the substitutions, and blit out the entire string as a byte array. This object can be cached/saved, and next time, resubstitute in the new value to use again. I.e., you save on parsing the document every time. (implementation is left as an exercise to the reader =D ) But please use a profiler to check whether this is actually the bottleneck that you say it is before embarking on writing a custom templating engine. The problem may actually be else where.
upvote count: 1
type: Answer

http://stackoverflow.com/a/390722
type: Answer
upvote count: 3
has comment: http://stackoverflow.com/comment/30275067
has comment: http://stackoverflow.com/comment/218602
score: -1
downvote count: 4
has body: Generally, this indicates someone who isn't comfortable with the new-fashioned C++ style of declaring when initialized. Back in the C days, it wasn't considered good form to define auto variables in an inner scope; C++ eliminated the parser restriction, and Java extended that. So you see code that has int q; for(q=0;q&lt;MAX;q++){ String s; int ix; // other stuff s = new String("Hello, there!"); // do something with s } In the extreme case, all the declarations may be at the top of a function, and not in enclosed scopes like the for loop here. IN general, though, the effect of this is to cause a String ctor to be called once, and the resulting String thrown away. (The desire to avoid this is just what led Stroustrup to allow declarations anywhere in the code.) So you are correct that it's unnecessary and bad style at best, and possibly actually bad.
answers question: http://stackoverflow.com/q/390703

http://stackoverflow.com/a/8222235
score: 3
downvote count: 0
type: Answer
upvote count: 3
answers question: http://stackoverflow.com/q/457463
has body: I am sure this will solve your problem. Mention in which column you need to set the combo box in .getColumn(int column) private void addComboToTable(JComboBox combo) { TableColumn gradeColumn = YourTable.getColumnModel().getColumn(0); JComboBox comboBox = combo; comboBox.removeAllItems(); try { comboBox.addItem("Item 1"); comboBox.addItem("Item 2"); comboBox.addItem("Item 3"); } catch (NullPointerException e) { } catch (Exception e) { e.printStackTrace(); } gradeColumn.setCellEditor(new DefaultCellEditor(comboBox)); }

http://stackoverflow.com/q/433406
tagged with: memory-management
accepted answer: http://stackoverflow.com/a/433473
score: 7
tagged with: java
has answer: http://stackoverflow.com/a/433478
upvote count: 7
type: Question
has title: How to get the max sizes of the heap and permgen from the JVM?
has answer: http://stackoverflow.com/a/434086
answer count: 3
downvote count: 0
tagged with: jvm
favorite count: 0
possible better answer: http://stackoverflow.com/a/434086
has body: I am trying to find out programatically the max permgen and max heap size with which a the JVM for my program has been invoked, not what is currently available to them. Is there a way to do that? I am familiar with the methods in Java Runtime object, but its not clear what they really deliver. Alternatively, is there a way to ask Eclipse how much was allocated for these two?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/433473

http://stackoverflow.com/a/614598
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/611990
accepted answer of: http://stackoverflow.com/q/611990
type: AcceptedAnswer
downvote count: 0
has body: Apperently this is a NetBeans issue for Mac OS X... Answer from netbeans forums
type: Answer

http://stackoverflow.com/a/563689
downvote count: 2
has comment: http://stackoverflow.com/comment/376692
upvote count: 19
has comment: http://stackoverflow.com/comment/5615359
score: 17
answers question: http://stackoverflow.com/q/563676
has comment: http://stackoverflow.com/comment/376787
type: Answer
has comment: http://stackoverflow.com/comment/377131
has body: No, the key is that you're supposed to override the default implementation of ToString() to make it useful. ToString() can be a great way to output the value of something back to the UI. A simple example would be if you have a Name class with a three strings (First, Middle, Last). You can have a ToString() method that formats it for the UI: "Last, First Middle" for example. Or a class that stores a mathematical operation (values Left=2, Right=3, Result=6 and an operator enum=Multiply). Call ToString() to get "2 * 3 = 6". However, it is probably more common to have a variety of different To&lt;qualifier&gt;String() methods, like the .NET DateTime class. (ToShortDateString(), ToLongDateString(), ToLongTimeString(), ...) Edit: As for why it's rooted at the Object class, it's simply because ToString() is a valid operation for anything. Additionally, strings can be a good way of marshaling between data types or data consumers, because it's (practically) guaranteed to be parsable and doesn't require extra encoding or care.

http://stackoverflow.com/a/58516673
has body: What is a synthetic class in Java? A synthetic class is a .class file generated by Java Compiler and it does not exist in the source code. Example usage of synthetic class: Anonymous inner class java.text.DigitList$1 is a synthetic class and it is a anonymous inner class inside java.text.DigitList And there is no source code file named like DigitList$1.java but it is a inner file in DigitList.java Why should it be used? It is a mechanism inside Java compiler logic to generate the .class file How can I use it? No, developers do NOT use it directly. Java compiler use synthetic to generate .class file, and then JVM reads the .class file to execute the program logic. More details This article explains synthetic class in details This link lists all synthetic class exits in JDK
type: Answer
answers question: http://stackoverflow.com/q/399546
score: 5
has comment: http://stackoverflow.com/comment/107396606
upvote count: 5
downvote count: 0

http://stackoverflow.com/comment/306285
type: Comment
has text: I use this method all the time, could you elaborate on what problems it causes? It has always seemed to work, but I have never cared if it took 1 ms or 100ms to finally see the change.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/462648

http://stackoverflow.com/comment/282973
score: 7
has text: The enum singleton pattern solves all of these problems (see Josh Bloch's comments on this). The knowledge of its existence should be more widespread among Java programmers.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/462174

http://stackoverflow.com/comment/6220042
type: AnswerComment
type: Comment
has text: Thanks a lot! BTW: If logrotation is done properly ('cp logfile oldfile; > logfile') then matt's solution should still work because the file reference isn't lost!
comment on: http://stackoverflow.com/a/4937594
score: 0

http://stackoverflow.com/comment/40950789
comment on: http://stackoverflow.com/q/444731
score: 0
has text: Why do you want to define these variables?
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/314357
score: 0
comment on: http://stackoverflow.com/q/498636
type: Comment
type: QuestionComment
has text: What character encoding is being used by your terminal?

http://stackoverflow.com/a/520389
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/520348
has comment: http://stackoverflow.com/comment/333907
type: Answer
has comment: http://stackoverflow.com/comment/333921
downvote count: 1
has body: The only real way of dealing with this is to have the browser constantly tell you that it's still there, say every 5-10 seconds. If you go for a minute without hearing anything, you assume the client is gone and forget what you're doing. There are several ways to implement this: Meta refresh: I don't like this because it's disconcerting and obvious for the user; An iframe that does that (less obvious); or Some AJAX technique, which is probably the best option. There's no real way you can detect if the client is still reading what you're sending. It takes time for TCP connections to die and the path to the client is often indirect anyway (through proxies and so forth) so forget about detecting that.
has comment: http://stackoverflow.com/comment/333885
accepted answer of: http://stackoverflow.com/q/520348
upvote count: 5
score: 4

http://stackoverflow.com/q/610773
has comment: http://stackoverflow.com/comment/423568
tagged with: command-line
score: 2
upvote count: 2
has answer: http://stackoverflow.com/a/610791
accepted answer: http://stackoverflow.com/a/610791
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/423573
type: Question
has title: I want to run an scons command in my current directory. How do I do this in Java?
has body: I am using Java to automate a build. I would like to run an 'scons' command in the current directory in which the build is being performed. How can I do this with Java? I have tried Runtime.getRuntime().exec(CurrentDir + commandString) This didn't work. Any ideas would be greatly appreciated.
answer count: 1
downvote count: 0
favorite count: 0

http://stackoverflow.com/q/583141
possible better answer: http://stackoverflow.com/a/583365
type: AnsweredQuestion
score: 4
has answer: http://stackoverflow.com/a/583365
tagged with: java
has title: How to use Java timezone id in a Windows (non-Java) application?
has body: I need to add timezone information to a db table with user maintained locations. The data will be accessed mostly from Java code but there is also some PL/SQL and Win32 (Delphi) code which needs to understand the timezone information. It seems straight forward to use the id from java.util.TimeZone. Java can easily convert that (obviously), Hibernate has built-in support for it and apparently also Oracle understands those timezone ids: select TZ_OFFSET('Pacific/Marquesas') from dual. The problem is: the timezone ids do not seem to be compatible with the Windows Timezone DB. For example, the java.util.timezone id "Pacific/Marquesas" (-09:30) is not in the timezone picklist in Windows. The registry does not contain it at all; see \SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones Here I can only pick either -09:00 or -10:00. So, if I were to store the timezone like this, how can I get to the actual offset/DST infos in Windows (without Java)? Hopefully this does not require a mapping table which I have to keep up to date whenever it changes. Is there a globally accepted standard which works better than the java timezone id? Update The timezone info is used in combination with DATE columns on the database. Those columns contain local date/time values. If a location can be associated with those values, the location's timezone enables me to convert the date/time value to UTC or any other timezone whenever needed. I realize that instead of DATE a TIMESTAMP_TZ data type or something similar would be more appropriate. However, this would require a data migration (for which the TZ is required again) and is not supported by the legacy applications which also work on the data (unless a lot of code is changed). The problem is almost the same if I had to convert the values to UTC. Bottom line is I need to keep the DATE values in local time but I need to know for some of them which TZ that means.
type: Question
has answer: http://stackoverflow.com/a/583174
has comment: http://stackoverflow.com/comment/397319
upvote count: 4
answer count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/395086
accepted answer: http://stackoverflow.com/a/583174
favorite count: 0
tagged with: timezone
tagged with: oracle-database
tagged with: windows

http://stackoverflow.com/q/376988
has answer: http://stackoverflow.com/a/377031
downvote count: 0
has answer: http://stackoverflow.com/a/376996
accepted answer: http://stackoverflow.com/a/377051
favorite count: 0
has body: I remember reading in some Java book about any operator other than 'instanceof' for comparing the type hierarchy between two objects. instanceof is the most used and common. I am not able to recall clearly whether there is indeed another way of doing that or not.
has answer: http://stackoverflow.com/a/377084
answer count: 4
type: AnsweredQuestion
tagged with: java
type: Question
score: 5
upvote count: 5
has title: Is there any way other than instanceof operator for object type comparison in java?
has answer: http://stackoverflow.com/a/377051
possible better answer: http://stackoverflow.com/a/376996

http://stackoverflow.com/a/644949
accepted answer of: http://stackoverflow.com/q/644856
upvote count: 10
answers question: http://stackoverflow.com/q/644856
has comment: http://stackoverflow.com/comment/458778
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 10
has body: The problem you are trying to avoid is waiting for for your http connection to determine that the URL you are trying to access is really unavailable. In order to achieve this you need to stop using url.openStream() which is a shortcut for openConnection().getInputStream() and get some finer control over your connection. URLConnection conn = url.openConnection(); conn.setConnectTimeout(timeoutMs); conn.setReadTimeout(timeoutMs); in = conn.getInputStream(); This code will allow you to timeout the connection attempt if either the connection or the read exceeds the time you provide in the timeoutMs paramater.
has comment: http://stackoverflow.com/comment/459469

http://stackoverflow.com/a/548730
upvote count: 2
answers question: http://stackoverflow.com/q/548706
type: Answer
has body: Using regular jsp you can really just tie together a few extra classes that constitute your framework, which will normally mean some kind of servlet filter that maps a url to a class. The reason you'll often want to do this is to run some code (your controller/action) before the rendering starts. It's all very simple ant not too far from stuff we're doing. But we're using a lot of JSTL, which is a framwork too. And some spring, yes. But a web framework is not needed.
score: 2
downvote count: 0

http://stackoverflow.com/q/434657
linked to: http://stackoverflow.com/q/18260213
has comment: http://stackoverflow.com/comment/18854123
type: UnansweredQuestion
tagged with: double
has comment: http://stackoverflow.com/comment/18854120
has comment: http://stackoverflow.com/comment/18854124
has comment: http://stackoverflow.com/comment/18854121
has answer: http://stackoverflow.com/a/36999064
has comment: http://stackoverflow.com/comment/18854122
tagged with: java
upvote count: 23
type: Question
has answer: http://stackoverflow.com/a/434698
has answer: http://stackoverflow.com/a/434772
has comment: http://stackoverflow.com/comment/18854119
has answer: http://stackoverflow.com/a/1657983
has body: Do we need to be careful when comparing a double value against zero? if ( someAmount &lt;= 0){ ..... }
has answer: http://stackoverflow.com/a/436409
has answer: http://stackoverflow.com/a/434911
downvote count: 0
answer count: 7
has title: Java: Double Value Comparison
has comment: http://stackoverflow.com/comment/18854125
favorite count: 0
score: 23
has comment: http://stackoverflow.com/comment/92090429
has comment: http://stackoverflow.com/comment/18854127
has answer: http://stackoverflow.com/a/48668617

http://stackoverflow.com/a/575261
answers question: http://stackoverflow.com/q/574984
score: 2
upvote count: 2
has body: Serialization is the easy way to do it, however if possible you could make it look like a real database table with a structure containing id (bigint), datatype (smallint), creationdate (date) and data (blob) and specifically make the client code to save the object's data there. This way you could do searches like "get all video prizes created between January 1st 2008 and January 15th 2009" and it wouldn't break down old data if your class would change too much for the serialization to stop working. This sort of solution would be easy to extend in the future too if there would be need for it; I understand this is a school assignment and such need most likely won't ever surface but if your teacher/professor knows his stuff, I bet he's willing to give an extra point or two for doing this excercise in this way since it takes a bit more time and shows that you can take the steps to prepare in advance for coping in the everchanging landscape of software development.
downvote count: 0
type: Answer

http://stackoverflow.com/q/507117
type: AnsweredQuestion
tagged with: fonts
tagged with: javahelp
score: 1
tagged with: java
upvote count: 1
accepted answer: http://stackoverflow.com/a/507188
type: Question
has body: Javahelp is the Java based help system that can easily be integrated in a Java application. The documentation does not give any information about it. On the web, many people state that it is not possible, that the help browser always uses a built-in font. I am not convinced that it is not possible. The help system of the IntelliJ IDE is based on javahelp and uses another font. So I think it must be possible. Is there someone who actually did this? For completeness: Including tags in the help files does not help. Stylesheets do not work.
has title: How can I change the Javahelp font?
answer count: 1
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/507188

http://stackoverflow.com/a/38805098
answers question: http://stackoverflow.com/q/496711
has body: There's a more elegant way in which you can use an external xml file and load it with file system resource then inject beans configured in it into your application context. Thus: import org.springframework.beans.BeansException; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.annotation.Order; import org.springframework.core.io.FileSystemResource; import org.springframework.stereotype.Service; @Service @Order(-100) public class XmlBeanInitializationService implements ApplicationContextAware, InitializingBean { private ApplicationContext applicationContext; @Value("${xmlConfigFileLocation}") private String xmlConfigFileLocation; @Override public void afterPropertiesSet() throws Exception { XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader((BeanDefinitionRegistry)applicationContext); reader.loadBeanDefinitions(new FileSystemResource(xmlConfigFileLocation)); } @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } } where ${xmlConfigFileLocation} is a property specified in your application.properties file which points to the file location in your system thus: xmlConfigFileLocation="your-file-path-anywhere-in-your-system" and your xml file may contain: &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"&gt; &l…
type: Answer
score: 0

http://stackoverflow.com/a/635959
answers question: http://stackoverflow.com/q/635935
has body: I always start with Joda Time. Working with dates and times in Java is always "fun" but Joda Time takes the strain off. They have Interval and Duration classes which do half of what you are looking for. Not sure if they have a function for outputing in readable format though. I'll keep looking. HTH
score: 0
type: Answer
upvote count: 1
downvote count: 1

executorservice
type: Tag
tags question: http://stackoverflow.com/q/370707
tag name: executorservice
tags question: http://stackoverflow.com/q/637110
tags question: http://stackoverflow.com/q/612656
tags question: http://stackoverflow.com/q/409932

http://stackoverflow.com/q/453684
has comment: http://stackoverflow.com/comment/3893425
has answer: http://stackoverflow.com/a/453707
has answer: http://stackoverflow.com/a/453724
has answer: http://stackoverflow.com/a/453718
has answer: http://stackoverflow.com/a/453702
has comment: http://stackoverflow.com/comment/4000082
score: 14
type: AnsweredQuestion
upvote count: 14
accepted answer: http://stackoverflow.com/a/453698
tagged with: java
type: Question
has body: One meme that gets stressed with Java development is always use ArrayList over Vector. Vector is deprecated. That may be true, but Vector and Hashtable have the advantage that they are synchronized. I am working with a heavily concurrent oriented application, wouldn't it benefit to use objects that are synchronized like Vector? It seems that they have their place?
tagged with: vector
downvote count: 0
answer count: 6
has answer: http://stackoverflow.com/a/453708
has title: Use Hashtable, Vector or HashMap or ArrayList in Java
has answer: http://stackoverflow.com/a/453698
favorite count: 0
possible better answer: http://stackoverflow.com/a/453724

http://stackoverflow.com/a/645180
has body: I was always partial to JCreator back in the day.
downvote count: 0
has comment: http://stackoverflow.com/comment/468739
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/468793
upvote count: 2
answers question: http://stackoverflow.com/q/643346

http://stackoverflow.com/a/514526
has body: This is a halfway-serious, completely-off-the-wall hack-thought: ...what if you spawned a new instance of java (with the new settings) from the current jvm then killed the old process from the new? I have no idea if this will help or not (or even work)...
answers question: http://stackoverflow.com/q/514487
has comment: http://stackoverflow.com/comment/328379
has comment: http://stackoverflow.com/comment/328470
downvote count: 0
has comment: http://stackoverflow.com/comment/331833
type: Answer
upvote count: 6
score: 6

http://stackoverflow.com/comment/269273
type: Comment
has text: +1, you should definitely change getData() to return Map<MyClass.Key, String>. It will not break older code.
comment on: http://stackoverflow.com/a/448175
score: 0
type: AnswerComment

http://stackoverflow.com/q/455753
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/455889
has body: I'm using a JTextArea to display a long text JTextArea _definition = new JTextArea(5, 50); with word-wrap _definition.setLineWrap(true); _definition.setWrapStyleWord(true); embedded in a JScrollPane add(new JScrollPane(_definition), gbc); All that is part of a JPanel with the GridBagLayout. Everything is working fine with shorter text, but when I add a long text with line wraps and the scrollbar is required, pack() goes south and all components have just a minimum size and the dialog is unusable (it's not only the TextArea that is affected). I've tried to figure out what is going on, but all I could figure out is that is has to do with the text in the TextArea. I'm stuck .. any ideas? Thanks!
score: 1
tagged with: java
upvote count: 1
tagged with: swing
type: Question
tagged with: sizing
accepted answer: http://stackoverflow.com/a/455889
answer count: 2
has title: JTextArea - very small size with long text
tagged with: textarea
possible better answer: http://stackoverflow.com/a/455777
downvote count: 0
has answer: http://stackoverflow.com/a/455777
favorite count: 0

http://stackoverflow.com/a/520335
answers question: http://stackoverflow.com/q/520328
downvote count: 11
has body: It is not possible, since all classes in the package might not be loaded, while you always knows package of a class.
score: -3
type: Answer
upvote count: 8

http://stackoverflow.com/comment/325758
comment on: http://stackoverflow.com/a/511948
score: 1
has text: @Jon, true, but that would result in a performance impact (no conversion instruction from long to double in any instruction set that I'm aware of). I wonder what Math.floor does with doubles > 2^53 at the first place. Some results aren't representable.
type: AnswerComment
type: Comment

http://stackoverflow.com/a/34928115
has comment: http://stackoverflow.com/comment/67172361
downvote count: 1
score: 7
answers question: http://stackoverflow.com/q/395401
has body: You can use the "Objects" class from JAVA (which is available since 1.7) Collection&lt;String&gt; myCollection = Arrays.asList("1273","123","876","897"); Objects.toString(myCollection); Output: 1273, 123, 876, 897 Another possibility is to use the "MoreObjects" class from Google Guave, which provides many of useful helper functions: MoreObjects.toStringHelper(this).add("NameOfYourObject", myCollection).toString()); Output: NameOfYourObject=[1273, 123, 876, 897] Guava docs
upvote count: 8
type: Answer

http://stackoverflow.com/a/430965
has body: My infrastructure looks like this for the webapp I'm involved in: IntelliJ Idea, I just use it for some time now, but I guess any halfway modern IDE will do it, just learn one and learn it well, so read NetBeans, JDeveloper, Eclipse but I never used one of them for longer time Teamcity, Continous Integration (which I love for the delayed checkin and remote runs, never ever check in a broken branch anymore!) Maven and Artifactory, Dependency Management for our software stack Tomcat (or Glassfish) SVN as SCM On the lib side I use Spring Hibernate JSF + Trinidad Spring Webflow JUnit Fitness EasyMock I guess for development you should also consider something like HSQL or something, don't make yourself depend on big databases and you can't run/test your stuff on the road ;-). The hard part in the beginning here is to set everything up properly in maven. This is not a task which just takes 5 minutes but I think it's worth it. I have not played around with Ivy yet maybe this might be a good solution too. I do not want to wade through ant scripts anymore, those are getting easily out of hand if your project grows. Everything works in Windows/Linux/Mac as you would expect from Java and a modern IDE.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/428594

http://stackoverflow.com/comment/360350
type: Comment
has text: I've used Eclipse in the distant past as an IDE and have been using Netbeans lately, which is where I found the Spring AF in the first place.
score: 0
comment on: http://stackoverflow.com/a/548435
type: AnswerComment

http://stackoverflow.com/a/48978108
answers question: http://stackoverflow.com/q/363681
has body: Say you want range between 0-9, 0 is minimum and 9 is maximum. The below function will print anything between 0 and 9. It's the same for all ranges. public static void main(String[] args) { int b = randomNumberRange(0, 9); int d = randomNumberRange (100, 200); System.out.println("value of b is " + b); System.out.println("value of d is " + d); } public static int randomNumberRange(int min, int max) { int n = (max + 1 - min) + min; return (int) (Math.random() * n); }
has comment: http://stackoverflow.com/comment/95457036
upvote count: 4
downvote count: 0
score: 4
type: Answer

http://stackoverflow.com/comment/249955
score: 0
type: Comment
type: QuestionComment
has text: It's a cool idea. With some swift AOP you could probably gin up a snazzy real time display of what's going on in the app context. I will keep an eye on this question.
comment on: http://stackoverflow.com/q/425794

http://stackoverflow.com/a/384123
accepted answer of: http://stackoverflow.com/q/384101
upvote count: 12
has comment: http://stackoverflow.com/comment/99250747
downvote count: 0
has comment: http://stackoverflow.com/comment/90615291
has comment: http://stackoverflow.com/comment/22409027
score: 12
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/384101
has body: Apparently you can directly invoke Eclipse's code formatter from the command line.
type: Answer
has comment: http://stackoverflow.com/comment/100169478

http://stackoverflow.com/a/44222874
type: Answer
answers question: http://stackoverflow.com/q/440786
has body: I absolutely agree with @duffymo that code should be tested from the client's view ( though he says he quit thinking this way). However, from this point of view, private vs others have different meanings. Client of a private method is the class itself so I prefer testing them through the external (public/package-protected) API. However, protected and package-protected members are there for external clients, so I test them with fakes which inherit the owning class or which reside in the same package.
score: 0

http://stackoverflow.com/comment/100282556
has text: @AlainO'Dea that linked answer describes the situation very well. `Thread.stop()` does not prevent the execution of `finally` when the thread was inside the `try` block, but it may prevent its completion when the thread was already inside the `finally` block. Note that these are the same restrictions as for ordinary code flow constructs. If a thread never reaches a `try` block, the `finally` block won’t be executed, further, `break` and `continue` targeting a loop outside the `try` construct or `return`,`throw` or any provoked exception within the `finally` block may prevent its completion.
type: Comment
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/519207

http://stackoverflow.com/q/537595
has answer: http://stackoverflow.com/a/541530
upvote count: 10
has answer: http://stackoverflow.com/a/539599
has answer: http://stackoverflow.com/a/1580282
has answer: http://stackoverflow.com/a/539611
tagged with: c++
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/538243
has answer: http://stackoverflow.com/a/537869
downvote count: 0
possible better answer: http://stackoverflow.com/a/537638
has answer: http://stackoverflow.com/a/539589
has answer: http://stackoverflow.com/a/537638
has body: Like most people, I learnt C++ after C. I learnt C++ because it was one of those languages which fetched jobs. I am still studying (doing masters) though. One of my cousins has been working as a developer for around 12 years. He advises me to learn Java so that I can land up in a good job. He says only few sectors like tele communications use C++ and almost all the enterprise software is developed in Java. I am working as a student technician in my university. The job involves Windows programming in C++. I learnt core Java. I do not know any of those Struts, Hibernate or whatever is out there. To be on the safer side, I am planning to master both. But I think Java is an ocean, though it's easier to program in Java than C++ (this is my opinion. C++ lovers don't kill me). What do you geeks and professionals out there advise me. Do you think I should learn both of them. Which sectors of the software industry use C++?
has answer: http://stackoverflow.com/a/537629
type: Question
has answer: http://stackoverflow.com/a/538436
accepted answer: http://stackoverflow.com/a/537635
has answer: http://stackoverflow.com/a/537808
tagged with: java
has answer: http://stackoverflow.com/a/539584
score: 10
has answer: http://stackoverflow.com/a/537646
has answer: http://stackoverflow.com/a/538315
has answer: http://stackoverflow.com/a/539626
has answer: http://stackoverflow.com/a/537886
has title: Which sector of software industry uses C++?
answer count: 25
has answer: http://stackoverflow.com/a/538480
has answer: http://stackoverflow.com/a/537731
has answer: http://stackoverflow.com/a/537635
has answer: http://stackoverflow.com/a/537641
has answer: http://stackoverflow.com/a/537668
has answer: http://stackoverflow.com/a/537636
favorite count: 0
has answer: http://stackoverflow.com/a/537813
has answer: http://stackoverflow.com/a/537643
has answer: http://stackoverflow.com/a/537621

http://stackoverflow.com/q/438508
score: 0
answer count: 1
tagged with: action
tagged with: applet
has title: How to securely trigger a Swing-Action in a restricted applet?
has answer: http://stackoverflow.com/a/438805
tagged with: swing
type: AnsweredQuestion
tagged with: java
has body: I simply want to call a swing action from my own popup menu. But since there is a security manager I need a solution to invoke this action without calling it directly. For instance the paste action of a text component will fail, because sun.swing.SwingUtilities2 cannot be loaded if there is any of my classes in the call stack. Is there any way to enqueue an event to the event thread? JComponent.dispatchEvent doesn't do the job because it processes the event itself.
type: Question
accepted answer: http://stackoverflow.com/a/438805
tagged with: security

http://stackoverflow.com/comment/731127
has text: Irfan, that's called Pugh's method, from what I recall
type: Comment
comment on: http://stackoverflow.com/a/462174
score: 0
type: AnswerComment

http://stackoverflow.com/a/611577
upvote count: 6
has comment: http://stackoverflow.com/comment/424472
score: 6
answers question: http://stackoverflow.com/q/550024
accepted answer of: http://stackoverflow.com/q/550024
type: AcceptedAnswer
downvote count: 0
has body: Have a look at http://sourceforge.net/projects/pjl-comp-filter/. Other custom solutions may have memory leaks. Also, if you are using mod_jk then you are certainly not using the 8080 connector (which supports compression) for those requests.
type: Answer

http://stackoverflow.com/q/571910
has comment: http://stackoverflow.com/comment/384836
favorite count: 0
has comment: http://stackoverflow.com/comment/383891
answer count: 4
type: UnansweredQuestion
has body: I heard from various sources that Java EE is highly scalable, but to me it seems that you could never scale a Java EE application to the level of the google search engine or any other large website. I would like to hear the technical reasons why it is so scalable.
has comment: http://stackoverflow.com/comment/383933
has comment: http://stackoverflow.com/comment/383903
has answer: http://stackoverflow.com/a/571951
has answer: http://stackoverflow.com/a/3003347
downvote count: 1
type: Question
tagged with: jakarta-ee
has title: Why is Java EE scalable?
has comment: http://stackoverflow.com/comment/383951
has comment: http://stackoverflow.com/comment/3068369
tagged with: java
score: 17
upvote count: 18
has answer: http://stackoverflow.com/a/572791
has answer: http://stackoverflow.com/a/571923

http://stackoverflow.com/comment/28315081
has text: How were you able to determine this ? I have a suspicion one of my applications may be suffering the same way.
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/622794
type: Comment

http://stackoverflow.com/comment/330546
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/512622
type: Comment
has text: Unfortunately, using a shutdown hook in Runtime does not work when using javaw.

http://stackoverflow.com/a/564985
has comment: http://stackoverflow.com/comment/376641
has comment: http://stackoverflow.com/comment/376208
type: Answer
has comment: http://stackoverflow.com/comment/1633225
has comment: http://stackoverflow.com/comment/377151
has comment: http://stackoverflow.com/comment/12077671
has comment: http://stackoverflow.com/comment/2242861
has body: The problem with Webstart is, that you actually have to 'start' something which isn't at all that fast even with a fast connection, while with a webapp you enter the URL and the app is there. Also a lot of things can go wrong with webstart. Maybe the intended user doesn't have the privileges needed, or the proxy of webstart is configured wrong, or something went wrong with jre dependencies or there is simply no java installed in the first place. So for the average john doe in the internet it is not at all pleasent. In controlled environments like a company it is a good and easy solution in many cases.
upvote count: 7
score: 7
answers question: http://stackoverflow.com/q/564936
has comment: http://stackoverflow.com/comment/376272
downvote count: 0
has comment: http://stackoverflow.com/comment/376377

http://stackoverflow.com/a/13347824
upvote count: 33
answers question: http://stackoverflow.com/q/415953
has comment: http://stackoverflow.com/comment/61121721
score: 32
type: Answer
has body: Another option is to use the Guava Hashing methods: Hasher hasher = Hashing.md5().newHasher(); hasher.putString("my string"); byte[] md5 = hasher.hash().asBytes(); Handy if you are already using Guava (which if you're not, you probably should be).
downvote count: 1
has comment: http://stackoverflow.com/comment/55291444

http://stackoverflow.com/a/15464954
downvote count: 0
has body: Java commons-io has a FileAlterationObserver. it does polling in combination with a FileAlterationMonitor. Similar to commons VFS. The advantag is that it has much less dependencies. edit: Less dependencies is not true, they are optional for VFS. But it uses java File instead of the VFS abstraction layer.
score: 8
answers question: http://stackoverflow.com/q/494869
type: Answer
upvote count: 8

http://stackoverflow.com/q/407405
tagged with: jboss
score: 4
possible better answer: http://stackoverflow.com/a/1161861
upvote count: 4
has answer: http://stackoverflow.com/a/3908634
tagged with: mbeans
downvote count: 0
tagged with: tomcat
accepted answer: http://stackoverflow.com/a/407413
favorite count: 0
has answer: http://stackoverflow.com/a/3238490
answer count: 4
type: AnsweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/1161861
has answer: http://stackoverflow.com/a/407413
has body: We have 2 applications that run under JBoss. I am looking for a way to reduce the overhead of the server. The main app runs under Tomcat. The other app is made up of MBeans. Is there a way to run MBeans under Tomcat? Alternative suggestions are appreciated.
has title: Can an MBean be run under Tomcat?

http://stackoverflow.com/a/601223
answers question: http://stackoverflow.com/q/601172
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/413615
score: 1
upvote count: 1
has body: Along with what other have said about needing to decalre it is a Graphics2D, take it out of the instance variables and make it a local variable. There is no point in having an instance variable that is used in only one method and always has the value overwitten each time that method is called. Instance variables are used to persist state between method calls... you are not doing that here. public void paint(Graphics g) { final Graphics2D g2d; g2d = (Graphics2D)g; g2d.drawImage(img, null, 0, 0); }
has comment: http://stackoverflow.com/comment/413590

http://stackoverflow.com/comment/289098
has text: It's just a question copied from java Puzzlers. -1
comment on: http://stackoverflow.com/q/471296
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/83590751
comment on: http://stackoverflow.com/a/501309
score: 0
type: AnswerComment
has text: @Franz: as soon as you are without source code, generics in Java become just syntactic sugar for writing less casting code. Then that could have be done with exceptions, not just with lists. Of course this whole conversation hinges on there being some Object contained within exceptions that needs casting.
type: Comment

http://stackoverflow.com/comment/267583
type: Comment
score: 0
type: AnswerComment
has text: In the first place it depends on the code that you want to write. Just saying that you might need a little more experience when you divert to not use synchronize(this).
comment on: http://stackoverflow.com/a/442597

http://stackoverflow.com/comment/324638
score: 0
type: Comment
comment on: http://stackoverflow.com/a/510622
has text: yes obviously, but how would I iterate through all the nodes knowing which ones are level 2?
type: AnswerComment

http://stackoverflow.com/a/607281
downvote count: 2
has comment: http://stackoverflow.com/comment/420182
score: 17
has comment: http://stackoverflow.com/comment/419633
has comment: http://stackoverflow.com/comment/419559
has comment: http://stackoverflow.com/comment/110440869
has comment: http://stackoverflow.com/comment/419567
has comment: http://stackoverflow.com/comment/140190904
has body: Using the javascript engine that is shipped with Java 6: import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; public class Wow { public static void main(String[] args) throws Exception { ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngine engine = factory.getEngineByName("JavaScript"); engine.eval("print(encodeURIComponent('\"A\" B ± \"'))"); } } Output: %22A%22%20B%20%c2%b1%20%22 The case is different but it's closer to what you want.
has comment: http://stackoverflow.com/comment/64755587
answers question: http://stackoverflow.com/q/607176
type: Answer
has comment: http://stackoverflow.com/comment/419512
has comment: http://stackoverflow.com/comment/39913659
upvote count: 19
has comment: http://stackoverflow.com/comment/140190890

http://stackoverflow.com/comment/5328550
type: Comment
has text: How does it handle if e.g. dates or months are entered without a leading zero which the rendering adds?
comment on: http://stackoverflow.com/a/2356590
score: 0
type: AnswerComment

http://stackoverflow.com/a/586252
answers question: http://stackoverflow.com/q/586218
score: 6
upvote count: 6
has comment: http://stackoverflow.com/comment/398064
has comment: http://stackoverflow.com/comment/401607
has comment: http://stackoverflow.com/comment/401602
has comment: http://stackoverflow.com/comment/399004
type: Answer
has body: Avoid compound keys like this: "E1234:An error has occured" I would use public enum Error { E1234("E1234", "An error has occured"), E1245("E1235", "Other error has occured"), private final String code; private final String description; Error(code, description) { this.code; this.description = description } @Override public String toString() { return this.code + ": " + this.description; } } Then, you can create your own interface with methods which accept an Error: public interface MyLogger { void error(Error); void info(Error); void warn(Error); void debug(Error); } Then implement it and delegate to log4j real logging job. This will help your developer avoiding problems.
downvote count: 0

http://stackoverflow.com/comment/248505
has text: What exactly is the problem? Got any hbms and cfgs files for us? You really need to give us more detail.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/424312

http://stackoverflow.com/comment/323617
type: AnswerComment
score: 0
type: Comment
has text: I think that is still true. But implementing a .Net service/client should be no biggy. Quite true, Jini is SOA, does not mandate what protocols are used. If fact you could implement Web Services on top of Jini.
comment on: http://stackoverflow.com/a/506989

http://stackoverflow.com/comment/362584
has text: Especially since this post is tagged with Java
comment on: http://stackoverflow.com/a/551036
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/376983
has text: @Alex Miller - Totally agree. A string representation means nothing other than it should be human readable, and for any complex object, don't expect a pretty format, just functional for debugging.
type: Comment
score: 1
comment on: http://stackoverflow.com/a/563859
type: AnswerComment

http://stackoverflow.com/comment/354323
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/542258
type: Comment
has text: Thanks for your answer. Is there an explanation for so many slashies?

http://stackoverflow.com/a/25853468
has body: You could use a cast: public class GenSet&lt;Item&gt; { private Item[] a; public GenSet(int s) { a = (Item[]) new Object[s]; } }
has comment: http://stackoverflow.com/comment/47093130
type: Answer
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/529085
score: 0

http://stackoverflow.com/comment/120106249
type: Comment
comment on: http://stackoverflow.com/q/370852
score: 0
type: QuestionComment
has text: The `java.util` Date-Time API and their formatting API, `SimpleDateFormat` are outdated and error-prone. Also, the [Home Page of Joda-Time](https://www.joda.org/joda-time/) reads: *Note that from Java SE 8 onwards, users are asked to migrate to java.time (JSR-310) - a core part of the JDK which replaces this project.* Check [this answer](https://stackoverflow.com/a/67752047/10819573) and [this answer](https://stackoverflow.com/a/67505173/10819573) to learn how to use `java.time` API with JDBC.

http://stackoverflow.com/a/621639
has body: Well, you haven't shown how your program is executing. Here's a complete program which only shows a single line: import org.apache.log4j.*; public class Test { public static void main(String[] args) { BasicConfigurator.configure(); // logger configuration Logger logger = Logger.getLogger(Test.class); logger.setLevel(Level.DEBUG); logger.info("Hello"); } } Is it possible that your code really is running three times?
upvote count: 2
type: Answer
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/621633

http://stackoverflow.com/comment/75197924
has text: I implemented a quick test running with Java 8, but temp folder was not deleted, see https://pastebin.com/mjgG70KG
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/618273

http://stackoverflow.com/comment/437387
comment on: http://stackoverflow.com/a/624210
has text: but no Java array (nor ByteBuffer, apparently) can be longer than 2 GB anyway. Seriously, just accept that this is your limit, and have your code give an error in the extremely unlikely circumstance that the long can't be cleanly cast to an int.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/647371
answers question: http://stackoverflow.com/q/647330
upvote count: 1
has body: There are many things that a Virtual Machine might chose to abstract away. The OS abstracts away some of the common hardware, by providing standard interfaces to them (block i/o, character i/o, etc). The JVM set out to abstract out the processor and the OS itself, a mighty goal by itself (at that time)! However, abstracting the peripheral hardware was, and will remain, a difficult goal to achieve. Perhaps, when we see more convergence of hand-helds/laptops/desktops/servers, the need to abstract out the hardware will diminish.
downvote count: 0
type: Answer
score: 1

http://stackoverflow.com/q/362665
type: Question
tagged with: websphere
score: 5
has answer: http://stackoverflow.com/a/396277
tagged with: tomcat
favorite count: 0
has answer: http://stackoverflow.com/a/362702
has answer: http://stackoverflow.com/a/363766
accepted answer: http://stackoverflow.com/a/363766
upvote count: 5
possible better answer: http://stackoverflow.com/a/396277
has title: Security of Tomcat versus WebSphere versus WebLogic
has answer: http://stackoverflow.com/a/4116648
downvote count: 0
has body: The company I work for sells a J2EE application that runs on Tomcat, WebSphere, or WebLogic. We have a customer that is trying to decide between Tomcat and WebSphere. They're leaning towards WebSphere because they're concerned that Tomcat has more security holes. After searching around on the web, I've been unable to find any sites or studies that compare the robustness of the major J2EE application servers from a security standpoint. Can any of you point me to information comparing app server security holes?
has answer: http://stackoverflow.com/a/363081
tagged with: jakarta-ee
type: AnsweredQuestion
tagged with: weblogic
has answer: http://stackoverflow.com/a/362697
tagged with: java
answer count: 6

http://stackoverflow.com/q/521117
has answer: http://stackoverflow.com/a/521831
tagged with: ant
has body: I am trying to revamp our build process, which is currently a gigantic Ant build.xml that calls into other ant build files and executes several Java classes to perform more complex logic that would be impossible/scary to attemp in Ant. Background: experience in Java and Ant, some Groovy Windows platforms Goals: run as a combination of command line cron and when a servlet is posted to as simplified as possible, fewest languages and bouncing between techs I need higher level logical power that a language like Java provides and Ant is pretty easy and we use the filtering to override default properties files for different clients. Mostly I'm wondering if there is something other than Ant/Java that people use.
possible better answer: http://stackoverflow.com/a/521782
has answer: http://stackoverflow.com/a/521238
has answer: http://stackoverflow.com/a/521166
answer count: 14
has answer: http://stackoverflow.com/a/762900
downvote count: 0
has answer: http://stackoverflow.com/a/521782
tagged with: build-process
favorite count: 0
has answer: http://stackoverflow.com/a/521576
accepted answer: http://stackoverflow.com/a/521178
score: 11
upvote count: 11
type: AnsweredQuestion
has title: What do you use for a complex build process?
has answer: http://stackoverflow.com/a/521862
tagged with: java
has answer: http://stackoverflow.com/a/546772
has answer: http://stackoverflow.com/a/546412
has answer: http://stackoverflow.com/a/521178
has answer: http://stackoverflow.com/a/2468466
has comment: http://stackoverflow.com/comment/334556
has answer: http://stackoverflow.com/a/521145
type: Question
has answer: http://stackoverflow.com/a/521867
has answer: http://stackoverflow.com/a/521392

http://stackoverflow.com/q/458114
has answer: http://stackoverflow.com/a/458221
has title: refresh setCellEditor for JTable
type: AnsweredQuestion
tagged with: swing
type: Question
has body: I was looking for an answer for a previous question and had an ingenious idea to overcome a limit on JTable. I need the editor to be different on a row by row basis, whereas JTable can only handle a single editor for each column. So my idea is to use a MouseListener to check the row and column on the JTable and set new editor each time. But, calling setCellEditor() a second time do not have any effect. The editor remains to be the first one that was set. So how can I make "setCellEditor" work a second time for the same column? Here's the code in MouseListener. public void mouseClicked(MouseEvent e) { int cols = resultTable.columnAtPoint(new Point(e.getX(), e.getY())); int rows = resultTable.rowAtPoint(new Point(e.getX(), e.getY())); StorageObject item = (StorageObject) resultTable.getModel().getValueAt(rows, cols); TableColumn col = resultTable.getColumnModel().getColumn(cols); col.setCellEditor(new MyComboBoxEditor(item.list)); }
tagged with: java
accepted answer: http://stackoverflow.com/a/458221
has answer: http://stackoverflow.com/a/458213
tagged with: jtable
answer count: 2
possible better answer: http://stackoverflow.com/a/458213
score: 0

http://stackoverflow.com/a/417571
has comment: http://stackoverflow.com/comment/243711
downvote count: 1
has comment: http://stackoverflow.com/comment/243027
upvote count: 5
type: Answer
has body: I made the original comment. My comment was that they are logically equivalent, but compile to different bytecode. I didn't add anything else to justify it at the time because there's not much to justify really-- they just do compile to different bytecode. If you declare a method as synchronized, then that synchronization is part of the method's definition. A synchronized block within a method isn't part of the method's definition, but instead involves separate bytecodes to acquire and release the monitor, as one of the posters above has illustrated. Strictly speaking, they're slightly different things, though to the overall logic of your program, they're equivalent. When does this matter? Well, on most modern desktop VMs, hardly ever. But for example: a VM could in principle make optimisations in one case but not the other there are some JIT compiler optimisations where the number of bytecodes in the method is taken as a criterion for what optimisations to make a VM without a JIT compiler (admittedly few nowadays, but maybe on an older mobile device?) will have more bytecodes to process on each call
answers question: http://stackoverflow.com/q/417285
has comment: http://stackoverflow.com/comment/243043
score: 4

http://stackoverflow.com/q/503578
type: Question
answer count: 2
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/541980
has answer: http://stackoverflow.com/a/503598
has body: I have a bit of code which runs in 10.919 s. Profiling it shows that 10.182 s are wasted in opaque.double Which is called when I use jClass.GetArrays(jArray1,jArray2); struct.prop1 = double(jArray1); struct.prop2 = double(jArray1); What can be done? I have to use Java to interact with external API. EDIT: I used the following hack: struct.prop1 = cell2mat( cell( jArray1) ); And got down to 1.5s / 2.2s EDIT: Making the java return long comma delimited string representation of the arrays and then using data = strread(char(jString),'%f','delimiter',',' ); Produced almost bearable performance
upvote count: 3
type: UnansweredQuestion
tagged with: double
tagged with: matlab
score: 3
has title: Passing a million numbers from java to matlab?
tagged with: java

http://stackoverflow.com/comment/125051953
comment on: http://stackoverflow.com/a/47725176
score: 1
type: AnswerComment
type: Comment
has text: Will `this.getClass().getResource("")` return null? Should it be `this.getClass().getResource(this.getClass.getName() + ".class")`?

http://stackoverflow.com/q/615708
tagged with: multiple-instances
has body: We have an application based on the netbeans rich client platform. Default behaviour is that only one instance of the software can run, and this can be overridden by specifying a different user-dir as argument when starting the application. Are there any alternatives to this? Our clients rely on being able to run several instances of the application. (We would prefer if we didnt have to implement our own launcher that examines netbeans userdir for locks to pass alternative userdirs) Is there a build-in way in the netbeans RCP to easily support multiple instances? cheers /B
has title: Running several instances of Netbeans RCP application simultaneously
accepted answer: http://stackoverflow.com/a/636345
favorite count: 0
tagged with: netbeans
upvote count: 2
type: AnsweredQuestion
score: 2
tagged with: java
tagged with: rcp
has comment: http://stackoverflow.com/comment/435943
type: Question
has answer: http://stackoverflow.com/a/636345
answer count: 2
possible better answer: http://stackoverflow.com/a/3729606
downvote count: 0
has answer: http://stackoverflow.com/a/3729606

http://stackoverflow.com/a/516061
type: Answer
answers question: http://stackoverflow.com/q/516049
has body: Yes, the finally block will always be run, unless there is a crash of the JVM (very rare, but that can happen).
score: 0
upvote count: 1
downvote count: 1

http://stackoverflow.com/comment/376663
score: 1
type: Comment
comment on: http://stackoverflow.com/a/565445
has text: Just tried this. It just prints a black square then 31;1mhello world! in black.
type: AnswerComment

http://stackoverflow.com/q/582493
has body: Is it worthwhile learning C# if you are a Linux user? There is Mono but it seems destined to always be behind the curve with the constant threat of MS action if they start to lose money. Currently I am leaning more towards Java as its is fully GPLed and there are no major threats of software patents. It already has a big oss community behind it and has a solid reputation on the server whereas C# still needs to prove itself there. The big advantage for C# programmers is that they are cheaper than Java developers. I also wonder exactly how portable C# code is though. Can one simply take a C# app written to target Mono and run it on windows?
has comment: http://stackoverflow.com/comment/394504
has answer: http://stackoverflow.com/a/582509
favorite count: 0
has answer: http://stackoverflow.com/a/586720
has answer: http://stackoverflow.com/a/582602
possible better answer: http://stackoverflow.com/a/582540
has comment: http://stackoverflow.com/comment/394477
downvote count: 2
has answer: http://stackoverflow.com/a/582540
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/582560
has comment: http://stackoverflow.com/comment/394645
has answer: http://stackoverflow.com/a/586671
tagged with: java
accepted answer: http://stackoverflow.com/a/582509
has answer: http://stackoverflow.com/a/582609
type: Question
tagged with: c#
answer count: 8
upvote count: 12
has answer: http://stackoverflow.com/a/582507
score: 10
has title: C# on Linux - Anyone got an opinion based on experience using mono?

http://stackoverflow.com/comment/5149899
score: 41
comment on: http://stackoverflow.com/a/4019116
type: AnswerComment
has text: This isn't really a third way. You're still implementing Runnable, just doing it anonymously.
type: Comment

http://stackoverflow.com/comment/65797329
type: Comment
comment on: http://stackoverflow.com/a/524491
has text: did not work for me, and also very complex to understand
score: 0
type: AnswerComment

http://stackoverflow.com/a/556554
type: AcceptedAnswer
type: Answer
has body: sp_help delivers all the information I need. This SP returns several ResultSets. The third ResultSet contains the information I need. Statement stmt = con.createStatement(); stmt.executeQuery("sp_help " + table); stmt.getMoreResults(); stmt.getMoreResults(); ResultSet rs = stmt.getResultSet(); //... while( rs.next() ) boolean identity = rs.getBoolean("Identity");
accepted answer of: http://stackoverflow.com/q/553751
answers question: http://stackoverflow.com/q/553751
score: 0

http://stackoverflow.com/a/20093642
downvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/369512
upvote count: 137
score: 135
has body: (from Ways to sort lists of objects in Java based on multiple fields) Working code in this gist Using Java 8 lambda's (added April 10, 2019) Java 8 solves this nicely by lambda's (though Guava and Apache Commons might still offer more flexibility): Collections.sort(reportList, Comparator.comparing(Report::getReportKey) .thenComparing(Report::getStudentNumber) .thenComparing(Report::getSchool)); Thanks to @gaoagong's answer below. Messy and convoluted: Sorting by hand Collections.sort(pizzas, new Comparator&lt;Pizza&gt;() { @Override public int compare(Pizza p1, Pizza p2) { int sizeCmp = p1.size.compareTo(p2.size); if (sizeCmp != 0) { return sizeCmp; } int nrOfToppingsCmp = p1.nrOfToppings.compareTo(p2.nrOfToppings); if (nrOfToppingsCmp != 0) { return nrOfToppingsCmp; } return p1.name.compareTo(p2.name); } }); This requires a lot of typing, maintenance and is error prone. The reflective way: Sorting with BeanComparator ComparatorChain chain = new ComparatorChain(Arrays.asList( new BeanComparator("size"), new BeanComparator("nrOfToppings"), new BeanComparator("name"))); Collections.sort(pizzas, chain); Obviously this is more concise, but even more error prone as you lose your direct reference to the fields by using Strings instead (no typesafety, auto-refactorings). Now if a field is renamed, the compiler won’t even report a problem. Moreover, because this solution uses reflection, the sorting is much slower. Getting there: Sorting with Google Guava’s ComparisonChain Collections.sort(pizzas, new Comparator&lt;Pizza&gt;() { @Override public int compare(Pizza p1, Pizza p2) { return ComparisonChain.start().compare(p1.size, p2.size).compare(p1.nrOfToppings, p2.nrOfToppings).compare(p1.name, p2.name).result(); // or in case the fields can be null: /* return ComparisonChain.start() .compare(p1.size, p2.size, Ordering.natural().nullsLast()) .compare(p1.nrOfToppings, p2.nrOfToppings, Ordering.natural().nullsLast()) .compare(p1.name, p2.name, Ordering.natural().nullsLast()) .r…

http://stackoverflow.com/q/457463
downvote count: 0
favorite count: 0
answer count: 9
has answer: http://stackoverflow.com/a/16738910
has answer: http://stackoverflow.com/a/457608
has answer: http://stackoverflow.com/a/458279
tagged with: jcombobox
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/457552
tagged with: java
has title: Putting JComboBox into JTable
has answer: http://stackoverflow.com/a/946949
has answer: http://stackoverflow.com/a/8262706
type: Question
possible better answer: http://stackoverflow.com/a/946949
has body: I want to put individual JComboBoxes into each cells of a JTable. ie. The JComboBox content is not identical for each cell. I basically would like to be able to just call the following code to add a row of JComboBox into the JTable. Anyone has any idea? Thanks JComboBox cb1 = new JComboBox(...); JComboBox cb2 = new JComboBox(...); model.addRow(new Object[] {"Row name", cb1, cb2} ); JComboBox cb3 = new JComboBox(...); JComboBox cb4 = new JComboBox(...); model.addRow(new Object[] {"Row name 2", cb3, cb4} ); The closest example code I can find is as follows. But it is for where JComboBox content is identical for the individual column. Not the solution I need. TableColumn col = table.getColumnModel().getColumn(vColIndex); col.setCellEditor(new MyComboBoxEditor(values)); where public class MyComboBoxEditor extends DefaultCellEditor { public MyComboBoxEditor(String[] items) { super(new JComboBox(items)); } }
has answer: http://stackoverflow.com/a/2670664
accepted answer: http://stackoverflow.com/a/458279
has answer: http://stackoverflow.com/a/664740
score: 15
tagged with: jtable
has comment: http://stackoverflow.com/comment/69823808
upvote count: 15
has answer: http://stackoverflow.com/a/8222235

http://stackoverflow.com/q/486381
has answer: http://stackoverflow.com/a/486389
tagged with: java
type: Question
tagged with: testing
accepted answer: http://stackoverflow.com/a/486389
has body: I am currently using JUnit 4.4 and Java 1.6.x. And after a recent code fix, we started getting this AssertionFailedError in my JUnit tests on the method: UtilityTest.testParseDate(4t): Mon Jan 15 09:26:07 PST 2001 expected: "Mon Jan 15 09:26:07 PST 2001" but was: "Mon Jan 15 09:26:07 PST 2001" junit.framework.AssertionFailedError: UtilityTest.testParseDate(4t): Mon Jan 15 09:26:07 PST 2001 expected: but was: at UtilityTest.testParseDate(Unknown Source) As you can see, the expected and actual appear identical, and after several code inspections, we can find no obvious error in the code. Test runs with actual data have also produced correct (expected) results. Has anyone seen this behavior before in JUnit, and if so, did you find the cause and/or a fix? I have seen the same thing in previous versions of Java and JUnit myself: always somewhat random when it occurs, and usually the only fix "that worked" was to retype the chunk of code in from scratch. Weird, yet that was tne only way to remove this error. I'm trying to find out something more "concrete" in the behavior this time. Thanks, -Richard
score: 0
answer count: 3
tagged with: junit
has answer: http://stackoverflow.com/a/486423
has answer: http://stackoverflow.com/a/488683
has title: JUnit produces strange AssertionFailedError
possible better answer: http://stackoverflow.com/a/486423
type: AnsweredQuestion

http://stackoverflow.com/a/636556
downvote count: 0
type: Answer
has body: Most likely because they don't conform to the standard get/set naming scheme (they say, "As of JDK version 1.1, replaced by setVisible(boolean)").
answers question: http://stackoverflow.com/q/636550
upvote count: 15
score: 15

http://stackoverflow.com/a/510909
score: 0
has body: Unfortunately not with spring 2.5.X. Your @Component-annotation describes the role of the bean while the scope is a separate axis, so a role and scope descriptor typically have to be applied separately to the implementation class. When viewed in this way it makes some sense (edit: at least it did so for a few seconds, anyway) I don't know how this will change i spring 3.x, which is not too far away. There seems to be some room for improvement.
answers question: http://stackoverflow.com/q/510876
type: Answer

http://stackoverflow.com/a/521590
type: Answer
upvote count: 5
score: 5
answers question: http://stackoverflow.com/q/521110
downvote count: 0
has body: FreeMind (Swing)

http://stackoverflow.com/comment/44653583
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/476519
score: 2
has text: @DavidRTribble, the convention comes from trying to differentiate company.com from company.org, etc. Java took the position that no domain name would indicate more than one company, so it was a fairly explicit, ubiquitous and universal "identifier". It's actually a cleaner technique in my opinion that "CompanyName" only in there is no guarantee that a two similarly named companies won't accidentally name something the same. For instance, before the World Wrestling Federation lost "WWF" to the World Wildlife Fund, they might both chose WWF.ProductName. If of course they were into software.:)

user-interface
tags question: http://stackoverflow.com/q/481802
tags question: http://stackoverflow.com/q/575782
tags question: http://stackoverflow.com/q/584449
tags question: http://stackoverflow.com/q/423524
tags question: http://stackoverflow.com/q/367940
tags question: http://stackoverflow.com/q/499162
tags question: http://stackoverflow.com/q/642925
tags question: http://stackoverflow.com/q/617713
tags question: http://stackoverflow.com/q/585071
tags question: http://stackoverflow.com/q/379354
tags question: http://stackoverflow.com/q/542844
type: Tag
tags question: http://stackoverflow.com/q/390394
tags question: http://stackoverflow.com/q/580228
tags question: http://stackoverflow.com/q/370259
tags question: http://stackoverflow.com/q/530938
tags question: http://stackoverflow.com/q/366391
tags question: http://stackoverflow.com/q/564759
tags question: http://stackoverflow.com/q/539076
tags question: http://stackoverflow.com/q/543574
tags question: http://stackoverflow.com/q/374605
tags question: http://stackoverflow.com/q/496233
tags question: http://stackoverflow.com/q/585802
tags question: http://stackoverflow.com/q/409541
tags question: http://stackoverflow.com/q/606489
tags question: http://stackoverflow.com/q/610918
tags question: http://stackoverflow.com/q/541802
tags question: http://stackoverflow.com/q/359993
tags question: http://stackoverflow.com/q/531831
tags question: http://stackoverflow.com/q/604541
tags question: http://stackoverflow.com/q/641172
tags question: http://stackoverflow.com/q/417517
tags question: http://stackoverflow.com/q/473540
tags question: http://stackoverflow.com/q/573936
tags question: http://stackoverflow.com/q/570785
tags question: http://stackoverflow.com/q/573826
tags question: http://stackoverflow.com/q/625076
tags question: http://stackoverflow.com/q/461112
tags question: http://stackoverflow.com/q/445899
tags question: http://stackoverflow.com/q/580391
tags question: http://stackoverflow.com/q/491323
tags question: http://stackoverflow.com/q/412271
tags question: http://stackoverflow.com/q/431579
tags question: http://stackoverflow.com/q/501533
tags question: http://stackoverflow.com/q/419157
tags question: http://stackoverflow.com/q/566186
tags question: http://stackoverflow.com/q/464149
tags question: http://stackoverflow.com/q/432818
tags question: http://stackoverflow.com/q/389051
tags question: http://stackoverflow.com/q/508723
tags question: http://stackoverflow.com/q/383995
tag name: user-interface
tags question: http://stackoverflow.com/q/584234
tags question: http://stackoverflow.com/q/468328
tags question: http://stackoverflow.com/q/549451
tags question: http://stackoverflow.com/q/569351
tags question: http://stackoverflow.com/q/602032
tags question: http://stackoverflow.com/q/477701
tags question: http://stackoverflow.com/q/571026
tags question: http://stackoverflow.com/q/370369
tags question: http://stackoverflow.com/q/614297
tags question: http://stackoverflow.com/q/579993
tags question: http://stackoverflow.com/q/369823
tags question: http://stackoverflow.com/q/520615
tags question: http://stackoverflow.com/q/505599
tags question: http://stackoverflow.com/q/518471
tags question: http://stackoverflow.com/q/556478

http://stackoverflow.com/a/561180
score: 0
has body: You could store the location of your properties file in JNDI? This should be portable across Tomcat, and for Java EE Application Servers.
type: Answer
answers question: http://stackoverflow.com/q/558502

http://stackoverflow.com/a/479298
score: 3
has comment: http://stackoverflow.com/comment/296346
has body: Have a look at this one: JavaBlackBelt.
downvote count: 0
type: Answer
upvote count: 3
answers question: http://stackoverflow.com/q/479112

jaxp
type: Tag
tag name: jaxp
tags question: http://stackoverflow.com/q/369760

apache-commons
tags question: http://stackoverflow.com/q/390115
tags question: http://stackoverflow.com/q/507660
tags question: http://stackoverflow.com/q/473379
tags question: http://stackoverflow.com/q/473065
tags question: http://stackoverflow.com/q/624581
tag name: apache-commons
type: Tag
tags question: http://stackoverflow.com/q/462566
tags question: http://stackoverflow.com/q/646189

http://stackoverflow.com/a/499444
has comment: http://stackoverflow.com/comment/316282
answers question: http://stackoverflow.com/q/499437
has comment: http://stackoverflow.com/comment/315003
has comment: http://stackoverflow.com/comment/315047
has comment: http://stackoverflow.com/comment/315017
type: Answer
has comment: http://stackoverflow.com/comment/315001
upvote count: 14
has comment: http://stackoverflow.com/comment/315038
downvote count: 5
has body: IMHO, it shouldn't be an exception at all. An exception, in my mind, should be used when exceptional things happen, and not as flow controls. In your case, it isn't at all an exceptional status that someone tries to transfer more money than the balance allows. I figure these things happen very often in the real world. So you should program against these situations. An exception might be that your if-statement evaluates the balance good, but when the money is actually being subtracted from the account, the balance isn't good anymore, for some strange reason. An exception might be that, just before calling transferTo(), you checked that the line was open to the bank. But inside the transferTo(), the code notices that the line isn't open any more, although, by all logic, it should be. THAT is an exception. If the line can't be opened, that's not an exception, that's a plausible situation. IMHO recap: Exceptions == weird black magic. being-constructive-edit: So, not to be all too contradictive, the method itself might very well throw an exception. But the use of the method should be controlled: You first check the balance (outside of the transferTo() method), and if the balance is good, only then call transferTo(). If transferTo() notices that the balance, for some odd reason, isn't good anymore, you throw the exception, which you diligently catch. In that case, you have all your ducks in a row, and know that there's nothing more you can do (because what was true became false, as if by itself), other than log the exception, send a notification to someone, and tell the customer politely that someone didn't sacrifice their virgins properly during the last full moon, and the problem will be fixed at the first possible moment. less-enterprisey-suggestion-edit: If you are doing this for your own pleasure (and the case seems to be this, see comments), I'd suggest returning a boolean instead. The usage would be something like this: // ... boolean success = transferTo(otherAcco…
score: 9

http://stackoverflow.com/a/460605
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/460602
type: Answer
has body: That's ok. Alternately you could use a HashSet. EDIT: You can compare objects in 2 ways: By Reference Custom The Default Object comparison is done by reference and it's implemented on the Object class. If any class in the hierarchy of your object overrides this default implementation then your doing a custom comparison. If this happens, you must also override the hashcode as well. Given this, IF you want to compare objects by reference but there's a custom implementation of equality then you should use a IdentityHashMap ELSE use a HashSet. If you want to maintain your current implementation with HashMap it's also fine. HashSet is internally implemented with an HashMap. But, instead of setting the value to 1, set it with null. There's also the question of the correct data structure. You could use a List instead of an Hash structure. The type of data structure you should use is up to you. This depends on many thinks like how many objects you intend to put in the collection, how many accesses there will be, insertions, etc.
downvote count: 0

http://stackoverflow.com/a/584052
has body: If you've got access to a server that can run Java, can you not run the whole thing on there anyway? Otherwise, as you've figured, you can just create a component with a remote function and have that do the work, along the lines of: &lt;cfcomponent output="false"&gt; &lt;cffunction name="runMyJava" returntype="String" output="false" access="remote"&gt; &lt;cfargument name="MyArg" type="String" /&gt; &lt;cfset var MyObj = createObject('java','whatever') /&gt; &lt;cfreturn MyObj.doJavaMagic( Arguments.MyArg ) /&gt; &lt;/cffunction&gt; &lt;/cfcomponent&gt; Then on your other server, you'd have something like... &lt;cfset MyWebService = createObject('webservice','https://myotherserver/mycomponent.cfc?wsdl')/&gt; &lt;cfset MyString = MyWebService.runMyJava( MyString ) /&gt; Note that this example uses https - since you'd presumably want to protect the data from flying over the Internet in plain text. It may also be sensible to IP-restrict the server so only you can connect to it, or use other appropriate methods to secure it.
score: 12
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/583809
upvote count: 12
downvote count: 0
answers question: http://stackoverflow.com/q/583809

http://stackoverflow.com/q/613973
answer count: 1
downvote count: 0
favorite count: 0
type: UnansweredQuestion
has title: Netbeans 6.5: Change an environment variable during run/debug/test?
tagged with: netbeans
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/618370
type: Question
has body: Up until Netbeans 6.1, I was using the following recipe to change the PATH environment variable during run/debug/test tasks: in the build.xml file I included: <property environment="env"/> <target name="-init-macrodef-java"> <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1"> <attribute default="${main.class}" name="classname"/> <element name="customize" optional="true"/> <sequential> <java classname="@{classname}" dir="${work.dir}" fork="true"> <jvmarg line="${run.jvmargs}"/> <env key="Path" path="${work.dir}/../../bin;${env.Path}"> ... (this was for Windows machines). Under Netbeans 6.5, this magic no longer seems to work, not for PATH, or other environment variables (using key="..." value="..." instead). I rebuild the NB projects from scratch to little avail, and I am no Ant expert to begin with. Any pointers/suggestions?
score: 3
tagged with: ant

http://stackoverflow.com/comment/211931
type: Comment
comment on: http://stackoverflow.com/a/377791
type: AnswerComment
has text: It might be the same conceptually, but it's a very different beast in Java and confusing references and objects has slowed down many, many beginners in their understanding.
score: 0

http://stackoverflow.com/comment/8131770
comment on: http://stackoverflow.com/a/513259
type: AnswerComment
score: 110
has text: It should be noted that `System.nanoTime()` is not _guaranteed_ to be more accurate than `System.currentTimeMillis()`. It is only guaranteed to be at least as accurate. It usually is substantially more accurate, however.
type: Comment

http://stackoverflow.com/comment/128254945
comment on: http://stackoverflow.com/a/51079545
has text: Why is there no such method on Android...
type: AnswerComment
type: Comment
score: 0

http://stackoverflow.com/comment/54449868
score: 0
type: AnswerComment
type: Comment
has text: Anyone reading this. For the multi-line case the flag DOTALL needs to be passed and ^ and $ need to be removed from the case.
comment on: http://stackoverflow.com/a/394278

http://stackoverflow.com/comment/323079
comment on: http://stackoverflow.com/a/507621
score: 3
has text: Can't you easily do this in the first method by moving the new operator into the static {} block and wrapping it?
type: AnswerComment
type: Comment

http://stackoverflow.com/a/52825237
downvote count: 0
has body: In case someone would like to use maven: (plus here some info about WSDL binding styles) org.codehaus.mojo axistools-maven-plugin 1.4 generate-sources generate-sources wsdl2java ${basedir}/src/main/resources/wsdl org.apache.axis axis 1.4 org.apache.axis axis-jaxrpc 1.4 commons-logging commons-logging 1.2 commons-discovery commons-discovery 0.5 axis axis-wsdl4j 1.5.1 org.apache.axis axis-saaj 1.4 javax.activation activation 1.1.1 javax.mail mail 1.4.7
type: Answer
answers question: http://stackoverflow.com/q/412772
upvote count: 7
score: 7

http://stackoverflow.com/comment/104340379
type: AnswerComment
score: 4
type: Comment
comment on: http://stackoverflow.com/a/17220893
has text: Do it in `@BeforeEach`(JUnit5) or `@Before`(JUnit 4). Good and simple.

http://stackoverflow.com/a/585275
downvote count: 0
score: 1
has body: I think that Java only includes that stuff you really need... So there won't be any difference in the final compiled version using one or the other way.
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/585268

http://stackoverflow.com/comment/239116
has text: I try to avoid invalid input. With a regex I can validate all at once and tell the user that the input is not valid. But I would like to reject invalid characters. My problem is the complex regex. I think the only way to do this is a state machine. I want to automate the creation of the statemachine
score: 0
comment on: http://stackoverflow.com/q/392983
type: QuestionComment
type: Comment

http://stackoverflow.com/q/415924
has answer: http://stackoverflow.com/a/41172350
linked to: http://stackoverflow.com/q/2533097
has title: What is the purpose of long, double, byte, char in Java?
has answer: http://stackoverflow.com/a/415933
tagged with: language-features
type: Question
has answer: http://stackoverflow.com/a/415928
has answer: http://stackoverflow.com/a/415929
type: AnsweredQuestion
has body: So I'm learning java, and I have a question. It seems that the types int, boolean and string will be good for just about everything I'll ever need in terms of variables, except perhaps float could be used when decimal numbers are needed in a number. My question is, are the other types such as long, double, byte, char etc ever used in normal, everyday programming? What are some practical things these could be used for? What do they exist for?
accepted answer: http://stackoverflow.com/a/416617
has comment: http://stackoverflow.com/comment/240350
tagged with: java
downvote count: 4
tagged with: types
has answer: http://stackoverflow.com/a/415940
answer count: 7
tagged with: variables
has answer: http://stackoverflow.com/a/415936
favorite count: 0
score: 47
possible better answer: http://stackoverflow.com/a/415940
upvote count: 51
has answer: http://stackoverflow.com/a/416617

generics
tags question: http://stackoverflow.com/q/393366
tags question: http://stackoverflow.com/q/418064
tags question: http://stackoverflow.com/q/450807
tags question: http://stackoverflow.com/q/373363
tags question: http://stackoverflow.com/q/605859
tags question: http://stackoverflow.com/q/482674
tags question: http://stackoverflow.com/q/559704
tags question: http://stackoverflow.com/q/370601
tags question: http://stackoverflow.com/q/623978
tags question: http://stackoverflow.com/q/416540
tags question: http://stackoverflow.com/q/635629
tags question: http://stackoverflow.com/q/628094
tags question: http://stackoverflow.com/q/461106
tags question: http://stackoverflow.com/q/501277
tags question: http://stackoverflow.com/q/593478
tags question: http://stackoverflow.com/q/462297
tags question: http://stackoverflow.com/q/502614
tags question: http://stackoverflow.com/q/529085
tags question: http://stackoverflow.com/q/393793
tags question: http://stackoverflow.com/q/603827
tags question: http://stackoverflow.com/q/502994
type: Tag
tags question: http://stackoverflow.com/q/607250
tags question: http://stackoverflow.com/q/416760
tags question: http://stackoverflow.com/q/440262
tags question: http://stackoverflow.com/q/393853
tags question: http://stackoverflow.com/q/509076
tags question: http://stackoverflow.com/q/646899
tags question: http://stackoverflow.com/q/387646
tags question: http://stackoverflow.com/q/372250
tags question: http://stackoverflow.com/q/560867
tags question: http://stackoverflow.com/q/380952
tags question: http://stackoverflow.com/q/574529
tags question: http://stackoverflow.com/q/432006
tags question: http://stackoverflow.com/q/388439
tags question: http://stackoverflow.com/q/520527
tags question: http://stackoverflow.com/q/619031
tags question: http://stackoverflow.com/q/490091
tags question: http://stackoverflow.com/q/591004
tags question: http://stackoverflow.com/q/584596
tags question: http://stackoverflow.com/q/383888
tags question: http://stackoverflow.com/q/515575
tags question: http://stackoverflow.com/q/470198
tags question: http://stackoverflow.com/q/452635
tags question: http://stackoverflow.com/q/462077
tags question: http://stackoverflow.com/q/450520
tags question: http://stackoverflow.com/q/457777
tags question: http://stackoverflow.com/q/590405
tags question: http://stackoverflow.com/q/618148
tags question: http://stackoverflow.com/q/361266
tags question: http://stackoverflow.com/q/414408
tags question: http://stackoverflow.com/q/557663
tags question: http://stackoverflow.com/q/387091
tags question: http://stackoverflow.com/q/393286
tags question: http://stackoverflow.com/q/632033
tags question: http://stackoverflow.com/q/360766
tags question: http://stackoverflow.com/q/393252
tags question: http://stackoverflow.com/q/473862
tags question: http://stackoverflow.com/q/579031
tags question: http://stackoverflow.com/q/621117
tags question: http://stackoverflow.com/q/503721
tags question: http://stackoverflow.com/q/449103
tag name: generics
tags question: http://stackoverflow.com/q/362367
tags question: http://stackoverflow.com/q/426505
tags question: http://stackoverflow.com/q/517751
tags question: http://stackoverflow.com/q/504332

http://stackoverflow.com/comment/3342635
type: Comment
comment on: http://stackoverflow.com/a/3237204
type: AnswerComment
has text: Correct, but the purpose of this example was to show how do proper synchronizing, if we decided to use method synchronization.
score: 0

http://stackoverflow.com/q/629721
has answer: http://stackoverflow.com/a/629809
favorite count: 0
has body: I have a wysiwyg text area in a Java webapp. Users can input text and style it or paste some already HTML-formatted text. What I am trying to do is to linkify the text. This means, converting all possible URLs within text, to their "working counterpart", i.e. adding &lt; a href="...">...&lt; /a>. This solution works when all I have is plain text: String r = "http(s)?://([\\w+?\\.\\w+])+([a-zA-Z0-9\\~\\!\\@\\#\\$\\%\\^\\&amp;amp;\\*\\(\\)_\\-\\=\\+\\\\\\/\\?\\.\\:\\;\\'\\,]*)?"; Pattern pattern = Pattern.compile(r, Pattern.DOTALL | Pattern.UNIX_LINES | Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(comment); comment = matcher.replaceAll("&lt;a href=\"$0\"&gt;$0&lt;/a&gt;"); // group 0 is the whole expression But the problem is when there is some already formatted text, i.e. that it already has the &lt; a href="...">...&lt; /a> tags. So I am looking for some way for the pattern not to match whenever it finds the text between two HTML tags (&lt; a>). I have read this can be achieved with lookahead or lookbehind but I still can't make it work. I am sure I am doing it wrong because the regex still matches. And yes, I have been playing around/ debugging groups, changing $0 to $1 etc. Any ideas?
answer count: 5
has comment: http://stackoverflow.com/comment/443132
has title: Linkify text with regular expressions in Java
accepted answer: http://stackoverflow.com/a/629809
has comment: http://stackoverflow.com/comment/449129
has comment: http://stackoverflow.com/comment/442737
has comment: http://stackoverflow.com/comment/442786
has comment: http://stackoverflow.com/comment/442452
tagged with: regex
has answer: http://stackoverflow.com/a/629780
tagged with: java
upvote count: 7
has answer: http://stackoverflow.com/a/629779
type: Question
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/442657
has comment: http://stackoverflow.com/comment/442635
has comment: http://stackoverflow.com/comment/442730
score: 7
has answer: http://stackoverflow.com/a/629829
possible better answer: http://stackoverflow.com/a/629800
has answer: http://stackoverflow.com/a/629800
downvote count: 0
linked to: http://stackoverflow.com/q/287144

http://stackoverflow.com/a/489747
has body: Have a look at §13.11.x of the Spring MVC documentation. It covers annotation-based controller configuration, including data binding. It should be very useful to you. Good luck!
type: AcceptedAnswer
upvote count: 16
accepted answer of: http://stackoverflow.com/q/489703
answers question: http://stackoverflow.com/q/489703
type: Answer
downvote count: 0
score: 16

http://stackoverflow.com/a/403621
score: 12
downvote count: 0
upvote count: 12
has body: Are you talking about package-private protection in Java? That's the protection that is in effect by default for class members. It's useful occasionally if you got classes that interact intimately in a way that requires additional information or methods to be visible. Say you have a Sink class, and several classes can write to that. The Sink has a public method that accepts basic data-types, and a package private method that accepts raw byte arrays. You don't want to make that method public, because you consider it too low-level for its users, but you want to make your other classes (in the package of the Sink) writing to that Sink use it. So you make the method accepting the byte array package private, and classes of your package such as ByteStreamSource could use it. Now, your protection looks like this: User Code using the package User ------ | -----------------------------|----- package public Interface | | Sink &lt;- package priv. iface -&gt; Sources The package private interface is orthogonal to the public interface established by the public methods. Package private'ness increases encapsulation, because it encourages you not to make public what shouldn't be public. It's similar to the friend keyword in C++ and the internal keyword in C#.
type: Answer
answers question: http://stackoverflow.com/q/403583

http://stackoverflow.com/a/1898838
has comment: http://stackoverflow.com/comment/3319948
type: Answer
has body: There are a number of reasons why one might use Tomcat over Jetty: One is already familiar with Tomcat One is developing web applications that need to be easily transported to a Tomcat installation The Jetty developer documentation is actually spottier than Tomcat's (amazing!) Getting questions answered in the Jetty community can sometimes take years, as in 2007. see Embedding Jetty Important: After Jetty 6.1.*, each web application opens into its own JVM, so if you're trying to gain programmatic access between your standalone access and your web app, your only hope is via a web API. If it's an issue for you, Tomcat is an open source project who intellectual property is owned by the Apache Foundation, Jetty is open source but owned by a small private company (Mortbay Consulting) Point #5 has been important in my work. For example, I can gain direct access to a JSPWiki instance via Tomcat, but it's completely inaccessible when using Jetty. I asked for a solution to that in 2007 and haven't yet heard an answer. So I finally gave up and began using Tomcat 6. I've looked into Glassfish and Grizzly, but so far Tomcat is (amazingly) the most stable and well-documented web container (which isn't saying much really).
upvote count: 14
score: 12
has comment: http://stackoverflow.com/comment/10777220
downvote count: 2
answers question: http://stackoverflow.com/q/640022
has comment: http://stackoverflow.com/comment/3593644
has comment: http://stackoverflow.com/comment/19134701

http://stackoverflow.com/a/374587
answers question: http://stackoverflow.com/q/374445
type: Answer
accepted answer of: http://stackoverflow.com/q/374445
score: 3
upvote count: 3
has comment: http://stackoverflow.com/comment/202897
has comment: http://stackoverflow.com/comment/213724
has comment: http://stackoverflow.com/comment/202898
type: AcceptedAnswer
downvote count: 0
has body: I'd say use Red5 if you are ok with programming java - it might feel trivial to implement your own server but I'd guess you probably will find out that there are some more things to it than you are thinking of now. However, if you want to program in erlang and think you'll have loads of fun developing your own server by all means go for it! Is also depends on the goal of your project - do you have to demonstrate you can get an online game going (go for Red5), or do you have to demonstrate you can program a distributed multiuser game server? (go for your own project progammed in Erlang) BTW: I'm using http://www.smartfoxserver.com/ for one of my current projects

http://stackoverflow.com/comment/385337
score: 0
comment on: http://stackoverflow.com/a/547722
type: Comment
type: AnswerComment
has text: @oxbow: Yeap, the Java bean model never got the desired effect ( which was to have truly standalone beans ) but the idiom was been very beneficial, specially in webdevelopment.

http://stackoverflow.com/comment/387538
has text: Thanks, an additional question: If I retrieve an object from EHcache (say, an array), and modify it - will the object be updated in the cache? ie. is EHCache maintaining references to the objects?
type: Comment
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/575696

http://stackoverflow.com/comment/38150894
type: AnswerComment
comment on: http://stackoverflow.com/a/580532
type: Comment
score: 0
has text: @user3111525 boy - that's the $10M question... I use JSR296 and JSR295 still. If I were starting a project from scratch, I would take a serious look at JavaFX.

http://stackoverflow.com/a/415341
type: Answer
has body: By any chance, are you using EntityMode.DOM4J ? (i.e. Hibernate --> XML instead of Hibernate --> POJO). Nested relationships do not work without tweaking because the XML generator infinitely recurses where as POJOS handle it them fine. I can elaborate, but if you're not using DOM4J, then the issue is something else.
answers question: http://stackoverflow.com/q/362252
score: 0

http://stackoverflow.com/comment/34337532
type: AnswerComment
comment on: http://stackoverflow.com/a/430357
score: 10
type: Comment
has text: I guess this guy doesn't realize that writing to a binary file may cause a lot of pain when somebody has only 128 as the top value for a byte.

http://stackoverflow.com/comment/335167
type: Comment
has text: same version (some of the time) the question is updated above.
comment on: http://stackoverflow.com/a/521730
type: AnswerComment
score: 0

http://stackoverflow.com/a/28227133
upvote count: 1
has body: Here's one way I handle this when I override the equals() operation. public abstract class Section&lt;T extends Section&gt; extends Element&lt;Section&lt;T&gt;&gt; { Object attr1; /** * Compare one section object to another. * * @param obj the object being compared with this section object * @return true if this section and the other section are of the same * sub-class of section and their component fields are the same, false * otherwise */ @Override public boolean equals(Object obj) { if (obj == null) { // this exists, but obj doesn't, so they can't be equal! return false; } // prepare to cast... Section&lt;?&gt; other; if (getClass() != obj.getClass()) { // looks like we're comparing apples to oranges return false; } else { // it must be safe to make that cast! other = (Section&lt;?&gt;) obj; } // and then I compare attributes between this and other return this.attr1.equals(other.attr1); } } This seems to work in Java 8 (even compiled with -Xlint:unchecked)
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/509076
score: 1

inversion-of-control
tags question: http://stackoverflow.com/q/554201
tag name: inversion-of-control
tags question: http://stackoverflow.com/q/540729
tags question: http://stackoverflow.com/q/582098
tags question: http://stackoverflow.com/q/490354
tags question: http://stackoverflow.com/q/502994
type: Tag

http://stackoverflow.com/comment/298898
comment on: http://stackoverflow.com/a/482068
type: Comment
score: 0
type: AnswerComment
has text: +1: The right behavior is whatever the particular platform does for other (non-Java) programs.

http://stackoverflow.com/a/492333
score: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/492315
answers question: http://stackoverflow.com/q/492315
has body: You might consider codegenerating those 20 screens, much like scaffolding in Ruby does. As far as DAO is concerned, you might pull CUD operations to some generic IBusinessObjectDao, leaving specific R operations (querying by various parameters) to concrete DAO implementations.
type: AcceptedAnswer

http://stackoverflow.com/q/427306
tagged with: java
tagged with: multithreading
possible better answer: http://stackoverflow.com/a/427313
has answer: http://stackoverflow.com/a/427315
has body: Certain methods in Java will block until they can do something, like ServerSocket.accept() and InputStream.read(), but how it does this is not easy for me to find. The closest thing I can think of is a while() loop with a Thread.sleep() each time through, but the longer the sleep period, the less responsive the blocking, and the shorter the sleep, the more spinning that occurs. I have two questions: How do various standard functions, like the ones above, block? Native code? while() loops? Something else? How should I implement methods that block?
type: Question
has answer: http://stackoverflow.com/a/427324
score: 4
upvote count: 4
accepted answer: http://stackoverflow.com/a/427441
downvote count: 0
has answer: http://stackoverflow.com/a/427313
favorite count: 0
has title: Block without spinning in Java?
has answer: http://stackoverflow.com/a/427441
answer count: 4
type: AnsweredQuestion

http://stackoverflow.com/comment/34883754
has text: +1 for making the benchmark but -1 for the implementation. You're mostly measuring how long it takes to create a `BigDecimal`... or more exactly, the creation overhead is present in all benchmarks and may dominate them. Unless it's what you wanted (but why?), you'd need to pre-create the values and store in an array.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/14733855
score: 1

http://stackoverflow.com/a/367745
answers question: http://stackoverflow.com/q/359147
upvote count: 2
type: Answer
score: 2
has body: You could use a URLRewrite filter. It's like how mod_rewrite is for Apache's HTTP web server. http://tuckey.org/urlrewrite/ "Redirect one url ^/some/old/page\.html$ /very/new/page.html Tiny/Freindly url ^/zebra$ /big/ugly/url/1,23,56,23132.html "
downvote count: 0

http://stackoverflow.com/a/488849
type: AcceptedAnswer
downvote count: 0
has body: Your code looks sane. That's how you're creating a new connection. Probably the error is where you close it. You should close it in a finally block. Some additional questions. 1) Are you sure those 50 conections come from this program ? Maybe there are some others comming from your same office. To confirm this you would need to stop the program, and look again in your connection monitor. 2) Does your application uses many connection simultaneously? Probably its a peak when you're using 50 at the same time. If you can post the code where you close the connection. Chances are the problem is there. Additionally I would suggest you to use a connection pool. You can build one your self or you can see the results from this page: How many JDBC connections in Java?
type: Answer
accepted answer of: http://stackoverflow.com/q/485984
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/485984

http://stackoverflow.com/a/627194
downvote count: 0
answers question: http://stackoverflow.com/q/623845
type: Answer
score: 1
upvote count: 1
has body: Java (unfortunately) doesn't have anything like this, but Groovy does: assert '''hello, world''' == 'hello,\nworld' //triple-quotes for multi-line strings, adds '\n' regardless of host system assert 'hello, \ world' == 'hello, world' //backslash joins lines within string I really liked this feature of C# back when I did some .NET work. It was especially helpful for cut and pasted SQL queries.
has comment: http://stackoverflow.com/comment/53682524

http://stackoverflow.com/comment/382405
has text: Sounds great, I guess I'll just search and change every single place in my code where a certain property of a class is being assigned. So much easier than just writing a setter to begin with! Plus, everyone can get and set my other property! I'm pretty sure they shouldn't set it, but who cares!
score: 0
comment on: http://stackoverflow.com/a/554801
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/27711062
has text: I would be interested in your feedback on [my answer](http://stackoverflow.com/questions/533102/what-strategy-do-you-use-for-package-naming-in-java-projects-and-why/18792438#18792438)
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/533361
type: Comment

http://stackoverflow.com/comment/203667
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/375588
has text: Nearly a dup of http://stackoverflow.com/questions/374964/how-can-i-make-arbitrary-font-files-available-to-java
score: 0

http://stackoverflow.com/a/565888
has body: You may have a memory leak. I would first connect jconsole to your application to determine if it is permgen space or just heap memory and then proceed to figure out where the leak is. Can you give us some more information? What is going on in your application as the memory grows? If you are relatively new to diagnosing this kind of problem, I would recommend jprofiler. You can download a fully functional trial version and take memory snapshots to see what objects are in memory. You can use this information to figure out which objects are the source of the leak.
answers question: http://stackoverflow.com/q/565871
upvote count: 1
score: 0
has comment: http://stackoverflow.com/comment/377147
downvote count: 1
type: Answer

optimization
tags question: http://stackoverflow.com/q/469657
tags question: http://stackoverflow.com/q/611732
tags question: http://stackoverflow.com/q/623892
tags question: http://stackoverflow.com/q/633299
tags question: http://stackoverflow.com/q/463460
tags question: http://stackoverflow.com/q/435553
tags question: http://stackoverflow.com/q/510061
tags question: http://stackoverflow.com/q/547934
tags question: http://stackoverflow.com/q/475516
tag name: optimization
tags question: http://stackoverflow.com/q/507987
tags question: http://stackoverflow.com/q/594722
tags question: http://stackoverflow.com/q/373397
tags question: http://stackoverflow.com/q/558978
tags question: http://stackoverflow.com/q/523531
type: Tag

http://stackoverflow.com/a/552325
score: 3
answers question: http://stackoverflow.com/q/552320
type: Answer
has body: I suspect what she meant was that the visibility of the field itself should be protected (or private) so that access only occurs through the getter. In the case of a collection, you may also want to do as @cletus suggests and return a copy of the collection if you don't want it to be modified outside the class. EDIT Based on your edit, she probably meant both. class Foo { protected string[] bar = &lt;some array contents&gt;; public string[] getBar() { return bar; } }
has comment: http://stackoverflow.com/comment/364077
downvote count: 1
upvote count: 4

http://stackoverflow.com/a/641913
has body: I'm not a threading expert, but isn't the whole point of threads that they are independent from each other - and non-deterministic?
answers question: http://stackoverflow.com/q/641906
upvote count: 1
type: Answer
downvote count: 0
score: 1

http://stackoverflow.com/comment/12771825
type: AnswerComment
has text: DbUtils is a helper library, so your still using JDBC. Have a look at their site for some of the advantages of using DbUtils. http://commons.apache.org/dbutils/
type: Comment
comment on: http://stackoverflow.com/a/642279
score: 0

http://stackoverflow.com/q/501588
has answer: http://stackoverflow.com/a/501598
has answer: http://stackoverflow.com/a/501599
type: Question
accepted answer: http://stackoverflow.com/a/501593
type: AnsweredQuestion
upvote count: 5
tagged with: java
has answer: http://stackoverflow.com/a/501623
answer count: 6
score: 5
has answer: http://stackoverflow.com/a/501633
has title: Returning a string entered as reverse text in Java
has answer: http://stackoverflow.com/a/10269511
downvote count: 0
tagged with: string
has body: I'm trying to make a method that returns a string of words in opposite order. IE/ "The rain in Spain falls mostly on the" would return: "the on mostly falls Spain in rain The" For this I am not supposed to use any built in Java classes just basic Java. So far I have: lastSpace = stringIn.length(); for (int i = stringIn.length() - 1; i &gt;= 0; i--){ chIn = stringIn.charAt(i); if (chIn == ' '){ word = stringIn.substring(i + 1, lastSpace); stringOut.concat(word); lastS = i; } } word = stringIn.substring(0,lastSpace); stringOut.concat(word); return stringOut; My problem is when stringOut is returned to its caller it always is a blank string. Am I doing something wrong? Maybe my use of string.concat()?
favorite count: 0
possible better answer: http://stackoverflow.com/a/501633
has answer: http://stackoverflow.com/a/501593
has comment: http://stackoverflow.com/comment/316763

http://stackoverflow.com/q/579925
score: 2
has answer: http://stackoverflow.com/a/584643
type: AnsweredQuestion
tagged with: nonblocking
has comment: http://stackoverflow.com/comment/391885
tagged with: algorithm
has answer: http://stackoverflow.com/a/580001
tagged with: java
has answer: http://stackoverflow.com/a/579946
has answer: http://stackoverflow.com/a/580572
accepted answer: http://stackoverflow.com/a/580572
type: Question
answer count: 8
has comment: http://stackoverflow.com/comment/397250
downvote count: 0
has answer: http://stackoverflow.com/a/584558
favorite count: 0
has answer: http://stackoverflow.com/a/580023
has answer: http://stackoverflow.com/a/579939
possible better answer: http://stackoverflow.com/a/579946
has answer: http://stackoverflow.com/a/584710
has title: Nonblocking algorithm to generate unique negative numbers
has body: I recently refactored a piece of code used to generate unique negative numbers. edit: Multiple threads obtain these ids and add as keys to a DB; numbers need to be negative to be easily identifiable -at the end of a test session they're removed from the DB. My Java algorithm looks like this: private final Set&lt;Integer&gt; seen = Collections.synchronizedSet(new HashSet&lt;Integer&gt;()); public Integer generateUniqueNegativeIds() { int result = 0; do { result = random.nextInt(); if (result &gt; 0) { result *= -1; } } while (!seen.add(result)); return result; } The code structure above, with its speculative addition to the set and "retry" loop, makes me think there's an equivalent nonblocking algorithm that replaces the synchronized set with any of the atomic variables. I made a few attempts to re-write using atomic variables but all failed the multithread attack test. Is there an elegant nonblocking equivalent? edit: for curiosity's sake here's a flawed attempt using an atomic integer as a guard private final AtomicInteger atomi = new AtomicInteger(0); public Integer generateUniqueNegativeIdsWithAtomicAlgo() { boolean added = false; int result = 0; do { result = random.nextInt(); if (result &gt; 0) { result *= -1; } if (atomi.compareAndSet(0, result)) { added = cache.add(result); } } while (!added); return atomi.getAndSet(0); } edit: test harness below: public static void main(String[] args) { final int NUMBER_OF_THREADS = 10000; final Set&lt;Integer&gt; uniques = Collections.synchronizedSet(new HashSet&lt;Integer&gt;()); final List&lt;Integer&gt; positives = Collections.synchronizedList(new ArrayList&lt;Integer&gt;()); final NegativeUniqueIdGenerator nuig = new NegativeUniqueIdGenerator(); Thread[] workers = new Thread[NUMBER_OF_THREADS]; long start = System.nanoTime(); for (int i = 0; i &lt; workers.length; i++) { Runnable runnable = new Runnable() { public void run() { int number = nuig.generateUniqueNegativeIds(); if (number &gt; 0) { positives.add(number); } u…
tagged with: atomic
has comment: http://stackoverflow.com/comment/397259
upvote count: 2
has comment: http://stackoverflow.com/comment/392963
has comment: http://stackoverflow.com/comment/396602

http://stackoverflow.com/a/438198
has body: (1) Depends on what you are looking for. You better check for yourself. I am not ware of any assistive technologies in place, but I wasn't looking for them either. Regarding the two specific capabilities you asked for: (a) Notifications are part of the API. (b) I am not aware that you can be notified on applications being started. (2/3) I don't the general amount of RAM that is available for apps, but I can give you an practical answer. Your app's process will be killed if it tries to grab more than 16MB. I don't know the exact clock speed, but on the android-dev list it was mentioned that the G1 doesn't run at full speed. The rationale behind it is that among other things more speed would run down the battery much more quickly. Just another practical matter regarding this question. If you want to discuss the constraints go to the android-dev list.
score: 2
downvote count: 0
upvote count: 2
answers question: http://stackoverflow.com/q/437517
type: Answer

http://stackoverflow.com/comment/6682761
type: AnswerComment
comment on: http://stackoverflow.com/a/4321449
type: Comment
score: 0
has text: That seems to me like a very clever way as it requires to create each object only once - compared to the XmlAdpater solution where you first create the bound type class instance and then copy all attributes to the value class instance. But the question is: Does this work also with JREs different to Sun/Oracle like OpenJDK?

http://stackoverflow.com/a/627111
has body: If you really don't want to use interfaces (and trust me you do!) you could use reflection to get the method you want to have called and then pass it to the one that needs to do the calling. This is as close to a C function pointer as you are going to get. Reflection will be slower (probably) than the interface way of doing it (but that won't matter unless it is called frequently). Reflection will not have the compile time type checking that the interface way of doing it has (which means you could crash at runtime). Reflection will be uglier code than the interface way of doing it as well. But if you really really really want to simulate C function pointers then reflection is as close as you are going to get.
type: Answer
score: 2
answers question: http://stackoverflow.com/q/626669
downvote count: 0
upvote count: 2

http://stackoverflow.com/comment/234538
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/403959
has text: This is a good solution, but does not work for non-string constants (I tried - several ways). That's why I ended up going with the less elegant ant replace method. -Richard
type: Comment

http://stackoverflow.com/a/25865742
has comment: http://stackoverflow.com/comment/93419583
score: 9
downvote count: 1
has body: public String escapeXml(String s) { return s.replaceAll("&amp;", "&amp;amp;").replaceAll("&gt;", "&amp;gt;").replaceAll("&lt;", "&amp;lt;").replaceAll("\"", "&amp;quot;").replaceAll("'", "&amp;apos;"); }
upvote count: 10
type: Answer
has comment: http://stackoverflow.com/comment/44715855
has comment: http://stackoverflow.com/comment/105133987
answers question: http://stackoverflow.com/q/439298
has comment: http://stackoverflow.com/comment/84524695

http://stackoverflow.com/comment/321668
comment on: http://stackoverflow.com/a/507278
score: 0
type: AnswerComment
type: Comment
has text: The regexp parser will go through your string character by character. At position 0 it will replace 'B' with 'e', at position 1 it will replace '' with 'e', and so on.

http://stackoverflow.com/q/596958
favorite count: 0
tagged with: css
answer count: 4
tagged with: highlight
has answer: http://stackoverflow.com/a/597091
has answer: http://stackoverflow.com/a/597122
upvote count: 5
downvote count: 0
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/597581
accepted answer: http://stackoverflow.com/a/597581
tagged with: java
has title: How can I highlight java code via CSS?
type: Question
has body: I saw some cool code highlighting that looked like code in Eclipse, however I can't find it. :( Do you know any cool java code highlight css?
possible better answer: http://stackoverflow.com/a/597122
has answer: http://stackoverflow.com/a/4693316
score: 5

http://stackoverflow.com/a/519198
has body: A tenth of a second difference? Noise from startup time (alone) will swamp that. Write something that runs for a minute or two.
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/332653
type: Answer
answers question: http://stackoverflow.com/q/519099
upvote count: 1
has comment: http://stackoverflow.com/comment/332630

http://stackoverflow.com/comment/88719311
comment on: http://stackoverflow.com/a/409571
type: AnswerComment
score: 0
type: Comment
has text: what do you mean by _*handle*_ when you say "_You should only catch exceptions that you can actually handle._"

http://stackoverflow.com/comment/235242
comment on: http://stackoverflow.com/a/410322
score: 0
has text: Still, a large part of the JVM is written in C. (Or, was when I last looked at it.)
type: AnswerComment
type: Comment

http://stackoverflow.com/a/582592
has body: I believe you want GenerationType.IDENTITY. MySql does not use a table or sequence for generating the Id value.
score: 30
has comment: http://stackoverflow.com/comment/394688
upvote count: 30
type: Answer
has comment: http://stackoverflow.com/comment/109151434
accepted answer of: http://stackoverflow.com/q/582526
has comment: http://stackoverflow.com/comment/394664
answers question: http://stackoverflow.com/q/582526
has comment: http://stackoverflow.com/comment/471803
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/415115
comment on: http://stackoverflow.com/q/602614
type: Comment
type: QuestionComment
has text: In fact, I think that before the edit, this question might have been a duplicate. I don't think it is now, though.
score: 0

http://stackoverflow.com/a/75160923
downvote count: 0
has body: What you want is a List of some kind of object. I personally do not like using generic Pair classes. They have too many disadvantages: They are not very expressive. They provide no contextual information besides their type arguments. They prevent you from using primitive types You can't apply any constraints on keys or values (besides their type, of course). They force you to carry the verbose type parameter declaration in many places (though this is somewhat mitigated by var and &lt;&gt;) I prefer using ad-hoc classes. While a few years ago, this came with annoying boilerplate, this is no longer the case. Here is a couple of alternatives that makes the declaration of the class really easy: Java 14 and above: use a record class record TypedCount(String type, int count) {} There, that's it. You get toString(), equals(), and hashCode() for free Before Java 14: use lombok's @Value annotation @Value class TypedCount { String type; int count; } That's also it. Lombok automatically makes the fields private final, constructors, getters, toString() and equals(). While this requires you to add lombok as a dependency, this is only a compile-time dependency that generates the code for you. The lombok library does not need to be in your classpath at runtime.
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/521171

http://stackoverflow.com/a/428966
has comment: http://stackoverflow.com/comment/29265193
has comment: http://stackoverflow.com/comment/48583474
has comment: http://stackoverflow.com/comment/24102486
type: Answer
has comment: http://stackoverflow.com/comment/252891
has comment: http://stackoverflow.com/comment/40525426
upvote count: 762
has body: Something like this should do the trick: String dt = "2008-01-01"; // Start date SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); c.setTime(sdf.parse(dt)); c.add(Calendar.DATE, 1); // number of days to add dt = sdf.format(c.getTime()); // dt is now the new date
downvote count: 3
has comment: http://stackoverflow.com/comment/1039478
has comment: http://stackoverflow.com/comment/83996800
has comment: http://stackoverflow.com/comment/16332507
score: 759
answers question: http://stackoverflow.com/q/428918
has comment: http://stackoverflow.com/comment/90180509
has comment: http://stackoverflow.com/comment/128156511
has comment: http://stackoverflow.com/comment/128123256
has comment: http://stackoverflow.com/comment/45156974

http://stackoverflow.com/q/643346
has answer: http://stackoverflow.com/a/653739
has answer: http://stackoverflow.com/a/645180
tagged with: java
has comment: http://stackoverflow.com/comment/456718
has answer: http://stackoverflow.com/a/645174
has answer: http://stackoverflow.com/a/643610
has answer: http://stackoverflow.com/a/643533
has answer: http://stackoverflow.com/a/643598
type: Question
has answer: http://stackoverflow.com/a/644426
has body: i have to work away from my desktop computer from time to time (for instance on trips). It is a low end laptop. I can use Eclipse but it is awfully slow. Is there a better choice? If possible not something like vi oder emacs. Laptop: 512 MB DDR RAM Intel Pentium M 760 2.0 GHz Windows XP SP3 There is no possibility to add more RAM
has answer: http://stackoverflow.com/a/643371
tagged with: ide
upvote count: 13
has answer: http://stackoverflow.com/a/643389
has answer: http://stackoverflow.com/a/643358
has answer: http://stackoverflow.com/a/643380
has answer: http://stackoverflow.com/a/643507
tagged with: windows
has answer: http://stackoverflow.com/a/643357
linked to: http://stackoverflow.com/q/646117
accepted answer: http://stackoverflow.com/a/643357
possible better answer: http://stackoverflow.com/a/643358
favorite count: 0
has answer: http://stackoverflow.com/a/643428
answer count: 20
has answer: http://stackoverflow.com/a/646228
has answer: http://stackoverflow.com/a/643586
score: 13
has title: What is a good IDE for Java programming on a low end laptop?
has comment: http://stackoverflow.com/comment/456687
has answer: http://stackoverflow.com/a/643391
has answer: http://stackoverflow.com/a/643398
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/456778
has answer: http://stackoverflow.com/a/645213
has answer: http://stackoverflow.com/a/643367
downvote count: 0

http://stackoverflow.com/comment/50299675
score: 3
type: AnswerComment
comment on: http://stackoverflow.com/a/31114423
has text: This Answer duplicates the content of multiple Answers including [the accepted Answer](http://stackoverflow.com/a/428966/642706) from three years ago. Please delete your Answer or edit to add value.
type: Comment

http://stackoverflow.com/q/531524
favorite count: 0
has body: Iam trying to create window service for my jar application. Application needs an argument and System property value while runtime. I dont know where to give argument value and system variable value in wrapper.conf file. please help me. I am getting the below error wrapper | Launching a JVM... jvm 1 | WrapperManager: Initializing... jvm 1 | jvm 1 | WrapperSimpleApp Usage: jvm 1 | java org.tanukisoftware.wrapper.WrapperSimpleApp {app_class} [app_arguments] jvm 1 | jvm 1 | Where: jvm 1 | app_class: The fully qualified class name of the application to run. jvm 1 | app_arguments: The arguments that would normally be passed to the jvm 1 | application. wrapper | JVM exited while loading the application.
upvote count: 2
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/3564065
score: 2
has title: Where to pass runtime argument in wrapper.conf file in java service wrapper?
tagged with: java-service-wrapper
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/531679
answer count: 2
downvote count: 0

http://stackoverflow.com/q/558839
has comment: http://stackoverflow.com/comment/371028
answer count: 1
has comment: http://stackoverflow.com/comment/371011
has comment: http://stackoverflow.com/comment/371044
has comment: http://stackoverflow.com/comment/370296
has comment: http://stackoverflow.com/comment/371146
has comment: http://stackoverflow.com/comment/371284
tagged with: arrays
has comment: http://stackoverflow.com/comment/370570
has comment: http://stackoverflow.com/comment/374009
has comment: http://stackoverflow.com/comment/370239
accepted answer: http://stackoverflow.com/a/558852
has comment: http://stackoverflow.com/comment/370246
has comment: http://stackoverflow.com/comment/370303
has body: I have written a page here on using arrays as proper objects with their own methods instead of relying on helper classes like Arrays, Arrays and ArrayUtils. ints.sort(); // instead of Arrays.sort(ints); // instead of int[] onemore = ArrayUtils.add(ints, 8); int[] onemore = ints.add(8); I am sure I am not the first with this idea but I have had trouble searching for others who have written about this before. Can anyone help me with some references on this topic? Can you add comments if you have a reference on why this is a bad idea or a good idea if you have one? Link deleted. Adding main points This follows from the idea of Project Coin OVERVIEW Provide a two sentence or shorter description of these five aspects of the feature: FEATURE SUMMARY: Should be suitable as a summary in a language tutorial. Treat array as objects with their own methods rather than values to be passed to helper methods. This leads to more natural coding and gives the methods more immediacy. e.g. through code completion. MAJOR ADVANTAGE: What makes the proposal a favorable change? It bring OO programming to arrays , supporting methods already available and written. MAJOR BENEFIT: Why is the platform better if the proposal is adopted? Object Orientated consistency for arrays. MAJOR DISADVANTAGE: There is always a cost. Someone has to write it and test it. ALTERNATIVES: Can the benefits and advantages be had some way without a language change? Call helper methods. EXAMPLES Show us the code! SIMPLE EXAMPLE: Show the simplest possible program utilizing the new feature. int[] ints = {5,4,3,2,1}; ints.sort(); // instead of Arrays.sort(ints); int pos = ints.indexOf(5); // instead of Arrays.asList(ints).indexOf(5); or ArraysUtils.indexOf(ints, 5); ints.reverse(); // instead of Arrays.reverse(ints); Array array = ints; // cast to super class. int length = array.getLength(); // instead of Array.getLength(array); Object n = array.get(3); // instead of Array.get(array, 3); array.set(3, 7); // instead of …
has comment: http://stackoverflow.com/comment/370235
score: 2
has comment: http://stackoverflow.com/comment/370227
type: AnsweredQuestion
tagged with: java-7
has comment: http://stackoverflow.com/comment/371288
has comment: http://stackoverflow.com/comment/372402
has comment: http://stackoverflow.com/comment/370165
favorite count: 0
has comment: http://stackoverflow.com/comment/370180
has comment: http://stackoverflow.com/comment/371040
has title: Arrays as proper objects
upvote count: 8
type: Question
has comment: http://stackoverflow.com/comment/370263
has comment: http://stackoverflow.com/comment/371290
has comment: http://stackoverflow.com/comment/371066
has comment: http://stackoverflow.com/comment/370279
has comment: http://stackoverflow.com/comment/370265
downvote count: 6
has comment: http://stackoverflow.com/comment/370258
has comment: http://stackoverflow.com/comment/370244
tagged with: oop
has comment: http://stackoverflow.com/comment/370318
has answer: http://stackoverflow.com/a/558852
has comment: http://stackoverflow.com/comment/370249
tagged with: java
has comment: http://stackoverflow.com/comment/370291

http://stackoverflow.com/comment/238521
score: 0
type: AnswerComment
type: Comment
has text: CruiseControl is another popular CI server. It can be integrated with Ant, Coberatura, jUnit etc. (as, probably, can Hudson, I'm sure).
comment on: http://stackoverflow.com/a/413837

http://stackoverflow.com/q/424895
has body: My company is trying to migrate away from a .NET application to something that is purely web-based, and very "ajaxy". The original .NET app is fairly interactive, roughly equivalent to Google Maps as far as user interaction is concerned (zoom, pan, annotate features on a vector map). Our .NET developer is really taken with Flex2. I'll admit to having a pretty strong Java bias. I also have about a year's worth of experience with GWT, and can get things done pretty quickly with it. Our codebase is mostly J2EE, so GWT seems a natural fit to me. I have zero experience with Flex, so I really can't make a recommendation for or against it Our primary interests in selecting a framework are the following: futureproof works on all major browsers fast & responsive user experience code should be unit testable code must be maintainable speed & ease of development supports vector graphics of some sort (SVG a plus) Care to weigh in on the pros &amp; cons of these two technologies, or even recommend a third option?
has comment: http://stackoverflow.com/comment/3603016
has answer: http://stackoverflow.com/a/637293
has answer: http://stackoverflow.com/a/2067784
type: Question
has answer: http://stackoverflow.com/a/2377984
score: 37
has comment: http://stackoverflow.com/comment/337890
has answer: http://stackoverflow.com/a/425100
favorite count: 0
has comment: http://stackoverflow.com/comment/4919655
has title: GWT vs Flex vs?
tagged with: ajax
upvote count: 38
has answer: http://stackoverflow.com/a/425133
answer count: 12
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/751956
has answer: http://stackoverflow.com/a/535071
tagged with: apache-flex
downvote count: 1
tagged with: gwt
has answer: http://stackoverflow.com/a/651848
has answer: http://stackoverflow.com/a/426456
has answer: http://stackoverflow.com/a/652069
tagged with: java
has answer: http://stackoverflow.com/a/425246
has answer: http://stackoverflow.com/a/4157486

http://stackoverflow.com/comment/438098
score: 0
type: Comment
has text: Added a stacktrace. The source code is not included, so debugging isn't really possible here.
type: QuestionComment
comment on: http://stackoverflow.com/q/625302

http://stackoverflow.com/a/10854850
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/527703
has body: The problem with Yahoo and Google data is that it violates terms of service if you're using it for commercial use. When your site/app is still small it's not biggie, but as soon as you grow a little you start getting cease and desists from the exchanges. A licensed solution example is FinancialContent: http://www.financialcontent.com/json.php or Xignite
score: 4
upvote count: 4

http://stackoverflow.com/comment/285718
type: Comment
score: 0
type: AnswerComment
has text: Yeah, that's a given, but it doesn't **all** have to be in C++.
comment on: http://stackoverflow.com/a/467782

http://stackoverflow.com/a/520868
has comment: http://stackoverflow.com/comment/334512
has comment: http://stackoverflow.com/comment/62214805
has comment: http://stackoverflow.com/comment/26854618
has comment: http://stackoverflow.com/comment/29805393
type: Answer
has comment: http://stackoverflow.com/comment/28450387
downvote count: 1
has comment: http://stackoverflow.com/comment/4316756
has body: DBCP is out of date and not production grade. Some time back we conducted an in-house analysis of the two, creating a test fixture which generated load and concurrency against the two to assess their suitability under real life conditions. DBCP consistently generated exceptions into our test application and struggled to reach levels of performance which C3P0 was more than capable of handling without any exceptions. C3P0 also robustly handled DB disconnects and transparent reconnects on resume whereas DBCP never recovered connections if the link was taken out from beneath it. Worse still DBCP was returning Connection objects to the application for which the underlying transport had broken. Since then we have used C3P0 in 4 major heavy-load consumer web apps and have never looked back. UPDATE: It turns out that after many years of sitting on a shelf, the Apache Commons folk have taken DBCP out of dormancy and it is now, once again, an actively developed project. Thus my original post may be out of date. That being said, I haven't yet experienced this new upgraded library's performance, nor heard of it being de-facto in any recent app framework, yet.
has comment: http://stackoverflow.com/comment/58158599
has comment: http://stackoverflow.com/comment/40429415
upvote count: 184
has comment: http://stackoverflow.com/comment/334748
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/520585
has comment: http://stackoverflow.com/comment/60604485
score: 183
answers question: http://stackoverflow.com/q/520585

http://stackoverflow.com/q/379675
answer count: 3
has answer: http://stackoverflow.com/a/71495995
has body: First, to make my job explaining a bit easier, here's some of my code: JSpinner spin = new JSpinner(); JFormattedTextField text = getTextField(spin); text.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { // Do stuff... } }); ... private JFormattedTextField getTextField(JSpinner spinner) { JComponent editor = spinner.getEditor(); if (editor instanceof JSpinner.DefaultEditor) { return ((JSpinner.DefaultEditor )editor).getTextField(); } else { System.err.println( "Unexpected editor type: " + spinner.getEditor().getClass() + " isn't a descendant of DefaultEditor" ); return null; } } So as you can see, I got that far. And indeed, when I type in a value into the text field component of the spinner (JFormattedTextField), and THEN press ENTER, it works. What I want now is to be able to have the text field respond to ENTER without having to manually type in a new value (which sorta defeats the purpose of making a spinner out of it). How do I do that?
has answer: http://stackoverflow.com/a/379787
tagged with: swing
accepted answer: http://stackoverflow.com/a/379787
possible better answer: http://stackoverflow.com/a/37754348
has answer: http://stackoverflow.com/a/37754348
type: AnsweredQuestion
tagged with: jspinner
upvote count: 5
tagged with: java
tagged with: listeners
tagged with: jtextfield
type: Question
score: 5
downvote count: 0
favorite count: 0
has title: Getting ENTER to work with a JSpinner the way it does with a JTextField

http://stackoverflow.com/a/10847102
upvote count: 3
answers question: http://stackoverflow.com/q/634798
type: Answer
score: 3
downvote count: 0
has body: Although the JGoodies Binding addresses this problem with the Delayed* classes, you may consider using an approach with standard Swing features. If you use a SwingWorker, you can publish elements in the background and process them in the EDT. The SwingWorker process will get chunks of published data and reduces the number of EDT changes.

http://stackoverflow.com/q/585071
answer count: 8
tagged with: c#
has answer: http://stackoverflow.com/a/585077
downvote count: 0
has answer: http://stackoverflow.com/a/19684793
score: 10
has answer: http://stackoverflow.com/a/10981999
has answer: http://stackoverflow.com/a/585181
has answer: http://stackoverflow.com/a/585079
has answer: http://stackoverflow.com/a/585087
has title: User Interface Design Tool
tagged with: user-interface
has answer: http://stackoverflow.com/a/585081
favorite count: 0
has answer: http://stackoverflow.com/a/585102
has body: I'm searching for a User Interface Design tool to visualize a possible GUI in a documentation. I must not generate code. I know that Microsoft Visio provides a functionality. But are there any alternatives? Which software do you use for visualizing a GUI? PS. Another well-known tool is The Pencil Project.
accepted answer: http://stackoverflow.com/a/585087
type: AnsweredQuestion
tagged with: java
upvote count: 10
possible better answer: http://stackoverflow.com/a/585077
type: Question

http://stackoverflow.com/a/1461443
downvote count: 0
answers question: http://stackoverflow.com/q/641387
has body: I had exactly the same problem. Setting connection-url as the following resolved the problem. jdbc:as400://[systemname]/[schema];extended dynamic=true;package=jbpkg;package cache=true;package library=jboss;errors=full
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/comment/299675
comment on: http://stackoverflow.com/a/483068
type: AnswerComment
has text: Additional information has been provided in the question. Thanks
score: 0
type: Comment

http://stackoverflow.com/a/2269835
has body: If you go with the solution mentioned by duffymo pointing to Vinny Carpenter's blog, I have a tip. There was one area that caused my container to hang indefinitely while contacting localhost (specifically in the private connect() method). Using the following hack was my workaround: private void connect(final String urlString) { HttpURLConnection conn; try { final URL url = new URL(urlString); conn = (HttpURLConnection)url.openConnection(); conn.setConnectTimeout(5000); //time it out quickly - otherwise hangs forever //seems to be an issue hitting localhost //will still precompile the page conn.setReadTimeout(100); conn.setAllowUserInteraction(true); conn.getInputStream(); conn.disconnect(); } catch (SocketTimeoutException e) { log.debug(e); } catch (IOException ioe) { log.error(ioe); } } Setting a timeout and ignoring the SocketTimeoutException worked (though admittedly not the best solution). Also, using this procedure means that you would need to specify the JSPs in web.xml. This was sufficient for my needs.
type: Answer
downvote count: 0
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/497830

http://stackoverflow.com/a/622240
has body: I agree that their website is confusing and hard to find the download link. When you go to their website, click "Current release build (JSR-231 1.1.1)" or just scroll to the very bottom of the page and you'll see the files. Download the corresponding file for whichever system you're using.
score: 3
downvote count: 0
upvote count: 3
type: Answer
answers question: http://stackoverflow.com/q/615899

http://stackoverflow.com/a/376647
downvote count: 1
score: 2
upvote count: 3
answers question: http://stackoverflow.com/q/373833
has body: I wouldn't recommended this is you've got a lot of "thinking" in your app, but using XSLT could be better (and potentially faster with XSLT-to-bytecode compilation) than Java manipulation.
type: Answer
has comment: http://stackoverflow.com/comment/544554
has comment: http://stackoverflow.com/comment/42483809

http://stackoverflow.com/a/1007046
answers question: http://stackoverflow.com/q/460446
has body: Pure virtual functions are in C++. C# uses Interfaces to serve the same purpose, so I'd suggest you go that route.
upvote count: 0
score: -2
type: Answer
downvote count: 2

http://stackoverflow.com/a/8346859
score: 3
downvote count: 0
answers question: http://stackoverflow.com/q/531096
has body: SpringSource itself have a good number of good sample applications available here: https://src.springframework.org/svn/spring-samples/ The best one to get started with here is probably: http://static.springsource.org/docs/petclinic.html
type: Answer
upvote count: 3

http://stackoverflow.com/a/460373
answers question: http://stackoverflow.com/q/460364
upvote count: 8
type: Answer
has body: You need to put the .jar file into your classpath when compiling/running your code. Then you just use standard imports of the classes in the .jar.
score: 8
downvote count: 0

http://stackoverflow.com/a/8895537
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/481446
type: Answer
upvote count: 1
has body: After lots of consideration, I find the following code best: MyResource resource = null; try { resource = new MyResource(); resource.doSomethingFancy(); resource.close(); resource = null; } finally { closeQuietly(resource) } void closeQuietly(MyResource a) { if (a!=null) try { a.close(); } catch (Exception e) { //ignore } } That code guarantees following: The resource is freed when the code finished Exceptions thrown when closing the resource are not consumed without processing them. The code does not try to close the resource twice, no unnecessary exception will be created.
has comment: http://stackoverflow.com/comment/11489077
has comment: http://stackoverflow.com/comment/23151099

http://stackoverflow.com/a/538271
has body: If I remember correctly, JSplitPanes always respect the minimum size of their components. Try explicitly setting the minimum size of the ChatView to (0,0) and see if that helps. If so, you can then look at each of the components inside it to see which is causing the problem.
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/350593
type: Answer
has comment: http://stackoverflow.com/comment/350590
accepted answer of: http://stackoverflow.com/q/538240
answers question: http://stackoverflow.com/q/538240
score: 4
upvote count: 4

http://stackoverflow.com/comment/405433
type: Comment
has text: Makes sense to me. I definitely recommend that you look at GlazedLists - it completely changed how I write code involving lists.
comment on: http://stackoverflow.com/a/589316
type: AnswerComment
score: 0

http://stackoverflow.com/a/16062731
score: -3
type: Answer
has body: I've actually in front of me a code which looks like this: for (int i = offset; i &lt; offset + length; i++) { char append = (char) (data[i] &amp; 0xFF); buffer.append(append); } ... for (int i = offset; i &lt; offset + length; i++) { char append = (char) (data[i] &amp; 0xFF); buffer.append(append); } ... for (int i = offset; i &lt; offset + length; i++) { char append = (char) (data[i] &amp; 0xFF); buffer.append(append); } So, relying on compiler abilities, I can assume there would be only one stack allocation for i and one for append. Then everything would be fine except the duplicated code. As a side note, java applications are known to be slow. I never tried to do profiling in java but I guess the performance hit comes mostly from memory allocation management.
has comment: http://stackoverflow.com/comment/22924108
downvote count: 3
answers question: http://stackoverflow.com/q/377763
has comment: http://stackoverflow.com/comment/23005460
upvote count: 0
has comment: http://stackoverflow.com/comment/23114426

http://stackoverflow.com/comment/61855125
score: 0
type: Comment
has text: He corrected the problem of 2 threads. So the tutorial is correct now.
comment on: http://stackoverflow.com/a/564806
type: AnswerComment

http://stackoverflow.com/comment/389178
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/577300
type: Comment
has text: the right question should probably be what is the difference bettween all those ways of getting a class loader and getting the resource.

http://stackoverflow.com/comment/58366698
has text: @RobertChristian good point, if you have to use an API which is not really fit for purpose, you need to use the API you have. +1
comment on: http://stackoverflow.com/a/484987
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/28913916
score: 1
comment on: http://stackoverflow.com/a/420714
type: AnswerComment
has text: I don't think the JVM version is a problem. The serialVersionUID is created *by the compiler* if you don't specify one.
type: Comment

http://stackoverflow.com/a/1197668
has comment: http://stackoverflow.com/comment/136139689
answers question: http://stackoverflow.com/q/585599
upvote count: 56
has body: This error happens on your side and NOT the other side. If the other side reset the connection, then the exception message should say: java.net.SocketException reset by peer The cause is the connection inside HttpClient is stale. Check stale connection for SSL does not fix this error. Solution: dump your client and recreate.
downvote count: 1
score: 55
type: Answer

http://stackoverflow.com/comment/316155
score: 0
type: AnswerComment
type: Comment
has text: You'll end up having to type nearly the same thing in the XML configuration files as you would in this case most of the time.
comment on: http://stackoverflow.com/a/500755

http://stackoverflow.com/comment/38189979
type: AnswerComment
has text: @JonSkeet Oh yes, I get you now, I completely overlooked the fact that you cant close over variables like that in 1.0, my bad! :)
comment on: http://stackoverflow.com/a/407294
score: 0
type: Comment

http://stackoverflow.com/a/399773
type: Answer
has body: You can also use the following HTML markup in your HTML: &lt;link rel="icon" type="image/gif" href="/img/image.gif"&gt; Most newer browsers should support it and I think it's generally a more clean way since you can use any image type/name/location you want.
upvote count: 24
downvote count: 0
score: 24
has comment: http://stackoverflow.com/comment/49358212
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/399286
answers question: http://stackoverflow.com/q/399286

http://stackoverflow.com/a/606884
upvote count: 1
has body: Read this, it will most likely be a solution to your problem It explains how you can get the size of the window and manage it's scrolling in JavaScript.
type: Answer
answers question: http://stackoverflow.com/q/592024
downvote count: 0
score: 1

http://stackoverflow.com/comment/40327128
has text: The OP is not necessarily debugging to System.out (which isn't necessarily conveniently accessible for a webserver)--he/she might need to send the original XML over a socket, store it somewhere, or calculate its statistics.
comment on: http://stackoverflow.com/a/25784117
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/538589
answers question: http://stackoverflow.com/q/517527
downvote count: 0
has body: After doing more research on this problem I came to the following conclusion/solution. I'm not sure if it's 100% correct..but it works. I put all of my configuration in the dispatcher-servlet.xml file. So instead of having a disptacher-servlet.xml and application-context.xml. The dispatcher-servlet.xml is loaded by the application (contextConfigLocation). Within the dispatcher-servlet.xml I import my security-context.xml and datasource-context.xml. Afer that, everything works.
type: Answer
score: 2
upvote count: 2

http://stackoverflow.com/comment/266168
has text: But if you promise to use just that one I'll give you a note that says "ok" ;)
type: Comment
comment on: http://stackoverflow.com/a/444501
score: 0
type: AnswerComment

http://stackoverflow.com/comment/301340
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/474535
score: 0
has text: Noticed you accepted my answer.. if you're actually using that code and find any problems with it or anything that it's lacking please let me know! email me from my website: http://www.vacant-nebula.com/contact/kip/

http://stackoverflow.com/a/570246
has comment: http://stackoverflow.com/comment/381702
has body: For each major release there is a large doc package, e.g. here for JDK 1.6. (I hope the link is correct, picked it out of the docs I downloaded a while ago. Can't connect to SUN either from here.)
score: 4
type: Answer
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/570218

http://stackoverflow.com/comment/208140
score: 1
has text: Yes, but IF you don't have any library at hand, AND the XML is very simple, I'd rather not depend on yet another library. Often you will need such a library anyway, and in that case you should use it.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/380652

http://stackoverflow.com/a/28466327
score: 52
has comment: http://stackoverflow.com/comment/63215901
answers question: http://stackoverflow.com/q/606352
has body: Wire Mock seems to offer a solid set of stubs and mocks for testing external web services. @Rule public WireMockRule wireMockRule = new WireMockRule(8089); @Test public void exactUrlOnly() { stubFor(get(urlEqualTo("/some/thing")) .willReturn(aResponse() .withHeader("Content-Type", "text/plain") .withBody("Hello world!"))); assertThat(testClient.get("/some/thing").statusCode(), is(200)); assertThat(testClient.get("/some/thing/else").statusCode(), is(404)); } It can integrate with spock as well. Example found here.
has comment: http://stackoverflow.com/comment/78444650
downvote count: 0
upvote count: 52
type: Answer

http://stackoverflow.com/comment/430434
type: AnswerComment
score: 0
type: Comment
has text: See http://download.java.net/media/jogl/builds/nightly/javadoc_public/javax/media/opengl/glu/GLU.html
comment on: http://stackoverflow.com/a/617487

http://stackoverflow.com/comment/4475416
comment on: http://stackoverflow.com/a/3430957
type: AnswerComment
has text: "ResultSet.getTimestamp and PreparedStatement.setTimestamp both say in their docs that they transform dates to/from the current JVM timezone by default when reading and writing from/to the database." Do you have a reference? I don't see any mention of this in the Java 6 Javadocs for these methods. According to http://stackoverflow.com/questions/4123534/before-writing-a-java-date-to-an-sql-timestamp-column-does-jdbc-translate-the-da/4124620#4124620, how these methods apply the time zone to a given `Date` or `Timestamp` is JDBC driver dependent.
type: Comment
score: 2

http://stackoverflow.com/a/414233
upvote count: 5
score: 4
type: Answer
downvote count: 1
answers question: http://stackoverflow.com/q/413898
has body: Can also think of static members not having a "this" pointer. They are shared among all instances.

http://stackoverflow.com/q/516798
favorite count: 0
tagged with: python
accepted answer: http://stackoverflow.com/a/516827
has title: Mixed language source directory layout
tagged with: java
has body: We are running a large project with several different languages: Java, Python, PHP, SQL and Perl. Until now people have been working in their own private repositories, but now we want to merge the entire project in a single repository. The question now is: how should the directory structure look? Should we have separate directories for each language, or should we separate it by component/project? How well does python/perl/java cope with a common directory layout?
type: Question
type: AnsweredQuestion
upvote count: 5
has answer: http://stackoverflow.com/a/516827
answer count: 2
score: 5
tagged with: sql
possible better answer: http://stackoverflow.com/a/518493
downvote count: 0
tagged with: directory
has answer: http://stackoverflow.com/a/518493

http://stackoverflow.com/q/562404
has answer: http://stackoverflow.com/a/562878
score: 3
upvote count: 3
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/562494
has answer: http://stackoverflow.com/a/562433
has title: configuring "plumbing" at runtime
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/374175
answer count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/562455
has answer: http://stackoverflow.com/a/563331
tagged with: design-patterns
has comment: http://stackoverflow.com/comment/376584
has body: This is kind of a design-patterns question in Java. I am designing a java .jar file to act as a frameworks for managing and processing a certain form of data. I want the end user to be able to dictate the "plumbing" configuration, within certain constraints, in a certain way. The pieces are producers and/or consumers, and I know how to implement them, but the connections are confusing to me... here's a nonsense example that sort of parallels my application. Suppose I have implemented these elements: AppleTree => produces apples ApplePieMaker => consumes apples, produces apple pies ApplePress => consumes apples, produces apple cider AppleSave => stores apples, apple pies, or apple cider into a file AppleLoad => "reconstitutes" apples, apple pies, or apple cider from a file that was produced by AppleSave ApplePieMonitor => displays apple pies on the screen in a GUI format, as they are produced Now I want the user to be able to specify things like: AppleTree | ApplePress | AppleSave cider1.sav (produce apples, make them into cider, save them to a file) AppleTree | AppleSave apple1.sav (produce apples, save them to a file) AppleLoad apple1.sav | ApplePieMaker | ApplePieMonitor (take saved apples, make them into pies, display the results on the screen in a GUI) (not sure how to illustrate this, but might be specified as follows) AppleTree tree1, ApplePieMaker piemaker1 &lt; tree1, AppleSave apples.sav &lt; tree1, AppleSave @select(*.sav) &lt; piemaker1, ApplePress press1 &lt; tree1, AppleSave cider.sav &lt; press1, ApplePieMonitor piemon1 &lt; piemaker1 (produce apples, make them into pies and cider, save the apples, pies and cider to separate files, with the pies going to a file selected by the user at runtime and the others going to predetermine files, and also display the pies on the screen in a GUI) So I have a rough idea of how to architect a configuration file: namely to structure the thing into elements that have at most 1 input and at most 1 output, and then for …

http://stackoverflow.com/a/630034
type: Answer
answers question: http://stackoverflow.com/q/629804
score: 3
has body: Trove offers a few advantages. smaller memory footprint, it doesn't used Map.Entry objects you can use hash strategies instead keys for maps, this saves memory and means you don't need to define a new key each time you want to cache an object on a new set of its attributes it has primitive collection types think it has some form of internal iterator That said, a lot has been done to improve jdk collections since trove was written. It's the hashing strategies that make it appealing to me though... Google for trove and read their overview.
upvote count: 3
downvote count: 0

http://stackoverflow.com/comment/401125
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/588578
type: Comment
has text: (or you could run it by hand :)

http://stackoverflow.com/comment/366974
comment on: http://stackoverflow.com/a/550336
type: AnswerComment
score: 0
type: Comment
has text: oh and btw, file.exist() == true

http://stackoverflow.com/comment/422456
has text: I edited the above into your post, I hope, I got it right. Thanks!
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/609981
type: Comment

http://stackoverflow.com/q/364114
has answer: http://stackoverflow.com/a/3734547
has answer: http://stackoverflow.com/a/364188
has answer: http://stackoverflow.com/a/364139
has answer: http://stackoverflow.com/a/5741365
has answer: http://stackoverflow.com/a/12746819
has answer: http://stackoverflow.com/a/39922969
has answer: http://stackoverflow.com/a/7623805
tagged with: java
has answer: http://stackoverflow.com/a/37221449
has comment: http://stackoverflow.com/comment/19150950
has comment: http://stackoverflow.com/comment/32867117
has answer: http://stackoverflow.com/a/16473926
has answer: http://stackoverflow.com/a/4958434
has answer: http://stackoverflow.com/a/9533639
type: Question
answer count: 25
has answer: http://stackoverflow.com/a/6592740
has answer: http://stackoverflow.com/a/14377305
has answer: http://stackoverflow.com/a/3743204
has answer: http://stackoverflow.com/a/21738885
downvote count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/35210338
score: 746
upvote count: 747
has answer: http://stackoverflow.com/a/7748177
linked to: http://stackoverflow.com/q/1729054
has answer: http://stackoverflow.com/a/39905292
has answer: http://stackoverflow.com/a/426176
has answer: http://stackoverflow.com/a/764684
linked to: http://stackoverflow.com/q/19065666
has answer: http://stackoverflow.com/a/33349540
tagged with: maven-2
has answer: http://stackoverflow.com/a/16904771
has title: Can I add jars to Maven 2 build classpath without installing them?
has answer: http://stackoverflow.com/a/79154337
has answer: http://stackoverflow.com/a/426267
has answer: http://stackoverflow.com/a/59565386
type: UnansweredQuestion
has body: Maven 2 is driving me crazy during the experimentation / quick and dirty mock-up phase of development. I have a pom.xml file that defines the dependencies for the web-app framework I want to use, and I can quickly generate starter projects from that file. However, sometimes I want to link to a 3rd party library that doesn't already have a pom.xml file defined, so rather than create the pom.xml file for the 3rd party lib by hand and install it, and add the dependency to my pom.xml, I would just like to tell Maven: "In addition to my defined dependencies, include any jars that are in /lib too." It seems like this ought to be simple, but if it is, I am missing something. Any pointers on how to do this are greatly appreciated. Short of that, if there is a simple way to point maven to a /lib directory and easily create a pom.xml with all the enclosed jars mapped to a single dependency which I could then name / install and link to in one fell swoop would also suffice.
linked to: http://stackoverflow.com/q/6571022

http://stackoverflow.com/a/497102
has body: Literals enclosed in double quotes, e.g. "foo", are strings, whereas single-quoted literals, e.g. 'c', are chars. In terms of concatenation behaviour, there'll be no discernible difference. Nevertheless, it's worth remembering that strings and chars aren't interchangeable in all scenarios, and you can't have a single-quoted string made up of multiple characters.
has comment: http://stackoverflow.com/comment/313044
has comment: http://stackoverflow.com/comment/312941
score: 27
upvote count: 27
downvote count: 0
answers question: http://stackoverflow.com/q/497081
type: Answer

http://stackoverflow.com/a/463568
score: 0
type: Answer
has body: There's also the option of SOAP but that's probably overkill assuming you've simply got two processes on the same machine. Still I mention it for sake of completeness.
answers question: http://stackoverflow.com/q/463240

http://stackoverflow.com/comment/291935
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/474470
type: Comment
has text: You could do it with a regular hashmap. You'd just need to define an object to use as the Key that has both coordinates in it.

http://stackoverflow.com/q/623618
has title: What is the definition of "accessor method"?
has answer: http://stackoverflow.com/a/30857410
has answer: http://stackoverflow.com/a/623628
has answer: http://stackoverflow.com/a/623631
upvote count: 18
downvote count: 1
favorite count: 0
tagged with: accessor
has answer: http://stackoverflow.com/a/623626
has answer: http://stackoverflow.com/a/16203032
possible better answer: http://stackoverflow.com/a/623628
has answer: http://stackoverflow.com/a/623632
type: AnsweredQuestion
tagged with: java
score: 17
has answer: http://stackoverflow.com/a/26395114
tagged with: definition
has answer: http://stackoverflow.com/a/1095588
type: Question
answer count: 8
has body: I've been having an argument about the usage of the word "accessor" (the context is Java programming). I tend to think of accessors as implicitly being "property accessors" -- that is, the term implies that it's more or less there to provide direct access to the object's internal state. The other party insists that any method that touches the object's state in any way is an accessor. I know you guys can't win the argument for me, but I'm curious to know how you would define the term. :)
accepted answer: http://stackoverflow.com/a/623631

http://stackoverflow.com/comment/413081
score: 0
type: AnswerComment
type: Comment
has text: What database? I've had trouble with Postgres taking itself off on a side jaunt cleaning itself up, and thus periodically introducing a wait.
comment on: http://stackoverflow.com/a/600623

http://stackoverflow.com/a/495286
answers question: http://stackoverflow.com/q/495217
has comment: http://stackoverflow.com/comment/311367
has body: You could use Card Layout for this. A Card Layout can contain many components (JPanel in your case), and you can switch between them. It's easy to add a card layout in the netbeans palette. Doc: http://java.sun.com/j2se/1.4.2/docs/api/java/awt/CardLayout.html
has comment: http://stackoverflow.com/comment/311082
score: 5
downvote count: 0
upvote count: 5
has comment: http://stackoverflow.com/comment/311376
type: Answer

http://stackoverflow.com/q/383888
has answer: http://stackoverflow.com/a/383903
has answer: http://stackoverflow.com/a/815351
has answer: http://stackoverflow.com/a/815641
has answer: http://stackoverflow.com/a/815392
downvote count: 0
answer count: 7
tagged with: generics
favorite count: 0
has body: Suppose I have this: class test&lt;T&gt; { private T[] elements; private int size; public test(int size) { this.size = size; elements = new T[this.size]; } } It seems this isn't possible because the compiler doesn't know what constructor to call once it tries to replace the generics code or something. What I'm wondering is, how would I go about doing this? I imagine it is possible, given how easily done it is in C++. Edit: Sorry I forgot the [] in the elements declaration.
has answer: http://stackoverflow.com/a/383895
has answer: http://stackoverflow.com/a/383892
score: 9
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/18137988
tagged with: java
type: Question
upvote count: 9
tagged with: arrays
has title: What is the easiest alternative to a generic array in Java?

http://stackoverflow.com/a/537956
type: Answer
answers question: http://stackoverflow.com/q/537921
upvote count: 1
score: 1
has body: You can't do it without iterating through the entire keySet. You can use a TreeMap with a sort criteria that will sort by some combination of the two integer properties if you're sure that you won't have other entries that have the same value of those integer properties, and then you can find the first match directly and then just iterate from there to the first non-match. But it seems unlikely you can achieve those conditions. Because collections have pretty low overhead (everything is stored by reference), I would consider making two sorted collections, possibly TreeSets, one sorted by the first property and one sorted by the second, and then pick out all the values that meet the criteria from both collections and union them together.
downvote count: 0

http://stackoverflow.com/comment/208012
score: 1
comment on: http://stackoverflow.com/a/380418
type: AnswerComment
type: Comment
has text: Note that the names of inner classes are not specified so they need not be of this form and it would be a bug to rely on that. But that being said, I've not yet seen a compiler that generates different names.

http://stackoverflow.com/comment/300891
comment on: http://stackoverflow.com/a/484180
has text: That code is part of the HttpClient API, which requires an InputStream.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/205678
score: 0
type: Comment
comment on: http://stackoverflow.com/a/377824
type: AnswerComment
has text: Yep. If you decompile your code with JAD you'll find that all the compile-time constants have been inlined. I would vote for the properties file or the static methods described.

http://stackoverflow.com/a/502252
has comment: http://stackoverflow.com/comment/23329092
has comment: http://stackoverflow.com/comment/38908466
upvote count: 242
has comment: http://stackoverflow.com/comment/122172602
has comment: http://stackoverflow.com/comment/12804785
has comment: http://stackoverflow.com/comment/24191867
has comment: http://stackoverflow.com/comment/55076472
has comment: http://stackoverflow.com/comment/55076580
answers question: http://stackoverflow.com/q/500508
type: Answer
downvote count: 3
score: 239
has body: Sometimes it's nice to be explicit (for readability) that the variable doesn't change. Here's a simple example where using final can save some possible headaches: public void setTest(String test) { test = test; } If you forget the 'this' keyword on a setter, then the variable you want to set doesn't get set. However, if you used the final keyword on the parameter, then the bug would be caught at compile time.
has comment: http://stackoverflow.com/comment/24192094

http://stackoverflow.com/a/636149
has body: Either Collections.emptyMap(), or if type inference doesn't work in your case, Collections.&lt;String, String&gt;emptyMap()
score: 7
upvote count: 7
answers question: http://stackoverflow.com/q/636126
downvote count: 0
type: Answer

http://stackoverflow.com/a/29543555
downvote count: 0
has comment: http://stackoverflow.com/comment/47241671
answers question: http://stackoverflow.com/q/481446
type: Answer
upvote count: 6
has body: As of Java 7 you no longer need to explicitly close resources in a finally block instead you can use try-with-resources syntax. The try-with-resources statement is a try statement that declares one or more resources. A resource is an object that must be closed after the program is finished with it. The try-with-resources statement ensures that each resource is closed at the end of the statement. Any object that implements java.lang.AutoCloseable, which includes all objects which implement java.io.Closeable, can be used as a resource. Assume the following code: try( Connection con = null; Statement stmt = con.createStatement(); Result rs= stmt.executeQuery(QUERY);) { count = rs.getInt(1); } If any exception happens the close method will be called on each of these three resources in opposite order in which they were created. It means the close method would be called first for ResultSetm then the Statement and at the end for the Connection object. It's also important to know that any exceptions that occur when the close methods is automatically called are suppressed. These suppressed exceptions can be retrieved by getsuppressed() method defined in the Throwable class. Source: https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html
score: 6
has comment: http://stackoverflow.com/comment/47241760
has comment: http://stackoverflow.com/comment/47240703
has comment: http://stackoverflow.com/comment/47241410

http://stackoverflow.com/a/5978742
downvote count: 0
answers question: http://stackoverflow.com/q/556807
type: Answer
score: 2
upvote count: 2
has body: The main issue is that java is a language that is written and designed to talk to a VM. I suppose it would be possible, but all you would be left is a very poorly optimized application with a self translating layer doing what the VM already does. I mean, sure, it is possible, it still wouldn't be a solution for anything i could think of. If your looking to make your sluggish java app native, maybe your thinking too hard, just use an application like JET, its actually quite good, and will give you the benefits a native app would bring. Of course if the VM is already doing what the app is asking it to do just as well as native code could(it happens.. sometimes :P) it might change nothing. Java to c#, tho, sounds more reasonable, as both the languages are written in similar ways, talking to a framework as such, but this would still leave code very much unoptimized as code written from scratch for a particular framework can not be bested.

http://stackoverflow.com/a/413241
type: Answer
has body: Are you sure that you are importing the correct Logger class? A common error is to import java.util.Logger instead of the Logger from the log4j package.
upvote count: 13
score: 12
downvote count: 1
answers question: http://stackoverflow.com/q/413226

http://stackoverflow.com/q/462898
tagged with: orm
has answer: http://stackoverflow.com/a/468434
upvote count: 10
has body: I have two related clases JPA-annotated. Alarm and Status. One Alarm can have one Status. What I need is to be able to delete one Status and "propagate" a null value to the Alarms that are in that Status that has been deleted. That is, I need the foreign key to be defined as "on delete set null". @Entity public class Alarm { @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="sequence") @SequenceGenerator(name="sequence", sequenceName="alarm_pk_seq") private Integer id; @OneToOne(cascade=CascadeType.ALL) @JoinColumn(name="idStatus") private Status status; // get/set } @Entity public class Status { @Id @Column(name="idStatus") private Integer id; private String description; // get/set } Example: Before: STATUS id description 1 new 2 assigned 3 closed ALARMS id status 1 1 2 2 3 2 After (deleting the status with id=2) STATUS id description 1 new 3 closed ALARMS id status 1 1 2 NULL 3 NULL I am using Hibernate and PostgreSQL, automatically generating the database from source code. I have tried with every possible CascadeType with no success. Is there anything wrong in the code ? Is it possible to do it with JPA ?
has answer: http://stackoverflow.com/a/12903347
answer count: 5
type: UnansweredQuestion
tagged with: jpa
downvote count: 0
favorite count: 0
has title: JPA not generating "on delete set null" FK restrictions
has answer: http://stackoverflow.com/a/520839
has answer: http://stackoverflow.com/a/968556
tagged with: foreign-keys
type: Question
has answer: http://stackoverflow.com/a/477827
score: 10
tagged with: java
tagged with: hibernate

http://stackoverflow.com/q/463029
tagged with: resources
type: Question
tagged with: c#
accepted answer: http://stackoverflow.com/a/463078
answer count: 3
has title: Initializing disposable resources outside or inside try/finally
has body: I have seen two ways of acquiring and disposing resources. Either: Resource resource = getResource(); try { /* do something with resource */ } finally { resource.close(); } or: Resource resource = null; try { resource = getResource(); /* do something with resource */ } finally { if (resource != null) resource.close(); } I was wondering which style is preferable. The first one avoids the if condition, while the second one (I presume) handles the case of thread abort right after the assignment but before entering the try block. What other pros and cons do these styles have over each other? Which one should I preferably use?
favorite count: 0
possible better answer: http://stackoverflow.com/a/463089
has answer: http://stackoverflow.com/a/463089
downvote count: 2
score: 5
has answer: http://stackoverflow.com/a/463078
upvote count: 7
has answer: http://stackoverflow.com/a/463075
tagged with: coding-style
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/a/7873389
answers question: http://stackoverflow.com/q/371538
has comment: http://stackoverflow.com/comment/21216875
has comment: http://stackoverflow.com/comment/55099964
has comment: http://stackoverflow.com/comment/17783359
has comment: http://stackoverflow.com/comment/10535411
has comment: http://stackoverflow.com/comment/55146655
has comment: http://stackoverflow.com/comment/21224111
has comment: http://stackoverflow.com/comment/55156755
type: Answer
has comment: http://stackoverflow.com/comment/10554096
has comment: http://stackoverflow.com/comment/21707041
has comment: http://stackoverflow.com/comment/36560406
has comment: http://stackoverflow.com/comment/10506487
upvote count: 41
has comment: http://stackoverflow.com/comment/21227461
has comment: http://stackoverflow.com/comment/54096662
has comment: http://stackoverflow.com/comment/21738198
has body: If performance and code size matter, check out greenDAO. I'm the author of it, and my motivation to create another ORM was to avoid reflection in the hotspots. It turned out that greenDAO can be up to 4 times faster than ORMLite. Checkout the feature page for details.
score: 40
downvote count: 1
has comment: http://stackoverflow.com/comment/11880388

http://stackoverflow.com/q/417285
score: 8
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/417317
has answer: http://stackoverflow.com/a/417313
has answer: http://stackoverflow.com/a/417382
has answer: http://stackoverflow.com/a/417317
type: Question
has answer: http://stackoverflow.com/a/417571
has answer: http://stackoverflow.com/a/417315
has answer: http://stackoverflow.com/a/10252955
downvote count: 0
answer count: 7
accepted answer: http://stackoverflow.com/a/417382
tagged with: synchronization
favorite count: 0
has answer: http://stackoverflow.com/a/649740
upvote count: 8
has title: Equivalent code for instance method synchronization in Java
has body: While discussing a Java synchronization question, someone made a comment that the following snippets are not equivalent (and may compile to different bytecodes): public synchronized void someMethod() { //stuff } and public void someMethod() { synchronized (this) { //stuff } } Are they equivalent?

http://stackoverflow.com/a/540824
type: Answer
score: 0
has comment: http://stackoverflow.com/comment/353002
answers question: http://stackoverflow.com/q/540729
has body: maybe lazy-init will do it, but i think spring will at least check if the bean implementation class is available at creation of the application context

http://stackoverflow.com/q/387646
type: AnsweredQuestion
score: 3
has body: Why is the compiler unable to infer the correct type for the result from Collections.emptySet() in the following example? import java.util.*; import java.io.*; public class Test { public interface Option&lt;A&gt; { public &lt;B&gt; B option(B b, F&lt;A,B&gt; f); } public interface F&lt;A,B&gt; { public B f(A a); } public Collection&lt;String&gt; getColl() { Option&lt;Integer&gt; iopt = null; return iopt.option(Collections.emptySet(), new F&lt;Integer, Collection&lt;String&gt;&gt;() { public Collection&lt;String&gt; f(Integer i) { return Collections.singleton(i.toString()); } }); } } Here's the compiler error message: knuttycombe@knuttycombe-ubuntu:~/tmp/java$ javac Test.java Test.java:16: &lt;B&gt;option(B,Test.F&lt;java.lang.Integer,B&gt;) in Test.Option&lt;java.lang.Integer&gt; cannot be applied to (java.util.Set&lt;java.lang.Object&gt;, &lt;anonymous Test.F&lt;java.lang.Integer,java.util.Collection&lt;java.lang.String&gt;&gt;&gt;) return iopt.option(Collections.emptySet(), new F&lt;Integer, Collection&lt;String&gt;&gt;() { ^ 1 error Now, the following implementation of getColl() works, of course: public Collection&lt;String&gt; getColl() { Option&lt;Integer&gt; iopt = null; Collection&lt;String&gt; empty = Collections.emptySet(); return iopt.option(empty, new F&lt;Integer, Collection&lt;String&gt;&gt;() { public Collection&lt;String&gt; f(Integer i) { return Collections.singleton(i.toString()); } }); } and the whole intent of the typesafe methods on Collections is to avoid this sort of issue with the singleton collections (as opposed to using the static variables.) So is the compiler simply unable to perform inference across multiple levels of generics? What's going on?
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/387661
type: Question
has answer: http://stackoverflow.com/a/387755
upvote count: 3
has answer: http://stackoverflow.com/a/387683
tagged with: generics
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/387662
possible better answer: http://stackoverflow.com/a/387755
tagged with: collections
accepted answer: http://stackoverflow.com/a/387661
has title: Why can't the Java compiler figure this out?

java-ws
tags question: http://stackoverflow.com/q/456865
tag name: java-ws
type: Tag
tags question: http://stackoverflow.com/q/596043

http://stackoverflow.com/q/494171
has answer: http://stackoverflow.com/a/779741
upvote count: 1
answer count: 7
tagged with: java
has body: in JBPM, can I have (technically) multiple transitions going out from a Task Node? If Yes, is it a good practice? Any help would be useful.
has answer: http://stackoverflow.com/a/1078078
has answer: http://stackoverflow.com/a/495450
type: UnansweredQuestion
tagged with: jboss
downvote count: 0
tagged with: workflow
score: 1
tagged with: jboss-tools
has answer: http://stackoverflow.com/a/802320
favorite count: 0
tagged with: jbpm
type: Question
has answer: http://stackoverflow.com/a/24976446
has answer: http://stackoverflow.com/a/495188
has title: JBPM: Multiple transitions going out from a Task Node
has answer: http://stackoverflow.com/a/53115964

http://stackoverflow.com/a/7783200
upvote count: 1
has body: This question is platform dependent. On my system, Debian Linux with OpenBox, JOptionPanes always show up on taskbar. I can't prevent any JDialog from appearing on taskbar.
downvote count: 0
answers question: http://stackoverflow.com/q/542844
type: Answer
has comment: http://stackoverflow.com/comment/9497450
score: 1
has comment: http://stackoverflow.com/comment/9515162

http://stackoverflow.com/comment/4838383
comment on: http://stackoverflow.com/q/638087
has text: There is also Oracle's Java 6 for ARM: http://www.oracle.com/technetwork/java/embedded/overview/index.html
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/a/8838787
upvote count: 74
score: 74
downvote count: 0
answers question: http://stackoverflow.com/q/527610
has comment: http://stackoverflow.com/comment/38855998
type: Answer
has comment: http://stackoverflow.com/comment/38846619
has body: From Java 6 onwards, keytool has an -importkeystore option, which should be able to convert a JKS store into a PKCS#12 store (.p12/.pfx): keytool -importkeystore -srckeystore thekeystore.jks \ -srcstoretype JKS \ -destkeystore thekeystore.pfx \ -deststoretype PKCS12 It will ask you to enter a password for source and destination (jks, pfx) files

http://stackoverflow.com/comment/456794
score: 0
type: Comment
has text: It feels the other way around for me, Eclipse feels a lot faster (and should be) since it's using SWT correct?
comment on: http://stackoverflow.com/a/643358
type: AnswerComment

http://stackoverflow.com/comment/228029
comment on: http://stackoverflow.com/a/402839
score: 0
type: Comment
has text: Yeah. XML. Not what I need unless I start going in a new direction with my project. Still, it's nice to know about.
type: AnswerComment

svn
tags question: http://stackoverflow.com/q/420013
tags question: http://stackoverflow.com/q/603786
tags question: http://stackoverflow.com/q/589021
type: Tag
tags question: http://stackoverflow.com/q/559326
tags question: http://stackoverflow.com/q/577868
tags question: http://stackoverflow.com/q/408110
tag name: svn

http://stackoverflow.com/comment/139731985
comment on: http://stackoverflow.com/a/428328
score: 0
type: AnswerComment
type: Comment
has text: Preferences is great but when you import Preferences there is no way to preview or even know reliably what was imported, since there is only one global Preferences.importPreferences(FileInputStream fis) method. Adding change listeners to know what was imported is cryptic and in my hands I could not get it to work. I'm here because I need to inspect a Preferences xml to know what I would get by importing.

http://stackoverflow.com/a/442252
upvote count: 5
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/440036
score: 5
has body: Keep in mind that threads are just one of several possible models for dealing with "concurrency". Python, for example, has one of the most advanced asynchronous (event based) non-threaded models in Twisted. Non-blocking models are quite powerful and are used as alternatives to threads in most of the highest scaling apps out there (eg. nginx, lighttpd). Your assumption that other popular languages need threads may simply be a symptom of a java centric (and hence thread-centric) world view. Take a look at the C10K page for a slightly dated but highly informative look at several models for how to handle large volumes of concurrent requests.

http://stackoverflow.com/a/453554
has comment: http://stackoverflow.com/comment/5093424
score: 55
type: Answer
has comment: http://stackoverflow.com/comment/48797799
has comment: http://stackoverflow.com/comment/137562709
downvote count: 0
upvote count: 55
has body: To some extent, random number generators are horses for courses. The Random class implements an LCG with reasonably chosen parameters. But it still exhibits the following features: fairly short period (2^48) bits are not equally random (see my article on randomness of bit positions) will only generate a small fraction of combinations of values (the famous problem of "falling in the planes") If these things don't matter to you, then Random has the redeeming feature of being provided as part of the JDK. It's good enough for things like casual games (but not ones where money is involved). There are no weak seeds as such. Another alternative which is the XORShift generator, which can be implemented in Java as follows: public long randomLong() { x ^= (x &lt;&lt; 21); x ^= (x &gt;&gt;&gt; 35); x ^= (x &lt;&lt; 4); return x; } For some very cheap operations, this has a period of 2^64-1 (zero is not permitted), and is simple enough to be inlined when you're generating values repeatedly. Various shift values are possible: see George Marsaglia's paper on XORShift Generators for more details. You can consider bits in the numbers generated as being equally random. One main weakness is that occasionally it will get into a "rut" where not many bits are set in the number, and then it takes a few generations to get out of this rut. Other possibilities are: combine different generators (e.g. feed the output from an XORShift generator into an LCG, then add the result to the output of an XORShift generator with different parameters): this generally allows the weaknesses of the different methods to be "smoothed out", and can give a longer period if the periods of the combined generators are carefully chosen add a "lag" (to give a longer period): essentially, where a generator would normally transform the last number generated, store a "history buffer" and transform, say, the (n-1023)th. I would say avoid generators that use a stupid amount of memory to give you a period longer than you…
has comment: http://stackoverflow.com/comment/5068812
has comment: http://stackoverflow.com/comment/48814812
has comment: http://stackoverflow.com/comment/93925964
accepted answer of: http://stackoverflow.com/q/453479
has comment: http://stackoverflow.com/comment/48629079
answers question: http://stackoverflow.com/q/453479
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/5094087
has comment: http://stackoverflow.com/comment/48714201

http://stackoverflow.com/comment/232453
score: 0
type: AnswerComment
type: Comment
has text: This was work that had been previously but I don't believe there is a reason for this.
comment on: http://stackoverflow.com/a/407502

http://stackoverflow.com/a/461643
type: Answer
score: 2
has body: What I do in my tests: I keep a DB version somewhere In the first test, I tear down the whole DB and build it from scratch I run each schema update in an individual test I run the "update DB" module as an individual test (must not do anything because all changes have been applied already). Optionally, I tear down the DB again and run this once. I load the test data into the DB (some of the tests above will do this if they fix data errors). Now, the test DB is ready for the "real" (application) tests. After each of the application tests, I roll back the current transaction so the test DB never changes after setup. To make testing faster, I usually have three test suites: One which contains on the DB setup, one which contains only the application tests and one which contains the other two suites. This allows me to quickly reset the test DB and run a single test from the app suite.
downvote count: 0
upvote count: 2
answers question: http://stackoverflow.com/q/461581

http://stackoverflow.com/comment/111251978
comment on: http://stackoverflow.com/a/517955
type: AnswerComment
score: 0
type: Comment
has text: In short words, use the strictfp, when you need the same floating calculation each time on different CPU model. Note that this can be overkill if your floating number is not that big.

http://stackoverflow.com/comment/44673008
comment on: http://stackoverflow.com/a/2179757
type: Comment
score: 2
has text: @LorDalCol Dollar is actually a Java library
type: AnswerComment

http://stackoverflow.com/q/637960
score: 0
tagged with: continuous-integration
tagged with: .net
has answer: http://stackoverflow.com/a/638001
accepted answer: http://stackoverflow.com/a/638001
possible better answer: http://stackoverflow.com/a/640162
has answer: http://stackoverflow.com/a/638365
has answer: http://stackoverflow.com/a/637967
answer count: 5
tagged with: cruisecontrol
has title: Continuous build with .NET and Java projects on a single machine
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/644648
has answer: http://stackoverflow.com/a/640162
type: Question
tagged with: java
has body: Is it possible to set up continuous build of projects written in .NET and Java on single build server with single set of applications? I've seen CruiseControl has support for both world but as far as I know these are two separate applications. Should I go with a separate machine to build Java projects (a machine for .NET projects is already set up)?

http://stackoverflow.com/comment/223654
type: Comment
has text: @Patrick: True. "Because it is noncopyable, it is safer than shared_ptr or std::auto_ptr for pointers which should not be copied." However, it wouldn't work in the situation described by the second bullet.
comment on: http://stackoverflow.com/a/397267
type: AnswerComment
score: 0

http://stackoverflow.com/a/403888
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/403825
has body: Yes it makes sense. However implicit in your question is that the wrong (for you) framework can be more pain than it's worth - and that's true. There is a world of difference between some heavy J2EE framework and something light and cheerful like grails.
upvote count: 2
type: Answer

http://stackoverflow.com/comment/36961929
has text: @TofuBeer -- When it fails, telling the user it failed is correct! What's your alternative, other than to "paper over" the failure with 'null' or incomplete/incorrect data? Pretending it succeeded is a lie, that just makes things worse. With 25 years experience in high-reliability systems, retry logic should only be used carefully & where appropriate. I would also expect a Visitor to likely fail again, no matter how many times you retry it. Unless you're flying a plane, swapping to a second version of the same algorithm is impractical & implausible (and may fail anyway).
type: Comment
comment on: http://stackoverflow.com/a/1694321
score: 2
type: AnswerComment

http://stackoverflow.com/a/7329242
score: 0
has comment: http://stackoverflow.com/comment/45487693
upvote count: 1
has body: I enclose my example code with &lt;pre class="brush: java"&gt;&lt;/pre&gt; tags and use SyntaxHighlighter for published javadocs. It doesn't hurt IDE and makes published code examples beautiful.
downvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/541920
has comment: http://stackoverflow.com/comment/52355810

http://stackoverflow.com/a/474676
upvote count: 4
downvote count: 0
score: 4
has body: If you need to do this frequently enough, then create a class just to hold the result and return that instead. This also allows you to DOCUMENT what your function returns in the same way that the parameters are documented.
type: Answer
answers question: http://stackoverflow.com/q/472129

http://stackoverflow.com/a/509115
has comment: http://stackoverflow.com/comment/2963186
score: 628
has comment: http://stackoverflow.com/comment/120993630
has comment: http://stackoverflow.com/comment/11413693
has comment: http://stackoverflow.com/comment/13946639
has body: The obvious answer, of course, is not to do the unchecked cast. If it's absolutely necessary, then at least try to limit the scope of the @SuppressWarnings annotation. According to its Javadocs, it can go on local variables; this way, it doesn't even affect the entire method. Example: @SuppressWarnings("unchecked") Map&lt;String, String&gt; myMap = (Map&lt;String, String&gt;) deserializeMap(); There is no way to determine whether the Map really should have the generic parameters &lt;String, String&gt;. You must know beforehand what the parameters should be (or you'll find out when you get a ClassCastException). This is why the code generates a warning, because the compiler can't possibly know whether is safe.
has comment: http://stackoverflow.com/comment/21314457
upvote count: 630
downvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/509076
has comment: http://stackoverflow.com/comment/49595504
has comment: http://stackoverflow.com/comment/13906030
has comment: http://stackoverflow.com/comment/26278387

http://stackoverflow.com/comment/215175
score: 0
type: AnswerComment
type: Comment
has text: An example where Java could do better, and is being considered for Java 7 is something like: Map<String,Integer> model = new HashMap<>();
comment on: http://stackoverflow.com/a/387661

http://stackoverflow.com/q/536211
has body: I have a jar application which process and converts file into csv file. I have made it to run in Windows service using Java Service Wrapper. It got installed my jar application successfully when I run "InstallApp-NT. Bat" file and starts running my application when I run "app" command. But when I try to start the service in Services, it's not starting and showing following message in dialog box: Windows could not start the generic Preprocessor application on Local Computer. For more information, review the System Event Log. If this is a non-microsoft service, contact the service vendor, and refer to service-specific error code1 I have the system log file and it showing the below error message System Event log: --> Wrapper Started as Service Java Service Wrapper Community Edition 3.3.2 Copyright (C) 1999-2009 Tanuki Software, Ltd. All Rights Reserved. http://wrapper.tanukisoftware.org Launching a JVM... WrapperManager: Initializing... WrapperSimpleApp: WrapperSimpleApp: Encountered an error running main: WrapperSimpleApp: java. Lang. NullPointerException WrapperSimpleApp: at java. Util. Hashtable. Put(Hashtable. Java: 396) WrapperSimpleApp: at java. Util. Properties. SetProperty(Properties. Java: 128) WrapperSimpleApp: at java. Lang. System. SetProperty(System. Java: 701) WrapperSimpleApp: at com. Dnb. Genericpreprocessor. Process. ProcessRunner. Main(Unknown Source) WrapperSimpleApp: at sun. Reflect. NativeMethodAccessorImpl. Invoke0(Native Method) WrapperSimpleApp: at sun. Reflect. NativeMethodAccessorImpl. Invoke(NativeMethodAccessorImpl. Java: 39) WrapperSimpleApp: at sun. Reflect. DelegatingMethodAccessorImpl. Invoke(DelegatingMethodAccessorImpl. Java: 25) WrapperSimpleApp: at java. Lang. Reflect. Method. Invoke(Method. Java: 585) WrapperSimpleApp: at org. Tanukisoftware. Wrapper. WrapperSimpleApp. Run(WrapperSimpleApp. Java: 238) WrapperSimpleApp: at java. Lang. Thread. Run(Thread. Java: 595) <-- Wrapper Stopped I don't think any error in application code becau…
has comment: http://stackoverflow.com/comment/6353977
type: UnansweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/537451
has answer: http://stackoverflow.com/a/536222
has title: Java Service wrapper while running jar application fom Windows service
has answer: http://stackoverflow.com/a/10545105
score: 0
has answer: http://stackoverflow.com/a/536225
answer count: 5
has answer: http://stackoverflow.com/a/536223

http://stackoverflow.com/a/636597
has comment: http://stackoverflow.com/comment/474252
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/619761
has comment: http://stackoverflow.com/comment/474259
has comment: http://stackoverflow.com/comment/470070
upvote count: 25
answers question: http://stackoverflow.com/q/619761
score: 20
has comment: http://stackoverflow.com/comment/10405952
type: Answer
has body: You're using JAXB 2.0 right? (since JDK6) There is a class: javax.xml.bind.annotation.adapters.XmlAdapter&lt;ValueType,BoundType&gt; which one can subclass, and override following methods: public abstract BoundType unmarshal(ValueType v) throws Exception; public abstract ValueType marshal(BoundType v) throws Exception; Example: public class YourNiceAdapter extends XmlAdapter&lt;ReceiverPerson,Person&gt;{ @Override public Person unmarshal(ReceiverPerson v){ return v; } @Override public ReceiverPerson marshal(Person v){ return new ReceiverPerson(v); // you must provide such c-tor } } Usage is done by as following: @Your_favorite_JAXB_Annotations_Go_Here class SomeClass{ @XmlJavaTypeAdapter(YourNiceAdapter.class) Person hello; // field to unmarshal } I'm pretty sure, by using this concept you can control the marshalling/unmarshalling process by yourself (including the choice the correct [sub|super]type to construct).
has comment: http://stackoverflow.com/comment/474266
downvote count: 5
has comment: http://stackoverflow.com/comment/6682683

http://stackoverflow.com/a/694793
has body: What is the scope of this library? Is this library used for just this particular web-application? If so, can we put the library in the WEB-INF/lib directory and check that into subversion as well? Libraries in the WEB-INF/lib directory should be automatically added to the classpath of the project.
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/537693
upvote count: 1
answers question: http://stackoverflow.com/q/614892

http://stackoverflow.com/q/460088
has answer: http://stackoverflow.com/a/613205
tagged with: collections
has answer: http://stackoverflow.com/a/460094
upvote count: 40
tagged with: list
tagged with: java
type: Question
has body: I'm looking for a structure which hashes keys without requiring a value. When queried, it should return true if the key is found and false otherwise. I'm looking for something similar to Hashtable&lt;MyClass, Boolean&gt; except insertion requires only a key and queries only ever return true or false, never null.
has answer: http://stackoverflow.com/a/460096
downvote count: 0
favorite count: 0
score: 40
has title: Is there a java hash structure with keys only and no values?
answer count: 4
has answer: http://stackoverflow.com/a/2020036
tagged with: hash
type: UnansweredQuestion

jaas
tags question: http://stackoverflow.com/q/471743
tags question: http://stackoverflow.com/q/471811
type: Tag
tags question: http://stackoverflow.com/q/528938
tags question: http://stackoverflow.com/q/628416
tags question: http://stackoverflow.com/q/605127
tag name: jaas
tags question: http://stackoverflow.com/q/472739

http://stackoverflow.com/comment/130962472
has text: This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32970092)
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/74107872

http://stackoverflow.com/q/468266
tagged with: multithreading
has answer: http://stackoverflow.com/a/501157
duplicate of: http://stackoverflow.com/q/1881714
has answer: http://stackoverflow.com/a/1972978
has answer: http://stackoverflow.com/a/468278
tagged with: java
type: Question
answer count: 8
has title: How to restart thread in java?
has body: I have created a program which searches for files in a source folder. If it finds any file, it processes that file and moves it to a destination folder, then looks for a new file in the source folder. It has to keep on checking the source folder for a file. I have used a thread to look for files in the source folder. The problem I am facing is whenever any exception is thrown during file processing, the thread gets stopped. I want the thread to be running even if an exception is thrown. It has to move the file that caused the error to some other folder and look for a new file in the source folder. How can I make the thread keep on running? Eg: public void run() { try { searchfile(); } catch(Exception e) { e.printStackTrace(); } } public void searchfile(){ ... } Update : I should be more clear in my question. Actually there are 4 source folders and 4 destination folders. I have to perform the same operation in each source &amp; destination pair. So i have created 4 threads in one class and do the operation in separate class. class MainClass { public static void main(String[] args){ for(int i=0;i&lt;4;i++){ SearchClass search = new SearchClass(); Thread thread = new Thread(search); thread.start(); } } } class SearchClass { public void run() { try { searchfile(); } catch(Exception e) { e.printStackTrace(); } } public void searchfile(){ ... } } All the thread wont stop running eventhough it caught any exception in middle. How can i do that?
has answer: http://stackoverflow.com/a/468423
has answer: http://stackoverflow.com/a/470628
downvote count: 0
linked to: http://stackoverflow.com/q/1881714
tagged with: exception
has answer: http://stackoverflow.com/a/468386
has answer: http://stackoverflow.com/a/468280
favorite count: 0
score: 8
upvote count: 8
has answer: http://stackoverflow.com/a/22449710
type: UnansweredQuestion

http://stackoverflow.com/a/489990
answers question: http://stackoverflow.com/q/489927
has comment: http://stackoverflow.com/comment/773094
has comment: http://stackoverflow.com/comment/9093648
score: 20
has body: Why two loops? (converted from C#, pardon any syntax errors) String s = "1 "; for (int i = 0; i &lt; 5; ++i) { s = s + "0 "; System.out.print(s); } Self-critique: two for loops (like Michael Haren's solution) would negate the string copying a StringBuffer/StringBuilder would negate the string copying
upvote count: 20
downvote count: 0
has comment: http://stackoverflow.com/comment/773105
type: Answer
has comment: http://stackoverflow.com/comment/773135
has comment: http://stackoverflow.com/comment/822487

http://stackoverflow.com/a/518417
has comment: http://stackoverflow.com/comment/332508
has comment: http://stackoverflow.com/comment/332460
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/518354
has comment: http://stackoverflow.com/comment/332377
has comment: http://stackoverflow.com/comment/342109
score: 0
has body: Try this: ${user.Admin} just in case capitalization is the problem. Sometimes EL does non-obvious things. However, I've usually been able to just use the equivalent of ${user.admin} in my el. Looking at my own code, I have many examples of doing the obvious thing where it works. Do you have the following methods in your class: public boolean isAdmin(){return isAdmin} public void isAdmin(boolean newValue) { ... } or do you have only the getter? If my code, I notice that I do not do the above. My setters all start with set such as: public boolean isAdmin(){return isAdmin} public void setAdmin(boolean newValue) { ... } and I am able to use the obvious lowercase solution ${user.admin} in my JSPs. This may depend on which EL processor you're using. NOTE: Added later because people still vote this down, obviously never having run into an example where this occurs. An example from my own JSPs that caused me to ask this question is that I have a method: public int getLANSomething() { ... } and I access this in EL as follows: ${agent.LANSomething} The rule appears to be getXXXyyy where XXX is all caps, you have to use caps to access it in EL. At least with Tomcat versions 4-6 that I have used.
type: Answer

http://stackoverflow.com/q/586077
tagged with: jpa
favorite count: 0
has answer: http://stackoverflow.com/a/589514
type: AnsweredQuestion
score: 41
has title: Does between in HQL compare strictly or not?
downvote count: 0
accepted answer: http://stackoverflow.com/a/586999
type: Question
tagged with: java
tagged with: hibernate
has answer: http://stackoverflow.com/a/586999
possible better answer: http://stackoverflow.com/a/589514
has body: if I write in HQL A between 5 and 10 is that equivalent to A &gt;= 5 and A &lt;= 10 or A &gt; 5 and A &lt; 10 or some other of the 4 combinations?
tagged with: hql
upvote count: 41
answer count: 2

http://stackoverflow.com/comment/49075624
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/3830563
type: Comment
has text: Nope - that's not true. Or if it's supposed to work that way it does not work.

http://stackoverflow.com/comment/31947501
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21212931
has text: While serializing, 2 passes are used. The first adds every unique object to an object list and creates an index for each object. The second pass. serializes a flat view of the object with the index used in place of the value of a field or array value. This way by the time the object list is processed there is a flat mapping of the serialized object, and its references without using a recursive writeObject.

http://stackoverflow.com/tag/c
tags question: http://stackoverflow.com/q/475329
tags question: http://stackoverflow.com/q/538752
tags question: http://stackoverflow.com/q/613063
tags question: http://stackoverflow.com/q/641514
tags question: http://stackoverflow.com/q/451886
tags question: http://stackoverflow.com/q/381680
tag name: c
type: Tag
tags question: http://stackoverflow.com/q/463618
tags question: http://stackoverflow.com/q/427035
tags question: http://stackoverflow.com/q/463155
tags question: http://stackoverflow.com/q/359732
tags question: http://stackoverflow.com/q/421951
tags question: http://stackoverflow.com/q/472249
tags question: http://stackoverflow.com/q/453776
tags question: http://stackoverflow.com/q/634963
tags question: http://stackoverflow.com/q/459479
tags question: http://stackoverflow.com/q/456926
tags question: http://stackoverflow.com/q/476576
tags question: http://stackoverflow.com/q/459822
tags question: http://stackoverflow.com/q/436989
tags question: http://stackoverflow.com/q/600651
tags question: http://stackoverflow.com/q/577622
tags question: http://stackoverflow.com/q/397867

http://stackoverflow.com/comment/194383
type: AnswerComment
comment on: http://stackoverflow.com/a/364464
type: Comment
has text: But is that the correct practice in those situations? I mean, ideally I would have liked a compile-time type check, which I can't get because of Java limitations.
score: 0

http://stackoverflow.com/q/512503
tagged with: .net
favorite count: 0
has answer: http://stackoverflow.com/a/512518
has body: At my company we develop applications that run on the JVM (Java EE and Grails) as well as .NET applications (ASP.NET and client/server Forms apps). In your experience, when have you recommended one over the other to a customer? I asked this question incorrectly here but I think the fact that I put an initial list got it closed. I'm looking for things like if you want to do X then Y is better because of Z. I think this would be a valuable resource/case-study to the community. For example, I tried doing some USB hardware stuff in Java/Windows and would not recommend it again because of the lack of good libraries in Java.
has title: Explaining .NET or Java to a client
answer count: 4
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/512573
downvote count: 0
type: Question
has answer: http://stackoverflow.com/a/512617
accepted answer: http://stackoverflow.com/a/512617
possible better answer: http://stackoverflow.com/a/512518
tagged with: java
has answer: http://stackoverflow.com/a/512543
upvote count: 2

http://stackoverflow.com/a/47943024
has body: Without using a final class, you can basically make all the constructors private: public class A { private A() {} //Overriding default constructor of Java } Which although will also make this class abstract-ish by disallowing creating an object of this class, yet as any inheritance requires super(); in the constructor, and because the constructor is private, a compilation error will be the maximum you can get when one tries to inherit that class. Yet, I would recommend using final instead as it is less code and includes the option of creating objects.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/451182

http://stackoverflow.com/comment/385078
score: 1
has text: What do you mean 'crushes' you program?
comment on: http://stackoverflow.com/q/573384
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/109023781
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/547793
has text: Can somebody tell me what is the meaning of putting<T extends IXMLizable> here .I am new to java.What does it do?

http://stackoverflow.com/comment/132066369
type: QuestionComment
has text: After reading the question, ALL the answers, and ALL the comments, I'm still wondering what is best for defining an exception message. :S
type: Comment
score: 0
comment on: http://stackoverflow.com/q/513600

http://stackoverflow.com/comment/15644160
type: Comment
score: 1
has text: WIth jre6, "%1$#" is ok but with jre7 "%1$#" throws java.util.FormatFlagsConversionMismatchException: Conversion = s, Flags = #. I have updated this answer by removing the "#".
type: AnswerComment
comment on: http://stackoverflow.com/a/391978

http://stackoverflow.com/a/644352
type: Answer
has body: Yo do observe this behavior even in latest 3.5 releases. One solution is to click on the function and to have the javadoc view opened. Even if the method is deprecated, the javadoc will be displayed in the javadoc view. alt text http://help.eclipse.org/help32/topic/org.eclipse.jdt.doc.user/tips/images/JavadocView.png Another solution: Preferences &gt; General &gt; Editors &gt; Text Editors &gt;Annotations: Click on warnings, un-select "Text as". The underline disappear, and you can hover and see the javadoc in the F2/focus view.
accepted answer of: http://stackoverflow.com/q/644262
score: 4
answers question: http://stackoverflow.com/q/644262
upvote count: 4
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/329166
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/515417
type: Comment
has text: @andynormancx Yes. That processing cannot cast from Object to JSObject.

http://stackoverflow.com/a/417313
score: 0
type: Answer
has body: I can't see any functional difference - both synchronize their entire method bodies on (this). How did the person who commented that these are different justify their statement?
answers question: http://stackoverflow.com/q/417285

http://stackoverflow.com/a/47183212
has comment: http://stackoverflow.com/comment/121289703
type: Answer
score: 31
answers question: http://stackoverflow.com/q/605696
upvote count: 31
has comment: http://stackoverflow.com/comment/83755844
has comment: http://stackoverflow.com/comment/86870026
downvote count: 0
has body: One liner: new File(uri.getPath).getName Complete code (in a scala REPL): import java.io.File import java.net.URI val uri = new URI("http://example.org/file.txt?whatever") new File(uri.getPath).getName res18: String = file.txt Note: URI#gePath is already intelligent enough to strip off query parameters and the protocol's scheme. Examples: new URI("http://example.org/hey/file.txt?whatever").getPath res20: String = /hey/file.txt new URI("hdfs:///hey/file.txt").getPath res21: String = /hey/file.txt new URI("file:///hey/file.txt").getPath res22: String = /hey/file.txt

http://stackoverflow.com/comment/16927363
has text: So this _is_ just for windows? Is there a _platform independent_ way to do this?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/12565525
type: Comment

http://stackoverflow.com/q/563305
upvote count: 9
tagged with: aop
answer count: 2
has title: Is it possible to do bytecode manipulation when using OSGi?
has answer: http://stackoverflow.com/a/563764
downvote count: 0
favorite count: 0
has body: I'm making an application server and in it I need to use some bytecode manipulation (e.g. inserting custom equals and hashCode methods to classes annotated with @Entity). Now I give the JVM a Java Agent (the -javaagent option) which does bytecode transformations using ASM. I've been considering using OSGi, but I don't know whether it allows me to do the necessary bytecode manipulation. Is it possible to do bytecode manipulation when using OSGi? How? Is it possible for a bundle to declare itself, that it requires some bytecode manipulation for it to work? For example the application server requires that some of its own core classes are manipulated. Is it possible to specify that some other bundle requires some bytecode manipulation, without that bundle knowing about it? For example all applications which run on the server must be manipulated, but the applications don't need to know about it. Is it possible for a bundle to declare itself, that all bundles which depend on it must be bytecode manipulated? This would make it easy for me to declare that all who depend on the API bundle which contains the @Entity annotation, must be manipulated.
score: 9
tagged with: osgi
tagged with: bytecode-manipulation
type: UnansweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/7895057

http://stackoverflow.com/a/64746092
has body: I have created my wrapper here, hope it will helps a lot, Click here You can modify depends on your requirements
score: -1
upvote count: 0
answers question: http://stackoverflow.com/q/439298
type: Answer
downvote count: 1

http://stackoverflow.com/q/457590
has answer: http://stackoverflow.com/a/457631
answer count: 7
tagged with: throttling
has title: How to throttle login attemps in Java webapp?
has answer: http://stackoverflow.com/a/457977
favorite count: 0
type: UnansweredQuestion
downvote count: 2
tagged with: authentication
has body: I want to implement an efficient mechanism to throttle login attemps in my Java web application, to prevent brute-force attacks on user accounts. Jeff explained the why, but not the how. Simon Willison showed an implementation in Python for Django: That doesn't really help me along as I can't use memcached nor Django. Porting his ideas from scratch doesn't seem like a great either - I don't want to reinvent the wheel. I found one Java implementation, though it seems rather naiive: Instead of a LRU cache, it just clears all entries after 15 minutes. EHCache could be an alternative for memcached, but I don't have any experience with it and don't really want to intoduce yet another technology if there are better alternatives for this task. So, whats a good way to implement login throttling in Java?
upvote count: 14
tagged with: java
has answer: http://stackoverflow.com/a/458019
has answer: http://stackoverflow.com/a/467904
has answer: http://stackoverflow.com/a/457606
linked to: http://stackoverflow.com/q/14042488
type: Question
score: 12
has answer: http://stackoverflow.com/a/30886363
has answer: http://stackoverflow.com/a/468021

http://stackoverflow.com/a/565883
answers question: http://stackoverflow.com/q/565871
type: Answer
downvote count: 6
upvote count: 7
has comment: http://stackoverflow.com/comment/377817
has comment: http://stackoverflow.com/comment/377265
score: 1
has comment: http://stackoverflow.com/comment/377330
has body: This is not normal, and is probably indicative of a memory leak. You should try using a memory profiler to see where your application is leaking. In general, you should be looking for loops or repeated operations where objects are created but not disposed of correctly.

http://stackoverflow.com/comment/110624785
type: Comment
comment on: http://stackoverflow.com/a/30511258
score: 1
type: AnswerComment
has text: Yeah, you're right about that. To do it right, I'd need to create at least two more collection classes to ensure both keySet and values are backed by both collections. I update my answer.

http://stackoverflow.com/comment/423349
comment on: http://stackoverflow.com/q/610976
type: Comment
has text: Purely functional languages allow you to see all previous values of variables. :)
type: QuestionComment
score: 1

http://stackoverflow.com/a/1246039
has body: Ok... Checked exceptions are not ideal and have some caveat but they do serve a purpose. When creating an API there are specific cases of failures that are contractual of this API. When in the context of a strongly statically typed language such as Java if one does not use checked exceptions then one must rely on ad-hoc documentation and convention to convey the possibility of error. Doing so removes all benefit that the compiler can bring in handling error and you are left completely to the good will of programmers. So, one removes Checked exception, such as was done in C#, how then can one programmatically and structurally convey the possibility of error ? How to inform the client code that such and such errors can occur and must be dealt with ? I hear all sorts of horrors when dealing with checked exceptions, they are misused this is certain but so are unchecked exceptions. I say wait a few years when APIs are stacked many layers deep and you will be begging for the return of some kind of structured mean to convey failures. Take the case when the exception was thrown somewhere at the bottom of the API layers and just bubbled up because nobody knew it was even possible for this error to occur, this even though it was a type of error that was very plausible when the calling code threw it (FileNotFoundException for example as opposed to VogonsTrashingEarthExcept... in which case it would not matter if we handle it or not since there is nothing left to handle it with). Many have argued that not being able to load the file was almost always the end of the world for the process and it must die a horrible and painful death. So yeah.. sure ... ok.. you build an API for something and it loads file at some point... I as the user of said API can only respond... "Who the hell are you to decide when my program should crash !" Sure Given the choice where exceptions are gobbled up and leave no trace or the EletroFlabbingChunkFluxManifoldChuggingException with a stack trace deep…
score: 8
type: Answer
answers question: http://stackoverflow.com/q/613954
downvote count: 0
upvote count: 8
has comment: http://stackoverflow.com/comment/34045834

http://stackoverflow.com/q/469657
has answer: http://stackoverflow.com/a/469671
type: Question
has body: Just wondering if anyone knew off the top of their heads if there was much difference in doing the following: String wibble = "&lt;blah&gt; blah blah &lt;/blah&gt;.... &lt;wibble&gt; blah wibble blah &lt;/wibble&gt; some more test here"; int i = wibble.lastIndexOf("&gt;"); int j = wibble.lastIndexOf('&gt;');
has answer: http://stackoverflow.com/a/469795
score: 5
has answer: http://stackoverflow.com/a/469683
has comment: http://stackoverflow.com/comment/288509
tagged with: performance
has answer: http://stackoverflow.com/a/469694
upvote count: 5
tagged with: java
accepted answer: http://stackoverflow.com/a/469795
answer count: 5
possible better answer: http://stackoverflow.com/a/469694
has answer: http://stackoverflow.com/a/469699
type: AnsweredQuestion
has title: String.lastIndexOf() is there a difference between a char and a string with a single character?
downvote count: 0
favorite count: 0
tagged with: optimization

http://stackoverflow.com/a/500627
has comment: http://stackoverflow.com/comment/77436584
downvote count: 0
score: 80
has comment: http://stackoverflow.com/comment/10028280
has comment: http://stackoverflow.com/comment/10028229
has comment: http://stackoverflow.com/comment/23331105
has comment: http://stackoverflow.com/comment/317442
upvote count: 80
has body: Let me explain a bit about the one case where you have to use final, which Jon already mentioned: If you create an anonymous inner class in your method and use a local variable (such as a method parameter) inside that class, then the compiler forces you to make the parameter final: public Iterator&lt;Integer&gt; createIntegerIterator(final int from, final int to) { return new Iterator&lt;Integer&gt;(){ int index = from; public Integer next() { return index++; } public boolean hasNext() { return index &lt;= to; } // remove method omitted }; } Here the from and to parameters need to be final so they can be used inside the anonymous class. The reason for that requirement is this: Local variables live on the stack, therefore they exist only while the method is executed. However, the anonymous class instance is returned from the method, so it may live for much longer. You can't preserve the stack, because it is needed for subsequent method calls. So what Java does instead is to put copies of those local variables as hidden instance variables into the anonymous class (you can see them if you examine the byte code). But if they were not final, one might expect the anonymous class and the method seeing changes the other one makes to the variable. In order to maintain the illusion that there is only one variable rather than two copies, it has to be final.
answers question: http://stackoverflow.com/q/500508
has comment: http://stackoverflow.com/comment/2193136
type: Answer
has comment: http://stackoverflow.com/comment/23329255
has comment: http://stackoverflow.com/comment/317793
has comment: http://stackoverflow.com/comment/2193421

http://stackoverflow.com/a/6706563
type: Answer
downvote count: 1
upvote count: 5
score: 4
has body: c3p0 is good when we are using mutithreading projects. In our projects we used simultaneously multiple thread executions by using DBCP, then we got connection timeout if we used more thread executions. So we went with c3p0 configuration.
answers question: http://stackoverflow.com/q/520585

http://stackoverflow.com/a/432012
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/432006
downvote count: 0
has body: You should also have myClass(Class&lt;T&gt; type, int size)

http://stackoverflow.com/a/637916
type: Answer
has body: You should split on any number of spaces, not just single ones. That is, add "+" to your regexp like this: String[] parts = str.trim().split("\\s+");
upvote count: 3
score: 3
accepted answer of: http://stackoverflow.com/q/637907
answers question: http://stackoverflow.com/q/637907
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/608720
downvote count: 0
answers question: http://stackoverflow.com/q/608704
accepted answer of: http://stackoverflow.com/q/608704
type: Answer
has body: Integer overflow&hellip; or more precisely, underflow. Instead, do an explicit comparison: private static final Comparator&lt;Thing&gt; reverse = new Comparator&lt;Thing&gt;() { public int compare(Thing a, Thing b) { int av = a.getValue(), bv = b.getValue(); return (av == bv) ? 0 : ((av &lt; bv) ? -1 : +1); } }; Using subtraction is fine if you are sure that the difference won't "wrap around". For example, when the values in question are constrained to be non-negative.
score: 20
upvote count: 20
type: AcceptedAnswer

http://stackoverflow.com/a/525867
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/37587468
type: Answer
accepted answer of: http://stackoverflow.com/q/525855
has comment: http://stackoverflow.com/comment/340347
upvote count: 29
has comment: http://stackoverflow.com/comment/339057
answers question: http://stackoverflow.com/q/525855
score: 29
has comment: http://stackoverflow.com/comment/339054
has body: According to this class: /** * Some components treat tabulator (TAB key) in their own way. * Sometimes the tabulator is supposed to simply transfer the focus * to the next focusable component. * * Here s how to use this class to override the "component's default" * behavior: * * JTextArea area = new JTextArea(..); * TransferFocus.patch( area ); * * This should do the trick. * This time the KeyStrokes are used. * More elegant solution than TabTransfersFocus(). * * @author kaimu * @since 2006-05-14 * @version 1.0 */ public class TransferFocus { /** * Patch the behaviour of a component. * TAB transfers focus to the next focusable component, * SHIFT+TAB transfers focus to the previous focusable component. * * @param c The component to be patched. */ public static void patch(Component c) { Set<KeyStroke> strokes = new HashSet<KeyStroke>(Arrays.asList(KeyStroke.getKeyStroke("pressed TAB"))); c.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, strokes); strokes = new HashSet<KeyStroke>(Arrays.asList(KeyStroke.getKeyStroke("shift pressed TAB"))); c.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, strokes); } } Note that patch() can be even shorter, according to Joshua Goldberg in the comments, since the goal is to get back default behaviors overridden by JTextArea: component.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERS‌​AL_KEYS, null); component.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERS‌​AL_KEYS, null); This is used in question "How can I modify the behavior of the tab key in a JTextArea?" The previous implementation involved indeed a Listener, and the a transferFocus(): /** * Override the behaviour so that TAB key transfers the focus * to the next focusable component. */ @Override public void keyPressed(KeyEvent e) { if(e.getKeyCode() == KeyEvent.VK_TAB) { System.out.println(e.getModifiers()); if(e.getModifiers() > 0) a.transferFocusBackward(); else a.transferFocus(); e.consume(); } } e.consume(); might ha…

http://stackoverflow.com/comment/425279
type: AnswerComment
has text: While I'd love to agree with you, I'm sort of stuck. I'm manipulating a field that is stored as a double, that is then passed into Oracle Applications. I have no control over the data field's type (double). This will work for most values, and they'll live with the occasional floating point anomaly.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/612257

tostring
tags question: http://stackoverflow.com/q/496591
tag name: tostring
tags question: http://stackoverflow.com/q/456367
type: Tag
tags question: http://stackoverflow.com/q/563676
tags question: http://stackoverflow.com/q/443730
tags question: http://stackoverflow.com/q/409784
tags question: http://stackoverflow.com/q/603013
tags question: http://stackoverflow.com/q/375128
tags question: http://stackoverflow.com/q/592276

http://stackoverflow.com/a/20534244
answers question: http://stackoverflow.com/q/536327
downvote count: 0
has body: If your futureTasks are more then 2, please consider [ListenableFuture][1]. When several operations should begin as soon as another operation starts -- "fan-out" -- ListenableFuture just works: it triggers all of the requested callbacks. With slightly more work, we can "fan-in," or trigger a ListenableFuture to get computed as soon as several other futures have all finished.
type: Answer
score: 2
upvote count: 2

http://stackoverflow.com/comment/84912488
has text: check my answer in case of Java Spring Boot: https://stackoverflow.com/a/48952844/986160
score: 0
type: Comment
comment on: http://stackoverflow.com/a/362006
type: AnswerComment

http://stackoverflow.com/a/430492
score: 7
has body: Java does not have pass-by-reference. You must encapsulate to achieve the desired functionality. Jon Skeet has a brief explanation why pass-by-reference was excluded from Java.
upvote count: 7
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/430479

http://stackoverflow.com/a/387716
downvote count: 1
answers question: http://stackoverflow.com/q/387256
has body: A C++ programmer will tell you that Java is rubbish. A Java programmer will tell you that C++ is rubbish. Therefore I conclude that they are indeed the same thing.
has comment: http://stackoverflow.com/comment/215424
upvote count: 20
has comment: http://stackoverflow.com/comment/215329
has comment: http://stackoverflow.com/comment/86611619
has comment: http://stackoverflow.com/comment/16486441
type: Answer
score: 19

http://stackoverflow.com/a/464424
score: 2
downvote count: 0
type: Answer
has body: Based on your error message, it simply means that your Server response message is SOAP 1.1, while you expect SOAP 1.2. You'll have to change to SOAP 1.1 on the client (using BasicHttpBinding, at least do it to test and see if it works that way).
upvote count: 2
answers question: http://stackoverflow.com/q/463194

http://stackoverflow.com/q/643906
tagged with: void
has answer: http://stackoverflow.com/a/644730
has answer: http://stackoverflow.com/a/646790
has answer: http://stackoverflow.com/a/644060
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/27827223
linked to: http://stackoverflow.com/q/47369776
tagged with: java
has comment: http://stackoverflow.com/comment/81692590
type: Question
has answer: http://stackoverflow.com/a/643919
accepted answer: http://stackoverflow.com/a/644060
has title: Uses for the Java Void Reference Type?
answer count: 11
has answer: http://stackoverflow.com/a/644823
has answer: http://stackoverflow.com/a/643920
has body: There is a Java Void -- uppercase V-- reference type. The only situation I have ever seen it used is to parameterize Callables final Callable&lt;Void&gt; callable = new Callable&lt;Void&gt;() { public Void call() { foobar(); return null; } }; Are there any other uses for the Java Void reference type? Can it ever be assigned anything other than null? If yes, do you have examples?
has answer: http://stackoverflow.com/a/10257143
has answer: http://stackoverflow.com/a/34249177
downvote count: 0
upvote count: 175
favorite count: 0
has comment: http://stackoverflow.com/comment/55790299
linked to: http://stackoverflow.com/q/34248693
has answer: http://stackoverflow.com/a/20540947
score: 175
possible better answer: http://stackoverflow.com/a/644730
has answer: http://stackoverflow.com/a/25230143

http://stackoverflow.com/comment/1039478
type: Comment
comment on: http://stackoverflow.com/a/428966
has text: @Esko, c.roll(Calendar.DATE, true) won't roll the month on the last day of the month.
type: AnswerComment
score: 53

http://stackoverflow.com/comment/135876995
type: Comment
has text: So, in the omitted prologue you convert IPv4 addresses and the network mask to integers
score: 1
comment on: http://stackoverflow.com/a/579300
type: AnswerComment

http://stackoverflow.com/q/518708
has title: Consequences of these Pointer Errors in C++ vs Managed
tagged with: pointers
has answer: http://stackoverflow.com/a/518753
has answer: http://stackoverflow.com/a/518848
favorite count: 0
tagged with: exception
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/518742
has comment: http://stackoverflow.com/comment/332247
has comment: http://stackoverflow.com/comment/332229
tagged with: c++
has body: I'm making this a community wiki in order to better understand the semantic differences between these errors and their runtime or compiled consequences. Also, I've coded on Java far too long and I want to learn pointers better in C++ -- so I need other people to do it. Edit2: I am refactoring this question. The distinction I am trying to draw is that on managed code, these errors are all uniformly dealt with via an Exception. However, C++ is not so simple -- and I want to understand whether in each case you are likely to get an error, segfault, recoverable behavior, or worse a silent error that propagates. Please see my new concrete examples (and yes, I know that the answer is always "exactly as it is coded"; I'm a programmer after all. I want to know the interesting details of what you often run in to.) Edit3: In the following, by "class" I instead mean an instance of a class. Thanks Error 1: Pointer value is NULL, aka pointer == 0 Managed code: Throws NullPointerException at runtime C++: ? Example: Well, duh, you have a pointer to a class but it is initialized to 0. What happens when you send it off to a function. ie. C++ does not leave any indication of class; it is just a concatenation of public "placeholders". Error 2: Pointer points to an former class in memory whose value is NULL or == 0 Managed code: Not allowed through memory model. All referenced objects remain in memory. No exceptional cases? C++: ? Example: You had a pointer to a class and the class got deleted. You then pass the pointer as an argument to a function. Obviously, the problem that occurs depends on how the function deals with the pointed to class. My question is: Is there failsafe handling for this on STL? A good proprietary library? The average open source code? Error 3: Pointer points to an class that is not of the correct class or subclass Managed code: Throws ClassCastException. C++: [correct if wrong] Compiler tries to fight this by not allowing bad casts. However, if this is to occur …
has answer: http://stackoverflow.com/a/518787
upvote count: 1
has answer: http://stackoverflow.com/a/518810
downvote count: 1
type: Question
answer count: 8
tagged with: java
has comment: http://stackoverflow.com/comment/332372
has answer: http://stackoverflow.com/a/518820
has answer: http://stackoverflow.com/a/518784
tagged with: managed
has comment: http://stackoverflow.com/comment/333761
has answer: http://stackoverflow.com/a/518760
score: 0

http://stackoverflow.com/a/14656171
type: Answer
answers question: http://stackoverflow.com/q/567996
upvote count: 9
score: 9
has body: I did not care for the Shade plugin since it rolls all the packages from all the jars together. To include all of the external libs you can use the Dependency Plugin as mentioned above. This example will create a "lib" directory under "target/classes" before the "package" phase. org.apache.maven.plugins maven-dependency-plugin 2.6 copy-dependencies prepare-package copy-dependencies target/classes/lib true junit,org.hamcrest,org.mockito,org.powermock,${project.groupId} generate-sources sources true true ${project.build.directory}
downvote count: 0

http://stackoverflow.com/q/626328
has answer: http://stackoverflow.com/a/626367
accepted answer: http://stackoverflow.com/a/626367
has body: I'm a .NET guy - and I mainly code in C#. Since C# 3.0, we can leverage lambda expressions and expression trees to use static reflection. For example, it is possible to implement GetMethodName in the following snippet to return the name of the method passed in parameter: string methodName = GetMethodName( o =&gt; o.DoSomething()); Console.WriteLine(methodName); // displays "DoSomething" Now, when I look at Mockito samples (or EasyMock ones) in the java world, I see: LinkedList mockedList = mock(LinkedList.class); when(mockedList.get(0)).thenReturn("first"); How does it work? How does the when method work ? How does it interpret mockedList.get(0) as a call to the get method with 0 passed as parameter and not as a value?
has answer: http://stackoverflow.com/a/626363
answer count: 4
has title: How does "static reflection" work in java? (ex. in mockito or easymock)
favorite count: 0
upvote count: 5
possible better answer: http://stackoverflow.com/a/627088
has answer: http://stackoverflow.com/a/627088
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/626356
downvote count: 0
tagged with: reflection
tagged with: java
tagged with: easymock
type: Question
tagged with: c#
score: 5
tagged with: mockito

http://stackoverflow.com/q/515996
upvote count: 8
has answer: http://stackoverflow.com/a/516067
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/516013
has answer: http://stackoverflow.com/a/516033
has answer: http://stackoverflow.com/a/516270
type: Question
has answer: http://stackoverflow.com/a/518397
possible better answer: http://stackoverflow.com/a/516011
has body: I am a .NET Developer with about 5 years of web development experience using Microsoft technologies starting with classic ASP to ASP .NET 3.5. I do have a little background in Java as well and can write/understand Java code very easily. I am looking for resources (online, books) that are compatible with my .NET experience. I am only interested in web development in Java and want to start at intermediate level even if it may require me to look up some details. What path or resources would you recommend for intermediate .NET web developers to gain equivalent proficiency in Java web development tools?
tagged with: .net
has answer: http://stackoverflow.com/a/516011
has title: Java for intermediate .NET Developer
accepted answer: http://stackoverflow.com/a/516013
downvote count: 0
answer count: 7
score: 8
favorite count: 0
has answer: http://stackoverflow.com/a/519109

http://stackoverflow.com/comment/205078
type: Comment
has text: I'd say C# is somewhat cross-platform if you use Mono.
comment on: http://stackoverflow.com/a/377225
type: AnswerComment
score: 0

http://stackoverflow.com/q/560712
score: 2
has answer: http://stackoverflow.com/a/560766
downvote count: 0
has body: I want to render MSWord, PDF, HTML, etc to an image (e.g. TIFF) from server-side Java. Most available products are shareware printer drivers, and so not suited to a commercial server app: I'd like the library which is robust, well-supported, performant, and concurrent. Any suggestions for open-source or commercial libraries?
has answer: http://stackoverflow.com/a/560759
tagged with: ms-word
favorite count: 0
upvote count: 2
type: UnansweredQuestion
tagged with: rendering
tagged with: java
tagged with: image
type: Question
has title: Document-Rendering in Java
answer count: 2

http://stackoverflow.com/a/397823
type: Answer
answers question: http://stackoverflow.com/q/397581
has body: IllegalArgumentException is indeed the answer here, but I'd say you have a problem with your design. In essence, your class invariant is dependent on the state of some external object, which is a violation of encapsulation. There's no way to determine whether a call to your constructor will succeed without knowledge of some other object, which leads to a confusing and easily misused API. This problem is mitigated somewhat if the list you refer to is a static final unmodifiable List (see java.util.Collections.unmodifiableList()) and contained within the class in question, but I still don't like it terribly much. Better is to encapsulate, if possible, the acceptable parameter values in an enum, which will eliminate the need for an exception altogether. I generally dislike exceptions thrown from constructors. If you must throw an exception, use a factory method instead. If an option is not available to you that eliminates the need for an external list, you may need to rethink your design.
score: 10
upvote count: 10
has comment: http://stackoverflow.com/comment/224041
has comment: http://stackoverflow.com/comment/223987
downvote count: 0

http://stackoverflow.com/a/624209
type: Answer
accepted answer of: http://stackoverflow.com/q/624181
has body: Place them on your classpath (place them with your .class files) and load them using the ClassLoader. Java: package mypackage; public class MyClass { public static void main(String[] args) { java.net.URL url = MyClass.class.getResource("/mypackage/image.gif"); System.out.println(url); } } Console output: C:\resource&gt;dir /b /s C:\resource\bin C:\resource\src C:\resource\bin\mypackage C:\resource\bin\mypackage\image.gif C:\resource\bin\mypackage\MyClass.class C:\resource\src\mypackage C:\resource\src\mypackage\MyClass.java C:\resource&gt;java -cp bin mypackage.MyClass file:/C:/resource/bin/mypackage/image.gif
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/437128
answers question: http://stackoverflow.com/q/624181
downvote count: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/9132659
has comment: http://stackoverflow.com/comment/437130

http://stackoverflow.com/a/425349
answers question: http://stackoverflow.com/q/425281
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/56293071
type: Answer
has body: You're right. The exception should be at the same level of abstraction where is used. This is the reason why since java 1.4 Throwable supports exception chaining. There is no point to throw FileNotFoundException for a service that uses a Database for instance, or for a service that is "store" agnostic. It could be like this: public abstract class Data { public abstract String read() throws DataUnavailableException; } class DataFile extends Data { public String read() throws DataUnavailableException { if( !this.file.exits() ) { throw new DataUnavailableException( "Cannot read from ", file ); } try { .... } catch( IOException ioe ) { throw new DataUnavailableException( ioe ); } finally { ... } } class DataMemory extends Data { public String read() { // Everything is performed in memory. No exception expected. } } class DataWebService extends Data { public string read() throws DataUnavailableException { // connect to some internet service try { ... } catch( UnknownHostException uhe ) { throw new DataUnavailableException( uhe ); } } } Bear in mind that if you program with inheritance in mind, you should design carefully for the specific scenarios and test implementations with those scenarios. Obviously if it is harder to code an general purpose library, because you don't know how is it going to be used. But most of the times applications are constrained to an specific domain. Should your new exception be Runtime or Checked? It depends, the general rule is to throw Runtime for programming errors and checked for recoverable conditions. If the exception could be avoided by programming correctly ( such as NullPointerException or IndexOutOfBounds ) use Runtime If the exception is due to some external resource out of control of the programmer ( the network is down for instance ) AND there is something THAT could be done ( Display a message of retry in 5 mins or something ) then a checked exception should be used. If the exception is out of control of the programmer, but NOTHI…
upvote count: 26
accepted answer of: http://stackoverflow.com/q/425281
score: 26
downvote count: 0

http://stackoverflow.com/q/512235
tagged with: java
tagged with: eclipse
type: Question
has answer: http://stackoverflow.com/a/14235521
score: 35
answer count: 3
has answer: http://stackoverflow.com/a/512253
accepted answer: http://stackoverflow.com/a/512253
has body: In a Eclipse a // TODO comment in a Java file marks an area in code as a task for later consideration. Is there a way to add other expressions that will do the same? For example if I want to use // myprojectname.
favorite count: 0
has answer: http://stackoverflow.com/a/522032
tagged with: todo
has title: Custom TODO mark in Eclipse
type: AnsweredQuestion
upvote count: 35
downvote count: 0
possible better answer: http://stackoverflow.com/a/522032

http://stackoverflow.com/a/385369
answers question: http://stackoverflow.com/q/385332
has body: I was using two web applications to avoid over writing the uploaded images in case I redeploy a new main application war file. But as you mention there is no other option but to stream them through a Servlet or something I guess I can keep them outside tomcat directory. I wanted to avoid writing this Streaming Servlet. Just too small project to deal with all the mess (like proper content type, 404, etc.) while writing the streaming servlet.
score: 0
type: Answer

http://stackoverflow.com/a/4938671
answers question: http://stackoverflow.com/q/626940
type: Answer
upvote count: 24
score: 24
has body: If you click build inside NetBeans, it should give you (in your compiler output) a message like, "To run this application from the command line without Ant, try: java -jar yourPathToRun"
downvote count: 0

http://stackoverflow.com/comment/367535
score: 1
comment on: http://stackoverflow.com/a/555851
type: AnswerComment
type: Comment
has text: Are you sure its not itself a programming language, which perhaps influenced by Java? http://en.wikipedia.org/wiki/Processing_(programming_language)

bytecode-manipulation
type: Tag
tag name: bytecode-manipulation
tags question: http://stackoverflow.com/q/563305

http://stackoverflow.com/a/396770
downvote count: 0
upvote count: 151
has comment: http://stackoverflow.com/comment/256487
type: Answer
has comment: http://stackoverflow.com/comment/44019446
score: 151
has body: You'll have to do this in two steps: 1. Give your JAR a groupId, artifactId and version and add it to your repository. If you don't have an internal repository, and you're just trying to add your JAR to your local repository, you can install it as follows, using any arbitrary groupId/artifactIds: mvn install:install-file -DgroupId=com.stackoverflow... -DartifactId=yourartifactid... -Dversion=1.0 -Dpackaging=jar -Dfile=/path/to/jarfile You can also deploy it to your internal repository if you have one, and want to make this available to other developers in your organization. I just use my repository's web based interface to add artifacts, but you should be able to accomplish the same thing using mvn deploy:deploy-file .... 2. Update dependent projects to reference this JAR. Then update the dependency in the pom.xml of the projects that use the JAR by adding the following to the element: ... com.stackoverflow... artifactId... 1.0 ...
answers question: http://stackoverflow.com/q/396245
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/396245

http://stackoverflow.com/comment/246517
has text: You might as well consider using SwingWorker (part of Java6, but exists as Open Source library for Java5) which will make the source code ligher (threading and EDT issues are handled by SwingWorker itself).
score: 0
type: Comment
comment on: http://stackoverflow.com/a/421416
type: AnswerComment

http://stackoverflow.com/a/30834587
downvote count: 0
has body: Assume there are two classes, Parent and Child. Parent is abstract. The declarations are as follows: abstract class Parent { abstract void run(); } class Child extends Parent { void run() {} } This means that any instance of Parent must specify how run() is executed. However, assume now that Parent is not abstract. class Parent { static void run() {} } This means that Parent.run() will execute the static method. The definition of an abstract method is "A method that is declared but not implemented", which means it doesn't return anything itself. The definition of a static method is "A method that returns the same value for the same parameters regardless of the instance on which it is called". An abstract method's return value will change as the instance changes. A static method will not. A static abstract method is pretty much a method where the return value is constant, but does not return anything. This is a logical contradiction. Also, there is really not much of a reason for a static abstract method.
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/370962

http://stackoverflow.com/q/393853
tagged with: types
has comment: http://stackoverflow.com/comment/220798
has answer: http://stackoverflow.com/a/393861
tagged with: generics
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/394034
has answer: http://stackoverflow.com/a/393872
has answer: http://stackoverflow.com/a/393970
tagged with: java
has title: Java: Trouble with Generics & Collection type detection
has answer: http://stackoverflow.com/a/394074
has body: I have a class called DataSet with various constructors, each specifying a different type of variable. It might look a bit like this: public class DataSet { private HashSet Data; public DataSet( DataObject obj ) { Data = new &lt;DataObject&gt;HashSet(); Data.add( obj ); } public DataSet( ObjectRelationship rel ) { Data = new &lt;ObjectRelationship&gt;HashSet(); Data.add( rel ); } // etc. Note: I haven't yet gotten to test that code due to incomplete parts (which I'm building right now). In a function that I'm currently building, getDataObjects(), I need to return all DataObject objects that this set represents. In the case of constructors that initiate the class's HashSet, Data with types other than DataObject (such as the above ObjectRelationship), there obviously won't be any DataObjects stored within. In this case, I need to be able to detect the type that the HashSet 'Data' was initiated with (like, to tell if it's 'ObjectRelationship' or not, I mean). How do I do this? tl;dr: How do I tell the type that a Collection (in this case, a HashSet) was initiated with in my code (like with an 'if' or 'switch' statement or something)?
type: Question
answer count: 8
has comment: http://stackoverflow.com/comment/220794
has answer: http://stackoverflow.com/a/393857
tagged with: hashset
has answer: http://stackoverflow.com/a/393940
has comment: http://stackoverflow.com/comment/220707
score: 0
has answer: http://stackoverflow.com/a/393855

http://stackoverflow.com/a/596530
has body: It depends if you consider if a subclass of a given class is equals to its parent. class LastName { (...) } class FamilyName extends LastName { (..) } here I would use 'instanceof', because I want a LastName to be compared to FamilyName class Organism { } class Gorilla extends Organism { } here I would use 'getClass', because the class already says that the two instances are not equivalent.
type: Answer
answers question: http://stackoverflow.com/q/596462
upvote count: 5
score: 5
downvote count: 0

http://stackoverflow.com/a/56442559
has body: @Thilo's answer is correct but I feel I must add that you have to take care for JAVA_OPTS environment variable. Many people/servers tend to use it (e.g: remote debugging) as whatever you put into JAVA_OPTS is passed as JVM arguments to any new JVM. If you have this environment variable set then any wrapper.java.additional.&lt;n&gt; will be ignored. I found that on the hard way :)
type: Answer
score: 0
answers question: http://stackoverflow.com/q/625011

http://stackoverflow.com/q/363681
has answer: http://stackoverflow.com/a/14843702
has comment: http://stackoverflow.com/comment/106181133
tagged with: random
has answer: http://stackoverflow.com/a/40854699
linked to: http://stackoverflow.com/q/45685026
answer count: 59
has answer: http://stackoverflow.com/a/23850587
has answer: http://stackoverflow.com/a/29021708
has answer: http://stackoverflow.com/a/363703
has answer: http://stackoverflow.com/a/9297051
has answer: http://stackoverflow.com/a/2310610
tagged with: integer
favorite count: 0
has answer: http://stackoverflow.com/a/33424282
score: 4127
has answer: http://stackoverflow.com/a/27156435
has answer: http://stackoverflow.com/a/424548
has answer: http://stackoverflow.com/a/48978108
has answer: http://stackoverflow.com/a/8913481
linked to: http://stackoverflow.com/q/6029495
has answer: http://stackoverflow.com/a/363708
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/49784982
has answer: http://stackoverflow.com/a/18554758
has answer: http://stackoverflow.com/a/68163344
has answer: http://stackoverflow.com/a/363732
has answer: http://stackoverflow.com/a/21127158
has answer: http://stackoverflow.com/a/47602699
has answer: http://stackoverflow.com/a/10930164
has answer: http://stackoverflow.com/a/30480195
has answer: http://stackoverflow.com/a/20175547
has answer: http://stackoverflow.com/a/6678179
has answer: http://stackoverflow.com/a/44653324
has answer: http://stackoverflow.com/a/74646697
has answer: http://stackoverflow.com/a/44228421
has answer: http://stackoverflow.com/a/50492122
has answer: http://stackoverflow.com/a/44202788
has answer: http://stackoverflow.com/a/43634278
has answer: http://stackoverflow.com/a/363691
has answer: http://stackoverflow.com/a/24216407
tagged with: java
has answer: http://stackoverflow.com/a/363692
has answer: http://stackoverflow.com/a/25101263
has answer: http://stackoverflow.com/a/28453447
has answer: http://stackoverflow.com/a/13098409
has answer: http://stackoverflow.com/a/47069053
has answer: http://stackoverflow.com/a/18955785
has answer: http://stackoverflow.com/a/46642267
has answer: http://stackoverflow.com/a/50627635
has title: How do I generate random integers within a specific range in Java?
has answer: http://stackoverflow.com/a/51961141
has answer: http://stackoverflow.com/a/16987468
type: Question
has answer: http://stackoverflow.com/a/363713
has answer: http://stackoverflow.com/a/41273686
has answer: http://stackoverflow.com/a/29517198
downvote count: 17
has answer: http://stackoverflow.com/a/13728977
has answer: http://stackoverflow.com/a/1377218
has answer: http://stackoverflow.com/a/4647255
has answer: http://stackoverflow.com/a/41735301
linked to: http://stackoverflow.com/q/11051205
has answer: http://stackoverflow.com/a/13098451
has answer: http://stackoverflow.com/a/56912649
has answer: http://stackoverflow.com/a/27180520
has body: How do I generate a random int value in a specific range? The following methods have bugs related to integer overflow: randomNum = minimum + (int)(Math.random() * maximum); // Bug: `randomNum` can be bigger than `maximum`. Random rn = new Random(); int n = maximum - minimum + 1; int i = rn.nextInt() % n; randomNum = minimum + i; // Bug: `randomNum` can be smaller than `minimum`.
has answer: http://stackoverflow.com/a/11923174
upvote count: 4144
has answer: http://stackoverflow.com/a/2271563
has answer: http://stackoverflow.com/a/29279143
has answer: http://stackoverflow.com/a/20761900
linked to: http://stackoverflow.com/q/738629
has answer: http://stackoverflow.com/a/65924896
has answer: http://stackoverflow.com/a/39711614
has answer: http://stackoverflow.com/a/363693
has answer: http://stackoverflow.com/a/70529176

http://stackoverflow.com/q/438594
has answer: http://stackoverflow.com/a/438643
has answer: http://stackoverflow.com/a/438693
has title: How to call java objects and functions from CPython?
tagged with: function
downvote count: 0
has answer: http://stackoverflow.com/a/24247890
score: 11
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/438693
upvote count: 11
favorite count: 0
answer count: 6
has body: I have a python program, which runs on the CPython implementation, and inside it I must call a function defined in a java program. How can I do this? It would be nice to be able to use some java objects too. Jython is not an option. I must run the python part in CPython.
has answer: http://stackoverflow.com/a/444447
type: Question
has answer: http://stackoverflow.com/a/3793504
tagged with: language-interoperability
tagged with: python
has answer: http://stackoverflow.com/a/438658
possible better answer: http://stackoverflow.com/a/3793504
tagged with: java

http://stackoverflow.com/q/435474
score: 2
upvote count: 2
type: UnansweredQuestion
tagged with: web-services
has body: Link is: http://people.apache.org/~ruchithf/hw-axis2/. Command line is: javac -extdirs d:\lib\ D:\stub\src\org\apache\ws\axis2\*.java -d d:\clientcode\ The Error is: C:\Program Files\Java\jdk1.6.0\bin&gt;javac -extdirs d:\lib\ D:\stub\src\org\apache \ws\axis2\*.java -d d:\clientcode\ D:\stub\src\org\apache\ws\axis2\Client.java:3: cannot find symbol symbol : class EchoRequest location: class org.apache.ws.axis2.SimpleServiceStub import org.apache.ws.axis2.SimpleServiceStub.EchoRequest; ^ D:\stub\src\org\apache\ws\axis2\Client.java:12: cannot find symbol symbol : class EchoRequest location: class org.apache.ws.axis2.Client EchoRequest request = new SimpleServiceStub.EchoRequest(); ^ D:\stub\src\org\apache\ws\axis2\Client.java:12: cannot find symbol symbol : class EchoRequest location: class org.apache.ws.axis2.SimpleServiceStub EchoRequest request = new SimpleServiceStub.EchoRequest(); ^ Note: D:\stub\src\org\apache\ws\axis2\SimpleServiceStub.java uses unchecked or u nsafe operations. Note: Recompile with -Xlint:unchecked for details. 3 errors C:\Program Files\Java\jdk1.6.0\bin&gt;javac -extdirs d:\lib\ D:\stub\src\org\apache \ws\axis2\*.java -d d:\clientcode\ D:\stub\src\org\apache\ws\axis2\Client.java:3: cannot find symbol symbol : class EchoRequest location: class org.apache.ws.axis2.SimpleServiceStub import org.apache.ws.axis2.SimpleServiceStub.EchoRequest; ^ D:\stub\src\org\apache\ws\axis2\Client.java:12: cannot find symbol symbol : class EchoRequest location: class org.apache.ws.axis2.Client EchoRequest request = new SimpleServiceStub.EchoRequest(); ^ D:\stub\src\org\apache\ws\axis2\Client.java:12: cannot find symbol symbol : class EchoRequest location: class org.apache.ws.axis2.SimpleServiceStub EchoRequest request = new SimpleServiceStub.EchoRequest(); ^ Note: D:\stub\src\org\apache\ws\axis2\SimpleServiceStub.java uses unchecked or u nsafe operations. Note: Recompile with -Xlint:unchecked for details. 3 errors
tagged with: java
has title: Why am I unable to generate client side code in web services 'Hello world' example?
type: Question
answer count: 2
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/435545
has comment: http://stackoverflow.com/comment/258262
has answer: http://stackoverflow.com/a/440318
has comment: http://stackoverflow.com/comment/258289

http://stackoverflow.com/a/363886
has body: throw code away rewrite in java ???? profit!
downvote count: 2
type: Answer
upvote count: 3
score: 1
answers question: http://stackoverflow.com/q/363805

http://stackoverflow.com/a/385594
type: Answer
score: 2
answers question: http://stackoverflow.com/q/385332
has body: I've solved this in different ways. First, the non-portable way, is that Glassfish (and I do believe Tomcat as well) allows you to map an external directory in to the webapps hierarchy. This works really well and does exactly what you want. It lets you store your images in an external directory away from your webapp, yet still serve them up. However, this technique is not portable. The way to I've done it portably is by creating a filter. You place the filter someplace obvious, say "/images". What the filter does is this: it checks for the image (or anything, it works with any static resource) in a special directory within the webapp. For our example we'll use the url "/webapp/images". if the file DOES NOT exist, we copy the file from your external location in to the appropriate spot within the webapp. So, let's say the reqyest url is "/images/banner.gif". And that your files are stored on disk at "/home/app/images". So, our source file is "/home/app/images/banner.gif". We then copy it to where we want it in the webapp tree. We use "ServletContext.getRealPath" for this. So, the destination will be "ServletContext.get RealPath("/webapp/images/banner.gif"). Just copy the source to the destination. if the file already existed, or now exists, simply forward to the actual image at /webapp/images/banner.gif. Effectively you end up having a file cache within your webapps deployment tree. The down side is that it's a cache, so it needs to be maintained (i.e. you should check if the original is newer than your cache, make sure you delete if the source is deleted, etc.). Also, it duplicates your resources, so your images will consume, eventually, twice as much disk space. Finally, there's the initial copy cost at start up. However, it DOES work, and it prevents you from having to serve up static resources using your own code. (Which is the 3rd solution, map a filter/servlet to intercept the URLs and simply stream it your self.) I would look at the construct within Tomcat (ass…
downvote count: 0
upvote count: 2

http://stackoverflow.com/a/672954
has comment: http://stackoverflow.com/comment/486534
score: 0
upvote count: 1
downvote count: 1
has body: Well, I'm not really a Java guy, so I can't say much, except for... JSF We tried to use it for some time and it was a disaster. Almots all basics steps had to be passed with lots of pain, no documentation, no examples, no community knowledge. We used then one plugin for Eclipse (Exadel Studio), we had a look at a few other JSF frameworks, they were all incompatible and poorly documented. As a matter of fact, of all those we tried, only Sun framework (forgot its name, based on NetBeans) could create a new JSF project even compilable out of the box. The rest required many days of configuration of apache and other things, which for an unexperienced person is a real challenge (though I managed it). Our team spent a few months on something which was done later in just a few weeks with ASP.NET. People were both inexperienced in JSF and ASP.NET. If JSF ecosystem is still that bad as it was in 2007, I would recommend avoiding it altogether, productivity is out of the question anyway. Maybe stick with JSP or something that is time-proved and well developed?
type: Answer
answers question: http://stackoverflow.com/q/645746

http://stackoverflow.com/q/430479
has answer: http://stackoverflow.com/a/431241
has comment: http://stackoverflow.com/comment/289828
downvote count: 0
has title: How do I use an equivalent to C++ reference parameters in Java?
favorite count: 0
has answer: http://stackoverflow.com/a/472188
upvote count: 8
has answer: http://stackoverflow.com/a/430496
has body: Suppose I have this in C++: void test(int &amp;i, int &amp;j) { ++i; ++j; } The values are altered inside the function and then used outside. How could I write a code that does the same in Java? I imagine I could return a class that encapsulates both values, but that seems really cumbersome.
has answer: http://stackoverflow.com/a/433631
has answer: http://stackoverflow.com/a/430491
score: 8
tagged with: reference
tagged with: c++
has answer: http://stackoverflow.com/a/431152
has answer: http://stackoverflow.com/a/430488
has comment: http://stackoverflow.com/comment/254073
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/373419
type: Question
has answer: http://stackoverflow.com/a/13633169
has answer: http://stackoverflow.com/a/28518436
tagged with: java
has comment: http://stackoverflow.com/comment/1201020
answer count: 11
has answer: http://stackoverflow.com/a/430530
has answer: http://stackoverflow.com/a/430492

http://stackoverflow.com/a/14707890
answers question: http://stackoverflow.com/q/458489
upvote count: 1
score: 1
downvote count: 0
has body: Apache ActiveMQ has a datastructure called BitArrayBin. This is used to find out whether a message is duplicated. A message ID is a combination of producer ID and sequence ID. Each producer will have a BitArrayBin to track its sequence IDs. Once it finds out the BitArrayBin for the given producer, it sets the sequence ID which is a long value to the BitArrayBin. oldValue = bitArrayBin.setBit(sequenceId, true) if (oldVlaue) { "message is duplicated" } The method returns the old Value. If y is the long index, it is used to derive at a bin index and an offset into it. y = bin index * 64 + offset BitArrayBin is nothing but a holder for many bins where the size can be defined during its construction. Each bin contains a long variable to store the bits so so it can store up to 64 boolean values. Bit masking is used to set the bit, and then, get it's value. This class doesn't have much documentation. You need to go through its source code to know the internals.
type: Answer

http://stackoverflow.com/comment/110051915
type: AnswerComment
comment on: http://stackoverflow.com/a/49058835
type: Comment
has text: Excelent answer
score: 0

http://stackoverflow.com/q/589732
tagged with: http://stackoverflow.com/tag/xml
type: AnsweredQuestion
upvote count: 3
has answer: http://stackoverflow.com/a/589968
type: Question
score: 3
tagged with: enums
tagged with: java
answer count: 6
has answer: http://stackoverflow.com/a/592193
accepted answer: http://stackoverflow.com/a/589968
downvote count: 0
has title: What is best practice for serializing Java enums to XML?
has body: Hi I have a Java enum and I want serialize a variable containing an enum value back and forth from XML for persistence. My enum is defined like this... public enum e_Type { e_Unknown, e_Categoric, e_Numeric } My variable is declared like this... private e_Type type; I want it to go into an XML tag like this... value What's the best practice for persisting values of enums in XML?
tagged with: persistence
favorite count: 0
tagged with: serialization
has answer: http://stackoverflow.com/a/589795
has answer: http://stackoverflow.com/a/2105111
possible better answer: http://stackoverflow.com/a/590062
has answer: http://stackoverflow.com/a/589736
has answer: http://stackoverflow.com/a/590062

http://stackoverflow.com/comment/372414
type: Comment
type: QuestionComment
has text: Is the image eventually going to be dynamically generated?
score: 0
comment on: http://stackoverflow.com/q/561215

http://stackoverflow.com/comment/336016
comment on: http://stackoverflow.com/a/522230
type: AnswerComment
has text: I'm curious about what you find "nasty" in the java language.
score: 0
type: Comment

http://stackoverflow.com/q/471296
has comment: http://stackoverflow.com/comment/288987
has comment: http://stackoverflow.com/comment/289013
accepted answer: http://stackoverflow.com/a/471314
favorite count: 0
has answer: http://stackoverflow.com/a/471639
answer count: 12
has comment: http://stackoverflow.com/comment/289478
has answer: http://stackoverflow.com/a/471734
score: 142
has answer: http://stackoverflow.com/a/6852808
has answer: http://stackoverflow.com/a/471314
upvote count: 149
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/471302
has answer: http://stackoverflow.com/a/472197
tagged with: java
has comment: http://stackoverflow.com/comment/288984
has answer: http://stackoverflow.com/a/471394
has comment: http://stackoverflow.com/comment/289098
has title: How can "while (i == i) ;" be a non-infinite loop in a single threaded application?
downvote count: 7
type: Question
has body: I just got a question that I can't answer. Suppose you have this loop definition in Java: while (i == i) ; What is the type of i and the value of i if the loop is not an infinite loop and the program is using only one thread?
has answer: http://stackoverflow.com/a/471317
has comment: http://stackoverflow.com/comment/289002
has comment: http://stackoverflow.com/comment/967780
has answer: http://stackoverflow.com/a/6856066
has answer: http://stackoverflow.com/a/471302
has answer: http://stackoverflow.com/a/1149055
has answer: http://stackoverflow.com/a/471318
has comment: http://stackoverflow.com/comment/288964
has answer: http://stackoverflow.com/a/6852418
has comment: http://stackoverflow.com/comment/289020

http://stackoverflow.com/q/366237
has answer: http://stackoverflow.com/a/366259
tagged with: division
downvote count: 1
has answer: http://stackoverflow.com/a/366253
has answer: http://stackoverflow.com/a/366240
has body: Here's an example: Double d = (1/3); System.out.println(d); This returns 0, not 0.33333... as it should. Does anyone know?
tagged with: java
answer count: 3
possible better answer: http://stackoverflow.com/a/366253
has title: Double value returns 0
has comment: http://stackoverflow.com/comment/77223990
linked to: http://stackoverflow.com/q/10455677
upvote count: 12
linked to: http://stackoverflow.com/q/4685450
accepted answer: http://stackoverflow.com/a/366240
score: 11
duplicate of: http://stackoverflow.com/q/4685450
type: AnsweredQuestion
favorite count: 0
type: Question

http://stackoverflow.com/a/24655212
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/529085
type: Answer
has comment: http://stackoverflow.com/comment/47093163
has body: I'm wondering if this code would create an effective generic array? public T [] createArray(int desiredSize){ ArrayList<T> builder = new ArrayList<T>(); for(int x=0;x<desiredSize;x++){ builder.add(null); } return builder.toArray(zeroArray()); } //zeroArray should, in theory, create a zero-sized array of T //when it is not given any parameters. private T [] zeroArray(T... i){ return i; } Perhaps an alternate way of creating such an array, if the size you required was known and small, would be to simply feed the required number of "null"s into the zeroArray command? Though obviously this isn't as versatile as using the createArray code.
score: 0

http://stackoverflow.com/a/533015
downvote count: 0
type: Answer
has body: Like many things in Swing, the answer to your question is revealed in the swing source code. From JLayeredPane.java: public static int getLayer(JComponent c) { Integer i; if((i = (Integer)c.getClientProperty(LAYER_PROPERTY)) != null) return i.intValue(); return DEFAULT_LAYER.intValue(); } public int getLayer(Component c) { Integer i; if(c instanceof JComponent) i = (Integer)((JComponent)c).getClientProperty(LAYER_PROPERTY); else i = (Integer)getComponentToLayer().get((Component)c); if(i == null) return DEFAULT_LAYER.intValue(); return i.intValue(); } It looks like the reason you are seeing some differences here is that the layer of a JComponent instance is stored as a property of the JComponent instance, but the layer of a Component instance is stored within a hashtable of JLayeredPane. Hence, getLayer(JComponent c) can be static while getLayer(Component c) cannot. As you might imagine, this is just the start of the strangeness of this class. Validating and painting JLayeredPane and contents can get complicated quickly.
upvote count: 3
accepted answer of: http://stackoverflow.com/q/499465
score: 3
answers question: http://stackoverflow.com/q/499465
type: AcceptedAnswer

http://stackoverflow.com/comment/127804387
type: Comment
has text: then why some frameworks, like kafka, when serializing data, don't mandate the instances to implement Serializable ?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/441346

http://stackoverflow.com/a/401846
upvote count: 5
score: 5
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/401783
answers question: http://stackoverflow.com/q/401783
type: Answer
has body: Just us the functions and types provided by &lt;Foundation/Foundation.h&gt;. NSSwappedFloat bigEndianFloat; memcpy(&amp;bigEndianFloat, [[file readDataOfLength:4] bytes], 4); float floatValue = NSSwapBigFloatToHost(bigEndianFloat); Note that they use a special type to hold the float before the bytes are swapped. This is because if you swap the bytes of a floating point value, it can be changed into a Signaling NaN, and on some processors, this will cause a hardware exception by just assigning it to a variable.

http://stackoverflow.com/a/35378242
answers question: http://stackoverflow.com/q/541487
type: Answer
has body: If I am not wrong, it's more or less similar to What is the difference between an interface and abstract class? extends establishes "Is A" relation & interface provides "Has a" capability. Prefer implements Runnable : If you don't have to extend Thread class and modify Thread API default implementation If you are executing a fire and forget command If You are already extending another class Prefer "extends Thread" : If you have to override any of these Thread methods as listed in oracle documentation page Generally you don't need to override Thread behaviour. So implements Runnable is preferred for most of the times. If you need some customization for this Thread API, you can extend Thread and modify implementation Thread(ThreadGroup group, Runnable target, String name, long stackSize) Allocates a new Thread object so that it has target as its run object, has the specified name as its name, and belongs to the thread group referred to by group, and has the specified stack size. On a different note, using advanced ExecutorService or ThreadPoolExecutorService API provides more flexibility and control. Have a look at this SE Question: ExecutorService vs Casual Thread Spawner
downvote count: 0
score: 6
upvote count: 6

http://stackoverflow.com/a/621782
has comment: http://stackoverflow.com/comment/79844353
upvote count: 10
type: Answer
answers question: http://stackoverflow.com/q/620993
score: 9
has comment: http://stackoverflow.com/comment/79839823
has body: Have a look at the JMimeMagic library. jMimeMagic is a Java library for determining the MIME type of files or streams.
has comment: http://stackoverflow.com/comment/79844612
downvote count: 1
has comment: http://stackoverflow.com/comment/79657107

http://stackoverflow.com/comment/346180
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/533362
has text: I'm not sure I follow what you are saying. I think it would help if you gave a precise definition of what you mean by the terms binding and dispatch. (Doesn't dispatch mean method invocation, in which case at some point in dynamic binding we end up with a jump/call instruction which is a dispatch??)
score: 0

http://stackoverflow.com/comment/31898903
score: 0
type: Comment
comment on: http://stackoverflow.com/a/440802
has text: @teddy_teddy & @Esko: since `protected` is **less** restrictive than the default "package" accessibility modifier, the method described by @Esko will work for both, but ideally it should be done in the "Maven way" noted by @sleske
type: AnswerComment

http://stackoverflow.com/a/646790
downvote count: 0
has comment: http://stackoverflow.com/comment/56239885
has comment: http://stackoverflow.com/comment/3314943
type: Answer
upvote count: 6
has comment: http://stackoverflow.com/comment/460111
score: 6
answers question: http://stackoverflow.com/q/643906
has body: Before generics, it was created for the reflection API, to hold TYPE returned by Method.getReturnType() for a void method, corresponding to the other primitive type classes. EDIT: From the JavaDoc of Void: "The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the Java keyword void". Prior to Generics, I am aware of no use other than reflection.

http://stackoverflow.com/comment/265633
type: Comment
type: QuestionComment
score: 2
has text: I am not sure I understand what result do you expect. I would use URLEncoder.
comment on: http://stackoverflow.com/q/444112

http://stackoverflow.com/q/367862
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/369653
score: 1
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/367882
has answer: http://stackoverflow.com/a/368446
possible better answer: http://stackoverflow.com/a/367868
has answer: http://stackoverflow.com/a/367868
upvote count: 1
favorite count: 0
has title: Java regexp for file filtering
answer count: 5
has answer: http://stackoverflow.com/a/367928
accepted answer: http://stackoverflow.com/a/367928
tagged with: regex
has body: I would like to build a regexp in Java that would be passed in a FilenameFilter to filter the files in a dir. The problem is that I can't get the hang of the regexp "mind model" :) This is the regexp that I came up with to select the files that I would like to exclude ((ABC|XYZ))+\w*Test.xml What I would like to do is to select all the files that end with Test.xml but do not start with ABC or XYZ. Could you please add any resources that could help me in my battle with regexps. Thanks The following resource explains a lot of things about regexp regular-expressions.info

http://stackoverflow.com/q/623533
favorite count: 0
has answer: http://stackoverflow.com/a/31982035
type: UnansweredQuestion
tagged with: android
has title: Android (Java) network programming resources
has answer: http://stackoverflow.com/a/16429580
tagged with: java
has body: I would like to develop an application for Android which would transfer data through TCP connection. Does anyone know for any good example or book where client-server connection example could be found? I'm quite new with Java and Android so I would be very thankful for any suggestion.
type: Question
has answer: http://stackoverflow.com/a/16497268
tagged with: network-programming
score: 15
upvote count: 15
answer count: 3
downvote count: 0

http://stackoverflow.com/comment/432267
type: Comment
comment on: http://stackoverflow.com/a/619304
has text: +1 on dismantling the problem, -1 on thinking there's any relationship between 'web2.0-ness' and platform
type: AnswerComment
score: 0

http://stackoverflow.com/comment/7216441
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/475886
has text: Be careful as there is a difference between escaping XML and HTML.
score: 10

http://stackoverflow.com/comment/449191
has text: Where is the HashMap "m" used? And is there a reason not to generify the class?
type: AnswerComment
comment on: http://stackoverflow.com/a/635927
score: 0
type: Comment

http://stackoverflow.com/a/561592
has body: It does not matter on a modern compiler. int v = i++; is the same as int v = i; i = i + 1; A modern compiler will discover that v is unused and the code to calculate v is pure (no side effects). Then it will remove v and the assignment code and will generate this i = i + 1;
has comment: http://stackoverflow.com/comment/372938
has comment: http://stackoverflow.com/comment/372761
has comment: http://stackoverflow.com/comment/372842
type: Answer
has comment: http://stackoverflow.com/comment/372695
downvote count: 2
upvote count: 7
answers question: http://stackoverflow.com/q/561588
has comment: http://stackoverflow.com/comment/372701
score: 5

http://stackoverflow.com/q/470724
has answer: http://stackoverflow.com/a/470741
has answer: http://stackoverflow.com/a/470799
tagged with: java
has body: I have found one error in my Java program: The public type abc class must be defined in its own class How can I resolve this error? I am using Eclipse. I am new to Java programming.
tagged with: class
type: Question
downvote count: 0
score: 4
has answer: http://stackoverflow.com/a/470796
has answer: http://stackoverflow.com/a/470731
has title: Defining classes in Java files
upvote count: 4
has answer: http://stackoverflow.com/a/470749
favorite count: 0
answer count: 5
type: UnansweredQuestion

http://stackoverflow.com/comment/2505074
type: Comment
type: QuestionComment
has text: Elaborate on what you mean by "best".
comment on: http://stackoverflow.com/q/632933
score: 0

http://stackoverflow.com/comment/333186
type: Comment
has text: Yup, that's what I wrote in the original entry :)
comment on: http://stackoverflow.com/a/519799
score: 0
type: AnswerComment

http://stackoverflow.com/comment/281342
has text: I know, but this ***** API has been considered feature complete for 5 years by the vendor in question, and has a huge installed base.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/462786

http://stackoverflow.com/q/406352
tagged with: matlab
type: Question
score: 1
tagged with: java
tagged with: memory
has body: I'm experiencing some issues regarding my javabuilder-compiled matlab-code. My application is basically split up like this: GUI: Java Calculations: Matlab The main problem is that when compiling my matlab-code with the javabuilder in Matlab (R17, 2007a), I have less memory available than I have when I compile the same code to an exe-file. I have confirmed this with the "feature('memstats')" function. My arrays are typically of size orders 1000000 x 25, and this is not initializable when run from java, as the largest contiguous memory space is too small (the biggest one is about 65MB, as opposed to about 1200MB when run as a ML exe-file). My rig is running Windows XP Professional x86 and has 4GB of memory. I've tried these two matlab/c-compilators (set up with the "mbuild -setup" command in the matlab command line): Lcc-win32 C 2.4.1 Microsoft Visual C++ 6.0 (also with the /LARGEADDRESSAWARE flag, which does not seem to help at all) Any suggestions?
has answer: http://stackoverflow.com/a/406432
downvote count: 0
has answer: http://stackoverflow.com/a/406690
has answer: http://stackoverflow.com/a/1260364
favorite count: 0
answer count: 3
has title: Problems with Matlab javabuilder and memory
type: UnansweredQuestion
upvote count: 1

http://stackoverflow.com/a/2183921
upvote count: 2
downvote count: 3
has comment: http://stackoverflow.com/comment/7494313
has comment: http://stackoverflow.com/comment/7494362
score: -1
has comment: http://stackoverflow.com/comment/11872704
has comment: http://stackoverflow.com/comment/11872398
has comment: http://stackoverflow.com/comment/7493364
answers question: http://stackoverflow.com/q/462297
has comment: http://stackoverflow.com/comment/2134666
has body: It is confusing in the beginning. But it helps in the situations below : class SomeAction implements Action { } // Later in the code. Class&lt;Action&gt; actionClass = Class.forName("SomeAction"); Action action = actionClass.newInstance(); // Notice you get an Action instance, there was no need to cast.
type: Answer
has comment: http://stackoverflow.com/comment/2136316
has comment: http://stackoverflow.com/comment/4615003

http://stackoverflow.com/a/399355
answers question: http://stackoverflow.com/q/399311
score: 0
type: Answer
has body: if you care about it's position, try adding it to a SortedSet (probably a TreeSet)

http://stackoverflow.com/comment/301621
comment on: http://stackoverflow.com/a/484218
type: AnswerComment
type: Comment
has text: Um of course C++ is bad... just look at the baroque headers system, the crippled preprocessor, the complexity of polymorphic storage, the near-impossibility of using exceptions correctly, the extremely lacking standard library... not to mention the verbosity and awkwardness of basic constructs...
score: 2

http://stackoverflow.com/comment/256537
comment on: http://stackoverflow.com/a/433478
type: AnswerComment
has text: I'm trying to do this from a program so I can give users a warning if they use less than my plugin will require.
score: 0
type: Comment

http://stackoverflow.com/comment/366798
has text: The other part of the question of course is which constructor is it actually considering. According to the log it has decided to ignore one of them, as it should. Why does it think it needs a String argument? Or is the String requirement an artefact of choosing the wrong constructor?
score: 0
type: Comment
comment on: http://stackoverflow.com/a/555015
type: AnswerComment

http://stackoverflow.com/comment/359102
type: AnswerComment
comment on: http://stackoverflow.com/a/544630
type: Comment
has text: I'm confused. xsl:strip-space strips whitespace-only text nodes from the source tree. So under what circumstances can the template matching text() nodes emit a message? All of the text nodes it's testing for have already been removed from the source tree.
score: 0

http://stackoverflow.com/comment/438089
has text: List is an interface - no implementation details there.
type: Comment
comment on: http://stackoverflow.com/a/625266
score: 0
type: AnswerComment

http://stackoverflow.com/a/2855486
type: Answer
answers question: http://stackoverflow.com/q/502256
has body: object reference is different from object. for eg: class Shape { int x = 200; } class Shape1 { public static void main(String arg[]) { Shape s = new Shape(); //creating object by using new operator System.out.println(s.x); Shape s1; //creating object reference s1 = s; //assigning object to reference System.out.println(s1.x); } }
score: 0

http://stackoverflow.com/comment/87383751
score: 5
has text: I get a NullPointerException when one of the fields I am comparing is null, like a String. Is there anyway to keep this compare format but allow it to be null safe?
comment on: http://stackoverflow.com/a/25501226
type: AnswerComment
type: Comment

http://stackoverflow.com/a/408198
upvote count: 6
has body: As a non-answer aside (the existing answers more than suffice), you might want to check out a whitepaper on the JVM garbage collection system if you are at all interested in GC. (Any, just google JVM Garbage Collection) I was amazed at some of the techniques used, and when reading through some of the concepts like "Eden" I really realized for the first time that Java and the JVM actually could beat C/C++ in speed. (Whenever C/C++ frees an object/block of memory, code is involved... When Java frees an object, it actually doesn't do anything at all; since in good OO code, most objects are created and freed almost immediately, this is amazingly efficient.) Modern GC's tend to be very efficient, managing older objects much differently than new objects, being able to control GCs to be short and half-assed or long and thorough, and a lot of GC options can be managed by command line switches so it's actually useful to know what all the terms actually refer to. Note: I just realized this was misleading. C++'s STACK allocation is very fast--my point was about allocating objects that are able to exist after the current routine has finished (which I believe SHOULD be all objects--it's something you shouldn't have to think about if you are going to think in OO, but in C++ speed may make this impractical). If you are only allocating C++ classes on the stack, it's allocation will be at least as fast as Java's.
has comment: http://stackoverflow.com/comment/108840802
answers question: http://stackoverflow.com/q/407855
has comment: http://stackoverflow.com/comment/1793294
downvote count: 0
has comment: http://stackoverflow.com/comment/1793280
score: 6
type: Answer
has comment: http://stackoverflow.com/comment/1793145

http://stackoverflow.com/a/580274
upvote count: 11
has body: The list.size() is past the last allowable index. for(int j = list.size() - 1; j &gt;= 0; j--) { System.out.println(list.get(j)); }
downvote count: 0
has comment: http://stackoverflow.com/comment/75802522
answers question: http://stackoverflow.com/q/580269
type: Answer
has comment: http://stackoverflow.com/comment/392235
score: 11

http://stackoverflow.com/comment/399361
has text: It's only shared between both classes, so I think it doesn't have to be.
score: 0
type: Comment
comment on: http://stackoverflow.com/q/587392
type: QuestionComment

http://stackoverflow.com/q/574397
has body: This is a jstack output from a running JVM "FooThread" prio=10 tid=0x00007f159c2ca000 nid=0x6e21 waiting on condition ..snipped java.lang.Thread.State: TIMED_WAITING (sleeping) at java.lang.Thread.sleep(Native Method) at com.myco.impl.QueueFooThread.run(Unknown Source) I want the line number in QueueFooThread to show up like this frame for the Catalina process at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1548) What should I do during compilation/bootstrap time to enable this ? Thanks
answer count: 4
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/386221
accepted answer: http://stackoverflow.com/a/574399
type: Question
tagged with: debugging
has answer: http://stackoverflow.com/a/599490
tagged with: java
has answer: http://stackoverflow.com/a/574445
tagged with: concurrency
has title: How to show source line numbers in jstack output?
score: 0
possible better answer: http://stackoverflow.com/a/574445
has answer: http://stackoverflow.com/a/574399
tagged with: jvm
has answer: http://stackoverflow.com/a/574607

http://stackoverflow.com/a/1949809
type: Answer
has body: Java hasn't got any love here? For 2D and 3D OpenGL on win/mac/linux/android, try libgdx. For 2D with API similar to Java2D try Slick. LWJGL for pure OpenGL bindings. Ardor3D or JMonkeyEngine for a higher level 3D library. For networking, KryoNet.
upvote count: 14
has comment: http://stackoverflow.com/comment/37095604
score: 14
answers question: http://stackoverflow.com/q/564469
downvote count: 0

http://stackoverflow.com/comment/211085
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/383570
type: Comment
has text: I'm not sure why you'd want to Integer maps easily to Strings via toString() and vice versa with Integer.valueOf() so what's the point?

http://stackoverflow.com/a/443755
has comment: http://stackoverflow.com/comment/265523
score: 0
answers question: http://stackoverflow.com/q/443558
type: Answer
has body: Hmm... without serialization, and without an ORM solution, I would fall back to some sort of XML based implementation? You'd still have to design it carefully if you want to pull out only some of the objects from the object graph - perhaps a different file for each object, where object relationships are referenced by a URI to another file? I would have said that wasn't "easy" because I've always found designing the mapping of XML to objects to be somewhat time consuming, but I was really inspired by a conversation on Apache Betwixt that has me feeling hopeful that I'm just out of date, and easier solutions are now available.

http://stackoverflow.com/a/462775
has comment: http://stackoverflow.com/comment/281274
answers question: http://stackoverflow.com/q/462696
type: Answer
has body: I don't think there is a perfect answer. I don't exactly know what you need to do, but can you do the writing to a new file, and then on success, rename files, rather than copying. Renaming is quick, and hence should be less prone a crash. This still won't help if it fails at the rename stage, but you've minimized the window of risk. Again, I'm not sure if it is applicable or relevant to your needs, but can you write some file block at the end of the file to show all the data has been written?
has comment: http://stackoverflow.com/comment/6298041
score: 0

http://stackoverflow.com/a/26803522
type: Answer
upvote count: 2
has body: Unfortunatelly, it is not so easy as Microsoft has removed advanced file association dialog in recent Windows editions. - With newer Windows versions you may only specify the application that is going to be used to open .jar file. Fixing .jar file opening on Windows requires two steps. Open the Control Panel, and chose "Default Programs -> Set Associations". Find .jar extension (Executable JAR file) there, and pick Java as default program to open this extension. It will probably be listed as "Java Platform(SE)". A faster alternative perhaps is straightforward right-click on a .jar file, and then change associated program by clicking on the "Change..." button. Now open the regedit, and open the HKEY_CLASSES_ROOT\jarfile\shell\open\command key. Luckilly for us, we may specify parameters there for the (Default) value. On my Windows system it looks like: C:\app\32\jre7\bin\javaw.exe" -jar "%1" %* but in most cases it is the following string: C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %* NOTES: Do not use java.exe there as it will open the shell window. The jarfix tool mentioned in this thread most likely does nothing more than the registry modification for you. I prefer manual registry change method, as that implies that system administrator can "push" the registry change to all workstations in the network.
score: 2
has comment: http://stackoverflow.com/comment/121653130
answers question: http://stackoverflow.com/q/394616
downvote count: 0

http://stackoverflow.com/comment/44923586
has text: You might find this useful http://www.rationaljava.com/2015/02/maven-tip-all-about-executable-jars.html
comment on: http://stackoverflow.com/q/574594
type: Comment
type: QuestionComment
score: 2

http://stackoverflow.com/a/4637105
score: 9
downvote count: 4
has comment: http://stackoverflow.com/comment/45813072
has body: You could use a static lookup table: public enum Suit { spades, hearts, diamonds, clubs; private static final Map&lt;Integer, Suit&gt; lookup = new HashMap&lt;Integer, Suit&gt;(); static { int ordinal = 0; for (Suit suit : EnumSet.allOf(Suit.class)) { lookup.put(ordinal, suit); ordinal+= 1; } } public Suit fromOrdinal(int ordinal) { return lookup.get(ordinal); } }
answers question: http://stackoverflow.com/q/609860
has comment: http://stackoverflow.com/comment/126325732
has comment: http://stackoverflow.com/comment/132554957
has comment: http://stackoverflow.com/comment/52585814
has comment: http://stackoverflow.com/comment/139256938
type: Answer
upvote count: 13
has comment: http://stackoverflow.com/comment/65014248
has comment: http://stackoverflow.com/comment/7602728

http://stackoverflow.com/q/431579
type: Question
upvote count: 2
has answer: http://stackoverflow.com/a/432068
has answer: http://stackoverflow.com/a/431853
tagged with: swing
tagged with: components
tagged with: java
downvote count: 1
has comment: http://stackoverflow.com/comment/255022
answer count: 5
type: UnansweredQuestion
tagged with: http://stackoverflow.com/tag/html
has answer: http://stackoverflow.com/a/431906
tagged with: user-interface
has body: Does anybody know of a pure java (ar at least cross platform) open source component/library which displays HTML which can contain swing components inside it? All I could find were either abandoned or incomplete. I am asking because I'm thinking about trying out approach to do use this combination for creating desktop application. EDIT:Seems like this question is missunderstood, so let me clarify it. I basically want to create desktop application in the similar way as web. Idealy I would like browser to serve as an UI layer. That browser should allow me to embed my own compoents, eg to be able to use JTextField instead of &lt;input type="text"&gt;. Since I don't know of such easily usable browser, I was asking for a html component which will let me do it. I hop the question is clearer right now.
score: 1
has title: Swing components inside HTML
favorite count: 0
has answer: http://stackoverflow.com/a/431862
has answer: http://stackoverflow.com/a/448641

http://stackoverflow.com/q/404733
tagged with: java
has answer: http://stackoverflow.com/a/32923176
has answer: http://stackoverflow.com/a/404742
has comment: http://stackoverflow.com/comment/138205135
answer count: 5
type: UnansweredQuestion
upvote count: 18
has answer: http://stackoverflow.com/a/32993311
has title: Java: how to check if character belongs to a specific unicode block?
has comment: http://stackoverflow.com/comment/107915392
tagged with: char
downvote count: 0
has body: I need to identify what natural language my input belongs to. The goal is to distinguish between Arabic and English words in a mixed input, where the input is Unicode and is extracted from XML text nodes. I have noticed the class Character.UnicodeBlock. Is it related to my problem? How can I get it to work? Edit: The Character.UnicodeBlock approach was useful for Arabic, but apparently doesn't do it for English (or other European languages) because the BASIC_LATIN Unicode block covers symbols and non-printable characters as well as letters. So now I am using the matches() method of the String object with the regex expression "[A-Za-z]+" instead. I can live with it, but perhaps someone can suggest a nicer/faster way.
tagged with: unicode
favorite count: 0
has answer: http://stackoverflow.com/a/409019
type: Question
has answer: http://stackoverflow.com/a/410854
tagged with: regex
score: 18

http://stackoverflow.com/a/40878647
score: 0
type: Answer
answers question: http://stackoverflow.com/q/507602
has body: Even with Guava's nice ImmutableMap class, sometimes I'd like to build a mutable map fluently. Finding myself wanting to avoid static blocks &amp; the anonymous subtype thing, when Java 8 came along I wrote a tiny library to help called Fluent. // simple usage, assuming someMap is a Map&lt;String, String&gt; already declared Map&lt;String, String&gt; example = new Fluent.HashMap&lt;String, String&gt;() .append("key1", "val1") .append("key2", "val2") .appendAll(someMap); With Java 8 interface defaulting I could implement the Fluent.Map methods for all standard Java Map implementations (ie HashMap, ConcurrentSkipListMap, ... etc) without tedious repetition. Unmodifiable maps are simple too. Map&lt;String, Integer&gt; immutable = new Fluent.LinkedHashMap&lt;String, Integer&gt;() .append("one", 1) .append("two", 2) .append("three", 3) .unmodifiable(); See https://github.com/alexheretic/fluent for source, documentation and examples.

http://stackoverflow.com/a/4356328
upvote count: 9
type: Answer
answers question: http://stackoverflow.com/q/557844
downvote count: 0
score: 9
has body: I've built a short implementation of "tail -f" in Scala some time ago: tailf. It takes care of file rotation as well and you may define your own logic what to do when it reaches EOF or finds the file has been renamed. You may take a look and port it to Java, since actually there is nothing complex in there. Few notes: the main file is Tail.scala and basically it defines FollowingInputStream which takes care of EOF/rename and follow method, which wraps FollowingInputStream into an unbounded enumeration in SequenceInputStream. So, as soon as FollowingInputStream ends, SequenceInputStream requests next element from an Enumeration and another FollowingInputStream gets created.

http://stackoverflow.com/comment/431961
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/619077
type: Comment
has text: The requirements here force me to reinvent the wheel as the code must run on plain Java without any JNI or library dependencies.

http://stackoverflow.com/a/422665
type: Answer
has body: If it's just a demo for a client I think a quick-and-dirty solution is sufficient, but ultimately it is you're job as a developer to protest if you think it's going to backfire. Uncle Bob in Clean Code drives home the point well: "What if you were a doctor and had a patient who demanded that you stopped all the silly hand-washing in preparation for surgery because it was taking too much time? Clearly the patient is the boss, and yet the doctor should absolutely refuse to comply. Why? Because the doctor knows more than the patient about the risks of the disease and infection. It would be unprofessional (never mind criminal) for the doctor to comply with the patient. So too it is unprofessional for programmers to bend to the will of managers who don't understand the risks of making messes."
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/417515
has comment: http://stackoverflow.com/comment/3503523
upvote count: 1

http://stackoverflow.com/q/396156
tagged with: swing
has title: Automatically size JPanel inside JFrame
upvote count: 11
tagged with: java
has answer: http://stackoverflow.com/a/408836
has answer: http://stackoverflow.com/a/396253
possible better answer: http://stackoverflow.com/a/396201
answer count: 5
tagged with: jpanel
has answer: http://stackoverflow.com/a/396201
score: 11
has answer: http://stackoverflow.com/a/17826700
has body: I have a JPanel subclass on which I add buttons, labels, tables, etc. To show on screen it I use JFrame: MainPanel mainPanel = new MainPanel(); //JPanel subclass JFrame mainFrame = new JFrame(); mainFrame.setTitle("main window title"); mainFrame.getContentPane().add(mainPanel); mainFrame.setLocation(100, 100); mainFrame.pack(); mainFrame.setVisible(true); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); But when I size the window, size of panel don't change. How to make size of panel to be the same as the size of window even if it was resized?
type: AnsweredQuestion
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/396253
type: Question
tagged with: jframe
has answer: http://stackoverflow.com/a/419873
tagged with: size

http://stackoverflow.com/a/548920
has body: You could also use the Java bindings of Qt. Qt is a multi-platform C++ framework which has, in my opinion, one of the most readable object models for GUI design. Have a look at the Trolltech (Nokia) Qt website. You can see a demo (which also has source code) using the Java Web Start feature. It gives a good impression about what can and can't be done, and how the source code looks.
answers question: http://stackoverflow.com/q/548415
has comment: http://stackoverflow.com/comment/74632525
score: 0
type: Answer

http://stackoverflow.com/q/456148
has answer: http://stackoverflow.com/a/456176
answer count: 9
has answer: http://stackoverflow.com/a/9540733
has answer: http://stackoverflow.com/a/23309900
possible better answer: http://stackoverflow.com/a/456150
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/11923024
has title: Suggestions for Java email templating?
tagged with: java
downvote count: 3
score: 44
accepted answer: http://stackoverflow.com/a/456176
type: Question
has body: we have an application that needs to send out various different types of template email. The current code is very cumbersome and not very flexible. Does any one konw of a library to help with this type of work... We are looking for some kind of templating library for email.
has answer: http://stackoverflow.com/a/456500
tagged with: frameworks
has answer: http://stackoverflow.com/a/20847683
upvote count: 47
has answer: http://stackoverflow.com/a/24485125
has answer: http://stackoverflow.com/a/458088
tagged with: email
has answer: http://stackoverflow.com/a/456150
tagged with: templates
favorite count: 0

http://stackoverflow.com/comment/73061231
type: Comment
has text: This is awesome. This answer should have received far more votes than 12. Well, 13 now.
comment on: http://stackoverflow.com/a/18785300
score: 0
type: AnswerComment

http://stackoverflow.com/comment/73074712
type: AnswerComment
type: Comment
has text: @igor How about because they just wanted to remove one line of logging not all lines of logging?
score: 1
comment on: http://stackoverflow.com/a/588831

http://stackoverflow.com/a/634631
type: AcceptedAnswer
upvote count: 26
type: Answer
downvote count: 0
has body: Use the ManagementFactory to get an OperatingSystemMXBean and call getSystemLoadAverage() on it.
score: 26
accepted answer of: http://stackoverflow.com/q/634580
answers question: http://stackoverflow.com/q/634580

http://stackoverflow.com/q/645002
tagged with: hibernate
upvote count: 1
answer count: 1
accepted answer: http://stackoverflow.com/a/645029
tagged with: maven-2
favorite count: 0
has title: Hibernate Core daily/weekly build Maven repository
has answer: http://stackoverflow.com/a/645029
has body: I'm looking for a Maven repository that contains daily or weekly builds of Hibernate Core. More specifically I'm trying to get a hibernate-core build that contains a bug fix which was checked-in on December 9, 2008. Unfortunately the most recent hibernate-core is 3.3.1GA built during September, 2008.
downvote count: 0
score: 1
tagged with: java
type: Question
type: AnsweredQuestion

http://stackoverflow.com/a/606643
type: Answer
accepted answer of: http://stackoverflow.com/q/585595
answers question: http://stackoverflow.com/q/585595
upvote count: 1
downvote count: 1
has body: No. For HTTP you don't actually need connection pooling (except if you are a browser). A HTTP connection is much cheaper than a database connection. However, You can use a custom resource, so you can configure the connection in JNDI. This article helped me out. There are also three follow up posts.
has comment: http://stackoverflow.com/comment/2285850
type: AcceptedAnswer
score: 0

http://stackoverflow.com/a/396784
upvote count: 9
type: Answer
has body: You should never construct a SQL query yourself using string concatenation. You should never manually escape variables/user data when constructing a SQL query. The actual escaping that is required varies depending on your underlying database, and at some point somebody WILL forget to escape. The point is this: with prepared statements, it is impossible to create a SQL injectable statement. With custom escaping, it is possible. The choice is obvious.
downvote count: 0
score: 9
answers question: http://stackoverflow.com/q/396749
has comment: http://stackoverflow.com/comment/223347

http://stackoverflow.com/a/377244
downvote count: 0
answers question: http://stackoverflow.com/q/377203
type: Answer
upvote count: 1
score: 1
has body: Has anyone tried the example ??? With 1.6.0 foo(null) is dispatched to the most specific method applicable which is foo(String)... If you add a new method say foo(Integer) the compiler cannot choose the most specific applicable method and shows an error. -Patrick

http://stackoverflow.com/a/555556
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/555503
downvote count: 0
type: Answer
has body: Here's a complete program which includes the asBytes() function which is what I assume you were looking for, the opposite to asHex(): public class Temp { public static String asHex (byte buf[]) { StringBuffer strbuf = new StringBuffer(buf.length * 2); int i; for (i = 0; i &lt; buf.length; i++) { if (((int) buf[i] &amp; 0xff) &lt; 0x10) strbuf.append("0"); strbuf.append(Long.toString((int) buf[i] &amp; 0xff, 16)); } return strbuf.toString(); } public static byte[] asBytes (String s) { String s2; byte[] b = new byte[s.length() / 2]; int i; for (i = 0; i &lt; s.length() / 2; i++) { s2 = s.substring(i * 2, i * 2 + 2); b[i] = (byte)(Integer.parseInt(s2, 16) &amp; 0xff); } return b; } static public void main(String args[]) { byte[] b = Temp.asBytes("010203040506070809fdfeff"); String s = Temp.asHex(b); System.out.println (s); } }

http://stackoverflow.com/comment/80832122
comment on: http://stackoverflow.com/a/447792
type: Comment
score: 0
has text: @NoctisSkytower, I've added some sample code (a method to perform the measurement). Unfortunately (or fortunately?) it's in Scala; feel free to translate and edit the answer though.
type: AnswerComment

http://stackoverflow.com/q/606062
linked to: http://stackoverflow.com/q/174171
type: Question
has title: Where should I put the SQL files in my Java project?
has answer: http://stackoverflow.com/a/606077
accepted answer: http://stackoverflow.com/a/606077
score: 26
tagged with: version-control
possible better answer: http://stackoverflow.com/a/606301
has body: I have a Java project which will include a number of large SQL statements for querying the database. My question is: where should I store them? I'm fairly sure I want each statement its own text file managed by source code control. As Java doesn't support multi-line strings I can't easily put the SQL in my .java files and I don't think I'd want to anyway. At build time I can put these text files in JAR and get the contents with ClassLoader.getResourceAsStream(). So my problem becomes in which directories should I put these files and what should I call them. Ideally I'd like people to tell from the .sql file which Java class uses it. What I definitely don't want is a single directory full of lots of files called things like report1.sql and report3.sql and so on. My inclination is to put them in the package directory with all the .java files but I have a colleague who doesn't like having anything other than .java files in this tree. So this leads to alternative of a separate directory structure which mirrors the Java packages but this seems like an unnecessary overhead. So I would be interested to hear what you do with your SQL files. We're using Netbeans 6.5 in case that will affect your answers. (This question is similar but sadly the answers are very C# specific, which is good for that question but bad for me.)
tagged with: sql
has answer: http://stackoverflow.com/a/29238408
downvote count: 0
has answer: http://stackoverflow.com/a/606266
has answer: http://stackoverflow.com/a/608551
favorite count: 0
linked to: http://stackoverflow.com/q/7686334
answer count: 5
upvote count: 26
has comment: http://stackoverflow.com/comment/46682735
has answer: http://stackoverflow.com/a/606301
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/13254712
tagged with: java

http://stackoverflow.com/a/54587791
answers question: http://stackoverflow.com/q/457684
type: Answer
score: 1
downvote count: 1
has body: Use https://jsoup.org , this is very simple and power.can read and change a html. Sample: Document doc = Jsoup.parse(page); //page can be a file or string. Element main = doc.getElementById("MainView"); Elements links = doc.select(".link"); for create elements can use j2html, https://j2html.com
upvote count: 2

http://stackoverflow.com/a/56528756
answers question: http://stackoverflow.com/q/469695
upvote count: 9
score: 8
has body: Using Java 8 - public static String encodeString(String plainString) { return Base64.getEncoder().encodeToString(plainString.getBytes()); } public static String decodeString(String encodedString) { byte[] bytes = Base64.getDecoder().decode(encodedString); return new String(bytes); }
type: Answer
downvote count: 1

http://stackoverflow.com/comment/192799
has text: A portlet application is indeed deployed in a War file and can contain servlets. I assumed that the question was if an existing application can be rendered as a portltet from the Portal Server. This is of course not possible.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/362597

http://stackoverflow.com/comment/51709132
has text: This is a really great summary of many of the pitfalls in the different methods. Thanks for such a complete write up!
comment on: http://stackoverflow.com/a/25426869
type: Comment
score: 7
type: AnswerComment

http://stackoverflow.com/comment/447918
score: 0
type: Comment
type: AnswerComment
has text: For some reason JSR295 seems to be dead - the latest version is 1.5 years old - while JGoodies Binding seems to be well alive. This makes JGoodies more attractive from developer point of view. Additionally, having tried both, JGoodies is noticeably easier to use.
comment on: http://stackoverflow.com/a/510987

http://stackoverflow.com/comment/316264
has text: @Peter Lawrey: Yes, but that is less readable. And with a good optimizer, there should be no real speed difference between the optimized and the readable version.
type: AnswerComment
comment on: http://stackoverflow.com/a/481836
score: 0
type: Comment

http://stackoverflow.com/a/13688184
has body: This is the issue of "Multiple Inheritance". We can "extends" not more than one abstarct class at one time through another class but in Interfaces, we can "implement" multiple interfaces in single class. So, though Java doesn't provide multiple inheritance in general but by using interfaces we can incorporate multiplt inheritance property in it. Hope this helps!!!
answers question: http://stackoverflow.com/q/639592
downvote count: 0
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/comment/116047966
type: Comment
comment on: http://stackoverflow.com/a/65628146
score: 0
type: AnswerComment
has text: A bit complicated, and perhaps because of that also not quite correct. I changed `current`to `LocalDate.of(2021, 7, 31);` and still got `true`, which can’t be right. Using `LocalDate` and `isBefore()` is a good idea.

http://stackoverflow.com/a/450063
type: Answer
upvote count: 4
downvote count: 0
has body: You can do it without recursion by SwingUtilities.getAncestorOfClass
answers question: http://stackoverflow.com/q/449915
score: 4
has comment: http://stackoverflow.com/comment/271284

http://stackoverflow.com/comment/118086273
comment on: http://stackoverflow.com/a/665165
score: 0
type: AnswerComment
has text: @cdalxndr yes, see https://stackoverflow.com/a/66802699/1069426 for an updated answer.
type: Comment

http://stackoverflow.com/comment/323357
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/480894
has text: If you upgrade your version of java, go straight to Java 6 as Java 5 will be EOL in October. :-]
type: Comment

http://stackoverflow.com/a/465993
score: 16
has comment: http://stackoverflow.com/comment/284214
type: Answer
downvote count: 2
has body: Is it really important for doC() to be executed when doB() fails? If not, why not simply let the Exception propagate up the stack to where it can be handled effectively. Personally, I consider using error codes a code smell. Edit: In your comment, you have described exactly the scenarion where you should simply declare public void doSomething() throws MyException
answers question: http://stackoverflow.com/q/465953
upvote count: 18

http://stackoverflow.com/a/466489
has body: As others have indicated, it really depends on the intended functionality of the methods involved here. If doSomething()'s role is to check something, returning a code that allows normal execution of its calling methods to continue (albeit on different paths depending on the code returned) then having it return that int may be fine. In that case, though, doB() should probably be consistent and return a boolean or something that doSomething() can check instead of throwing an exception which won't really do anything else. If doB() were a public method of a another class that might have other uses outside of doSomething() (as opposed to a private method in the same class as you indicated) and it throws an exception and you want to use it in doSomething() (which has the same role indicated above), then your example would be fine. The fact that the code you return when doB() throws an exception is called ERROR, though, indicates that it's probably a failure that would prevent whatever operation doSomething() is a part of from completing. In that case, you should probably not catch the exception thrown by doB() and just let it be thrown up the stack until it reaches a point where it can be handled or until it reaches your general error handler which can report/log it or whatever.
answers question: http://stackoverflow.com/q/465953
type: Answer
score: 0

http://stackoverflow.com/comment/245258
has text: @Sathish Sounds like you should re-think that design
score: 34
comment on: http://stackoverflow.com/q/421280
type: Comment
type: QuestionComment

http://stackoverflow.com/q/586042
type: Question
has body: Let's say I have a set of Countries in my application. I expect this data to change but not very often. In other words, I do not look at this set as an operational data (I would not provide CRUD operations for Country, for example). That said I have to store this data somewhere. I see two ways to do that: Database driven. Create and populate a Country table. Provide some sort of DAO to access it (findById() ?). This way client code will have to know Id of a country (which also can be a name or ISO code). On the application side I will have a class Country. Application driven. Create an Enum where I can list all the Countries known to my system. It will be stored in DB as well, but the difference would be that now client code does not have to have lookup method (findById, findByName, etc) and hardcode Id, names or ISO codes. It will reference particular country directly. I lean towards second solution for several reasons. How do you do this? Is this correct to call this 'dictionary data'? Addendum: One of the main problems here is that if I have a lookup method like findByName("Czechoslovakia") then after 1992 this will return nothing. I do not know how the client code will react on it (after all it sorta expects always get the Country back, because, well, it is a dictionary data). It gets even worse if I have something like findById(ID_CZ). It will be really hard to find all these dependencies. If I will remove Country.Czechoslovakia from my enum, I will force myself to take care of any dependency on Czechoslovakia.
has answer: http://stackoverflow.com/a/586124
has title: Where do you put your dictionary data?
score: 4
upvote count: 4
possible better answer: http://stackoverflow.com/a/586084
accepted answer: http://stackoverflow.com/a/586103
has answer: http://stackoverflow.com/a/586068
has answer: http://stackoverflow.com/a/586166
has answer: http://stackoverflow.com/a/586084
downvote count: 0
answer count: 7
has answer: http://stackoverflow.com/a/586064
favorite count: 0
has answer: http://stackoverflow.com/a/586061
tagged with: dictionary
type: AnsweredQuestion
tagged with: enums
tagged with: java
has answer: http://stackoverflow.com/a/586103

http://stackoverflow.com/a/497400
upvote count: 1
has body: PrettyFaces lets you rewrite your url. If you prefer something more lightweight, extend NavigationHandler and override handleNavigation, e.g. by calling context.getExternalContext().redirect()
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/490124
score: 1

http://stackoverflow.com/a/33119860
answers question: http://stackoverflow.com/q/443708
upvote count: 2
has body: I've recently started doing something like this: public class Main { @FunctionalInterface public interface NotDotNetDelegate { int doSomething(int a, int b); } public static void main(String[] args) { // in java 8 (lambdas): System.out.println(functionThatTakesDelegate((a, b) -&gt; {return a*b;} , 10, 20)); } public static int functionThatTakesDelegate(NotDotNetDelegate del, int a, int b) { // ... return del.doSomething(a, b); } }
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/q/508630
has answer: http://stackoverflow.com/a/508974
has title: Java equivalent of unsigned long long?
tagged with: primitive
downvote count: 1
has comment: http://stackoverflow.com/comment/53446180
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/25159316
has answer: http://stackoverflow.com/a/24060247
tagged with: unsigned
has answer: http://stackoverflow.com/a/26981063
has answer: http://stackoverflow.com/a/508646
tagged with: java
possible better answer: http://stackoverflow.com/a/25248688
score: 119
type: Question
upvote count: 120
has answer: http://stackoverflow.com/a/508648
accepted answer: http://stackoverflow.com/a/508642
has answer: http://stackoverflow.com/a/508710
has body: In C++, I enjoyed having access to a 64 bit unsigned integer, via unsigned long long int, or via uint64_t. Now, in Java longs are 64 bits, I know. However, they are signed. Is there an unsigned long (long) available as a Java primitive? How do I use it?
tagged with: unsigned-long-long-int
has answer: http://stackoverflow.com/a/508642
answer count: 10
has answer: http://stackoverflow.com/a/25248688
favorite count: 0
has answer: http://stackoverflow.com/a/27356981

http://stackoverflow.com/comment/322032
type: Comment
has text: I tried to fill in the gap, I hope I guessed correctly ;-)
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/507556

http://stackoverflow.com/comment/37140365
type: AnswerComment
comment on: http://stackoverflow.com/a/18366452
type: Comment
has text: As of 2014, this should be the accepted answer. Looks like well-maintained, well-tested, concurrent implementation of tries.
score: 3

http://stackoverflow.com/comment/1448767
score: 0
type: AnswerComment
has text: Writing an answer to your own question and accepting it is a bit questionable if you ask me. A bit like upvoting yourself (which of course isn't possible)
type: Comment
comment on: http://stackoverflow.com/a/573468

http://stackoverflow.com/a/646030
has body: Try this: Integer startIn = null; try { startIn = Integer.valueOf(startField.getText()); } catch (NumberFormatException e) { . . . } if (startIn == null) { // Prompt for value... }
downvote count: 0
upvote count: 8
type: Answer
answers question: http://stackoverflow.com/q/646012
score: 8

http://stackoverflow.com/comment/16028580
score: 0
type: Comment
has text: Very true! But no one seems to know it...
comment on: http://stackoverflow.com/a/2414803
type: AnswerComment

http://stackoverflow.com/a/4177678
type: Answer
score: 13
downvote count: 2
upvote count: 15
answers question: http://stackoverflow.com/q/412380
has body: To enhance JodaStephen's answer, Apache Commons IO has FilenameUtils which does this. Example (on Linux): assert org.apache.commons.io.FilenameUtils.concat("/home/bob", "work\\stuff.log") == "/home/bob/work/stuff.log" It's platform independent and will produce whatever separators your system needs.

http://stackoverflow.com/a/419317
downvote count: 0
type: Answer
has body: Add a space after the colons: Manifest-Version: 1.0 Main-Class: t
has comment: http://stackoverflow.com/comment/43523561
upvote count: 17
accepted answer of: http://stackoverflow.com/q/419314
answers question: http://stackoverflow.com/q/419314
score: 17
type: AcceptedAnswer

http://stackoverflow.com/comment/57062739
comment on: http://stackoverflow.com/a/11970766
has text: An equivalent of `(int) Math.ceil(requiredCapacity / 0.75)`, avoiding a method call and conversions to and from floating-point, is `(requiredCapacity*4+2)/3`. This gives the same result while using purely `int` arithmetic.
score: 10
type: AnswerComment
type: Comment

http://stackoverflow.com/q/472377
has answer: http://stackoverflow.com/a/474368
type: Question
has title: Is there a Java equivalent to Apple's Core Data?
has answer: http://stackoverflow.com/a/498414
downvote count: 0
tagged with: database-design
tagged with: persistence
has answer: http://stackoverflow.com/a/476256
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/480976
type: UnansweredQuestion
score: 13
tagged with: core-data
upvote count: 13
has body: I have recently heard a lot of praise for Apple's Core Data architecture. Is there something similar in Java land, so that I can play around with Core Data's ideas (in order to evaluate how it stacks up against something like Hibernate) without having to get into Cocoa/Objective-C first?
tagged with: java

http://stackoverflow.com/q/624137
favorite count: 0
tagged with: linux
tagged with: time
has comment: http://stackoverflow.com/comment/437388
answer count: 4
upvote count: 13
has comment: http://stackoverflow.com/comment/437435
tagged with: java
has answer: http://stackoverflow.com/a/624167
score: 13
has answer: http://stackoverflow.com/a/624168
has answer: http://stackoverflow.com/a/624146
type: Question
type: AnsweredQuestion
tagged with: testing
has comment: http://stackoverflow.com/comment/437088
has answer: http://stackoverflow.com/a/624155
accepted answer: http://stackoverflow.com/a/624155
tagged with: date
has body: I have a Java app that runs on linux that has a lots of events and business logic that revolve around times and dates. For testing, is it possible to tweak something into time going faster. Let's say, make a whole computer-year finish in one hour wall time?
has comment: http://stackoverflow.com/comment/437008
has title: Simulating "faster time" in linux
downvote count: 0
possible better answer: http://stackoverflow.com/a/624168

http://stackoverflow.com/comment/14651411
type: Comment
comment on: http://stackoverflow.com/a/621849
has text: @guido Thank you for pointing out the error! The code has been fixed.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/328802
type: QuestionComment
comment on: http://stackoverflow.com/q/515133
type: Comment
score: 0
has text: "I would like to make it so that the MainMode class " - I don't see any MainMode class in your program. Can you explain?

http://stackoverflow.com/a/3233312
answers question: http://stackoverflow.com/q/599161
has body: This is quite an old conversation by now and apache commons are now using a StringBuilder internally: http://commons.apache.org/lang/api/src-html/org/apache/commons/lang/StringUtils.html#line.3045 This will as we know improve performance, but if performance is critical then the method used might be somewhat inefficient. Whereas the interface is flexible and will allow for consistent behaviour across different Collection types it is somewhat inefficient for Lists, which is the type of Collection in the original question. I base this in that we are incurring some overhead which we would avoid by simply iterating through the elements in a traditional for loop. Instead there are some additional things happening behind the scenes checking for concurrent modifications, method calls etc. The enhanced for loop will on the other hand result in the same overhead since the iterator is used on the Iterable object (the List).
type: Answer
score: 0

http://stackoverflow.com/a/573411
answers question: http://stackoverflow.com/q/573361
type: Answer
upvote count: 1
has body: Although I'm not sure what/why you will accomplish with this, you can just try to connect to the server with regular client sockets. If you do that in a loop you can probe all the ports. This may/may not tell you if the port is occupied, since there may be firewalls blocking certain ports. At least you can see if you see the port. Tools like nmap will of course give you much more sophisticated analysis.
downvote count: 0
score: 1

http://stackoverflow.com/comment/22073751
comment on: http://stackoverflow.com/q/434989
has text: I asked a [similar question](http://stackoverflow.com/questions/414109/) relating to .NET generic Dictionary<TKey,TValue> recently. You might find the discussion interesting there too.
type: Comment
type: QuestionComment
score: 2

http://stackoverflow.com/q/387768
has body: I'm trying to use a transparent PNG as the icon for my Java application. The image on the JFrame and task bar work great. However, when I use the image with a TrayIcon, I get a black matte background around the edge of the PNG. Has anybody else come across this issue? I would really like to use a PNG instead of GIF or JPEG.
downvote count: 0
answer count: 1
tagged with: transparency
has answer: http://stackoverflow.com/a/388885
favorite count: 0
type: UnansweredQuestion
score: 6
tagged with: trayicon
tagged with: http://stackoverflow.com/tag/png
upvote count: 6
tagged with: java
has title: PNG TrayIcon transparency on Windows
type: Question

http://stackoverflow.com/comment/131933432
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/13781114
score: 2
has text: @TimM. Thanks for that; it let me pick a static palette quickly so I can move on with my life and come back to this later, . Here's that same color list in `0xRRGGBBAA` format: https://pastebin.com/RynaPDQK

http://stackoverflow.com/q/495273
downvote count: 0
tagged with: language-agnostic
favorite count: 0
has body: I've been jumping from C# to Java an awful lot and the "differences" between the two are a bit of an annoyance. Would it be possible to write a set of extentions/plugins that would merge the two languages syntaxes. I'm talking about adding either IDE support or using language constructs that would for example: treat these two lines equivalently: System.out.println("Blah"); Console.out.writeline("Blah"); Automatically notice that when you type in string you mean String Recognise common API calls and translate them in the background. The end goal being to be able to write a java/C# program and to pick at compile time which VM/Runtime you are targeting. If you could do this would it be a good idea? If not why not? The two languages are so similar it's painful in some aspects but in other aspects they are really different. I've seen Code that will translate a C# project into Java and I'm assuming there is probably the reverse, what I am proposing is a middle ground, so we can all just "get along".
has answer: http://stackoverflow.com/a/495416
upvote count: 1
has title: Should C# and Java incorporate each others syntax?
has answer: http://stackoverflow.com/a/495281
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/495336
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/495333
has answer: http://stackoverflow.com/a/495388
type: Question
answer count: 8
tagged with: c#
possible better answer: http://stackoverflow.com/a/495298
has answer: http://stackoverflow.com/a/495298
tagged with: .net
accepted answer: http://stackoverflow.com/a/495281
has answer: http://stackoverflow.com/a/495307
has answer: http://stackoverflow.com/a/495366

http://stackoverflow.com/comment/50989393
type: Comment
comment on: http://stackoverflow.com/a/15646871
has text: Java 7 is EOLed, Java 9 is coming, this is right the answer to me!
score: 4
type: AnswerComment

http://stackoverflow.com/comment/307955
has text: Arbitrary user on the system.
score: 0
comment on: http://stackoverflow.com/q/491877
type: QuestionComment
type: Comment

http://stackoverflow.com/a/4993673
downvote count: 0
score: 5
answers question: http://stackoverflow.com/q/638886
type: Answer
upvote count: 5
has body: There is a tricky solution for the problem. It's not necessary to have the code inside an iframe. We can have a dummy iframe just as a layer above the applet. And then an absolute div with the text can easily placed above that iframe. working example Applet z index issue Message Java applet that draws animated bubbles.

http://stackoverflow.com/a/603209
has comment: http://stackoverflow.com/comment/516025
type: Answer
score: 4
has body: Maven also houses a large repository of commonly used open source projects. During the build Maven can download these dependencies for you (as well as your dependencies dependencies :)) to make this part of building a project a little more manageable.
answers question: http://stackoverflow.com/q/603189
upvote count: 4
downvote count: 0

http://stackoverflow.com/a/417647
type: Answer
has body: In Java, the abstract class annotation indicates that the class cannot be directly instantiated. A class could be declared abstract simply because it should never be instantiated (perhaps it contains only static methods), or because its subclasses should be instantiated instead. It is not a requirement that abstract classes contain abstract methods (the inverse is true: a class containing one or more abstract methods must be abstract.) The question of whether you should duplicate the abstract method definition might be perceived as a style question - but I would be hard pressed to come up with an argument in favor of duplicating the definition (the only argument I can come up with is in the case where the class hierarchy might change the semantics or use of the method, and thus you'd like to provide an additional javadoc in class B.) The primary argument against re-definition of the abstract method is that duplicate code is bad - it makes refactoring more cumbersome and such (all the classic "don't duplicate code" arguments apply.)
answers question: http://stackoverflow.com/q/417590
score: 35
upvote count: 35
downvote count: 0

last-modified
type: Tag
tags question: http://stackoverflow.com/q/459622
tag name: last-modified

http://stackoverflow.com/q/623939
tagged with: performance
has body: I've read plenty of articles about tuning GC in Java and have often wondered how many people really use some of the more advanced features. I've always avoided tuning where possible and concentrated on writing the simplest possible code I can (Brian Goetz's advice) - this seems to have worked well for me so far. Are these tuning strategies resilient to change across VM versions or do they require constant re-assessment? The one tuning that I have made use of is the -server flag.
has answer: http://stackoverflow.com/a/623975
score: 21
has title: Has anyone found Garbage Collection tuning to be useful?
tagged with: java
possible better answer: http://stackoverflow.com/a/623974
answer count: 6
type: Question
has answer: http://stackoverflow.com/a/623948
has comment: http://stackoverflow.com/comment/437259
linked to: http://stackoverflow.com/q/202502
favorite count: 0
has answer: http://stackoverflow.com/a/624136
upvote count: 21
has comment: http://stackoverflow.com/comment/437129
downvote count: 0
tagged with: garbage-collection
has answer: http://stackoverflow.com/a/624166
has answer: http://stackoverflow.com/a/623970
has answer: http://stackoverflow.com/a/623974
accepted answer: http://stackoverflow.com/a/623970
type: AnsweredQuestion

http://stackoverflow.com/comment/254816
score: 8
has text: @Uri, it can be a large issue if you do math intensive work. Consider the JITing of a primitive type. Math instructions on primitives can be easily JIT'd into corresponding assembly. But if math is hand implemented it won't translate directly to assembly and hence performance will suffer.
type: AnswerComment
comment on: http://stackoverflow.com/a/430357
type: Comment

http://stackoverflow.com/comment/386928
type: Comment
has text: You might want to Google "double checked locking is broken java 6". It found this: http://www.ibm.com/developerworks/java/library/j-dcl.html
type: AnswerComment
comment on: http://stackoverflow.com/a/574853
score: 0

http://stackoverflow.com/q/397226
tagged with: java
has answer: http://stackoverflow.com/a/1135360
type: Question
has answer: http://stackoverflow.com/a/439878
score: 4
tagged with: struts
has answer: http://stackoverflow.com/a/397231
has title: I'd like to learn Struts.Is there any good web sites or books?
downvote count: 1
answer count: 7
has body: I want learn it for abc. And I'd like to know what's the difference between struts 1 and struts 2.
favorite count: 0
upvote count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/17746648
has answer: http://stackoverflow.com/a/397323
has answer: http://stackoverflow.com/a/14875941
has answer: http://stackoverflow.com/a/437460

http://stackoverflow.com/comment/67030029
has text: answer the question is the main goal. this answer does not provide any solution that works!
comment on: http://stackoverflow.com/a/536279
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/36994691
type: Comment
comment on: http://stackoverflow.com/a/7157273
has text: Exponential expansion through the call tree is effectively an insistence on being handled immediately. This could have been could worthwhile if applied solely to _contingencies_, which are predictable & potentially recoverable, but 'checked' behavior was erroneously widened to a broad range of unpredictable & unrecoverable _failures_. 'File open' or 'connect JDBC' are reasonable to require checked -- most other IOException, SQLException, RemoteException not so. This was a major error in Java library design. See my answer & a basic primer on exception-handling.
score: 3
type: AnswerComment

http://stackoverflow.com/comment/16992669
has text: And iterating through Unicode strings is a bit more complicated. See here: http://stackoverflow.com/q/1527856/402322
type: Comment
score: 1
comment on: http://stackoverflow.com/a/10035382
type: AnswerComment

developer-tools
tags question: http://stackoverflow.com/q/615208
type: Tag
tag name: developer-tools

http://stackoverflow.com/a/45045080
downvote count: 0
score: 16
has comment: http://stackoverflow.com/comment/134909410
has comment: http://stackoverflow.com/comment/131234083
answers question: http://stackoverflow.com/q/529085
upvote count: 16
has body: You do not need to pass the Class argument to the constructor. Try this. public class GenSet<T> { private final T[] array; @SafeVarargs public GenSet(int capacity, T... dummy) { if (dummy.length > 0) throw new IllegalArgumentException( "Do not provide values for dummy argument."); this.array = Arrays.copyOf(dummy, capacity); } @Override public String toString() { return "GenSet of " + array.getClass().getComponentType().getName() + "[" + array.length + "]"; } } and GenSet<Integer> intSet = new GenSet<>(3); System.out.println(intSet); System.out.println(new GenSet<String>(2)); result: GenSet of java.lang.Integer[3] GenSet of java.lang.String[2]
type: Answer

http://stackoverflow.com/a/643507
answers question: http://stackoverflow.com/q/643346
type: Answer
score: 1
has body: Get more memory if you can. SciTE, JUnit, Ant and jvisualvm used to run fine on my notebook, which had 768M, or the 2GB/1GHz netbook I now use. On the rare occasions you must use a debugger, then there's always jdb. The problems I've had with IDEs on notebooks are more to do with screen estate rather than performance. OTOH I gave up on Netbeans as its text editor was too slow on a 'standard built business desktop' machine last time I was contracting.
upvote count: 1
downvote count: 0

http://stackoverflow.com/a/1209107
type: Answer
answers question: http://stackoverflow.com/q/602905
score: 0
has body: Do you want to add a dependency on the source jars deployed to the repository? If so you can do it by adding the sources classifier to the dependency. See this answer for more details. If not, can you clarify further please.

http://stackoverflow.com/a/438125
has comment: http://stackoverflow.com/comment/49491790
upvote count: 5
answers question: http://stackoverflow.com/q/423032
score: 4
has comment: http://stackoverflow.com/comment/49410685
type: Answer
has body: This question is based on a wrong statement: I know that an interface must be public Not really, you can have interfaces with default access modifier. The problem is I can't make the interface or the implemented methods protected Here it is: C:\oreyes\cosas\java\interfaces&gt;type a\*.java a\Inter.java package a; interface Inter { public void face(); } a\Face.java package a; class Face implements Inter { public void face() { System.out.println( "face" ); } } C:\oreyes\cosas\java\interfaces&gt;type b\*.java b\Test.java package b; import a.Inter; import a.Face; public class Test { public static void main( String [] args ) { Inter inter = new Face(); inter.face(); } } C:\oreyes\cosas\java\interfaces&gt;javac -d . a\*.java b\Test.java b\Test.java:2: a.Inter is not public in a; cannot be accessed from outside package import a.Inter; ^ b\Test.java:3: a.Face is not public in a; cannot be accessed from outside package import a.Face; ^ b\Test.java:7: cannot find symbol symbol : class Inter location: class b.Test Inter inter = new Face(); ^ b\Test.java:7: cannot find symbol symbol : class Face location: class b.Test Inter inter = new Face(); ^ 4 errors C:\oreyes\cosas\java\interfaces&gt; Hence, achieving what you wanted, prevent interface and class usage outside of the package.
downvote count: 1
has comment: http://stackoverflow.com/comment/49543320

http://stackoverflow.com/a/559856
has comment: http://stackoverflow.com/comment/3896277
has body: The Javadocs from Sun for each collection class will generally tell you exactly what you want. HashMap, for example: This implementation provides constant-time performance for the basic operations (get and put), assuming the hash function disperses the elements properly among the buckets. Iteration over collection views requires time proportional to the "capacity" of the HashMap instance (the number of buckets) plus its size (the number of key-value mappings). TreeMap: This implementation provides guaranteed log(n) time cost for the containsKey, get, put and remove operations. TreeSet: This implementation provides guaranteed log(n) time cost for the basic operations (add, remove and contains). (emphasis mine)
answers question: http://stackoverflow.com/q/559839
score: 15
type: Answer
has comment: http://stackoverflow.com/comment/623438
upvote count: 16
has comment: http://stackoverflow.com/comment/372291
downvote count: 1
has comment: http://stackoverflow.com/comment/371303

http://stackoverflow.com/q/489360
has answer: http://stackoverflow.com/a/491301
downvote count: 0
favorite count: 0
answer count: 3
has body: Does anyone know if HQL has a keyword to identify rows such as ROWID or ROWNUM? I would like to implement pagination with HQL but I am not able to use .setMaxResult() or .setFirstResult() because I don't work with the session object directly and therefore don't use the Query object but simply create my query as a string and use the .find() method. I tried using LIMIT and OFFSET in my query, but HQL seems to be ignoring these keywords and is returning the whole result to me no matter what. I'm also not able to use Hibernate criteria because it does not have support for the "HAVING" clause that appears in my query. My last resort is to restrict the result set using the ROWNUM/ROWID keyword. Does anyone else have any other suggestions?
has answer: http://stackoverflow.com/a/23698107
has answer: http://stackoverflow.com/a/840108
type: UnansweredQuestion
type: Question
upvote count: 9
tagged with: java
tagged with: hibernate
tagged with: pagination
has title: HQL - row identifier for pagination
tagged with: hql
score: 9

http://stackoverflow.com/a/519911
has body: If the array is sorted, then do a modified binary search. Basically if you do not find the number, then at the end of search return the lower bound.
downvote count: 0
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/519881
type: Answer

http://stackoverflow.com/a/43660123
has body: We had a similar problem. In our case it was the webserver that had ESI enabled (http://www-01.ibm.com/support/docview.wss?uid=swg27015501). We did a TCP dump to see what happened there and saw that the RES package (after browser closed) was never send back to the application. The webserver recieved it but did not send it further. Therefore printer.checkError() never returned true and the printer kept flushing data. After disabling this feature, the RES package was send through to the application and after some time printer.checkError() returned true. That's why I stumbled over your question. It keeps sending 3 times. After that it checkError() returns true.
type: Answer
answers question: http://stackoverflow.com/q/520348
score: 0

http://stackoverflow.com/a/496933
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/312690
type: Answer
has body: If you have the ability to run your own software (i.e. Dedicated/VPS) then you could investigate using Tesseract OCR with cfexecute to convert the PDFs to text?
accepted answer of: http://stackoverflow.com/q/496875
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/496875

http://stackoverflow.com/q/370962
has comment: http://stackoverflow.com/comment/136358897
type: Question
has answer: http://stackoverflow.com/a/370967
answer count: 30
has answer: http://stackoverflow.com/a/71947774
has answer: http://stackoverflow.com/a/50840314
has answer: http://stackoverflow.com/a/12545325
has answer: http://stackoverflow.com/a/65475133
has answer: http://stackoverflow.com/a/53533628
has answer: http://stackoverflow.com/a/20305668
has body: The question is in Java why can't I define an abstract static method? for example abstract class foo { abstract void bar( ); // &lt;-- this is ok abstract static void bar2(); //&lt;-- this isn't why? }
has answer: http://stackoverflow.com/a/372544
has answer: http://stackoverflow.com/a/32815763
has answer: http://stackoverflow.com/a/1595000
has answer: http://stackoverflow.com/a/30972338
tagged with: static-methods
has answer: http://stackoverflow.com/a/69698385
tagged with: abstract-class
has answer: http://stackoverflow.com/a/24937307
downvote count: 4
has comment: http://stackoverflow.com/comment/68304429
upvote count: 686
has answer: http://stackoverflow.com/a/34104505
has answer: http://stackoverflow.com/a/43953020
has answer: http://stackoverflow.com/a/49188073
favorite count: 0
has answer: http://stackoverflow.com/a/68826612
has answer: http://stackoverflow.com/a/30834587
accepted answer: http://stackoverflow.com/a/372544
linked to: http://stackoverflow.com/q/70324
has answer: http://stackoverflow.com/a/34105327
has answer: http://stackoverflow.com/a/31480184
has answer: http://stackoverflow.com/a/34900818
has answer: http://stackoverflow.com/a/32281821
linked to: http://stackoverflow.com/q/3284
has answer: http://stackoverflow.com/a/22582759
linked to: http://stackoverflow.com/q/512877
has answer: http://stackoverflow.com/a/370966
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/14911236
score: 682
has answer: http://stackoverflow.com/a/59541347
has answer: http://stackoverflow.com/a/75692514
tagged with: java
has answer: http://stackoverflow.com/a/9774365
has answer: http://stackoverflow.com/a/371011
has title: Why can't static methods be abstract in Java?
has answer: http://stackoverflow.com/a/16558928
possible better answer: http://stackoverflow.com/a/370967

http://stackoverflow.com/q/435912
favorite count: 0
accepted answer: http://stackoverflow.com/a/2192676
type: AnsweredQuestion
tagged with: java
type: Question
has title: Has anyone successfully used signature timestamps in a java applet?
answer count: 2
score: 5
has body: Java 1.5 added an enhancement to support signature timestamps. The idea, as far as I can tell, is that signed jar files should not become invalid just because the code signing certificate has expired, as long as the files were signed while the certificate was valid. In theory, this means we do not have to re-sign and redeploy our applications every year when the certificate expires. Unfortunately, there seem to be problems in the implementation, based on these two forum threads: http://forums.sun.com/thread.jspa?threadID=744677 http://forums.sun.com/thread.jspa?threadID=5309004 I'm about to begin testing this, but I was wondering if anyone has successfully done this, without having to import the timestamping certificate on the client (which would defeat the whole purpose)?
has answer: http://stackoverflow.com/a/2192676
upvote count: 5
downvote count: 0
has answer: http://stackoverflow.com/a/443539
tagged with: security
possible better answer: http://stackoverflow.com/a/443539
tagged with: applet

http://stackoverflow.com/a/474598
answers question: http://stackoverflow.com/q/474535
upvote count: 3
has body: If you multiply the numerator and denominator of one Fraction with the denominator of the other and vice versa, you end up with two fractions (that are still the same values) with the same denominator and you can compare the numerators directly. Therefore you wouldn't need to calculate the double value: public int compareTo(Fraction frac) { int t = this.numerator * frac.getDenominator(); int f = frac.getNumerator() * this.denominator; if(t&gt;f) return 1; if(f&gt;t) return -1; return 0; }
type: Answer
has comment: http://stackoverflow.com/comment/1388147
downvote count: 0
has comment: http://stackoverflow.com/comment/292187
has comment: http://stackoverflow.com/comment/293126
score: 3

http://stackoverflow.com/a/546317
downvote count: 0
score: 5
type: Answer
has comment: http://stackoverflow.com/comment/364528
has body: Use JAAS with an LDAP LoginModule. This will allow you to plug-into the underlying Java security infrastructure. When you need to take the app offline or "debug" the app, you can easily swap-out the LDAP module for a dummy module. This allows you to continue testing your "security", without depending on Active Directory. Highly testable, decoupled, and you can the authentication scheme at a later time with almost no grief.
answers question: http://stackoverflow.com/q/545667
has comment: http://stackoverflow.com/comment/368641
upvote count: 5
has comment: http://stackoverflow.com/comment/841131

http://stackoverflow.com/a/633110
score: 26
answers question: http://stackoverflow.com/q/631695
upvote count: 26
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/447404
has body: I just went through this LazyInitialization marathon. The core problem is that you're trying to access an hibernate-managed entity outside of the lifecycle of the Session, i.e. in the web view of Spring MVC. In my case, this was a List&lt;&gt; @OneToMany association, which are lazily loaded by default. There are a few different approaches -- Mark mentioned one, where you do a "dummy" iteration over the lazy associations. You can also force eager loading, either via the configuration (class-wide) (in JPA it'd be @Fetch(value = FetchType.EAGER)) or more specifically through the HQL. But this will prove more problematic if your lazy associations are Lists. The cleanest solution I found was to use Spring's OpenEntityManagerInViewFilter (there's an OpenSessionInViewFilter for Hibernate) -- a simple servlet filter you drop in to web.xml (ahead of your other servlet filters), and Spring will automatically create a thread-safe, transaction-aware Session per-HTTP-request. No more LazyInitializationException!

http://stackoverflow.com/a/516011
type: Answer
has body: Get yourself a copy of eclipse, and just start reading other people's code, and reading some java docs. The Java website has all the docs online, and they're one of the best language specs I've seen. Really, if you know C# pretty well, Java should be a cake walk. The languages are pretty similar, so you just need to get to know the different frameworks.
upvote count: 4
score: 4
answers question: http://stackoverflow.com/q/515996
downvote count: 0

http://stackoverflow.com/a/39230204
answers question: http://stackoverflow.com/q/524081
type: Answer
has body: Is there an easier way to do this? Yes; Since version 6, you can use class path wildcards. javac -cp .;../lib/* yourJavaCodeDir/YourJavaFile.java See also this related Q&amp;A.
score: 0

http://stackoverflow.com/a/589909
downvote count: 0
has body: I assume your class is a bean that by definition implements Serializable. A transient variable will be excluded from the serialization process. If you serialize and then deserialize the bean the value will be actually have the default value. PMD assumes you are dealing with a serializable bean here. For a bean it is expected to have getters/setters for all member variables. As you have omitted these, you imply that your member variable is not part of the bean ....and so does not need to be serialized. If that is the case you should exclude it from the serialization. Which you do by marking the variable as "transient".
has comment: http://stackoverflow.com/comment/401720
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/589855
type: Answer
accepted answer of: http://stackoverflow.com/q/589855
upvote count: 9
score: 9

http://stackoverflow.com/q/509440
accepted answer: http://stackoverflow.com/a/514183
answer count: 1
favorite count: 0
upvote count: 2
has answer: http://stackoverflow.com/a/514183
tagged with: annotations
tagged with: jmx
has body: I'm using a MXBean to instrument a certain feature, and I have a method that takes in 3 input arguments. By default, on the jconsole, the arguments are displayed as p1, p2, p3 etc. I have @params describing each parameter. How do I make jConsole use those? public class Sample implements SampleMXBean { /** * method 1 * * @param input1 Input One * @param input2 Input Two */ public void getInput(int input1, int input2) { ... ... } } I have registered the above MXBean , and when I launch, the panel for this operation, I get a button with "getInput" as the text, and 2 text boxes with names as p1 and p2, instead of "Input One" and "Input Two". Are there any annotations that I need to use to achieve this? (Btw I'm using jdk1.6)
type: AnsweredQuestion
score: 2
tagged with: java
type: Question
tagged with: jconsole
downvote count: 0
has title: How do I change the description of input's displayed for an operation defined using a MXBean

http://stackoverflow.com/a/554285
score: 3
answers question: http://stackoverflow.com/q/553857
downvote count: 0
type: Answer
has body: Following up to what Jon said... Both Java 5 and Java 6 allow metaprogramming. Java 5 uses a separate apt tool; Java 6 integrates it into the compiler. (Though the Java 5 apt is still available in Java 6) Unfortunately each uses a different API. I'm currently using the Java 5 API for my Bean annotations See http://code.google.com/p/javadude/wiki/Annotations for an example (NOTE: I'm currently making some major updates, some of which change the API.) Very cool stuff... -- Scott
upvote count: 3

http://stackoverflow.com/comment/3790726
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/602636
score: 1
has text: From the stack trace you can see that the Exception happens while iterating through the HashMap. Surely some other thread is modifying the map but the exception occurs in the thread that's iterating.

http://stackoverflow.com/comment/318018
comment on: http://stackoverflow.com/a/503011
score: 1
has text: And how do you deal with code duplication? Probably have a middle class that is also generic, no? Tks
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/384058
comment on: http://stackoverflow.com/a/552221
score: 0
type: AnswerComment
has text: Thanks...BufferInputStream does work. I guess my problem was I was trying to buffer ServletInputStream which I can't since it's #available() always returns 0 (and BufferInputStream relies on that).
type: Comment

continuous-integration
tags question: http://stackoverflow.com/q/603786
tags question: http://stackoverflow.com/q/604385
tags question: http://stackoverflow.com/q/502064
tags question: http://stackoverflow.com/q/533388
tags question: http://stackoverflow.com/q/389680
tag name: continuous-integration
tags question: http://stackoverflow.com/q/386697
tags question: http://stackoverflow.com/q/487901
tags question: http://stackoverflow.com/q/461581
tags question: http://stackoverflow.com/q/637960
tags question: http://stackoverflow.com/q/439164
tags question: http://stackoverflow.com/q/472596
tags question: http://stackoverflow.com/q/385401
type: Tag
tags question: http://stackoverflow.com/q/502776
tags question: http://stackoverflow.com/q/470141

http://stackoverflow.com/a/502388
upvote count: 116
has comment: http://stackoverflow.com/comment/5647812
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/30993233
has comment: http://stackoverflow.com/comment/61596402
type: Answer
score: 115
has comment: http://stackoverflow.com/comment/116633266
has comment: http://stackoverflow.com/comment/17138464
has comment: http://stackoverflow.com/comment/5625835
has comment: http://stackoverflow.com/comment/2685932
has comment: http://stackoverflow.com/comment/20056439
has comment: http://stackoverflow.com/comment/3845987
downvote count: 1
accepted answer of: http://stackoverflow.com/q/502218
has comment: http://stackoverflow.com/comment/12004416
has body: Run the untrusted code in its own thread. This for example prevents problems with infinite loops and such, and makes the future steps easier. Have the main thread wait for the thread to finish, and if takes too long, kill it with Thread.stop. Thread.stop is deprecated, but since the untrusted code shouldn't have access to any resources, it would be safe to kill it. Set a SecurityManager on that Thread. Create a subclass of SecurityManager which overrides checkPermission(Permission perm) to simply throw a SecurityException for all permissions except a select few. There's a list of methods and the permissions they require here: Permissions in the JavaTM 6 SDK. Use a custom ClassLoader to load the untrusted code. Your class loader would get called for all classes which the untrusted code uses, so you can do things like disable access to individual JDK classes. The thing to do is have a white-list of allowed JDK classes. You might want to run the untrusted code in a separate JVM. While the previous steps would make the code safe, there's one annoying thing the isolated code can still do: allocate as much memory as it can, which causes the visible footprint of the main application to grow. JSR 121: Application Isolation API Specification was designed to solve this, but unfortunately it doesn't have an implementation yet. This is a pretty detailed topic, and I'm mostly writing this all off the top of my head. But anyway, some imperfect, use-at-your-own-risk, probably buggy (pseudo) code: ClassLoader class MyClassLoader extends ClassLoader { @Override public Class&lt;?&gt; loadClass(String name) throws ClassNotFoundException { if (name is white-listed JDK class) return super.loadClass(name); return findClass(name); } @Override public Class findClass(String name) { byte[] b = loadClassData(name); return defineClass(name, b, 0, b.length); } private byte[] loadClassData(String name) { // load the untrusted class data here } } SecurityManager class MySecurityManager extends Se…
answers question: http://stackoverflow.com/q/502218

http://stackoverflow.com/q/448846
downvote count: 0
tagged with: workflow
favorite count: 0
has answer: http://stackoverflow.com/a/29984140
score: 3
has answer: http://stackoverflow.com/a/448875
tagged with: rules
type: AnsweredQuestion
upvote count: 3
has title: Free / OpenSource Java Rules / Workflow engine
type: Question
has body: I am looking for a Java Rules / Workflow engine. Something similar to Microsoft Workflow Engine. Can someone recommend a product?
possible better answer: http://stackoverflow.com/a/448874
tagged with: java
has answer: http://stackoverflow.com/a/448874
accepted answer: http://stackoverflow.com/a/448875
answer count: 3

http://stackoverflow.com/comment/205263
comment on: http://stackoverflow.com/a/377238
has text: @Software Monkey: Once you accept that the constant null is of null type and the null type is a subtype of all types, this is quite obvious. Object < String < nulltype. So String is preferable over Object. Glad this was useful. Thanks for the +1.
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/q/561671
tagged with: java
possible better answer: http://stackoverflow.com/a/563003
tagged with: collections
answer count: 7
has answer: http://stackoverflow.com/a/561921
has answer: http://stackoverflow.com/a/561802
tagged with: concurrency
has answer: http://stackoverflow.com/a/562924
upvote count: 27
has answer: http://stackoverflow.com/a/561848
type: AnsweredQuestion
downvote count: 0
favorite count: 0
has body: Should I use old synchronized Vector collection, ArrayList with synchronized access or Collections.synchronizedList or some other solution for concurrent access? I don't see my question in Related Questions nor in my search (Make your collections thread-safe? isn't the same). Recently, I had to make kind of unit tests on GUI parts of our application (basically using API to create frames, add objects, etc.). Because these operations are called much faster than by a user, it shown a number of issues with methods trying to access resources not yet created or already deleted. A particular issue, happening in the EDT, came from walking a linked list of views while altering it in another thread (getting a ConcurrentModificationException among other problems). Don't ask me why it was a linked list instead of a simple array list (even less as we have in general 0 or 1 view inside...), so I took the more common ArrayList in my question (as it has an older cousin). Anyway, not super familiar with concurrency issues, I looked up a bit of info, and wondered what to choose between the old (and probably obsolete) Vector (which has synchronized operations by design), ArrayList with a synchronized (myList) { } around critical sections (add/remove/walk operations) or using a list returned by Collections.synchronizedList (not even sure how to use the latter). I finally chose the second option, because another design mistake was to expose the object (getViewList() method...) instead of providing mechanisms to use it. But what are the pros and cons of the other approaches? [EDIT] Lot of good advices here, hard to select one. I will choose the more detailed and providing links/food for thoughts... :-) I like Darron's one too. To summarize: As I suspected, Vector (and its evil twin, Hashtable as well, probably) is largely obsolete, I have seen people telling its old design isn't as good as newer collections', beyond the slowness of synchronization forced even in single thread environment…
has answer: http://stackoverflow.com/a/561716
type: Question
accepted answer: http://stackoverflow.com/a/562924
has comment: http://stackoverflow.com/comment/372814
has title: Best way to control concurrent access to Java collections
has answer: http://stackoverflow.com/a/563003
has answer: http://stackoverflow.com/a/562903
score: 27

http://stackoverflow.com/a/479734
answers question: http://stackoverflow.com/q/479701
upvote count: 4
downvote count: 0
has body: Java (and .Net) virtual machines catch code that tries to write outside of reserved memory. Applications that don't handle this correctly can still cause security problems. If malicious users can trigger exceptions by entering invalid input they can do denial of service attacks for example.
score: 4
type: Answer

http://stackoverflow.com/q/593478
has answer: http://stackoverflow.com/a/593535
has title: What rules are used for type inference when using Generics
tagged with: type-inference
type: AnsweredQuestion
score: 3
downvote count: 0
tagged with: java
has body: Does anyone know where I can find a discussion on how type inference works when using Generics in Java.
type: Question
has answer: http://stackoverflow.com/a/593567
possible better answer: http://stackoverflow.com/a/593548
upvote count: 3
answer count: 3
accepted answer: http://stackoverflow.com/a/593535
has answer: http://stackoverflow.com/a/593548
tagged with: generics
favorite count: 0

http://stackoverflow.com/a/2033120
has body: Java Opensource Single Sign On (JOSSO) is at http://www.josso.org/ They have a page on NTLM, although I'm not sure how well it works.
upvote count: 1
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/576850
type: Answer

http://stackoverflow.com/comment/385828
comment on: http://stackoverflow.com/q/573982
type: Comment
type: QuestionComment
score: 2
has text: "Mono will always trail behind the latest developments in the .NET framework" What do you mean? Mono is already faster than MS' "official" runtime in some cases.

http://stackoverflow.com/a/470741
upvote count: 9
score: 9
downvote count: 0
type: Answer
has body: Each source file must contain only one public class. A class named ClassName should be in a file named ClassName.java, and only that class should be defined there. Exceptions to this are anonymous and inner classes, but understanding you are a beginner to Java, that is an advanced topic. For now, keep one class per file. Answering your addition: it is OK to inherit classes and that's totally fine. This does not matter, each class should still have its own file.
answers question: http://stackoverflow.com/q/470724
has comment: http://stackoverflow.com/comment/288297

http://stackoverflow.com/comment/8376652
comment on: http://stackoverflow.com/a/525018
has text: Liked checklist, but I dont think warp-*** makes sense.
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/a/419912
downvote count: 0
accepted answer of: http://stackoverflow.com/q/419833
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/419833
has body: If you are using ant, the JUnit task takes a classpath. <pathelement path="${test.jar.path}" /> ... You can use the antcall task to call your test target repeatedly with a differed value for the test.jar.path property.
type: AcceptedAnswer

http://stackoverflow.com/comment/35049958
has text: Wanting to call `super.super.toString()` contradicts your own decision when you choose to extend a class thus accepting **all** (not some of) its features.
score: 10
comment on: http://stackoverflow.com/q/586363
type: QuestionComment
type: Comment

http://stackoverflow.com/q/499504
accepted answer: http://stackoverflow.com/a/499514
tagged with: replace
possible better answer: http://stackoverflow.com/a/500960
has title: replacing regex in java string
has answer: http://stackoverflow.com/a/500960
tagged with: string
favorite count: 0
has body: I have this java string: String bla = "&lt;my:string&gt;invalid_content&lt;/my:string&gt;"; How can I replace the "invalid_content" piece? I know I should use something like this: bla.replaceAll(regex,"new_content"); in order to have: "&lt;my:string&gt;new_content&lt;/my:string&gt;"; but I can't discover how to create the correct regex help please :)
upvote count: 2
answer count: 5
tagged with: regex
has answer: http://stackoverflow.com/a/499514
type: AnsweredQuestion
score: 1
has answer: http://stackoverflow.com/a/499517
tagged with: java
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/499520
has answer: http://stackoverflow.com/a/501186

http://stackoverflow.com/comment/4702679
comment on: http://stackoverflow.com/a/535071
type: Comment
score: 2
type: AnswerComment
has text: Jobs won't 'stop intentionally crippling his products'. Flash will never be supported on iOS (iPhone, iPad) and Apple has been very clear about this. Adobe has given up trying to support it: http://www.wired.com/gadgetlab/2010/04/adobe-flash-iphone/ So, if you want your app to run on iOS (or more likely a mobile version of it written by the same dev team that builds your desktop app), Flex is not a good choice. Or your dev team swaps between languages and programming environments, which is rather inefficient IMO when you could homogenize on HTML/JS/CSS and 'float' dev resources as necessary

http://stackoverflow.com/a/453025
answers question: http://stackoverflow.com/q/453018
downvote count: 9
has comment: http://stackoverflow.com/comment/273657
score: 0
has comment: http://stackoverflow.com/comment/273613
has body: On Unix-based systems, use the wc command on the command-line.
upvote count: 9
has comment: http://stackoverflow.com/comment/273568
type: Answer
has comment: http://stackoverflow.com/comment/273659

http://stackoverflow.com/a/30119004
score: 99
upvote count: 99
has comment: http://stackoverflow.com/comment/84792948
downvote count: 0
has body: I've found this to be the most clear and concise way to do it: MessageDigest md5 = MessageDigest.getInstance("MD5"); md5.update(StandardCharsets.UTF_8.encode(string)); return String.format("%032x", new BigInteger(1, md5.digest()));
answers question: http://stackoverflow.com/q/415953
type: Answer
has comment: http://stackoverflow.com/comment/62954906

http://stackoverflow.com/a/21864471
downvote count: 4
has body: To add to all the answers, printing the object as a JSON string is also an option. Using Jackson: ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter(); System.out.println(ow.writeValueAsString(anyArray)); Using Gson: Gson gson = new Gson(); System.out.println(gson.toJson(anyArray));
type: Answer
answers question: http://stackoverflow.com/q/409784
upvote count: 7
score: 3
has comment: http://stackoverflow.com/comment/96019710

http://stackoverflow.com/a/634176
has comment: http://stackoverflow.com/comment/449301
upvote count: 2
has comment: http://stackoverflow.com/comment/450069
has comment: http://stackoverflow.com/comment/449841
answers question: http://stackoverflow.com/q/424341
has body: I take it you want to be able to resume from where the snapshot was stored, as if nothing thereafter had happened. I wonder how many framework components and libraries such functionality would break. Suddenly, you are reviving a JVM state from storage; in the meantime, the clock has mysteriously skipped forward by 23 hours, network connections are no longer valid, GUI objects no longer have any underlying O/S handles... I'd say this is nontrivial, and impossible in the general case without modifying the framework extensively.
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/450041
score: 2
has comment: http://stackoverflow.com/comment/459809

http://stackoverflow.com/a/78291489
score: 0
type: Answer
answers question: http://stackoverflow.com/q/420013
has body: This is old but still a problem. I use refactor to move the class associated with the servlet to the new package. Then open web.xml, find the servlet and prepend the new package name to the servlet-class tag. I moved GetArticle servlet from default package to the api package: GetArticles GetArticles api.GetArticles

http://stackoverflow.com/a/416018
has body: If you look at the implementation of the Collections.unmodifiable*(...) methods, you can see that they just wrap the collection. Doing a deep utility in same way should be doable. The downside of this is that it adds extra method call to the collection access and so affects performance.
score: 0
answers question: http://stackoverflow.com/q/415967
type: Answer

http://stackoverflow.com/a/669571
has body: Since Jython 2.5 you can use django to satisfy the requirements you listed. It's pretty easy to generate war files from django projects and deploy them on J2EE application servers.
downvote count: 0
has comment: http://stackoverflow.com/comment/483167
has comment: http://stackoverflow.com/comment/483130
type: Answer
answers question: http://stackoverflow.com/q/645746
score: 1
upvote count: 1

garbage-collection
tags question: http://stackoverflow.com/q/457229
tags question: http://stackoverflow.com/q/449409
tags question: http://stackoverflow.com/q/473685
tags question: http://stackoverflow.com/q/555580
tags question: http://stackoverflow.com/q/541832
tags question: http://stackoverflow.com/q/414388
tags question: http://stackoverflow.com/q/407855
tags question: http://stackoverflow.com/q/623939
tags question: http://stackoverflow.com/q/424949
tags question: http://stackoverflow.com/q/520922
tags question: http://stackoverflow.com/q/418272
tags question: http://stackoverflow.com/q/466878
tags question: http://stackoverflow.com/q/383833
tags question: http://stackoverflow.com/q/574021
tag name: garbage-collection
tags question: http://stackoverflow.com/q/483427
tags question: http://stackoverflow.com/q/480566
type: Tag
tags question: http://stackoverflow.com/q/577773
tags question: http://stackoverflow.com/q/492703
tags question: http://stackoverflow.com/q/453023
tags question: http://stackoverflow.com/q/427363

http://stackoverflow.com/a/554599
has body: Okay I just overcame this problem. Make sure when you run rmiregistry that your CLASSPATH environment variable is set. For example, you might have a script: set CLASSPATH=[path to jdbc driver].jar rmiregistry.exe This was all I needed to get my lost classpath working. I'm not sure how to send -cp commandline to rmiregistry.exe. Its documentation is quite lacking.
upvote count: 10
type: Answer
has comment: http://stackoverflow.com/comment/672571
score: 7
has comment: http://stackoverflow.com/comment/24495117
has comment: http://stackoverflow.com/comment/46034478
answers question: http://stackoverflow.com/q/464687
downvote count: 3

http://stackoverflow.com/q/533464
has comment: http://stackoverflow.com/comment/346248
has answer: http://stackoverflow.com/a/533473
has title: protected/private - why bother?
duplicate of: http://stackoverflow.com/q/99688
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
type: Question
accepted answer: http://stackoverflow.com/a/533473
tagged with: encapsulation
has body: DUPE: Private vs. Public members in practice (how important is encapsulation?) In the course of writing a program in Java, I have abstracted out some libraries that I can see a possible use for in future projects. Why should I bother with setting restricted access (private/protected) on any of these methods? It seems like this will just make my life more complicated in the future. If I use public on everything, I will never need to worry about whether I can call something from some other class. I have never seen a case in any of my code yet where it made any sense for me to use anything except public. Is it so wrong to use 'public' on everything? Am I going to be struck down by the Java gods?
answer count: 1
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/417183
has comment: http://stackoverflow.com/comment/77952367
has body: You can't do it using environment variables. It's done via "non standard" options. Run: java -X for details. The options you're looking for are -Xmx and -Xms (this is "initial" heap size, so probably what you're looking for.)
answers question: http://stackoverflow.com/q/417152
score: 9
downvote count: 4
type: Answer
upvote count: 13

http://stackoverflow.com/a/644658
score: 0
type: Answer
has body: Use ping first, but you can measure the RTT by sending a packet and having the other end sending the packet back. It is important that you measure when the boxes are under typical load because that will tell you the RTT you can expect to typically get. You can average the latencies over many packets, millions or even billions to get a consistent value.
answers question: http://stackoverflow.com/q/616896

http://stackoverflow.com/q/601315
tagged with: java
has answer: http://stackoverflow.com/a/4339297
type: Question
has comment: http://stackoverflow.com/comment/24766461
downvote count: 0
answer count: 6
has answer: http://stackoverflow.com/a/2153208
favorite count: 0
has answer: http://stackoverflow.com/a/9309020
tagged with: batch-file
has body: I know how to start the batch file using java code. When i run the batch file command prompt is opened. To close the command prompt i am using the taskill /im cmd.exe. but the problem is that the command prompt that is used to start the jboss is also closed. i want to kill the cmd with a particular process id. How do i get the process id of a particular cmd promt and kill that using java
tagged with: cmd
has answer: http://stackoverflow.com/a/601326
has title: exit the batch file after running using java
upvote count: 2
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/601472
has answer: http://stackoverflow.com/a/601324
score: 2

http://stackoverflow.com/q/450183
type: Question
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/271139
has answer: http://stackoverflow.com/a/617226
has comment: http://stackoverflow.com/comment/273440
favorite count: 0
has comment: http://stackoverflow.com/comment/271168
type: UnansweredQuestion
upvote count: 1
has body: I am creating a blog using Apache Roller Weblogger software, am very new to this.. I am deploying it on the Tomcat, and m using the PostgreSQL database.. I did all the configuration in the roller-custom.properties.. If i give the url http://localhost:8080/roller/ in the browser I am getting the resource not available error, And in the roller.log file if I check, the database is loading fine.. Please if anybody have relevant suggestion please do share..
has title: Apache Roller Weblogger software
tagged with: apache-roller
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/290615

http://stackoverflow.com/comment/38188878
has text: @Jon, was it a bug in C# 1.0? Shouldn't ideally `Outer` be 9?
comment on: http://stackoverflow.com/a/407294
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/45487693
type: AnswerComment
score: 0
type: Comment
has text: highlight asked at: http://stackoverflow.com/questions/1391614/syntax-highlighting-for-javadoc
comment on: http://stackoverflow.com/a/7329242

http://stackoverflow.com/a/40737274
upvote count: 3
score: 3
has body: Create a URL-object pointing to the test class itself. final URL url = new URL("file://" + getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
downvote count: 0
answers question: http://stackoverflow.com/q/565535
type: Answer

http://stackoverflow.com/q/395816
favorite count: 0
has answer: http://stackoverflow.com/a/395823
has answer: http://stackoverflow.com/a/395822
has title: Function pointers/delegates in Java?
answer count: 10
has answer: http://stackoverflow.com/a/1415158
has answer: http://stackoverflow.com/a/5164416
tagged with: function-pointers
has comment: http://stackoverflow.com/comment/222546
has body: For my Java game server I send the Action ID of the packet which basically tells the server what the packet is for. I want to map each Action ID (an integer) to a function. Is there a way of doing this without using a switch?
upvote count: 21
has answer: http://stackoverflow.com/a/395825
accepted answer: http://stackoverflow.com/a/395823
linked to: http://stackoverflow.com/q/122407
type: AnsweredQuestion
score: 21
has answer: http://stackoverflow.com/a/46725845
possible better answer: http://stackoverflow.com/a/54135416
tagged with: java
has comment: http://stackoverflow.com/comment/21188748
has answer: http://stackoverflow.com/a/54135416
has answer: http://stackoverflow.com/a/62516217
type: Question
tagged with: delegates
has answer: http://stackoverflow.com/a/395826
downvote count: 0
has answer: http://stackoverflow.com/a/395860
has comment: http://stackoverflow.com/comment/222555

http://stackoverflow.com/a/504005
has comment: http://stackoverflow.com/comment/319176
accepted answer of: http://stackoverflow.com/q/504003
type: AcceptedAnswer
score: 18
upvote count: 19
has comment: http://stackoverflow.com/comment/318930
downvote count: 1
type: Answer
has body: Yes, you can follow an if statement with a single statement without using curly braces (but do you really want to?), but your problem is more subtle. Try changing: if (x=y) to: if (x==y) Some languages (like PHP, for example) treat any non-zero value as true and zero (or NULL, null, nil, whatever) as false, so assignment operations in conditionals work. Java only allows boolean expressions (expressions that return or evaluate to a boolean) inside conditional statements. You're seeing this error because the result of (x=y) is the value of y, not true or false. You can see this in action with this simple example: if (1) System.out.println("It's true"); if (true) System.out.println("It's true"); The first statement will cause compilation to fail because 1 cannot be converted to a boolean. Edit: My guess on your updated example (which you should have put in the question and not as a new answer) is that you are trying to access realOther after you assign it in those statements. This will not work as the scope of realOther is limited to the if/else statement. You need to either move the declaration of realOther above your if statement (which would be useless in this case), or put more logic in your if statement): if (other instanceof Square) ((Square) other).doSomething(); else ((Rectangle) other).doSomethingElse(); To assist further we would need to see more of your actual code. Edit: Using the following code results in the same errors you are seeing (compiling with gcj): public class Test { public static void Main(String [] args) { Object other = new Square(); if (other instanceof Square) Square realOther = (Square) other; else Rectangle realOther = (Rectangle) other; return; } } class Rectangle { public Rectangle() { } public void doSomethingElse() { System.out.println("Something"); } } class Square { public Square() { } public void doSomething() { System.out.println("Something"); } } Note that adding curly braces to that if/else statement reduces the error to a warnin…
answers question: http://stackoverflow.com/q/504003

http://stackoverflow.com/a/583634
downvote count: 2
has comment: http://stackoverflow.com/comment/54734776
has comment: http://stackoverflow.com/comment/93729849
has comment: http://stackoverflow.com/comment/43804751
has comment: http://stackoverflow.com/comment/93896126
accepted answer of: http://stackoverflow.com/q/443499
upvote count: 456
type: AcceptedAnswer
has body: I hope you were joking about writing your own parser. :-) For such a simple mapping, most tools from http://json.org (section java) would work. For one of them (Jackson https://github.com/FasterXML/jackson-databind/#5-minute-tutorial-streaming-parser-generator), you'd do: Map&lt;String,Object&gt; result = new ObjectMapper().readValue(JSON_SOURCE, HashMap.class); (where JSON_SOURCE is a File, input stream, reader, or json content String)
type: Answer
answers question: http://stackoverflow.com/q/443499
has comment: http://stackoverflow.com/comment/66553772
score: 454

http://stackoverflow.com/comment/431114
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/618167
has text: sounds good. what would the past tense be? Sket? "Jon Skeet sket me AGAIN!" :)
score: 0

http://stackoverflow.com/comment/10776462
type: Comment
has text: Peaberry (http://code.google.com/p/peaberry/) is an adaptation of Guice to work with OSGi.
comment on: http://stackoverflow.com/a/457726
type: AnswerComment
score: 0

http://stackoverflow.com/q/363792
has answer: http://stackoverflow.com/a/363818
accepted answer: http://stackoverflow.com/a/363952
has answer: http://stackoverflow.com/a/363811
upvote count: 4
has answer: http://stackoverflow.com/a/11919339
has answer: http://stackoverflow.com/a/363808
type: AnsweredQuestion
tagged with: c#
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/363952
type: Question
has body: My friend and I are having a disagreement over an application development issue. It's a simple production management application. According to my friend, the front-end stores data in XML, and a Java program will read the XML document, store it (at the back-end), and apply some business logic and again store the results into another XML document. And a C# front-end will display the result ( He wants to use sockets for communicating the status of XML ). I think this is a bad idea. I suggested that whole application should either be written in C# or in Java. Note: The application is standalone. It's not used over a network. Have any of you tried this? Please share your thoughts :)
possible better answer: http://stackoverflow.com/a/363827
tagged with: desktop-application
score: 4
has answer: http://stackoverflow.com/a/363827
has title: Program with C# front-end and Java back-end: Good or Bad Practice?
has comment: http://stackoverflow.com/comment/193801
has answer: http://stackoverflow.com/a/363868
answer count: 7
favorite count: 0

http://stackoverflow.com/a/446523
answers question: http://stackoverflow.com/q/446439
has comment: http://stackoverflow.com/comment/268096
upvote count: 1
accepted answer of: http://stackoverflow.com/q/446439
score: 1
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/268130
type: Answer
has body: You only have the exe version and not the bat files, because you've downloaded the Windows Installer and not the zip file. The bat files are only included in the zip file. You can download the zip and copy the bat files to the bin directory. No need to uninstall. I bet that you have a PATH problem. Check if there is an old version of Java in a system directory. Also, make sure that you modify the PATH system wide and not per command line session.

http://stackoverflow.com/comment/86619913
type: AnswerComment
score: 0
type: Comment
has text: The facts are there... some minor semantics about the reference being passed by value but the reference (pointer - I program in "C" too) ... can point to anything as the example provided shows. This results in the returned value being changed. As to the OP "question"... an earlier comment read "This is not a question, it's a statement of your opinion"... so there is some disagreement as to whether there was a question in there at all rather than a rather ambiguous discussion about the use of the final keyword.
comment on: http://stackoverflow.com/a/37931786

http://stackoverflow.com/comment/315866
score: 7
comment on: http://stackoverflow.com/a/500495
has text: That's generally the case when you do a "instanceof" check
type: AnswerComment
type: Comment

http://stackoverflow.com/a/475238
type: Answer
has body: Basically, the rule of thumb is if it uses any data specific to the object, instance. So Math.max is static but BigInteger.bitCount() is instance. It obviously gets more complicated as your domain model does, and there are border-line cases, but the general idea is simple.
answers question: http://stackoverflow.com/q/475097
upvote count: 1
score: 0
downvote count: 1

http://stackoverflow.com/comment/12552177
comment on: http://stackoverflow.com/a/2924453
type: AnswerComment
has text: At least in Java 1.6, this generates a warning: "Unchecked cast from Object[] to T[]"
type: Comment
score: 5

http://stackoverflow.com/comment/250603
score: 0
type: Comment
has text: That would certainly protect; declaring doPeriodicWork as synchronized would accomplish the same thing and probably be a little cleaner. That being said, there are probably smaller critical sections within doPeriodicWork that could be protected individually if moving to a thread pool.
type: AnswerComment
comment on: http://stackoverflow.com/a/426795

http://stackoverflow.com/a/36402326
downvote count: 0
has comment: http://stackoverflow.com/comment/86525547
answers question: http://stackoverflow.com/q/600146
upvote count: 6
type: Answer
score: 6
has body: //gets program.exe from inside the JAR file as an input stream InputStream is = getClass().getResource("program.exe").openStream(); //sets the output stream to a system folder OutputStream os = new FileOutputStream("program.exe"); //2048 here is just my preference byte[] b = new byte[2048]; int length; while ((length = is.read(b)) != -1) { os.write(b, 0, length); } is.close(); os.close();

http://stackoverflow.com/comment/4163932
type: Comment
comment on: http://stackoverflow.com/a/611777
has text: @pwes - that's true, but in this particular case, the `InputStream` class establishes a specific contract that *should* be upheld by *every* implementation. This allows callers to treat all `InputStream` implementations alike, without special treatment for one implementation that violates the contract. It's perfectly valid for a non-blocking implementation of an input stream to use a -1 value to signal "no data", but it should declare a new interface, not try to masquerade as an `InputStream`.
type: AnswerComment
score: 0

http://stackoverflow.com/a/507608
type: Answer
has comment: http://stackoverflow.com/comment/325390
answers question: http://stackoverflow.com/q/507556
upvote count: 17
has body: Quite the opposite. JDBC support in Spring is very simple. Here is basic example: dataSource = ... obtain data source... (e.g. via Spring config) SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); Map&lt;String, Object&gt; row = jdbcTemplate.queryForMap( "SELECT * FROM MyTable WHERE ID=? LIMIT 1", 100); JdbcTemplate and SimpleJdbcTemplate has lot of query methods you may find useful. For mapping rows to your objects, take a look at RowMapper and ParameterizedRowMapper &lt; T >. For your datasource you usually want to use some advanced DataSource with pooling support. For testing, simple BasicDataSource will do: BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName("driverClassName"); ds.setUrl("jdbc://..."); ds.setUsername("username"); ds.setPassword("password");
has comment: http://stackoverflow.com/comment/325480
accepted answer of: http://stackoverflow.com/q/507556
score: 17
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/323631

http://stackoverflow.com/q/434408
has answer: http://stackoverflow.com/a/434434
tagged with: java
answer count: 3
downvote count: 0
has title: Why are System.out/err implemented as Byte Streams in Java?
has body: I was having a look at this tutorial at Sun on command line I/O. It stated that: You might expect the Standard Streams to be character streams, but, for historical reasons, they are byte streams. System.out and System.err are defined as PrintStream objects. Although it is technically a byte stream, PrintStream utilizes an internal character stream object to emulate many of the features of character streams. Does any one know what "the historical reasons" are?
favorite count: 0
accepted answer: http://stackoverflow.com/a/434434
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/434413
upvote count: 3
has answer: http://stackoverflow.com/a/434413
has answer: http://stackoverflow.com/a/434427
type: Question
score: 3
tagged with: iostream

timer
tag name: timer
tags question: http://stackoverflow.com/q/589399
tags question: http://stackoverflow.com/q/409932
tags question: http://stackoverflow.com/q/399924
tags question: http://stackoverflow.com/q/454274
type: Tag
tags question: http://stackoverflow.com/q/522800
tags question: http://stackoverflow.com/q/416893
tags question: http://stackoverflow.com/q/637110
tags question: http://stackoverflow.com/q/426758

http://stackoverflow.com/comment/265645
comment on: http://stackoverflow.com/a/444060
score: 0
type: AnswerComment
has text: Yes, while the OP's question is very vague and leaves out most useful information, it's clear that something is looking for a no-arg constructor for Terminal.
type: Comment

http://stackoverflow.com/a/52823159
answers question: http://stackoverflow.com/q/468789
downvote count: 0
type: Answer
score: 1
upvote count: 1
has body: Here's something you can do that works across operating systems Using regex match to check for existing known invalid characters. if (newName.matches(".*[/\n\r\t\0\f`?*\\&lt;&gt;|\":].*")) { System.out.println("Invalid!"); } else { System.out.println("Valid!"); } Pros This works across operating systems You can customize it whatever way you want by editing that regex. Cons This might not be a complete list and need more research to fill in more invalid patterns or characters.

integer-overflow
tags question: http://stackoverflow.com/q/512266
tag name: integer-overflow
type: Tag

http://stackoverflow.com/q/401513
score: 0
tagged with: web-deployment
has answer: http://stackoverflow.com/a/401529
has answer: http://stackoverflow.com/a/402535
has body: Consider the following example structure - Project - www - files + documents + html + images + scripts - WEB-INF * web.xml The documents folder needs to be a symlink or in some other way external from the war file because users will add and remove documents (through a mapped network drive). I'd like to deploy the webapp as a war-file but I don't know how to do that and take the above into account. Could you give some pointers? /Adam
answer count: 9
has answer: http://stackoverflow.com/a/401876
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/402182
has answer: http://stackoverflow.com/a/37633765
has answer: http://stackoverflow.com/a/402596
tagged with: java
has answer: http://stackoverflow.com/a/403141
has answer: http://stackoverflow.com/a/401534
type: Question
has title: War-file deployment with shared resources
has answer: http://stackoverflow.com/a/401545

http://stackoverflow.com/a/444374
answers question: http://stackoverflow.com/q/438463
type: Answer
score: 1
upvote count: 1
has body: You might think about using a JFrame instead. It may give you a little more flexibility. If you are using a JFrame and you want it to popup on top of the other windows use: myFrame.setVisible(true); myFrame.setState(Frame.NORMAL); The setState will show the window to the user if it was in minimized state previously.
downvote count: 0

http://stackoverflow.com/a/460375
upvote count: 37
downvote count: 0
has body: Not every jar file is executable. Now, you need to import the classes, which are there under the jar, in your java file. For example, import org.xml.sax.SAXException; If you are working on an IDE, then you should refer its documentation. Or at least specify which one you are using here in this thread. It would definitely enable us to help you further. And if you are not using any IDE, then please look at javac -cp option. However, it's much better idea to package your program in a jar file, and include all the required jars within that. Then, in order to execute your jar, like, java -jar my_program.jar you should have a META-INF/MANIFEST.MF file in your jar. See here, for how-to.
has comment: http://stackoverflow.com/comment/100974032
accepted answer of: http://stackoverflow.com/q/460364
answers question: http://stackoverflow.com/q/460364
score: 37
type: AcceptedAnswer
type: Answer

http://stackoverflow.com/comment/388222
has text: This question was in fact answered in your previous question on this topic: http://stackoverflow.com/questions/519631/java-keywords
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/576253

http://stackoverflow.com/q/520241
upvote count: 38
tagged with: trigonometry
answer count: 7
favorite count: 0
tagged with: tf-idf
score: 38
has answer: http://stackoverflow.com/a/520299
possible better answer: http://stackoverflow.com/a/22913525
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/520281
has body: How do I find the cosine similarity between vectors? I need to find the similarity to measure the relatedness between two lines of text. For example, I have two sentences like: system for user interface user interface machine … and their respective vectors after tF-idf, followed by normalisation using LSI, for example [1,0.5] and [0.5,1]. How do I measure the smiliarity between these vectors?
type: Question
has answer: http://stackoverflow.com/a/22913525
has answer: http://stackoverflow.com/a/520263
tagged with: vector
downvote count: 0
has answer: http://stackoverflow.com/a/52579351
has answer: http://stackoverflow.com/a/520325
accepted answer: http://stackoverflow.com/a/520325
has answer: http://stackoverflow.com/a/40686894
has title: How do I calculate the cosine similarity of two vectors?

http://stackoverflow.com/comment/16210244
comment on: http://stackoverflow.com/a/9571146
score: 0
type: AnswerComment
has text: Just to follow up - the above source code is no longer working for me under reflections-0.9.8. Using more specific types does work, but Object.class doesn't. I haven't found a solution to this yet; it's possible it may be specific to me but I can't see a cause yet.
type: Comment

http://stackoverflow.com/comment/1998171
comment on: http://stackoverflow.com/q/396749
has text: You could one further on this, and use Hibernate (or another ORM) : then you can (mainly) avoid mixing SQL in with your Java code altogether. There's a bit of a learning curve with it (esp. collections) : but lots of docs and tutorials around. If your existing data is already structured as java beans then Hibernate can use these: it can even generate tables based on your classes - or create your java beans based on DB tables.
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/a/544899
upvote count: 2
has body: Why not add a public getDisplayName() method to your enum?
answers question: http://stackoverflow.com/q/544215
score: 2
has comment: http://stackoverflow.com/comment/358900
downvote count: 0
type: Answer

http://stackoverflow.com/q/545056
has answer: http://stackoverflow.com/a/29733268
possible better answer: http://stackoverflow.com/a/63490836
has comment: http://stackoverflow.com/comment/357169
has answer: http://stackoverflow.com/a/63490836
has answer: http://stackoverflow.com/a/545068
answer count: 6
has comment: http://stackoverflow.com/comment/357164
favorite count: 0
has answer: http://stackoverflow.com/a/2652638
has body: I asked this question previously (any-good-tutorial-for-moving-from-eclipse-to-vim) From the inputs, I started using GVIM instead of Eclipse. I added ctags to it and I am able to navigate now comfortably. The only problem left for me is "Debugging"? I tried searching for some links, and couldn't find a useful one? If anyone using or familiar with Java Debugging using vim/Gvim, can provide their inputs/ links/tutorials, it would be very helpful.
has comment: http://stackoverflow.com/comment/357070
has title: How to Debug Java Application using VIM/GVIM?
has answer: http://stackoverflow.com/a/553945
score: 30
tagged with: vim
tagged with: editor
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/545074
accepted answer: http://stackoverflow.com/a/545074
tagged with: java
has comment: http://stackoverflow.com/comment/91842303
upvote count: 30
type: Question
tagged with: debugging

http://stackoverflow.com/a/463203
has body: As quoted from the ?: Operator MSDN page, "the conditional operator (?:) returns one of two values depending on the value of a Boolean expression." So you can use the ternary operator to return more than just booleans: string result = (value &gt; 100 ) ? "value is big" : "value is small";
score: 4
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/463155
type: Answer

http://stackoverflow.com/comment/345154
type: Comment
score: 0
comment on: http://stackoverflow.com/a/532229
type: AnswerComment
has text: I wish it wasn't so expensive :(

http://stackoverflow.com/comment/367388
type: Comment
has text: The only problem with public attributes is they might be a good idea when you implement them, but may later constrain you down the road when you want greater control over your sets/gets.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/554801

http://stackoverflow.com/q/392268
downvote count: 0
type: UnansweredQuestion
score: 1
favorite count: 0
has body: In Java SAX processing, I dot not manage to obtain entity reference names from the org.xml.sax.ext.EntityResolver2 resolveEntity method. The name argument is always null even if the documentation states that 'name' is never null when invoked by a SAX2 parser. Any idea ? To demonstrate the issue, I have created a Jython 2.5 script. It prints (on my box): Entity Resolver 2 enabled: True Entity name: None Jython 2.5 script: # Jython from org.python.core.util import StringUtil from jarray import array # Java Standard Edition from org.xml.sax import * from org.xml.sax.ext import * from org.xml.sax.helpers import * from java.io import ByteArrayInputStream xml = """\ &lt;!DOCTYPE doc [&lt;!ENTITY entity SYSTEM "entity-file"&gt; ]&gt; &lt;doc&gt;&amp;entity;&lt;/doc&gt; """ def empty_source(): _source = InputSource() byte_stream = ByteArrayInputStream(array([], "b")) _source.setByteStream(byte_stream) return _source class Handler(EntityResolver2): def getExternalSubset(self, name, baseURI): return None def resolveEntity(self, name, publicId, baseURI, systemId): print "Entity name:", name return empty_source() reader = XMLReaderFactory.createXMLReader() enabled = reader.getFeature("http://xml.org/sax/features/use-entity-resolver2") print "Entity Resolver 2 enabled:", enabled handler = Handler() reader.setEntityResolver(handler) bytes = StringUtil.toBytes(xml) byte_stream = ByteArrayInputStream(bytes) source = InputSource(byte_stream) reader.parse(source)
has title: How do I manage to get a non-null name argument with org.xml.sax.ext.EntityResolver2 resolveEntity method?
type: Question
tagged with: http://stackoverflow.com/tag/xml
has answer: http://stackoverflow.com/a/393119
upvote count: 1
tagged with: sax
answer count: 1
tagged with: java

http://stackoverflow.com/a/473732
has body: In some circumstances, it can be useful to null variables (usually instance or class variables). But nulling a local variable immediately before the end of the method does absolutely nothing. When you set a variable to null, you are merely removing that reference to the actual object. But when a local variable goes out of scope, the reference is removed anyway; therefore, setting it to null as the last line of the method is simply redundant.
answers question: http://stackoverflow.com/q/473685
score: 0
type: Answer

http://stackoverflow.com/comment/37916750
type: QuestionComment
has text: See [generic-key-value-pair-collection-in-that-preserves-insertion-order](http://stackoverflow.com/questions/1396718/generic-key-value-pair-collection-in-that-preserves-insertion-order)
comment on: http://stackoverflow.com/q/486948
score: 0
type: Comment

http://stackoverflow.com/comment/133261365
comment on: http://stackoverflow.com/a/11726687
has text: This doesn't work in Java 11: there is no method `Throwable.getStackTraceElement(int)`
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/423517
has text: *Technically* the old String is still around until the garbage collector runs, but since you no longer have the pointer to it...
comment on: http://stackoverflow.com/q/610976
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/292347
score: 3
type: Comment
type: QuestionComment
has text: I didn't tag it as java, I simply initiated the PostBroker service and generated a RandomSOverflowTag using the SOverflowTagFactory. Who'd have thought.
comment on: http://stackoverflow.com/q/473088

http://stackoverflow.com/a/377827
upvote count: 5
type: Answer
has body: You need to create a separate jar(s) with all classes (and all their dependencies) which instances you plan to cache and then deploy this jar as well as ehcache.jar as a library (depending of what application server you use the procedure might be different), in case of Tomcat 6 that means just copy jars to lib folder. What happen then is that ehcache and your domain classes will be loaded by the classloader shared by all web applications, so instances will be cached and accessible in memory. The dependencies of your domain classes are important, so you should see whether this approach is feasible in your project. It might also affect the way you restart the web applications. Furthermore you should be aware that cache and sharing are not necessary the same thing. Cache is an optimization. If you put object instance into cache it might be evicted immediately if, for instance, cache doesn't have enough storage space or eviction policy configuration. So may be you have to review the way you plan to use ecache in general.
downvote count: 0
has comment: http://stackoverflow.com/comment/207538
has comment: http://stackoverflow.com/comment/207535
score: 5
accepted answer of: http://stackoverflow.com/q/376903
answers question: http://stackoverflow.com/q/376903
type: AcceptedAnswer

http://stackoverflow.com/a/551103
accepted answer of: http://stackoverflow.com/q/550919
upvote count: 19
has comment: http://stackoverflow.com/comment/363095
downvote count: 2
has comment: http://stackoverflow.com/comment/363770
score: 17
has comment: http://stackoverflow.com/comment/362722
has comment: http://stackoverflow.com/comment/363077
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/550919
has comment: http://stackoverflow.com/comment/363079
has body: Taking your followup: What if this is just the "investibility" logic for a customer wishing for a business loan. Perhaps the innvestibility decision of a customer for another product is really quite different ... Also, what if there are new products coming out all the time, each with different investibility decisions and I don't want to be updating my core Customer class every time this happens? and one of your comments: I'm not entirely sure about holding logic close to the data on which it operates. The real world doesn't work like this. When I ask for a loan, the bank decides whether I qualify. They don't ask me to decide for myself. you are right, as far as this goes. boolean investable = customer.isInvestable(); is not the optimal solution for the flexibility you're talking about. However, the original question didn't mention the existence of a separate Product base class. Given the additional information now available, the best solution would appear to be boolean investable = product.isInvestable(customer); The investability decision is made (polymorphically!) by the Product, in accordance with your "real world" argument and it also avoids having to make new customer subclasses each time you add a product. The Product can use whatever methods it wants to make that determination based on the Customer's public interface. I'd still question whether there are appropriate additions which could be made to Customer's interface to eliminate the need for switch, but it may still be the least of all evils. In the particular example provided, though, I'd be tempted to do something like: if (customer.getCategory() &lt; PRIME) { investable = customer.getSavingsAccount().getBalance() &gt; 1e6; } else { investable = customer.isCeo(); } I find this cleaner and clearer than listing off every possible category in a switch, I suspect it's more likely to reflect the "real world" thought processes ("are they below prime?" vs. "are they sub-prime or mid-prime?"), and it avoids havi…
has comment: http://stackoverflow.com/comment/362676
type: Answer

http://stackoverflow.com/q/640119
answer count: 2
downvote count: 0
favorite count: 0
has body: I am looking for a java library to efficently/fast transcodig and manipulation mp3 files. I am working on a sophisticated streaming server that mixes music and has some other functions to allow to users to interact with each other. A recommendation functonallity for example should fade over the stream of the sending user to the reciever of the recommendation. All the fuctionallity is implemented right now and works well using UPnP-AV devices. The next step would be not to simply switch the tracks like I do it now. It should be a smooth fade between songs. Any suggestions on that? Mayby java is not the right solution to work with sound. If you know a better way to do transcoding and manipuation of audio let me know. (Transcoding is needed because not all audio sources are available as mp3 but internally I do work only with MP3)
has answer: http://stackoverflow.com/a/640197
tagged with: transcoding
type: UnansweredQuestion
has title: Java to transcode and manipulate mp3 files
tagged with: upnp
has answer: http://stackoverflow.com/a/1685776
score: 1
tagged with: streaming
upvote count: 1
has comment: http://stackoverflow.com/comment/453587
type: Question
tagged with: audio-streaming
tagged with: java

http://stackoverflow.com/a/510724
has comment: http://stackoverflow.com/comment/2580012
answers question: http://stackoverflow.com/q/510610
type: Answer
downvote count: 0
score: 1
upvote count: 1
has body: The following works for first level children. To expand ALL children replace .children() with .breadthFirstEnumeration() import javax.swing.*; import javax.swing.tree.*; import java.awt.BorderLayout; import java.awt.event.*; import java.util.*; public class Tree { public static void main(String[] args) { JPanel panel = new JPanel(new BorderLayout()); final JTree tree = new JTree(); panel.add(new JScrollPane(tree)); JButton btn = new JButton("Press Me"); btn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { for (Enumeration e = ((TreeNode)tree.getModel().getRoot()).children();e.hasMoreElements();) { TreeNode tn = (TreeNode)e.nextElement(); tree.expandPath(new TreePath(((DefaultTreeModel)tree.getModel()).getPathToRoot(tn))); } } }); panel.add(btn, BorderLayout.SOUTH); JFrame frame = new JFrame(""); frame.getContentPane().add(panel); frame.setSize(300, 300); frame.setLocation(100, 100); frame.pack(); frame.show(); } }

http://stackoverflow.com/a/472594
type: Answer
answers question: http://stackoverflow.com/q/469884
upvote count: 5
has body: A bit more searching has turned up CronExecutorService in HA-JDBC. Interestingly, it has a dependency on Quartz for its CronExpression class, but that's it. That's not too bad. Update: I've fixed the broken links to point at new versions, but I don't know if that is the only dependency any more
downvote count: 0
has comment: http://stackoverflow.com/comment/50502908
has comment: http://stackoverflow.com/comment/50498621
score: 5

http://stackoverflow.com/q/449445
has title: Java Static
duplicate of: http://stackoverflow.com/q/335311
has answer: http://stackoverflow.com/a/449468
has answer: http://stackoverflow.com/a/449476
score: 0
favorite count: 0
tagged with: static
has body: Duplicate: What does the 'static' keyword do in a class? I've read this post already. What does the "static" keyword in a method do? I remember being told that static != clingy...but that is pretty much all I know about this keyword.
answer count: 5
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/270405
has answer: http://stackoverflow.com/a/449481
tagged with: keyword
has answer: http://stackoverflow.com/a/449473
has comment: http://stackoverflow.com/comment/43245800
duplicate of: http://stackoverflow.com/q/413898
upvote count: 3
tagged with: java
downvote count: 3
tagged with: methods
has answer: http://stackoverflow.com/a/449463
type: Question

http://stackoverflow.com/comment/58309766
type: QuestionComment
type: Comment
has text: Similar Question with multiple Answers: [How can I determine if a date is between two dates in Java?](http://stackoverflow.com/q/883060/642706)
score: 1
comment on: http://stackoverflow.com/q/494180

http://stackoverflow.com/a/629317
score: 0
has comment: http://stackoverflow.com/comment/441903
answers question: http://stackoverflow.com/q/629315
type: Answer
upvote count: 1
downvote count: 1
has body: You'll need multithreading for this. Ready to take the plunge?

http://stackoverflow.com/comment/10135484
comment on: http://stackoverflow.com/a/3758903
type: AnswerComment
score: 0
type: Comment
has text: Which solution do you mean with "second solution"? The sequence of the answers changes over time and can be shown in different sortings as well. You can use the "link" below the solution.

http://stackoverflow.com/a/424146
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/424119
has body: iText supports RTF.
score: 0
type: Answer

http://stackoverflow.com/a/574518
has comment: http://stackoverflow.com/comment/386344
score: 2
upvote count: 2
downvote count: 0
answers question: http://stackoverflow.com/q/574492
has body: Consider using a CardLayout instead, which manages two or more components (usually JPanel instances) that share the same display space. That way you don't have to fiddle with adding and removing components at runtime.
type: Answer

http://stackoverflow.com/comment/121581098
type: AnswerComment
has text: Won't any data contributed by bits other than the last 32 or so be shifted off the left of the result register and be lost?
score: 0
type: Comment
comment on: http://stackoverflow.com/a/13413618

http://stackoverflow.com/a/4434354
downvote count: 0
type: Answer
has body: Modern dongles, used correctly, can provide very strong levels of protection against illegal copying. CodeMeter from Wibu-Systems has survived several public cracking contests (most recently in China!) with no winners. The reason is strong encryption: the executable is encrypted completely with AES 128-bit encryption, and the key generation for decryption occurs only in the dongle. Since the half-life of the keys is short, even discovering one key (which would require enormous effort) doesn't provide a universal crack. Crackers are very smart people, and won't work any harder than necessary to crack software. It's easy to leave vulnerabilities in the software if software protection isn't the main focus of your research and development efforts. Getting a good dongle and following carefully the manufacturer's suggestions for protecting are the best insurance against illegal copying. Some useful questions when evaluating a system for protection: 1. Does it support the OS versions you want to target with your executable? 2. Does it encrypt the communications between the dongle and the OS? 3. Can it detect debuggers and lock the license if a debugger is running? 4. Does it use a smart card chip (harder to sniff with hardware tools)? 5. Does it use a single key or multiple keys? 6. Does it support the license models (pay per use, pay per time, etc) that you want? 7. Are a rich set of tools available to make it easy to use? 8. Can it protect other file types besides .exe files? 9. How good is their developer support? Has it been outsourced to another country? 10. How many reference customers can they provide? Cost can be $50-$100 per copy (or less or more; depends on a bunch of factors). Most reputable vendors will provide you with pricing information with a simple phone call. Hope this helps.
score: 2
has comment: http://stackoverflow.com/comment/17542262
upvote count: 2
answers question: http://stackoverflow.com/q/445911

http://stackoverflow.com/q/440262
favorite count: 0
answer count: 3
tagged with: generics
upvote count: 11
has body: How come, in Java, I can write List&lt;?&gt; list = new LinkedList&lt;Double&gt;(); but not List&lt;Container&lt;?&gt;&gt; list = new LinkedList&lt;Container&lt;Double&gt;&gt;(); where Container is just something like public class Container&lt;T&gt; { ... } This came up because I have a method that accepts a List&lt;Container&lt;?&gt;&gt;, and I would like to use Arrays.asList to pass arguments to it: process(Arrays.asList(new Container&lt;Double&gt;(), new Container&lt;Double&gt;())); But the language doesn't allow this, because it infers the type of Arrays.asList to be List&lt;Container&lt;Double&gt;&gt;, and that is not assignable to List&lt;Container&lt;?&gt;&gt;. If I add a String-parameterized Container to the call, process(Arrays.asList(new Container&lt;Double&gt;(), new Container&lt;String&gt;())); it still doesn't work, because it infers the type List&lt;Container&lt;? extends Serializable &amp; Comparable&lt;?&gt;&gt;&gt; for Arrays.asList. Only if I pass in something that is neither Comparable nor Serializable does it work properly. Of course, I can put in a cast and get the compiler to shut up, but I'm wondering if I'm doing something wrong here.
has answer: http://stackoverflow.com/a/440309
has answer: http://stackoverflow.com/a/440634
has title: Java generics: List<Container<?>> = new LinkedList<Container<Double>>() is prohibited?
type: Question
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/440634
score: 11
has answer: http://stackoverflow.com/a/803338
accepted answer: http://stackoverflow.com/a/440309
downvote count: 0

http://stackoverflow.com/a/472656
accepted answer of: http://stackoverflow.com/q/471342
downvote count: 0
score: 7
upvote count: 7
type: AcceptedAnswer
has body: The problem is the order you are creating the streams: In the server from the article (which I assume is what you are using), when a new connection is opened, the server opens first an input stream, and then an output stream: public Connect(Socket clientSocket) { client = clientSocket; try { ois = new ObjectInputStream(client.getInputStream()); oos = new ObjectOutputStream(client.getOutputStream()); } catch(Exception e1) { // ... } this.start(); } The commented example code uses the reverse order, first establishing the output stream, then the input stream: // open a socket connection socket = new Socket("localhost", 2000); // open I/O streams for objects oos = new ObjectOutputStream(socket.getOutputStream()); ois = new ObjectInputStream(socket.getInputStream()); But your code does it the other way around: server = new Socket(host, port); in = new ObjectInputStream(server.getInputStream()); out = new ObjectOutputStream(server.getOutputStream()); Establishing an output stream/input stream pair will stall until they have exchanged their handshaking information, so you must match the order of creation. You can do this just by swapping lines 34 and 35 in your example code.
answers question: http://stackoverflow.com/q/471342
type: Answer

http://stackoverflow.com/q/632716
upvote count: 1
tagged with: sizing
has answer: http://stackoverflow.com/a/632719
score: 1
tagged with: java
has title: How to fix the size of a Java heap
type: Question
downvote count: 0
has answer: http://stackoverflow.com/a/633183
favorite count: 0
tagged with: heap-memory
tagged with: strict
has body: I know Java VM has "-XMx" and "-XMs" for setting the size of the heap. It also has a feature called "ergonomics", that can intelligently adjust the size of the heap. But, I have a problem at hand requiring the heap with strictly fixed size. Here is the command line arguments: "-Xms2m -Xmx2m -XX:+PrintGCDetails" However, by observing the GC logs, it seems the size of the heap was not fixed at 2048K. See, e.g. 2368K, 2432K, 2176K, etc: [GC [PSYoungGen: 480K-&gt;72K(704K)] 1740K-&gt;1332K(2368K), 0.0032190 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] [GC [PSYoungGen: 560K-&gt;64K(768K)] 2094K-&gt;1598K(2432K), 0.0033090 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] [GC [PSYoungGen: 544K-&gt;32K(768K)] 1675K-&gt;1179K(2176K), 0.0009960 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] Is there a way to do the "strict sizing" (no more no less) of a Java heap?
has answer: http://stackoverflow.com/a/884561
has answer: http://stackoverflow.com/a/881843
has answer: http://stackoverflow.com/a/636261
answer count: 5
type: UnansweredQuestion

http://stackoverflow.com/a/616985
downvote count: 0
score: 8
upvote count: 8
type: Answer
has body: public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_RIGHT ) { //Right arrow key code } else if (e.getKeyCode() == KeyEvent.VK_LEFT ) { //Left arrow key code } else if (e.getKeyCode() == KeyEvent.VK_UP ) { //Up arrow key code } else if (e.getKeyCode() == KeyEvent.VK_DOWN ) { //Down arrow key code } repaint(); } The KeyEvent codes are all a part of the API: http://docs.oracle.com/javase/7/docs/api/java/awt/event/KeyEvent.html
has comment: http://stackoverflow.com/comment/429851
answers question: http://stackoverflow.com/q/616924

http://stackoverflow.com/a/457794
has body: That will return the same as ArrayList.class. Java generics erase the generic type at runtime; in other words, from "list" you'll never know the element type is String. There's a great FAQ on this at http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/457777
accepted answer of: http://stackoverflow.com/q/457777
upvote count: 7
score: 7

http://stackoverflow.com/q/588634
accepted answer: http://stackoverflow.com/a/588656
has answer: http://stackoverflow.com/a/589388
has answer: http://stackoverflow.com/a/588653
downvote count: 0
has answer: http://stackoverflow.com/a/588665
favorite count: 0
possible better answer: http://stackoverflow.com/a/589388
tagged with: exception
has answer: http://stackoverflow.com/a/67735389
score: 18
has body: If i remember correctly in .NET one can register "global" handlers for unhandled exceptions. I am wondering if there is something similar for Java.
type: AnsweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/588656
has answer: http://stackoverflow.com/a/588667
has title: Is there an unhandled exception handler in Java?
answer count: 6
upvote count: 18

http://stackoverflow.com/comment/393238
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/581020
has text: It'll break (i.e. identityHashCode will not necessarily be unique) on any reasonable VM. identityHashCode is not an I.D.

http://stackoverflow.com/comment/280734
has text: Nice and simple solution. To alter that to his new conditions: .*(\d{2}/\d{2}/\d{4})
comment on: http://stackoverflow.com/a/461672
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/412507
type: Answer
score: 2
has body: I think using @ignore is OK as long as there is - A good reason why the method cannot be tested in some form and it is documented as such in the code. This should be a special case and warrant a discussion or code review to see if there is any way to test it. The test is not yet built - this should ideally happen only for legacy code. This should be also subject to code review and tasks should be put to add tests. That's the rules at least in my mind ;-)
upvote count: 2
downvote count: 0
answers question: http://stackoverflow.com/q/412409

http://stackoverflow.com/q/647017
has title: Java Abstract Class Confusion: overridden method not being called
answer count: 4
has body: So I have two classes. One is abstract: public abstract class AbstractClient { protected boolean running = true; protected void run() { Scanner scanner = new Scanner(System.in); displayOptions(); while (running) { String input = null; while (scanner.hasNext()) { input = scanner.next(); } processInputCommand(input); } } abstract void displayOptions(); abstract void processInputCommand(String input); } One is the concrete subclass: public class BasicClient extends AbstractClient { private IBasicServer basicServer; public static void main(String[] args) { new BasicClient(); } public BasicClient() { try { System.setSecurityManager(new RMISecurityManager()); Registry registry = LocateRegistry.getRegistry(); basicServer = (IBasicServer) registry.lookup(IBasicServer.LOOKUPNAME); run(); } catch (Exception e) { e.printStackTrace(); } } @Override void displayOptions() { BasicClientOptions.displayOptions(); } @Override void processInputCommand(String input) { // TODO Auto-generated method stub } } Now in the subclass I call the run() method of the abstract class because this should be common to all clients. Inside the run() method is a call to the abstract method displayOptions(). I have overridden displayOptions() in the subclass so I assumed that it would invoke the subclassed method but it seems it has not. Is there a way to do this or have I made an obvious mistake or have I misunderstood how abstract classes should work? P.S I tried putting a print statement inside the subclassed displayOptions() to ensure I hadn't done something daft with method I call. Many thanks, Adam
favorite count: 0
has answer: http://stackoverflow.com/a/1500192
upvote count: 3
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/647025
score: 3
has answer: http://stackoverflow.com/a/647035
has answer: http://stackoverflow.com/a/647213
tagged with: java
type: Question
downvote count: 0
tagged with: abstract-class

http://stackoverflow.com/a/461910
has comment: http://stackoverflow.com/comment/12374293
has comment: http://stackoverflow.com/comment/300598
has comment: http://stackoverflow.com/comment/280730
has comment: http://stackoverflow.com/comment/280707
score: 65
upvote count: 65
downvote count: 0
has comment: http://stackoverflow.com/comment/5174781
has comment: http://stackoverflow.com/comment/280654
answers question: http://stackoverflow.com/q/461896
type: Answer
has comment: http://stackoverflow.com/comment/3850532
has body: One classic problem is changing the object you're synchronizing on while synchronizing on it: synchronized(foo) { foo = ... } Other concurrent threads are then synchronizing on a different object and this block does not provide the mutual exclusion you expect.
has comment: http://stackoverflow.com/comment/3854027
has comment: http://stackoverflow.com/comment/296688
has comment: http://stackoverflow.com/comment/290790

http://stackoverflow.com/a/388449
has body: java.lang.Cloneable is a marker interface. It's solely for the purpose so that Object.clone can throw an exception to signal a class does not support cloning by using for example if(!(this instanceof Cloneable)) throw...; From the documentation: The method clone for class Object performs a specific cloning operation. First, if the class of this object does not implement the interface Cloneable, then a CloneNotSupportedException is thrown. It's got no methods. Making it a generic isn't going to be of any use.
upvote count: 6
downvote count: 0
answers question: http://stackoverflow.com/q/388439
type: Answer
has comment: http://stackoverflow.com/comment/215883
score: 6
has comment: http://stackoverflow.com/comment/215874

http://stackoverflow.com/a/407085
upvote count: 1
has body: Why is it a pain to create a new buffer in the loop? That's what the garbage collector is there for. There would need to be a new allocation under the covers in clear() anyway. If you really want to implement your SuperBuffer, it would not be that hard at all. Just create a subclass of OutputStream with a clear() function, and then wrap a PrintStream around that. You could use a CharBuffer in your super buffer if you wanted.
answers question: http://stackoverflow.com/q/407026
downvote count: 0
type: Answer
score: 1

http://stackoverflow.com/a/5613537
answers question: http://stackoverflow.com/q/403256
has body: If you use resources extensively, you might consider using Commons VFS. Also supports: * Local Files * FTP, SFTP * HTTP and HTTPS * Temporary Files "normal FS backed) * Zip, Jar and Tar (uncompressed, tgz or tbz2) * gzip and bzip2 * resources * ram - "ramdrive" * mime There's also JBoss VFS - but it's not much documented.
type: Answer
score: 0

http://stackoverflow.com/a/366227
type: Answer
has comment: http://stackoverflow.com/comment/196049
upvote count: 4
score: 0
downvote count: 4
has body: I'm reasonably certain this is not possible using regular expressions alone. Checking whether something is contained inside some other tag is a parsing operation. This seems like the same problem as trying to parse XML with a regex -- it can't be done correctly. You may be able to get your desired outcome by repeatedly applying a non-greedy, non-global regex that matches the quoted strings, then once you can't find anything else, split it at the spaces... that has a number of problems, including keeping track of the original order of all the substrings. Your best bet is to just write a really simple function that iterates over the string and pulls out the tokens you want.
has comment: http://stackoverflow.com/comment/195788
answers question: http://stackoverflow.com/q/366202

http://stackoverflow.com/a/31061425
upvote count: 36
downvote count: 0
type: Answer
has body: All the benchmarks presented here have some flaws, thus results are not reliable. I was surprised that nobody used JMH for benchmarking, so I did. Results: Benchmark Mode Cnt Score Error Units MyBenchmark.testOld thrpt 20 9645.834 ± 238.165 ops/s // using + MyBenchmark.testNew thrpt 20 429.898 ± 10.551 ops/s // using String.format Units are operations per second, the more the better. Benchmark source code. OpenJDK IcedTea 2.5.4 Java Virtual Machine was used. So, old style (using +) is much faster.
answers question: http://stackoverflow.com/q/513600
score: 36

http://stackoverflow.com/a/368100
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/368094
upvote count: 12
score: 12
has body: I prefer using the value returned by System.currentTimeMillis() for all kinds of calculations and only use Calendar or Date if I need to really display a value that is read by humans. This will also prevent 99% of your daylight-saving-time bugs. :)

http://stackoverflow.com/comment/97598732
has text: Is it applicable to only objects ? Can we serialize variables (declared without using objects) ?
type: Comment
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/447920

http://stackoverflow.com/comment/422433
type: Comment
comment on: http://stackoverflow.com/q/609963
score: 0
type: QuestionComment
has text: Thanks. I felt this should somehow be obvious, but I still didn't get it.

http://stackoverflow.com/q/359732
has title: Why is it considered a bad practice to omit curly braces?
accepted answer: http://stackoverflow.com/a/359753
has answer: http://stackoverflow.com/a/359750
possible better answer: http://stackoverflow.com/a/361327
has comment: http://stackoverflow.com/comment/75575122
has answer: http://stackoverflow.com/a/359762
has comment: http://stackoverflow.com/comment/1128241
has answer: http://stackoverflow.com/a/1019773
has answer: http://stackoverflow.com/a/365713
score: 188
tagged with: c++
has answer: http://stackoverflow.com/a/359789
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/359776
tagged with: coding-style
has answer: http://stackoverflow.com/a/363308
has answer: http://stackoverflow.com/a/359771
has answer: http://stackoverflow.com/a/359862
has answer: http://stackoverflow.com/a/359886
has comment: http://stackoverflow.com/comment/2094554
tagged with: java
has answer: http://stackoverflow.com/a/399211
has answer: http://stackoverflow.com/a/361238
has answer: http://stackoverflow.com/a/379984
has answer: http://stackoverflow.com/a/1020049
has answer: http://stackoverflow.com/a/5739489
has answer: http://stackoverflow.com/a/361472
has answer: http://stackoverflow.com/a/588831
has answer: http://stackoverflow.com/a/359787
has answer: http://stackoverflow.com/a/359797
type: Question
has answer: http://stackoverflow.com/a/360020
has answer: http://stackoverflow.com/a/359805
tagged with: c#
has answer: http://stackoverflow.com/a/365723
has answer: http://stackoverflow.com/a/361103
has answer: http://stackoverflow.com/a/1365312
has comment: http://stackoverflow.com/comment/190755
answer count: 52
has answer: http://stackoverflow.com/a/361368
has answer: http://stackoverflow.com/a/359791
has answer: http://stackoverflow.com/a/359784
downvote count: 5
has answer: http://stackoverflow.com/a/360033
has comment: http://stackoverflow.com/comment/64123853
tagged with: http://stackoverflow.com/tag/c
has answer: http://stackoverflow.com/a/359753
has comment: http://stackoverflow.com/comment/54612249
has answer: http://stackoverflow.com/a/359768
has comment: http://stackoverflow.com/comment/39895121
has comment: http://stackoverflow.com/comment/59524025
has answer: http://stackoverflow.com/a/361846
has answer: http://stackoverflow.com/a/360002
has answer: http://stackoverflow.com/a/359777
has answer: http://stackoverflow.com/a/359902
has answer: http://stackoverflow.com/a/359839
has answer: http://stackoverflow.com/a/360963
has comment: http://stackoverflow.com/comment/103135952
has body: Why does everyone tell me writing code like this is a bad practice? if (foo) Bar(); //or for(int i = 0 i &lt; count; i++) Bar(i); My biggest argument for omitting the curly braces is that it can sometimes be twice as many lines with them. For example, here is some code to paint a glow effect for a label in C#. using (Brush br = new SolidBrush(Color.FromArgb(15, GlowColor))) { for (int x = 0; x &lt;= GlowAmount; x++) { for (int y = 0; y &lt;= GlowAmount; y++) { g.DrawString(Text, this.Font, br, new Point(IconOffset + x, y)); } } } //versus using (Brush br = new SolidBrush(Color.FromArgb(15, GlowColor))) for (int x = 0; x &lt;= GlowAmount; x++) for (int y = 0; y &lt;= GlowAmount; y++) g.DrawString(Text, this.Font, br, new Point(IconOffset + x, y)); You can also get the added benefit of chaining usings together without having to indent a million times. using (Graphics g = Graphics.FromImage(bmp)) { using (Brush brush = new SolidBrush(backgroundColor)) { using (Pen pen = new Pen(Color.FromArgb(penColor))) { //do lots of work } } } //versus using (Graphics g = Graphics.FromImage(bmp)) using (Brush brush = new SolidBrush(backgroundColor)) using (Pen pen = new Pen(Color.FromArgb(penColor))) { //do lots of work } The most common argument for curly braces revolves around maintance programming, and the problems that would ensue by inserting code between the original if statement and its intended result: if (foo) Bar(); Biz(); Questions: Is it wrong to want to use the more compact syntax which the language offers? The people that design these languages are smart, I can't imagine they would put a feature which is always bad to use. Should we or Shouldn't we write code so the lowest common denominator can understand and have no problems working with it? Is there another argument that I'm missing?
has answer: http://stackoverflow.com/a/1731105
has answer: http://stackoverflow.com/a/359761
has answer: http://stackoverflow.com/a/1020035
has answer: http://stackoverflow.com/a/359930
has answer: http://stackoverflow.com/a/361280
has comment: http://stackoverflow.com/comment/190727
has answer: http://stackoverflow.com/a/1015869
has answer: http://stackoverflow.com/a/361327
has answer: http://stackoverflow.com/a/359752
has answer: http://stackoverflow.com/a/359747
has answer: http://stackoverflow.com/a/359766
favorite count: 0
has answer: http://stackoverflow.com/a/359794
has answer: http://stackoverflow.com/a/359754
has answer: http://stackoverflow.com/a/360011
upvote count: 193
has answer: http://stackoverflow.com/a/359948
has answer: http://stackoverflow.com/a/360012
has answer: http://stackoverflow.com/a/360048

http://stackoverflow.com/comment/221877
type: AnswerComment
type: Comment
has text: You use snapshot versions for all the small modules. But it does use a significant amount of memory in the IDE with all these modules. 500mb to 1gb memory is not uncommon. Can be a bit painful with 32 bit XP and 3gb memory max
comment on: http://stackoverflow.com/a/372248
score: 0

http://stackoverflow.com/comment/299061
type: Comment
comment on: http://stackoverflow.com/a/482068
score: 0
type: AnswerComment
has text: Zach, I agree with your general assessment but unfortunately this doesn't answer my question. I *want* to break away from the conventional behavior but I'm finding it impossible to do so. I'm trying to find out if this is a Swing bug or user error.

http://stackoverflow.com/comment/25365954
has text: @Booyeoo: Or more specifically: `import groovy.time.TimeCategory import groovy.time.TimeDuration` @Patrick: As long as you asked: Yes, I love Groovy.
score: 5
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2757551

http://stackoverflow.com/a/40717503
upvote count: 4
downvote count: 0
has body: As mentioned by sombody above, restarting eclipse worked for me for the user defined environment variable. After I restart eclipse IDE, System.getenv() is picking up my environment variable.
score: 4
answers question: http://stackoverflow.com/q/531694
has comment: http://stackoverflow.com/comment/129811741
type: Answer

http://stackoverflow.com/comment/7143326
score: 0
type: Comment
type: QuestionComment
has text: Related: http://stackoverflow.com/questions/462094/in-java-how-do-i-make-a-class-with-a-private-constructor-whose-superclass-also-h and http://stackoverflow.com/questions/4682659/accessing-constructor-from-abstract-base-class-with-reflection
comment on: http://stackoverflow.com/q/624458

http://stackoverflow.com/a/449589
type: Answer
answers question: http://stackoverflow.com/q/449558
has comment: http://stackoverflow.com/comment/270697
has body: I'm not sure that I fully understand your question. If you are interested in materials about learning Java (rather than API references), you can download all of it as a zip file. It will be multiple HTML files, but I've never seen a real problem with browsing them unless I wanted a printout. If you need a printout of the tutorial, just get the tutorial in book form. If you are looking for the JavaDocs for a specific API, and you use Eclipse, your best bet might be to use the version of Eclipse that is specific for Java and comes packaged with the JDK source code (or just download the source code). You can then read the documentation of methods through different views like the Java Browsing view.
has comment: http://stackoverflow.com/comment/270530
downvote count: 0
score: 8
upvote count: 8
has comment: http://stackoverflow.com/comment/3667368

http://stackoverflow.com/a/369526
answers question: http://stackoverflow.com/q/369512
upvote count: 3
type: Answer
downvote count: 0
score: 3
has body: If there are multiple ways a user might order person, you could also have multiple Comparators setup as constants somewhere. Most of the sort operations and sorted collections take a comparator as a parameter.

http://stackoverflow.com/a/484221
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/484182
has body: A. Sounds like it's time for a database :-). Rather than having a shared file what about storing the data in a database. B. Alternatively - layering: Lock threads within a process with a standard synchronized lock. Lock inter-process/machine with a file-based lock type thing - e.g. create a directory to hold the lock. Nest 2 inside 1. Still has the clean-up problem. C. Alternatively some kind of write to new file/rename strategy so that reader don't need to lock maybe?
downvote count: 0
type: Answer

http://stackoverflow.com/a/634754
upvote count: 255
type: AcceptedAnswer
type: Answer
has comment: http://stackoverflow.com/comment/14480786
answers question: http://stackoverflow.com/q/633158
accepted answer of: http://stackoverflow.com/q/633158
has body: For a long time I believed that there was a value in having a "centralized, declarative, configuration" like the xml files we all used to use. Then I realized that most of the stuff in the files wasn't configuration - it was never changed anywhere after development, ever. Then I realized that "centralized" only has value in quite small systems - only in small systems will you ever be able to grok a configuration file as a whole. And what is really the value of understanding the wiring as a whole, when the same "wirings" are mostly duplicated by dependencies in the code? So the only thing I've kept is meta-data (annotations), which is still kind-of declarative. These never change at runtime and they're never "configuration" data that someone will change on the fly - so I think keeping it in the code is nice. I use full auto-wiring as much as I can. I love it. I won't go back to old-style spring unless threatened at gun-point. My reasons for preferring fully @Autowired have changed over time. Right now I think the most important reason for using autowiring is that there's one less abstraction in your system to keep track of. The "bean name" is effectively gone. It turns out the bean name only exists because of xml. So a full layer of abstract indirections (where you would wire bean-name "foo" into bean "bar") is gone. Now I wire the "Foo" interface into my bean directly, and implementation is chosen by run-time profile. This allows me to work with code when tracing dependencies and implementations. When I see an autowired dependency in my code I can just press the "go to implementation" key in my IDE and up comes the list of known implementations. In most cases there's just one implementation and I'm straight into the class. Can't be much simpler than that, and I always know exactly what implementation is being used (I claim that the opposite is closer to the truth with xml wiring - funny how your perspective changes!) Now you could say that it's just a very simple la…
downvote count: 0
score: 255

http://stackoverflow.com/a/7325155
score: 0
type: Answer
has body: I am not sure if referencing files or folders is the good way. You should use modularization. So you domain classes will be stored in separate "project". It is possible to do it by creating plugins. You can find great explanation and source code here.
answers question: http://stackoverflow.com/q/395675

http://stackoverflow.com/a/422201
type: Answer
score: 0
has body: You may want to consider using Apache Collections. They have a bunch of LRU implementations. Otherwise, you can easily write a similar wrapper for the standard library collections; I don't think there's one you can use directly.
answers question: http://stackoverflow.com/q/422181

http://stackoverflow.com/comment/308043
comment on: http://stackoverflow.com/q/492280
type: Comment
type: QuestionComment
score: 0
has text: I swear I thought this said "how to ejaculate com+ libraries". I need some sleep.

http://stackoverflow.com/a/55608879
type: Answer
answers question: http://stackoverflow.com/q/420223
has body: Use Comparable interface for sorting on the basis of more than one value like age,name,dept_name... For one value use Comparator interface
score: 0

http://stackoverflow.com/comment/2129340
has text: Valid reasons for wanting to do this exist. I've had a few occasions where I found it helpful during testing for instance.
comment on: http://stackoverflow.com/a/421349
score: 20
type: AnswerComment
type: Comment

http://stackoverflow.com/a/616692
type: Answer
has body: You can think on the "intranet" of an Enterprise. In a enterprise your systems may be exposed using web technologies without having to go to internet for that. In the standard edition, you don't get any of those "enteprise" features ( no jsp, no application servers ) just the core of the libraries. The micro edition is for mobiles and a like. And those tools suit better on a "enterprise" environment, but they are no limited to it. You may use spring for a desktop application, or Hibernate for a local database, but most of the times, Hibernate is used to access the enterprise database. All these ( Spring, Hibernate and lot other tools ) are not part of core of the Java Platform, they are 3rd party solutions.
answers question: http://stackoverflow.com/q/616598
score: 0

http://stackoverflow.com/q/377819
has body: Let's say I have a class like this: class ApplicationDefs{ public static final String configOption1 = "some option"; public static final String configOption2 = "some other option"; public static final String configOption3 = "yet another option"; } Many of the other classes in my application are using these options. Now, I want to change one of the options alone and deploy just the compiled class. But if these fields are in-lined in the consumer classes this becomes impossible right? Is there any option to disable the in-lining of compile time constants?
tagged with: java
answer count: 6
has answer: http://stackoverflow.com/a/377958
linked to: http://stackoverflow.com/q/39386014
downvote count: 0
has answer: http://stackoverflow.com/a/2338074
favorite count: 0
has title: Are all compile-time constants inlined?
tagged with: inlining
score: 25
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/377824
upvote count: 25
tagged with: compile-time-constant
accepted answer: http://stackoverflow.com/a/2338074
has answer: http://stackoverflow.com/a/377825
possible better answer: http://stackoverflow.com/a/377824
type: Question
has answer: http://stackoverflow.com/a/377860
has answer: http://stackoverflow.com/a/377828

http://stackoverflow.com/a/505018
has comment: http://stackoverflow.com/comment/319921
type: Answer
has comment: http://stackoverflow.com/comment/319918
has comment: http://stackoverflow.com/comment/45853703
has comment: http://stackoverflow.com/comment/320502
has body: Interfaces allow statically typed languages to support polymorphism. An Object Oriented purist would insist that a language should provide inheritance, encapsulation, modularity and polymorphism in order to be a fully-featured Object Oriented language. In dynamically-typed - or duck typed - languages (like Smalltalk,) polymorphism is trivial; however, in statically typed languages (like Java or C#,) polymorphism is far from trivial (in fact, on the surface it seems to be at odds with the notion of strong typing.) Let me demonstrate: In a dynamically-typed (or duck typed) language (like Smalltalk), all variables are references to objects (nothing less and nothing more.) So, in Smalltalk, I can do this: |anAnimal| anAnimal := Pig new. anAnimal makeNoise. anAnimal := Cow new. anAnimal makeNoise. That code: Declares a local variable called anAnimal (note that we DO NOT specify the TYPE of the variable - all variables are references to an object, no more and no less.) Creates a new instance of the class named "Pig" Assigns that new instance of Pig to the variable anAnimal. Sends the message makeNoise to the pig. Repeats the whole thing using a cow, but assigning it to the same exact variable as the Pig. The same Java code would look something like this (making the assumption that Duck and Cow are subclasses of Animal: Animal anAnimal = new Pig(); duck.makeNoise(); anAnimal = new Cow(); cow.makeNoise(); That's all well and good, until we introduce class Vegetable. Vegetables have some of the same behavior as Animal, but not all. For example, both Animal and Vegetable might be able to grow, but clearly vegetables don't make noise and animals cannot be harvested. In Smalltalk, we can write this: |aFarmObject| aFarmObject := Cow new. aFarmObject grow. aFarmObject makeNoise. aFarmObject := Corn new. aFarmObject grow. aFarmObject harvest. This works perfectly well in Smalltalk because it is duck-typed (if it walks like a duck, and quacks like a duck - it is a duck.) In this ca…
has comment: http://stackoverflow.com/comment/325558
has comment: http://stackoverflow.com/comment/319724
has comment: http://stackoverflow.com/comment/319913
score: 33
has comment: http://stackoverflow.com/comment/319899
upvote count: 33
answers question: http://stackoverflow.com/q/504904
downvote count: 0
has comment: http://stackoverflow.com/comment/324822

http://stackoverflow.com/a/29670746
has body: Old post, but I was struggling with this. My problem was more with Javafx allowing the JOptionPane to go behind the current Java window. Therefore I used the following which does what the original poster asked by putting the JOptionPane in front of all windows; even JAVAFX. Firstly the old JOptionPane: JOptionPane.showMessageDialog(null, "Here I am"); Now an JOptionPane that stays in front: final JDialog dialog = new JDialog(); dialog.setAlwaysOnTop(true); JOptionPane.showMessageDialog(dialog, "Here I am"); And for fun here is everything in one long line: JOptionPane.showMessageDialog( ((Supplier&lt;JDialog&gt;) () -&gt; {final JDialog dialog = new JDialog(); dialog.setAlwaysOnTop(true); return dialog;}).get() , "Here I am"); You can make a static method some where that will return the JDialog for you and then just call it in the JOptionPane to clean up your code a bit.
score: 10
upvote count: 10
downvote count: 0
answers question: http://stackoverflow.com/q/438463
type: Answer

http://stackoverflow.com/comment/22904149
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/3477915
has text: @Plaudit checkout gm4java, it creates a pool of GM process in interactive mode and doesn't need to fork every time to convert an image. http://kennethxu.blogspot.com/2013/04/integrate-java-and-graphicsmagick.html

http://stackoverflow.com/a/8068634
downvote count: 0
answers question: http://stackoverflow.com/q/359993
type: Answer
has body: Have a look at tools like: MetaWidget http://www.metawidget.org/ Apache Isis They generate UI's "on-the-fly" but allow you to customise the UI when necessary. Much better than code generation.
upvote count: 5
score: 5

http://stackoverflow.com/comment/16277461
comment on: http://stackoverflow.com/a/515115
type: Comment
has text: -1 The OP is not trying to get the code fixed. This does not answer the OP's question: _Can someone explain to me what the reasoning behind this design choice was?_
score: 0
type: AnswerComment

http://stackoverflow.com/comment/86611619
comment on: http://stackoverflow.com/a/387716
score: 1
has text: @Aleks can I introduce you to VB?
type: AnswerComment
type: Comment

http://stackoverflow.com/q/579993
has answer: http://stackoverflow.com/a/580048
score: 2
tagged with: java
has answer: http://stackoverflow.com/a/580022
type: Question
has answer: http://stackoverflow.com/a/580026
has answer: http://stackoverflow.com/a/584067
has title: How can I make it so that a JPanel updates itself once the window scrolls?
has body: I'm new to Java so this is probably pretty simple, but I'm not sure how to make it work. Basically, I have a class which I use to draw a grid, which extends JPanel. I put this class in a window, inside a JScrollPane. The scroll works the way I want it to, except the drawing inside my class doesn't update itself once the window scrolls. It does update if the window is resized though. I think I'm supposed to use events/listeners or something like that, but I'm not sure where to start looking. edit: also, when i open one of the menus and it overlaps on the drawing, the region that was covered by the menus isn't updated. Okay, let's try again: I have a class called draw. Then I have a GridBagLayout out of draws. This creates the grid I need. I have an object moving around the grid, so this way I can update the grid without having to calculate myself the rectangles that have to be updated. Then this grid is inside a JScrollPane, which is not subclassed. I use pack() when I create my Window, but the thing is, the Window may be bigger than the resolution allows, so I need it to be scrollable. The scroll works for me, but it doesn't update the image when I use it. However, resizing the window does update it. What I want is a way to redraw all my window when I click the JScrollPane. And now, I also need to redraw the whole thing (or some parts, I'll see that later) once I access the menus, because the draw parts of the grid under the menus are not updated. That's the best way I can describe it.
downvote count: 0
answer count: 6
tagged with: user-interface
has answer: http://stackoverflow.com/a/584054
favorite count: 0
has answer: http://stackoverflow.com/a/581129
upvote count: 2
type: UnansweredQuestion
tagged with: swing

http://stackoverflow.com/a/370421
has comment: http://stackoverflow.com/comment/219574
has body: Not clear on what you do and don't have control over at this point. If you can interpose a different OutputStream class on the destination file, you could use a subtype of OutputStream which converts Strings to bytes under a charset you define, say UTF-8 by default. If modified UTF-8 is suffcient for your needs, you can use DataOutputStream.writeUTF(String): byte inbytes[] = new byte[1024]; FileInputStream fis = new FileInputStream("response.txt"); fis.read(inbytes); String in = new String(inbytes, "UTF8"); DataOutputStream out = new DataOutputStream(new FileOutputStream("response-2.txt")); out.writeUTF(in); // no getBytes() here If this approach is not feasible, it may help if you clarify here exactly what you can and can't control in terms of data flow and execution environment (though I know that's sometimes easier said than determined). Good luck.
answers question: http://stackoverflow.com/q/361975
score: 1
type: Answer
upvote count: 2
downvote count: 1

http://stackoverflow.com/q/386792
has answer: http://stackoverflow.com/a/3730797
has answer: http://stackoverflow.com/a/389734
has answer: http://stackoverflow.com/a/5807559
has answer: http://stackoverflow.com/a/11801514
has title: In Java Swing how do you get a Win32 window handle (hwnd) reference to a window?
downvote count: 0
possible better answer: http://stackoverflow.com/a/3730797
has body: In Java 1.4 you could use ((SunToolkit) Toolkit.getDefaultToolkit()).getNativeWindowHandleFromComponent() but that was removed. It looks like you have to use JNI to do this now. Do you have the JNI code and sample Java code to do this? I need this to call the Win32 GetWindowLong and SetWindowLong API calls, which can be done via the Jawin library. I would like something very precise so I can pass a reference to the JDialog or JFrame and get the window handle. Swing transparency using JNI may be related.
has answer: http://stackoverflow.com/a/413895
favorite count: 0
score: 29
tagged with: swing
upvote count: 29
linked to: http://stackoverflow.com/q/265602
type: AnsweredQuestion
tagged with: winapi
tagged with: java
accepted answer: http://stackoverflow.com/a/413895
has answer: http://stackoverflow.com/a/6553061
type: Question
tagged with: hwnd
tagged with: java-native-interface
answer count: 6

http://stackoverflow.com/comment/656534
has text: There is an example how to use this fuction. It is the testFunc-json-document.xsl file in the Tests folder: http://fxsl.cvs.sourceforge.net/viewvc/fxsl/fxsl-xslt2/Tests/testFunc-json-document.xsl?revision=1.1&view=markup When applied on any XML file (not used) this transformation produces the correct result. One potential factor that could cause your problem is the use of relatively old version of Saxon -- please use a 9.x version of Saxon. Also, the link in your message is unreachable.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/561337
type: Comment

http://stackoverflow.com/a/7952126
upvote count: 20
has comment: http://stackoverflow.com/comment/79131898
has comment: http://stackoverflow.com/comment/77102449
score: 20
downvote count: 0
answers question: http://stackoverflow.com/q/615948
has body: Runtime runtime = Runtime.getRuntime(); try { Process p1 = runtime.exec("cmd /c start D:\\temp\\a.bat"); InputStream is = p1.getInputStream(); int i = 0; while( (i = is.read() ) != -1) { System.out.print((char)i); } } catch(IOException ioException) { System.out.println(ioException.getMessage() ); }
type: Answer

http://stackoverflow.com/comment/1795556
score: 44
type: AnswerComment
has text: Yeah, I'm sure Gosling is very ignorant about Java in comparison to you.
comment on: http://stackoverflow.com/a/1553151
type: Comment

http://stackoverflow.com/comment/101479336
score: 0
type: Comment
has text: @Gibson: with 2000 reputation you can [apply an edit immediately](https://stackoverflow.com/help/privileges/edit), but you can suggest one much earlier. Suggested edits are voted on by the community.
type: AnswerComment
comment on: http://stackoverflow.com/a/380828

http://stackoverflow.com/a/476223
downvote count: 0
type: Answer
has body: There are two popular approaches. One is to provide a clone method as you mentioned, like so. public class C implements Cloneable { @Override public C clone() { try { final C result = (C) super.clone(); // copy fields that need to be copied here! return result; } catch (final CloneNotSupportedException ex) { throw new AssertionError(); } } Pay attention to the "copy fields ... here!" part. The initial result is only a shallow copy, meaning that if there's a reference to an object, both the original and result will share the same object. For example, if C contains private int[] data you'd probably want to copy that. ... final C result = (C) super.clone(); result.data = data.clone(); return result; ... Note that you don't need to copy primitive fields, as their content is already copied, or immutable objects, as they can't change anyways. The second approach is to provide a copy constructor. public class C { public C(final C c) { // initialize this with c } } Or a copy factory. public class C { public static C newInstance(final C c) { return new C(c); } private C(final C c) { // initialize this with c } } Both approaches have their respective properties. clone is nice because its a method, so you don't have to know the exact type. In the end, you should always end up with a "perfect" copy. The copy constructor is nice because the caller has a chance to decide, as can be seen by the Java Collections. final List c = ... // Got c from somewhere else, could be anything. // Maybe too slow for what we're trying to do? final List myC = new ArrayList(c); // myC is an ArrayList, with known properties I recommend choosing either approach, whichever suits you better. I'd use the other approaches, like reflective copying or immediate serializing/deserializing, in unit tests only. To me, they feel less appropriate for production code, mainly because of performance concerns.
score: 21
upvote count: 21
answers question: http://stackoverflow.com/q/475842

http://stackoverflow.com/comment/132259999
type: AnswerComment
score: 0
has text: Quiz any developer about Unicode, and pretty soon you discover that many developers actually don't fully understand what goes on with codepoints, grapheme clusters, etc... If Java really wanted to simplify things, don't introduce null and the fragile class hierarchies.
type: Comment
comment on: http://stackoverflow.com/a/430357

http://stackoverflow.com/q/452969
upvote count: 112
has answer: http://stackoverflow.com/a/452981
tagged with: class
score: 112
has title: Does python have an equivalent to Java Class.forName()?
has answer: http://stackoverflow.com/a/78449259
downvote count: 0
linked to: http://stackoverflow.com/q/10675054
possible better answer: http://stackoverflow.com/a/452971
favorite count: 0
has answer: http://stackoverflow.com/a/452971
has answer: http://stackoverflow.com/a/20507847
has answer: http://stackoverflow.com/a/58449145
tagged with: python
accepted answer: http://stackoverflow.com/a/452981
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/128059216
tagged with: java
has answer: http://stackoverflow.com/a/453459
has body: I have the need to take a string argument and create an object of the class named in that string in Python. In Java, I would use Class.forName().newInstance(). Is there an equivalent in Python? Thanks for the responses. To answer those who want to know what I'm doing: I want to use a command line argument as the class name, and instantiate it. I'm actually programming in Jython and instantiating Java classes, hence the Java-ness of the question. getattr() works great. Thanks much.
type: Question
tagged with: instantiation
answer count: 8
has answer: http://stackoverflow.com/a/30042585
has comment: http://stackoverflow.com/comment/48200568
has answer: http://stackoverflow.com/a/3610097

http://stackoverflow.com/comment/340760
type: Comment
has text: And if you DO know what you're doing, the next guy to touch the code won't, and THEN it will break. This is very bad advice. People have trouble enough dealing with text; encouraging them to mix it with binary data is just plain irresponsible.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/520954

http://stackoverflow.com/comment/419340
comment on: http://stackoverflow.com/a/607056
type: Comment
has text: the whole clicking a button thing?
type: AnswerComment
score: 0

http://stackoverflow.com/comment/74647980
has text: This used to work in 3.0, but has been broken since 3.1, see https://jira.spring.io/browse/SPR-9214 and https://jira.spring.io/browse/SPR-10281
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/10587580
type: Comment

http://stackoverflow.com/q/466143
has title: QCompleter and QLineEdit for multiple words
type: AnsweredQuestion
favorite count: 0
tagged with: c++
score: 4
has comment: http://stackoverflow.com/comment/289819
has body: Is there any way to have the QCompleter to act like an autocomplete for multiple words? Someone has any idea how to do it?
answer count: 1
tagged with: qt
tagged with: java
upvote count: 4
has answer: http://stackoverflow.com/a/466246
has comment: http://stackoverflow.com/comment/284378
downvote count: 0
accepted answer: http://stackoverflow.com/a/466246
type: Question

http://stackoverflow.com/a/46044878
answers question: http://stackoverflow.com/q/494180
downvote count: 0
has comment: http://stackoverflow.com/comment/79049839
score: 1
has comment: http://stackoverflow.com/comment/79049748
upvote count: 1
has comment: http://stackoverflow.com/comment/79049823
type: Answer
has body: This was clearer to me, // declare calendar outside the scope of isWithinRange() so that we initialize it only once private Calendar calendar = Calendar.getInstance(); public boolean isWithinRange(Date date, Date startDate, Date endDate) { calendar.setTime(startDate); int startDayOfYear = calendar.get(Calendar.DAY_OF_YEAR); // first day is 1, last day is 365 int startYear = calendar.get(Calendar.YEAR); calendar.setTime(endDate); int endDayOfYear = calendar.get(Calendar.DAY_OF_YEAR); int endYear = calendar.get(Calendar.YEAR); calendar.setTime(date); int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR); int year = calendar.get(Calendar.YEAR); return (year &gt; startYear &amp;&amp; year &lt; endYear) // year is within the range || (year == startYear &amp;&amp; dayOfYear &gt;= startDayOfYear) // year is same as start year, check day as well || (year == endYear &amp;&amp; dayOfYear &lt; endDayOfYear); // year is same as end year, check day as well }

http://stackoverflow.com/a/2020036
has body: Java Set is designed to remove duplicates and hopefully the HashMap must be using Java Set internally for managing key as keys can never have duplicates, So you should be considering set for your requirement.
answers question: http://stackoverflow.com/q/460088
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/22956705

http://stackoverflow.com/comment/92971004
type: Comment
comment on: http://stackoverflow.com/a/37448602
score: 2
has text: -XX:+UseStringDeduplication (which requires -XX:+UseG1GC) appears to be a good addition to that list, see https://stackoverflow.com/questions/27949213/string-deduplication-feature-of-java-8/27953779#27953779 and https://blog.codecentric.de/en/2014/08/string-deduplication-new-feature-java-8-update-20-2/
type: AnswerComment

http://stackoverflow.com/q/623990
has answer: http://stackoverflow.com/a/624051
upvote count: 2
has answer: http://stackoverflow.com/a/623993
type: Question
has title: Do you know of a Java library to access the native linux api?
tagged with: java
accepted answer: http://stackoverflow.com/a/624051
has answer: http://stackoverflow.com/a/624044
has body: Do you know of a Java library to access the native linux api? I guess something like this must use JNI. So be it.
downvote count: 0
favorite count: 0
tagged with: linux
possible better answer: http://stackoverflow.com/a/624007
has answer: http://stackoverflow.com/a/624007
has comment: http://stackoverflow.com/comment/436847
answer count: 4
score: 2
type: AnsweredQuestion

http://stackoverflow.com/a/366511
has body: Without code this would be my guess: 1) you use a variable named 'event' but it is not one of the arguments in you method. (Alternatively: you forgot to declare it, but from the name I'd guess it's belongs in a method call) 2) You call the method 'findbunki' on an object of type java.awt.Point - Point does not have that method. Find the class that has the fundbunki method (probably one of your own classes) and call the method on an object of that type.
type: Answer
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/366438
upvote count: 2

http://stackoverflow.com/comment/227687
score: 0
type: Comment
comment on: http://stackoverflow.com/a/402414
has text: No, I suppose. Its rendering it perfectly in 4 columns as expected. The only problem is the tag <s:checkbox>.
type: AnswerComment

http://stackoverflow.com/a/1493954
has comment: http://stackoverflow.com/comment/81701503
answers question: http://stackoverflow.com/q/595872
upvote count: 62
has body: Here is some information about one more source of the JSESSIONID cookie: I was just debugging some Java code that runs on a tomcat server. I was not calling request.getSession() explicitly anywhere in my code but I noticed that a JSESSIONID cookie was still being set. I finally took a look at the generated Java code corresponding to a JSP in the work directory under Tomcat. It appears that, whether you like it or not, if you invoke a JSP from a servlet, JSESSIONID will get created! Added: I just found that by adding the following JSP directive: &lt;%@ page session="false" %&gt; you can disable the setting of JSESSIONID by a JSP.
score: 62
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/52881298

http://stackoverflow.com/q/377242
has answer: http://stackoverflow.com/a/393740
answer count: 1
downvote count: 0
has body: Has anybody tried to use JavaFX Script in server side applications? The language itself looks quite nice and modern, and is fully Java compatible. If Sun is serious about it, it could be quite ubiquitus on the server side too, where Java is strong. What do you think?
tagged with: server-side
favorite count: 0
score: 2
tagged with: javafx-1
accepted answer: http://stackoverflow.com/a/393740
upvote count: 2
type: AnsweredQuestion
tagged with: java
tagged with: javafx
type: Question
has title: JavaFX Script for server side applications

http://stackoverflow.com/comment/24809052
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/480406
has text: I know this post is old, but if anyone reads it: HttpURLConnection is now preferred over HttpClient, see [this blog post](http://android-developers.blogspot.com/2011/09/androids-http-clients.html) for info.
score: 12

http://stackoverflow.com/a/573404
type: Answer
answers question: http://stackoverflow.com/q/573384
score: 0
has body: This is really hard without seeing the definition of StackLinked, is that one of your own classes? I can think of several options: The stack is somehow empty (e.g., a was not one of these characters'). Or the 'a' is saved as a Character in the stack (rather than as a char), and then the conversion to Integer fails. You may need to first get the char out of the Character.

http://stackoverflow.com/a/422038
answers question: http://stackoverflow.com/q/421251
upvote count: 4
downvote count: 0
score: 4
has body: As has been noted, you must maintain the session cookie between requests (see CookieHandler). Here is a sample implementation: class MyCookieHandler extends CookieHandler { private Map&lt;String, List&lt;String&gt;&gt; cookies = new HashMap&lt;String, List&lt;String&gt;&gt;(); @Override public Map&lt;String, List&lt;String&gt;&gt; get(URI uri, Map&lt;String, List&lt;String&gt;&gt; requestHeaders) throws IOException { String host = uri.getHost(); Map&lt;String, List&lt;String&gt;&gt; ret = new HashMap&lt;String, List&lt;String&gt;&gt;(); synchronized (cookies) { List&lt;String&gt; store = cookies.get(host); if (store != null) { store = Collections.unmodifiableList(store); ret.put("Cookie", store); } } return Collections.unmodifiableMap(ret); } @Override public void put(URI uri, Map&lt;String, List&lt;String&gt;&gt; responseHeaders) throws IOException { List&lt;String&gt; newCookies = responseHeaders.get("Set-Cookie"); if (newCookies != null) { String host = uri.getHost(); synchronized (cookies) { List&lt;String&gt; store = cookies.get(host); if (store == null) { store = new ArrayList&lt;String&gt;(); cookies.put(host, store); } store.addAll(newCookies); } } } }
type: Answer

http://stackoverflow.com/comment/349068
type: AnswerComment
comment on: http://stackoverflow.com/a/531829
type: Comment
has text: while its longer, its not more obscure to use a library call like StringUtil.isNullOrEmpty(someString); , and the reason is that having a name there makes it much more readable. the performance hit is negligible, so its a win.
score: 1

http://stackoverflow.com/comment/29942698
type: AnswerComment
type: Comment
score: 0
has text: Please, I want to see your "clear performance advantage". http://raid6.com.au/~onlyjob/posts/arena/
comment on: http://stackoverflow.com/a/531825

http://stackoverflow.com/comment/400032
has text: Why so many Datasources?
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/588103

http://stackoverflow.com/a/413323
answers question: http://stackoverflow.com/q/413292
has comment: http://stackoverflow.com/comment/238255
upvote count: 5
has comment: http://stackoverflow.com/comment/238367
has comment: http://stackoverflow.com/comment/238038
has comment: http://stackoverflow.com/comment/238006
score: 5
has comment: http://stackoverflow.com/comment/238046
downvote count: 0
has comment: http://stackoverflow.com/comment/238184
has comment: http://stackoverflow.com/comment/238127
type: Answer
has body: You can switch on the unused code rules in PMD (there's a NetBeans plugin), then run PMD over a whole project.
has comment: http://stackoverflow.com/comment/238085
has comment: http://stackoverflow.com/comment/238057

http://stackoverflow.com/a/59822159
upvote count: 3
downvote count: 1
has body: My solution is to transfer the HSSFWorkbook to ByteArrayOutputStream first, and then create an InputStream from ByteArrayOutputStream : HSSFWorkbook wb = ... // Fill an empty output stream ByteArrayOutputStream baos = new ByteArrayOutputStream(); wb.write(baos); // Close the document wb.close(); // Create the input stream (do not forget to close the inputStream after use) InputStream is = new ByteArrayInputStream(baos.toByteArray());
answers question: http://stackoverflow.com/q/378883
type: Answer
score: 2

http://stackoverflow.com/comment/7979562
comment on: http://stackoverflow.com/a/6238790
has text: You're close, but your code will not compile. You try to access getNumber from a static context in your main method. Do you actually tried to compile this? (and should'nt your UltraFoo extend SuperFoo?)
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/405795
comment on: http://stackoverflow.com/a/582487
score: 0
type: AnswerComment
type: Comment
has text: Thanks :) The advantage of the BigInt code is that it's a single line (and more easy to understand). That's why I gave it a +1.

http://stackoverflow.com/comment/442509
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/629804
score: 0
has text: What are the keys and values in this table? If they're not primitives, what's wrong with the normal HashMap etc?

http://stackoverflow.com/a/8652883
answers question: http://stackoverflow.com/q/628082
score: 0
has body: Even better is the TN5250j Console, which can be used to extract data from the AS/400.
type: Answer

http://stackoverflow.com/comment/279710
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/460627
has text: Note that HashSet is really just a wrapper around a HashMap with null values, so the only difference is that the intent is clearer.
score: 0

http://stackoverflow.com/comment/303853
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/487632
has text: You'd probably get more responses if you don't make this a community wiki.

http://stackoverflow.com/a/758065
has body: I am using JPA (OpenJPA implementation from Apache which is based on the KODO JDO codebase which is 5+ years old and extremely fast/reliable). IMHO anyone who tells you to bypass the specs is giving you bad advice. I put the time in and was definitely rewarded. With either JDO or JPA you can change vendors with minimal changes (JPA has orm mapping so we are talking less than a day to possibly change vendors). If you have 100+ tables like I do this is huge. Plus you get built0in caching with cluster-wise cache evictions and its all good. SQL/Jdbc is fine for high performance queries but transparent persistence is far superior for writing your algorithms and data input routines. I only have about 16 SQL queries in my whole system (50k+ lines of code).
answers question: http://stackoverflow.com/q/530215
upvote count: 10
type: Answer
downvote count: 0
score: 10

http://stackoverflow.com/a/6185359
has comment: http://stackoverflow.com/comment/58053344
type: Answer
has comment: http://stackoverflow.com/comment/19983244
has comment: http://stackoverflow.com/comment/25474687
downvote count: 1
has body: If you need a temporary directory for testing and you are using JUnit, @Rule together with TemporaryFolder solves your problem: @Rule public TemporaryFolder folder = new TemporaryFolder(); From the documentation: The TemporaryFolder Rule allows creation of files and folders that are guaranteed to be deleted when the test method finishes (whether it passes or fails) Update: If you are using JUnit Jupiter (version 5.1.1 or greater), you have the option to use JUnit Pioneer which is the JUnit 5 Extension Pack. Copied from the project documentation: For example, the following test registers the extension for a single test method, creates and writes a file to the temporary directory and checks its content. @Test @ExtendWith(TempDirectory.class) void test(@TempDir Path tempDir) { Path file = tempDir.resolve("test.txt"); writeFile(file); assertExpectedFileContent(file); } More info in the JavaDoc and the JavaDoc of TempDirectory Gradle: dependencies { testImplementation 'org.junit-pioneer:junit-pioneer:0.1.2' } Maven: org.junit-pioneer junit-pioneer 0.1.2 test Update 2: The @TempDir annotation was added to the JUnit Jupiter 5.4.0 release as an experimental feature. Example copied from the JUnit 5 User Guide: @Test void writeItemsToFile(@TempDir Path tempDir) throws IOException { Path file = tempDir.resolve("test.txt"); new ListWriter(file).write("a", "b", "c"); assertEquals(singletonList("a,b,c"), Files.readAllLines(file)); }
has comment: http://stackoverflow.com/comment/19980794
has comment: http://stackoverflow.com/comment/27921338
has comment: http://stackoverflow.com/comment/12616000
score: 181
upvote count: 182
answers question: http://stackoverflow.com/q/617414

http://stackoverflow.com/comment/283675
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/465303
has text: There's plenty of 1.1 code still in production. Things have one downhill from there, anyway :)
score: 0

http://stackoverflow.com/q/565531
has answer: http://stackoverflow.com/a/565551
has body: i need to alert or warn the user.. while user login into particular account 'your account has been expired next week' like that.. my user table having validfrom and validto date. Before 1 week of validto date.. i need to warn users at every time login. my application using strus2.. for above business logic i need any schedular.. otherwise any easy way.. pl help me
tagged with: authentication
upvote count: 1
has title: before Warning login
type: Question
tagged with: warnings
tagged with: struts2
answer count: 3
downvote count: 0
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/696106
has answer: http://stackoverflow.com/a/565896
score: 1
tagged with: java

http://stackoverflow.com/comment/33239478
has text: I used this to catch a servlet exception in Eclipse debugging a problem that I couldn't seem to catch in the app code itself. Many thanks for this tip!
type: Comment
score: 0
comment on: http://stackoverflow.com/a/370929
type: AnswerComment

http://stackoverflow.com/a/482686
has body: Weka is awesome, but Classifier4J is probably closer to what you want, since it's more aimed at text recognition.
upvote count: 3
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/480683
downvote count: 0
answers question: http://stackoverflow.com/q/480683
score: 3
type: Answer
has comment: http://stackoverflow.com/comment/2592650

http://stackoverflow.com/a/363252
score: -1
answers question: http://stackoverflow.com/q/359625
downvote count: 1
type: Answer
upvote count: 0
has comment: http://stackoverflow.com/comment/22701873
has body: If you want something that's blisteringly fast, and you have a very clear idea of what formats you want to accept, you can build a state machine DFA by hand. This is essentially how regexes work under the hood anyway, but you can avoid the regex compilation step this way, and it may well be faster than a generic regex compiler.

http://stackoverflow.com/a/431097
has body: I think you want to use WebStart. You can deploy from a browser but it is otherwise a full blown application. There are a few browserish security restrictions, but, as you're using an Applet currently, I think I can assume they're not a problem.
type: Answer
answers question: http://stackoverflow.com/q/431044
score: 4
upvote count: 4
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/431044

http://stackoverflow.com/a/387764
score: 1
type: AcceptedAnswer
has body: Classes under sun.* are not public APIs, may change without notice and do all sorts. Forutnately untrusted code cannot access them at all. javac objects to their use. There's no need to decompile the code - the original source is available, although not necessarily up to date.
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/216397
has comment: http://stackoverflow.com/comment/215459
accepted answer of: http://stackoverflow.com/q/387415
answers question: http://stackoverflow.com/q/387415
upvote count: 1

http://stackoverflow.com/comment/108517988
comment on: http://stackoverflow.com/a/29674295
score: 0
type: AnswerComment
has text: All 3 of those requires API level 24 on android.
type: Comment

http://stackoverflow.com/q/497176
score: 2
tagged with: java
has answer: http://stackoverflow.com/a/497208
upvote count: 4
has answer: http://stackoverflow.com/a/2607864
has answer: http://stackoverflow.com/a/497195
answer count: 7
has answer: http://stackoverflow.com/a/497264
favorite count: 0
has title: Can classes in java that implement runnable have methods other than run()?
has body: I'm trying to implement a simple class like this: public static void main(String args[]) { try { myClass test = new Thread(new myClass(stuff)); test.start(); test.join(); } catch (Throwable t) { } } When I try to include a print() method in myClass and use it, I get a "cannot find symbol" in class java.lang.Thread. I don't really have to make this a thread, but I would like to, just to test it. Will I have to change it if I want my print() method to work? EDIT: I am sorry, I just realized I can call print() inside the run() function lol. Why can't I call it outside though? That doesn't make sense to me. If I add synchronized or something can I call the function outside of run/the class? EDIT2: Sorry I miswrote the names here. EDIT3: I'm currently doing this: Thread test = new Thread(new myClass(stuff)); teste.start(); teste.join(); If I use new Runner, it seems I can't use start() and join(). Is there a way to go about that? EDIT4: Okay, let's try one more time please: I have myEnvironment, which is a class and I have myAgent, which is another class. myAgent is the thread. myAgent requires a myEnvironment, so I was passing it as a parameter to the constructor. However, I couldn't do this by extending Thread, because constructor (myEnvironment) wasn't found. Do I have to set myEnvironment via another function or can I pass it using the constructor?
has comment: http://stackoverflow.com/comment/312925
has answer: http://stackoverflow.com/a/497189
has answer: http://stackoverflow.com/a/497185
type: UnansweredQuestion
tagged with: multithreading
downvote count: 2
has answer: http://stackoverflow.com/a/497197
type: Question

http://stackoverflow.com/a/35180265
downvote count: 0
score: 26
has comment: http://stackoverflow.com/comment/112689391
type: Answer
has comment: http://stackoverflow.com/comment/117954910
upvote count: 26
has body: Key notes: Strategy is behavioral design pattern. It is used to switch between family of algorithms. One real word example : Airlines offering discounts during some months (July-December). You can have one Fare module, which decides pricing options depending on month number. Have a look at a simple example. This example can be extended to on-line retailing applications, which provides discount to shopping cart items on special days/happy hours easily. import java.util.*; /* Interface for Strategy */ interface OfferStrategy { public String getName(); public double getDiscountPercentage(); } /* Concrete implementation of base Strategy */ class NoDiscountStrategy implements OfferStrategy { public String getName() { return this.getClass().getName(); } public double getDiscountPercentage() { return 0; } } /* Concrete implementation of base Strategy */ class QuarterDiscountStrategy implements OfferStrategy { public String getName() { return this.getClass().getName(); } public double getDiscountPercentage() { return 0.25; } } /* Context , which is optional can be single interface for client. */ class StrategyContext { double price; // price for some item or air ticket etc. Map<String, OfferStrategy> strategyContext = new HashMap<String, OfferStrategy>(); StrategyContext(double price) { this.price = price; strategyContext.put(NoDiscountStrategy.class.getName(), new NoDiscountStrategy()); strategyContext.put(QuarterDiscountStrategy.class.getName(), new QuarterDiscountStrategy()); } public void applyStrategy(OfferStrategy strategy) { /* Currently applyStrategy has simple implementation. You can use Context for populating some more information, which is required to call a particular operation */ System.out.println("Price before offer :" + price); double finalPrice = price - (price*strategy.getDiscountPercentage()); System.out.println("Price after offer:" + finalPrice); } public OfferStrategy getStrategy(int monthNo) { /* In absence of this Context method, client has to import …
answers question: http://stackoverflow.com/q/370258

http://stackoverflow.com/comment/252976
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/429402
has text: What's riskier? A data breach and losing all your users (and probably the company going under), or delaying a new feature by a few days while the security implications are evaluated? You might be able to sway them with some examples of companies that have gone under after a breach...

http://stackoverflow.com/comment/1570596
type: Comment
score: 2
has text: Basically your argument is "Managing exceptions is tiring so I'd rather not deal with it". As the exception bubbles up it looses meaning and context making is practically useless. As designer of an API you should make is contractually clear as to what can be expected when things go wrong, if my program crashes because I was not informed that this or that exception can "bubbles up" then you, as designer, failed and as a result of your failure my system is not as stable as it can be.
type: AnswerComment
comment on: http://stackoverflow.com/a/614122

http://stackoverflow.com/q/382536
possible better answer: http://stackoverflow.com/a/382661
favorite count: 0
has answer: http://stackoverflow.com/a/382541
has comment: http://stackoverflow.com/comment/210341
has answer: http://stackoverflow.com/a/399386
type: AnsweredQuestion
score: 1
has answer: http://stackoverflow.com/a/382661
type: Question
tagged with: java
has body: Is there an online Java book like Dive into Python for learning Python? Other resources online besides the standard Java documentation (which is awesome but almost too technical) .
upvote count: 2
accepted answer: http://stackoverflow.com/a/382541
answer count: 3
has title: Online Java Book
downvote count: 1

http://stackoverflow.com/comment/326719
type: AnswerComment
type: Comment
has text: I like this answer better because it mentions the standard convention you can use to differentiate between interfaces and classes.
score: 3
comment on: http://stackoverflow.com/a/513051

http://stackoverflow.com/comment/283698
score: 16
has text: I think you're looking at getRead*LOCK*Count*(), rather than getRead*HOLD*Count*(). The latter has no such warning in the Javadocs and does return the number of holds for the current thread (e.g. lock twice in thread A, then 3 times in thread B, it will return 2 in thread A and not 5).
type: AnswerComment
comment on: http://stackoverflow.com/a/464824
type: Comment

http://stackoverflow.com/comment/328347
score: 0
comment on: http://stackoverflow.com/a/514486
type: Comment
has text: Actually the behaviour would be exactly the same were arguments passed by value in Java. Or by any mean actually. The behaviour he shows only has to do with parameter binding.
type: AnswerComment

http://stackoverflow.com/a/503399
type: Answer
score: 0
answers question: http://stackoverflow.com/q/503369
has body: Older versions of the JRE are generally smaller, since the standard API has been continuously added to. Of course, this is only an option if your app does not require recent language features and/or API classes. Also, double-check that you're using a JRE rather than a JDK (which is much larger)

cachedrowset
type: Tag
tag name: cachedrowset
tags question: http://stackoverflow.com/q/462534

http://stackoverflow.com/comment/219427
type: Comment
score: 0
type: AnswerComment
has text: +1. If you need to process the whole picture, then SetPixel/GetPixel are SLOW.
comment on: http://stackoverflow.com/a/392335

http://stackoverflow.com/comment/24983428
comment on: http://stackoverflow.com/a/813851
type: Comment
has text: `if you insert or delete an element in the middle using ListIterator.add() or Iterator.remove(), it will be O(1)` why? first we need to find element in the middle, so why it not O(n)?
score: 1
type: AnswerComment

http://stackoverflow.com/q/371019
accepted answer: http://stackoverflow.com/a/371256
has title: Java listener must inherit from java.util.EventListener - why?
possible better answer: http://stackoverflow.com/a/371039
type: AnsweredQuestion
tagged with: java
upvote count: 10
type: Question
answer count: 2
score: 10
has answer: http://stackoverflow.com/a/371256
downvote count: 0
has body: In the javadoc it says that EventListener is "A tagging interface that all event listener interfaces must extend." Why is that? What's the significance of making a custom listener implement EventListner? Is there any special handling for EventListner somewhere?
tagged with: events
has answer: http://stackoverflow.com/a/371039
favorite count: 0
tagged with: listener

http://stackoverflow.com/comment/650053
type: Comment
has text: Thanks for this question, the answers cleared up a lot of misconceptions I had. I looked into the correct way to do Java threads before SO existed and there was a lot of misinformation/outdated information out there.
comment on: http://stackoverflow.com/q/541487
score: 69
type: QuestionComment

http://stackoverflow.com/q/510632
tagged with: concurrency
has answer: http://stackoverflow.com/a/60007016
has answer: http://stackoverflow.com/a/38727973
has title: What's the difference between ConcurrentHashMap and Collections.synchronizedMap(Map)?
has answer: http://stackoverflow.com/a/46872806
has answer: http://stackoverflow.com/a/42696348
has answer: http://stackoverflow.com/a/26958843
has answer: http://stackoverflow.com/a/510654
has comment: http://stackoverflow.com/comment/42977542
upvote count: 654
has answer: http://stackoverflow.com/a/47982606
has comment: http://stackoverflow.com/comment/105204004
favorite count: 0
has answer: http://stackoverflow.com/a/510675
answer count: 19
has body: I have a Map which is to be modified by several threads concurrently. There seem to be three different synchronized Map implementations in the Java API: Hashtable Collections.synchronizedMap(Map) ConcurrentHashMap From what I understand, Hashtable is an old implementation (extending the obsolete Dictionary class), which has been adapted later to fit the Map interface. While it is synchronized, it seems to have serious scalability issues and is discouraged for new projects. But what about the other two? What are the differences between Maps returned by Collections.synchronizedMap(Map) and ConcurrentHashMaps? Which one fits which situation?
has answer: http://stackoverflow.com/a/17776425
has answer: http://stackoverflow.com/a/510660
has answer: http://stackoverflow.com/a/6540791
has answer: http://stackoverflow.com/a/13111472
has answer: http://stackoverflow.com/a/34367014
tagged with: dictionary
has answer: http://stackoverflow.com/a/8253533
possible better answer: http://stackoverflow.com/a/17776425
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/510654
has answer: http://stackoverflow.com/a/510665
has comment: http://stackoverflow.com/comment/42726844
has answer: http://stackoverflow.com/a/13119819
downvote count: 1
has answer: http://stackoverflow.com/a/510695
type: Question
has answer: http://stackoverflow.com/a/510667
score: 653
has answer: http://stackoverflow.com/a/35392530
tagged with: java

http://stackoverflow.com/a/477629
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/477609
downvote count: 0
has body: Which do you feel is simpler or clearer? I suggest you do that.
type: Answer

http://stackoverflow.com/a/489930
upvote count: 4
score: 4
answers question: http://stackoverflow.com/q/489913
has body: That's because when you declare public static void funk(int a, int[] b) The scope of the variable a is only that method. Then when you change the value, you are changing only the value of that variable in that method. About the b. Thats a new object reference to the same array created in main, that's why it seems the value does change ( what is changing is the array object underneath ) But try this: public static void funk(int a, int[] b) { // create a new reference for b int[] c = new int[b.length]; c[0] = b[0]; b = c; // The same. b[0] = b[0] * 2; a = b[0] + 5; } When you do that you'll the the value of tiger didn't change either ( only the content of the new array c created in funk ) You can simulate the pass by ref using a wrapper. See this post. Although I haven't got any comments about that EDIT Just for fun: I have modified your code to use the wrapper posted above. It looks pretty strange but looks like it works. // By ref simulated. public class Test { public static void funk(_&lt;Integer&gt; a, int[] b) { b[0] = b[0] * 2; a.s( b[0] + 5 ) ; } public static void main(String[] args) { _&lt;Integer&gt; bird = new _&lt;Integer&gt;(10); int[] tiger = {7}; Test.funk( bird , tiger ); System.out.println("bird = " + bird ); System.out.println("tiger = " + tiger[0] ); } } Prints bird = 19 tiger = 14 :-S
downvote count: 0
type: Answer

http://stackoverflow.com/comment/58151442
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/541773
has text: I used it to create generic logger, So i sent object to the logger, and it logs depending on the class name of the object, rather than giving log tag or log string everytime. thank you
score: 0

http://stackoverflow.com/comment/53729482
comment on: http://stackoverflow.com/a/590446
has text: it's almost always faster on x86_64, as indicated in the above paragraph
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/444317
type: AnswerComment
score: 0
type: Comment
has text: Connections are thread-safe. Sessions on down (sessions, consumers, producers) are not thread-safe. Your code needs to avoid multithreaded access. To enforce that, JMS couldn't multithread listener calls on one consumer.
comment on: http://stackoverflow.com/a/628337

http://stackoverflow.com/q/574021
accepted answer: http://stackoverflow.com/a/620893
tagged with: java
upvote count: 10
possible better answer: http://stackoverflow.com/a/574155
has answer: http://stackoverflow.com/a/574049
type: Question
has answer: http://stackoverflow.com/a/574155
downvote count: 0
has body: I'm running a memory intensive app on a machine with 16Gb of RAM, and an 8-core processor, and Java 1.6 all running on CentOS release 5.2 (Final). Exact JVM details are: java version "1.6.0_10" Java(TM) SE Runtime Environment (build 1.6.0_10-b33) Java HotSpot(TM) 64-Bit Server VM (build 11.0-b15, mixed mode) I'm launching the app with the following command line options: java -XX:+UseConcMarkSweepGC -verbose:gc -server -Xmx10g -Xms10g ... My application exposes a JSON-RPC API, and my goal is to respond to requests within 25ms. Unfortunately, I'm seeing delays up to and exceeding 1 second and it appears to be caused by garbage collection. Here are some of the longer examples: [GC 4592788K-&gt;4462162K(10468736K), 1.3606660 secs] [GC 5881547K-&gt;5768559K(10468736K), 1.2559860 secs] [GC 6045823K-&gt;5914115K(10468736K), 1.3250050 secs] Each of these garbage collection events was accompanied by a delayed API response of very similar duration to the length of the garbage collection shown (to within a few ms). Here are some typical examples (these were all produced within a few seconds): [GC 3373764K-&gt;3336654K(10468736K), 0.6677560 secs] [GC 3472974K-&gt;3427592K(10468736K), 0.5059650 secs] [GC 3563912K-&gt;3517273K(10468736K), 0.6844440 secs] [GC 3622292K-&gt;3589011K(10468736K), 0.4528480 secs] The thing is that I thought the UseConcMarkSweepGC would avoid this, or at least make it extremely rare. On the contrary, delays exceeding 100ms are occurring almost once a minute or more (although delays of over 1 second are considerably rarer, perhaps once every 10 or 15 minutes). The other thing is that I thought only a FULL GC would cause threads to be paused, yet these don't appear to be full GCs. It may be relevant to note that most of the memory is occupied by a LRU memory cache that makes use of soft references. Any assistance or advice would be greatly appreciated.
has answer: http://stackoverflow.com/a/574057
has answer: http://stackoverflow.com/a/574233
answer count: 7
has answer: http://stackoverflow.com/a/620893
has title: Reducing JVM pause time > 1 second using UseConcMarkSweepGC
score: 10
tagged with: jvm-arguments
tagged with: jvm
favorite count: 0
has answer: http://stackoverflow.com/a/574241
tagged with: garbage-collection
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/8891977
tagged with: performance

http://stackoverflow.com/a/523542
type: Answer
has comment: http://stackoverflow.com/comment/336996
has comment: http://stackoverflow.com/comment/1540740
answers question: http://stackoverflow.com/q/523531
score: 0
upvote count: 1
has comment: http://stackoverflow.com/comment/337624
downvote count: 1
has comment: http://stackoverflow.com/comment/338653
has comment: http://stackoverflow.com/comment/338029
has body: The java.lang.Math functions call the hardware functions. There should be simple appromiations you can make but they won't be as accurate. On my labtop, sin and cos takes about 144 ns.

list
type: Tag
tags question: http://stackoverflow.com/q/598796
tags question: http://stackoverflow.com/q/379551
tags question: http://stackoverflow.com/q/371839
tag name: list
tags question: http://stackoverflow.com/q/374339
tags question: http://stackoverflow.com/q/523871
tags question: http://stackoverflow.com/q/626671
tags question: http://stackoverflow.com/q/374586
tags question: http://stackoverflow.com/q/616958
tags question: http://stackoverflow.com/q/460088
tags question: http://stackoverflow.com/q/580160

http://stackoverflow.com/q/373397
tagged with: optimization
downvote count: 0
has answer: http://stackoverflow.com/a/405446
tagged with: jvm
has comment: http://stackoverflow.com/comment/15569797
favorite count: 0
has title: Taking a snapshot of optimized JVM runtime
type: Question
score: 9
has body: I know that the JVM can do some pretty serious optimizations at runtime, especially in -server mode. Of course, it takes a little while for the JVM to settle down and reach peak performance. Is there any way to take a snapshot of those optimizations so they can be applied immediately the next time you run your app? "Hey JVM! Great job optimizing my code. Could you write that down for me for later?"
tagged with: java
answer count: 2
linked to: http://stackoverflow.com/q/11652499
upvote count: 9
has comment: http://stackoverflow.com/comment/202976
has answer: http://stackoverflow.com/a/374204
type: UnansweredQuestion

http://stackoverflow.com/q/566275
has body: I'm noticing some weird behavior using standard logging during JUnit tests. Does JUnit redirect standard output to a different stream? How can I get access to that? Here's a simple JUnit test that demonstrates the behavior I'm describing. @Test public void logMessage() { // set up new logger with output directed to standard out Logger logger = Logger.getLogger("my.test.logger"); logger.addHandler(new StreamHandler(System.out, new SimpleFormatter())); // log a warning message logger.warning("logger message"); // message 1 // turn off parent handlers logger.setUseParentHandlers(false); // log a second warning message logger.warning("second logger message"); // message 2 // print somehting to standard output System.out.println("standard output message"); //message 3 } Notice that I've created a new logger that simply sends its log messages to standard output (System.out). Here's the Junit output Testsuite: com.my.FormatterTest Feb 19, 2009 12:02:33 PM com.my.FormatterTest logMessage WARNING: logger message standard output message Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.079 sec ------------- Standard Output --------------- standard output message ------------- ---------------- --------------- ------------- Standard Error ----------------- Feb 19, 2009 12:02:33 PM com.my.FormatterTest logMessage WARNING: logger message ------------- ---------------- --------------- Feb 19, 2009 12:02:33 PM com.my.FormatterTest logMessage WARNING: logger message Feb 19, 2009 12:02:33 PM com.my.FormatterTest logMessage WARNING: second logger message test: BUILD SUCCESSFUL (total time: 2 seconds) Why don't message 1 or message 2 show up in the Standard Output portion of the JUnit output? Thanks!
has title: Weird JUnit logging behavior
tagged with: logging
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/566364
has answer: http://stackoverflow.com/a/570644
upvote count: 4
answer count: 2
tagged with: junit
possible better answer: http://stackoverflow.com/a/566364
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/570644
score: 4
type: AnsweredQuestion

http://stackoverflow.com/q/512304
has answer: http://stackoverflow.com/a/512938
has title: How to avoid the form being submitted after displaying alert?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/512318
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/512340
type: Question
has answer: http://stackoverflow.com/a/512340
tagged with: javascript
favorite count: 0
answer count: 3
upvote count: 1
accepted answer: http://stackoverflow.com/a/512318
tagged with: jsf
downvote count: 0
has body: If the user name and password do not match it displays an alert but if I click ok to the alert the form is logged in. Can anyone tell me how to avoid it? Thanks. <f:view> Insert title here <h:form id="loginForm"> Login page <h:panelGrid columns="2"> <h:outputLabel value="UserName"></h:outputLabel> <h:inputText id="name" value="#{user.name}"> </h:inputText> <h:outputLabel value="Password"></h:outputLabel> <h:inputSecret id="password" value="#{user.password}"></h:inputSecret> </h:panelGrid> <h:commandButton type="button" value="Login" action="logged" onclick="checkPassword(this.form)"></h:commandButton> </h:form> </f:view>

http://stackoverflow.com/comment/452679
has text: Do you mean, remove quotes when they are escaped?
comment on: http://stackoverflow.com/q/639264
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/350533
comment on: http://stackoverflow.com/a/537957
type: AnswerComment
has text: Depending on the likely values you will be retrieving it may be more efficient to sort the map by a function of the integers (such as sum), and search between the lowest and highest possible value.
score: 0
type: Comment

http://stackoverflow.com/a/2868646
type: Answer
has body: It would help to know exactly what repeated queries that you're seeing. As others pointed out, we're just speculating without seeing your mappings. You might be running into Hibernate's eager fetching. This is where Hibernate tries to load an entire object graph for every User (and their Addresses, Phones, Pets, etc.) matching the very general name contains 'tom' query. Try turning off default eager fetching for User properties in your Hibernate mapping files or annotations and then do the following: Let's say you're getting lots of repeated queries looking into the tables USER_ADDRESS (hibernate property "addresses"), USER_PHONE (property "phones"), and USER_PET (property "pets"). Use the following criteria calls to join these attributes in the original query and reduce repeated queries. Hibernate knows how to break these columns apart into separate objects. You can also try adding a maximum number of returned results. Criteria myUsers = getCurrentSession().createCriteria(User.class); myUsers = myUsers.add(Restrictions.ilike("name", "tom", MatchMode.ANYWHERE)); myUsers.createCriteria("addresses"); // NEW myUsers.createCriteria("phones"); // NEW myUsers.createCriteria("pets"); // NEW myUsers.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); myUsers.setMaxResults(100); // NEW result.addAll(myUsers.list()); You can learn more in sections 15.4-15.6 here
answers question: http://stackoverflow.com/q/362252
score: 0

http://stackoverflow.com/comment/7194711
score: 0
type: Comment
type: QuestionComment
has text: @finnw, If you want interoperability rather than performance, why don't use just use the built in ByteBuffer. Can you to tell me again, what you need which the built in ByteBuffer doesn't do already?
comment on: http://stackoverflow.com/q/624458

http://stackoverflow.com/comment/125147737
type: Comment
score: 1
comment on: http://stackoverflow.com/a/9609015
has text: I know this is old but there is no point in using PowerMock when you can just call `SecurityContextHolder.setContext()` or `.setStrategyName(className)` to achieve the same thing.
type: AnswerComment

http://stackoverflow.com/a/477953
has body: What about profiling this native code outside of the Java application? Usually the JNI code is a wrapper around some library that is not Java specific. Not sure if that is true for your specific case, but if it is then maybe the memory problems can be isolated by writing a plain C or C++ test framework around that library? If your framework is in C++ then you might also be able to supply your own new and delete operators and track memory usage yourself. You'll have to collect statistics and process them with some scripts but it can work well.
score: 1
answers question: http://stackoverflow.com/q/451282
downvote count: 0
type: Answer
upvote count: 1

http://stackoverflow.com/comment/430713
score: 0
type: AnswerComment
has text: @juggler555: Thanks, that works, provided the component is *not* opaque (when I left it opaque, text updates "scribbled" over the top of the previous).
type: Comment
comment on: http://stackoverflow.com/a/615748

http://stackoverflow.com/q/581821
has answer: http://stackoverflow.com/a/581863
score: 2
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/593872
upvote count: 2
tagged with: domain-driven-design
possible better answer: http://stackoverflow.com/a/593872
accepted answer: http://stackoverflow.com/a/581863
type: AnsweredQuestion
tagged with: java
type: Question
has title: What are the best practices when batch exporting from an application following DDD
tagged with: .net
tagged with: export
has body: Let's say you have a database with a lot of products/customers/orders and the codebase (java/c#) contains all the business logic. During the night several batches are needed to export data to flat files and then ftp them to a proprietary system. How should we do this "write-database-into-a-flat-file? What are the best-practices? Some thoughts: we could create a stored procedure and use f.ex ssis to fetch the data? Maybe we can do this if we have a "batch-output-database-table" but not if we have to do logic before the file is written? we could do all the logic in managed code using the same repositories / business logic as the rest of the domain? (this could be a slow process compared to the stored procedure solution) What if the only interface for the domain-services are web services (which could take "long" time for each request), will the "best practices" change ?
answer count: 2

http://stackoverflow.com/q/409932
has answer: http://stackoverflow.com/a/409993
has answer: http://stackoverflow.com/a/66558216
type: AnsweredQuestion
tagged with: java
has body: I have code where I schedule a task using java.util.Timer. I was looking around and saw ExecutorService can do the same. So this question here, have you used Timer and ExecutorService to schedule tasks, what is the benefit of one using over another? Also wanted to check if anyone had used the Timer class and ran into any issues which the ExecutorService solved for them.
score: 312
type: Question
tagged with: scheduling
upvote count: 312
downvote count: 0
possible better answer: http://stackoverflow.com/a/410220
answer count: 6
accepted answer: http://stackoverflow.com/a/409993
has answer: http://stackoverflow.com/a/410220
has answer: http://stackoverflow.com/a/40317753
tagged with: executorservice
tagged with: scheduled-tasks
favorite count: 0
has title: Java Timer vs ExecutorService?
tagged with: timer
has answer: http://stackoverflow.com/a/29594520
has answer: http://stackoverflow.com/a/409966
has comment: http://stackoverflow.com/comment/24905632

http://stackoverflow.com/comment/412260
score: 0
type: Comment
type: QuestionComment
has text: Read some code from other people to see how they do it.
comment on: http://stackoverflow.com/q/589603

http://stackoverflow.com/comment/2089612
type: Comment
score: 1
comment on: http://stackoverflow.com/a/627973
has text: This answer implies that "coding to interfaces" means that every class must implement a separate interface. This isn't what the principle, as described in the GoF book, means. In reality, it only applies for cases where you need, or already have, two separate object types, one for the abstraction (interface) and another for one implementation of that abstraction.
type: AnswerComment

http://stackoverflow.com/comment/61118132
comment on: http://stackoverflow.com/a/647140
type: AnswerComment
score: 0
has text: Is there any way to prevent from my code to be decompiled ? If I store sensitive information inside the CLASS files
type: Comment

http://stackoverflow.com/a/38675063
type: Answer
upvote count: 3
downvote count: 1
answers question: http://stackoverflow.com/q/525212
score: 2
has body: The ZT Process Executor library is an alternative to Apache Commons Exec. It has functionality to run commands, capturing their output, setting timeouts, etc. I have not used it yet, but it looks reasonably well-documented. An example from the documentation: Executing a command, pumping the stderr to a logger, returning the output as UTF8 string. String output = new ProcessExecutor().command("java", "-version") .redirectError(Slf4jStream.of(getClass()).asInfo()) .readOutput(true).execute() .outputUTF8(); Its documentation lists the following advantages over Commons Exec: Improved handling of streams Reading/writing to streams Redirecting stderr to stdout Improved handling of timeouts Improved checking of exit codes Improved API One liners for quite complex use cases One liners to get process output into a String Access to the Process object available Support for async processes ( Future ) Improved logging with SLF4J API Support for multiple processes

http://stackoverflow.com/comment/409444
has text: Thanks for your feedback. I generally provide enough detail so that experts in the area should be able to piece it together or ask for more detail. The jab on my communication skills was a bit uncalled for, but +1 for highlighting the need for more detail.
comment on: http://stackoverflow.com/a/595991
type: AnswerComment
type: Comment
score: 0

http://stackoverflow.com/comment/39554575
type: AnswerComment
comment on: http://stackoverflow.com/a/541506
type: Comment
has text: @m0skit0 the point of the code by user949300 is that it uses a conditional to only enable multi-threading when there are enough physical core
score: 1

http://stackoverflow.com/comment/77925160
score: 1
comment on: http://stackoverflow.com/a/30048656
type: AnswerComment
type: Comment
has text: @JingHe - if you would end up reading byte per byte - like I usually do -, you can write those individual bytes either to a fixed size buffer (e.g. `byte[] buffer = new byte[1024]`), but I personally like the following construction better: `buffer = new ByteArrayOutputStream(); buffer.write(byte);`. A `ByteArrayOutputStream` acts like a flexible buffer (it auto resizes).

http://stackoverflow.com/a/445152
answers question: http://stackoverflow.com/q/445070
score: 2
upvote count: 2
type: Answer
has body: I'm no game developer, but that framerate seems very slow. I'm not quite sure how your code is working, but one possibility for improving rendering performance would be to find those parts of the display that don't change much (such as the walls of the maze) and avoid re-creating them for each frame. Create a BufferedImage containing the constant elements (maze?, background) and then re-draw it first for each frame. On top of this Buffered image, draw the variable elements (PacMan, ghosts, dots, etc). This technique, along with many other Java2D performance tips, is discussed in Romain Guy's excellent book Filthy Rich Clients.
downvote count: 0

http://stackoverflow.com/a/592805
downvote count: 0
upvote count: 122
has comment: http://stackoverflow.com/comment/34429402
type: Answer
answers question: http://stackoverflow.com/q/591172
has comment: http://stackoverflow.com/comment/91899641
has body: In the future, if you need to quickly find a keyboard shortcut for something simple, just hit Ctrl+Shift+L.
score: 122

http://stackoverflow.com/a/520011
has comment: http://stackoverflow.com/comment/333513
has comment: http://stackoverflow.com/comment/333433
type: Answer
has comment: http://stackoverflow.com/comment/334120
score: 11
has comment: http://stackoverflow.com/comment/334089
has comment: http://stackoverflow.com/comment/334074
upvote count: 11
has comment: http://stackoverflow.com/comment/2617816
accepted answer of: http://stackoverflow.com/q/519914
answers question: http://stackoverflow.com/q/519914
has comment: http://stackoverflow.com/comment/336164
has body: I agree with Jon and Kent but, like Scott Myers (in Effective C++), I go much further. I believe that every class should be either abstract, or final. That is, only leaf classes in any hierarchy are really apt for direct instantiation. All other classes (i.e. inner nodes in the inheritance) are “unfinished” and should consequently be abstract. It simply makes no sense for usual classes to be further extended. If an aspect of the class is worth extending and/or modifying, the cleaner way would be to take that one class and separate it into one abstract base class and one concrete interchangeable implementation.
has comment: http://stackoverflow.com/comment/126277758
has comment: http://stackoverflow.com/comment/126279819
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/333437
downvote count: 0

http://stackoverflow.com/a/627437
downvote count: 0
type: Answer
upvote count: 14
has body: From JDK6 you should be able to get extra information by setting the sun.io.serialization.extendedDebugInfo system property: -Dsun.io.serialization.extendedDebugInfo=true
answers question: http://stackoverflow.com/q/627389
score: 14
has comment: http://stackoverflow.com/comment/44912740
has comment: http://stackoverflow.com/comment/44909714

http://stackoverflow.com/a/62184254
has body: Your one-hour-off problem is indeed likely due to time zone adjustment being applied. I am guessing you were (a) exchanging strings rather than objects with the database, (b) using the terrible legacy date-time classes, or (c) are using tools or middleware that are lying to you about the values retrieved from the database because of the well-intentioned by confusing anti-feature of applying a default time zone after retrieval from the database and before displaying/reporting to you. java.time The solution is to always use the modern java.time classes, and use a JDBC driver compliant with JDBC 4.2 or later. Capture the current moment in UTC. Instant instant = Instant.now() ; Your JDBC driver may or may not support Instant. The JDBC 4.2 spec inexplicably requires support for OffsetDateTime but not the two more commonly used types Instant &amp; ZonedDateTime. No problem, as we can easily convert. OffsetDateTime odt = instant.atOffset( ZoneOffset.UTC ) ; This OffsetDateTime is still in UTC (an offset of zero hours-minutes-seconds) because we specified the ZoneOffset.UTC constant. Save to database. myPreparedStatement.setObject( … , odt ) ; Retrieval. OffsetDateTime odt = myResultSet.getObject( … , OffsetDateTime.class ) ; Adjust to a time zone for presentation to the user. ZoneId z = ZoneId.of( "Africa/Tunis" ) ; ZonedDateTime zdt = odt.atZoneSameInstant​( z ) ; Generate output for user-interface, automatically localized. Locale locale = Locale.JAPAN ; // Specify a `Locale` to determine DateTimeFormatter f = DateTimeFormatter.ofLocalizedDateTime( FormatStyle.LONG ).withLocale( locale ) ; String output = zdt.format( f ) ; Notice that in none of this code did we use a String as a date-time value. If you exchange these smart objects rather than dumb strings with your database, you will have no injection of time zone adjustments. About java.time The java.time framework is built into Java 8 and later. These classes supplant the troublesome old legacy date-time classes such a…
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/477965
downvote count: 0
type: Answer

http://stackoverflow.com/comment/383951
comment on: http://stackoverflow.com/q/571910
score: 0
type: Comment
type: QuestionComment
has text: Hence the scientific papers quoted in my answer :)

http://stackoverflow.com/comment/402142
has text: The newInstance(T.class) was a copy & paste which I didn't see. Still the question seems to be about how to write a generic method.
type: Comment
comment on: http://stackoverflow.com/a/590418
score: 0
type: AnswerComment

http://stackoverflow.com/a/538353
upvote count: 1
has body: I would suggest you not share project files between users. If you take a copy of their project files, just keep this as a local copy.
downvote count: 0
answers question: http://stackoverflow.com/q/534494
type: Answer
score: 1

http://stackoverflow.com/q/535004
has answer: http://stackoverflow.com/a/535013
downvote count: 0
has answer: http://stackoverflow.com/a/535018
tagged with: java
tagged with: java-time
tagged with: date
has answer: http://stackoverflow.com/a/29268825
type: Question
has answer: http://stackoverflow.com/a/535017
accepted answer: http://stackoverflow.com/a/535017
possible better answer: http://stackoverflow.com/a/535026
has answer: http://stackoverflow.com/a/535026
has body: I have a string containing the UNIX Epoch time, and I need to convert it to a Java Date object. String date = "1081157732"; DateFormat df = new SimpleDateFormat(""); // This line try { Date expiry = df.parse(date); } catch (ParseException ex) { ex.getStackTrace(); } The marked line is where I'm having trouble. I can't work out what the argument to SimpleDateFormat() should be, or even if I should be using SimpleDateFormat().
answer count: 6
has answer: http://stackoverflow.com/a/34444188
has title: Unix epoch time to Java Date object
score: 108
has comment: http://stackoverflow.com/comment/105397750
favorite count: 0
linked to: http://stackoverflow.com/q/20367546
has comment: http://stackoverflow.com/comment/30491317
type: AnsweredQuestion
upvote count: 108

http://stackoverflow.com/a/627947
accepted answer of: http://stackoverflow.com/q/627868
has comment: http://stackoverflow.com/comment/440710
answers question: http://stackoverflow.com/q/627868
upvote count: 3
score: 3
has comment: http://stackoverflow.com/comment/440697
has body: You need to be very careful with this. There are some things, like declaring constants like this: public static final int FOO = 1; that the depends on task (and javac itself) don't always pick up on (I am not 100% certain that the one above messes with Ant, but I know some things do). I did use the depend task a long time ago and quickly removed it as I kept needed to do full builds to ensure that things were sane.
has comment: http://stackoverflow.com/comment/440949
type: AcceptedAnswer
downvote count: 0
type: Answer

http://stackoverflow.com/comment/767026
has text: Rod Waldhoff apologized for having developed Commons Logging: http://radio.weblogs.com/0122027/2003/08/15.html SLF4J is a wonderfull alternative.
comment on: http://stackoverflow.com/a/607886
type: AnswerComment
score: 2
type: Comment

http://stackoverflow.com/q/427837
has answer: http://stackoverflow.com/a/2357538
favorite count: 0
possible better answer: http://stackoverflow.com/a/429284
answer count: 4
type: AnsweredQuestion
downvote count: 0
has body: I have a problem with my web module classpath in Websphere v6.1. In my WEB-INF/lib I have a largish number of jar files which include xercesImpl.jar and xmlparserv2.jar. I need both jars to be present, but they appear to confict with each other. Specifically, each jar contains a META-INF/services directory so, when we try to get an instance of a DocumentBuilderFactory via JAXP, which instance we get depends upon the order in which these two jars appear in the classpath. I always want to use the xerces instance of the DocumentBuildFactory, so I want to push xercesImpl.jar to the front of the classpath. I've tried to do this by specifying a Class-Path section in the Manifest file for the war file, but the class path that I actually get in my WAS Module Compound CLass Loader in is very strange. I seem to get some standard stuff that WAS puts on, followed by the contents of WEB-INF lib in alphabetical order, followed by the classpath specified by the Manifest file. If I don't put a manifest file into the war at all, I get the standard stuff followed by the contents of WEB-INF/lib but in an arbitrary order. What am I missing? Is there a way in which I can set the class path up to be exactly what I want? Dave
score: 7
tagged with: java
has answer: http://stackoverflow.com/a/1706812
type: Question
accepted answer: http://stackoverflow.com/a/429192
has title: How do I manage the ClassPath in WebSphere
has answer: http://stackoverflow.com/a/429284
has answer: http://stackoverflow.com/a/429192
tagged with: websphere
upvote count: 7

http://stackoverflow.com/a/591314
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/403067
answers question: http://stackoverflow.com/q/591291
downvote count: 0
type: Answer
has body: The first obvious thing to always say is: Confine usage of Swing components to the AWT Event Dispatch Thread (EDT). public class GraphicTest { public static void main(final String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { runEDT(); } }); } private static void runEDT() { assert java.awt.EventQueue.isDispatchThread(); JFrame frame = new JFrame("GraphicTest"); ... I don't know why memory size would be important. Perhaps it affects the timings in someway. Perhaps the JVM decides it is running on a server-class machine and runs with more aggressive optimisation.

http://stackoverflow.com/comment/40724137
has text: `URLEncoder.encode("+", "UTF-8");` yields `"%2B"`, which is the proper URL encoding, so your solution is, my apologies, totally unnecessary. Why on earth `URLEncoder.encode` doesn't turn spaces into `%20` is beyond me.
type: Comment
comment on: http://stackoverflow.com/a/10032289
score: 1
type: AnswerComment

http://stackoverflow.com/comment/339010
has text: I like Java's anonymous classes... nice for visitors for example.
comment on: http://stackoverflow.com/q/525711
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/24853220
has text: still, I'd argue that a constructor `new File(String... pathElements)` would be cleaner, possible with an added `new File(File basepath, String... pathElements)`
comment on: http://stackoverflow.com/a/412495
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/a/541788
has body: Any use of any of the methods suggested is considered a code smell which is based in a bad OO design. If your design is good, you should not find yourself needing to use getClass() or instanceof. Any of the suggested methods will do, but just something to keep in mind, design-wise.
has comment: http://stackoverflow.com/comment/355068
has comment: http://stackoverflow.com/comment/14689040
score: 23
has comment: http://stackoverflow.com/comment/58151592
has comment: http://stackoverflow.com/comment/353908
has comment: http://stackoverflow.com/comment/33065071
has comment: http://stackoverflow.com/comment/27978544
has comment: http://stackoverflow.com/comment/353858
has comment: http://stackoverflow.com/comment/98304390
downvote count: 26
upvote count: 49
has comment: http://stackoverflow.com/comment/33833965
has comment: http://stackoverflow.com/comment/120322760
answers question: http://stackoverflow.com/q/541749
has comment: http://stackoverflow.com/comment/58633462
type: Answer
has comment: http://stackoverflow.com/comment/353878

http://stackoverflow.com/comment/48265965
type: Comment
comment on: http://stackoverflow.com/a/381043
score: 0
type: AnswerComment
has text: @PopCatalin there are obvious patterns and correlations in such raw measurements. That's why they apply a 'whitening phase'. (Randomness Extractor on wikipedia)

http://stackoverflow.com/comment/529248
type: AnswerComment
comment on: http://stackoverflow.com/a/717185
type: Comment
has text: Most OS'es have a minimum size for the buffer size so setting such small values won't do what you think it will. I would suggest trying 64*1024 or larger.
score: 0

http://stackoverflow.com/comment/8124925
type: Comment
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/565290
has text: No you can just keep the setter **private ** anyway. Immutability is an other topic, by definition imuttable is when you can't change it's value after created like String for example. So this in your example it's a bug Look at C# or language supoorting properties.

http://stackoverflow.com/q/600834
tagged with: eclipse
answer count: 1
tagged with: eclipse-rcp
has title: In Eclipse plugins, is there a programmatic equivalence to the markerAnnotationSpecification extension point?
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/608026
tagged with: editor
tagged with: java
score: 0
tagged with: eclipse-pde
type: Question
has body: The extension point org.eclipse.ui.editors.markerAnnotationSpecification is used to change how certain user-defined text annotations appear in the editor. Is there a way to create or modify or override these programatically from a plugin?

http://stackoverflow.com/a/619539
answers question: http://stackoverflow.com/q/618844
has body: I have used an approach like the one you're suggesting ( log to a db ) in the past and it has been very helpful. Not only you cat get the error via SQL but you can also generate reports of what's the most recurring errors and attend them first. On the design we did, equals stacktraces belong to the same records ( since they were originated exactly in the same place ) We had an small app that pooled that db and we knew then a new exception was generated instead of getting an e-mail that summed with the rest of the previous weeks were ignored altogether. Of course this database design was very specific for the application we had and additional identifications were possible, we had software version, build, some times input parameters , etc. etc. With time, the system administrators get to know what to do with each kind of exception and proceed accordingly. But! Your application may not be that big anyway. Probably you can have the same just parsing the log files.
score: 1
upvote count: 1
type: Answer
downvote count: 0

http://stackoverflow.com/q/614297
downvote count: 0
score: 4
tagged with: user-interface
has body: I have an editor pane which displays an HTML file. When I ask it to do it once, it displays the HTML file fine. I then make changes to my HTML file and use the setPage method so that it prints the updated HTML file but it doesn't do this even though the HTML file is changed. Is this a problem with the Editor pane or is there something wrong with my code?
favorite count: 0
tagged with: jeditorpane
type: UnansweredQuestion
has title: Using JEditorPane and its setPage method
has answer: http://stackoverflow.com/a/615790
tagged with: java
type: Question
upvote count: 4
answer count: 2
has answer: http://stackoverflow.com/a/614380

http://stackoverflow.com/a/577970
score: 0
has body: Have you run your app through a profiler to see that what you think is happening with respect to memeory is what is actually happening? One thing I do when I am looking into this is use the Netbeans profiler (though any profiler should give this to you) is look at the live bytes (the memory allocation) and see if the ones that have a large amount of allocated bytes and allocated objectd are what I am expecting and are coming from where I expect. You can also probably use the profiler to look at the effect your tuning is having, run the app without any tuing args, and then add your tuning args and run it again and see what is going on with the memory.
type: Answer
answers question: http://stackoverflow.com/q/577773

http://stackoverflow.com/comment/338649
type: AnswerComment
has text: "Task bar may be on any edge of the screen" -- that's my taskbar you're talking about (at the right of the screen). Too many applications *forced* me to move it to the left (arghh!), and still some don't work correctly.
type: Comment
comment on: http://stackoverflow.com/a/525434
score: 0

http://stackoverflow.com/comment/396979
type: AnswerComment
has text: Why would you ever want to replace a method for testing? I want to test the method not the replacement!
comment on: http://stackoverflow.com/a/585042
score: 0
type: Comment

http://stackoverflow.com/comment/191829
comment on: http://stackoverflow.com/a/361308
type: AnswerComment
score: 0
type: Comment
has text: To frame the question I had to cut out a lot of code and actually move stuff around. The actual code does implement a Visitor pattern like you recommend. The type is actually being passed into a Castor method so that it knows how to unmarshal to a Java object.

http://stackoverflow.com/comment/433851
comment on: http://stackoverflow.com/q/620934
has text: Just out of curiosity, what what the programming language you use before java?
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/382442
has body: I'm in the same spot you are... My plan was to pull the SQL into separate.sql files within the project and create a utility method to read the file in when I need the query. string sql = "select asd,asdf,ads,asdf,asdf," + "from asdfj asfj as fasdkfjl asf" + "..........................." + "where user = @user and ........"; The query gets dumped into a file called usageReportByUser.sql and the becomes something like this. string sql = util.queries("usageReportByUser"); Make sure it's done in a way that the files are not publicly accessible.
answers question: http://stackoverflow.com/q/382361
type: Answer
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/210084
upvote count: 2

http://stackoverflow.com/a/457913
type: Answer
answers question: http://stackoverflow.com/q/457696
score: 0
has body: If you want to evaluate Excel formulae, frankly Excel is the only reliable way to do this. So running Excel via a COM bridge is the way to go. I've done this before in Java using JACOB and that works very nicely. Excel looks after all the functionality. You just have to populate your spreadsheet (in memory) and let Excel do the rest.

http://stackoverflow.com/q/498534
has title: Asynchronous processing in Java from a servlet
upvote count: 5
tagged with: java
tagged with: quartz-scheduler
type: Question
answer count: 2
score: 5
downvote count: 0
tagged with: tomcat
has answer: http://stackoverflow.com/a/498550
tagged with: jms
tagged with: asynchronous
favorite count: 0
has body: I currently have a tomcat container -- servlet running on it listening for requests. I need the result of an HTTP request to be a submission to a job queue which will then be processed asynchronously. I want each "job" to be persisted in a row in a DB for tracking and for recovery in case of failure. I've been doing a lot of reading. Here are my options (note I have to use open-source stuff for everything). 1) JMS -- use ActiveMQ (but who is the consumer of the job in this case another servlet?) 2) Have my request create a row in the DB. Have a seperate servlet inside my Tomcat container that always runs -- it Uses Quartz Scheduler or utilities provided in java.util.concurrent to continously process the rows as jobs (uses thread pooling). I am leaning towards the latter because looking at the JMS documentation gives me a headache and while I know its a more robust solution I need to implement this relatively quickly. I'm not anticipating huge amounts of load in the early days of deploying this server in any case. A lot of people say Spring might be good for either 1 or 2. However I've never used Spring and I wouldn't even know how to start using it to solve this problem. Any pointers on how to dive in without having to re-write my entire project would be useful. Otherwise if you could weigh in on option 1 or 2 that would also be useful. Clarification: The asynchronous process would be to screen scrape a third-party web site, and send a message notification to the original requester. The third-party web site is a bit flaky and slow and thats why it will be handled as an asynchronous process (several retry attempts built in). I will also be pulling files from that site and storing them in S3.
possible better answer: http://stackoverflow.com/a/498552
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/498550
has answer: http://stackoverflow.com/a/498552

http://stackoverflow.com/a/607286
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/607106
downvote count: 0
type: Answer
has body: I've once done something that sounds similar to your goal by using JRuby on top of Java. The core part was in Java and would be always running, and the Ruby scripts were loaded dynamically using JRuby. That way, I could add functionality without restarting (or compiling) the Java part.

http://stackoverflow.com/a/9043937
score: 5
downvote count: 0
has body: Yes, If you call ThreadA call , then not need to call the start method and run method is call after call the ThreadA class only. But If use the ThreadB call then need to necessary the start thread for call run method. If you have any more help, reply me.
type: Answer
answers question: http://stackoverflow.com/q/541487
upvote count: 5

http://stackoverflow.com/comment/424669
has text: There is a pure perl XML parsing library, but nobody who cares about speed uses it. Most perl XML parsing involves expat or libxml2 under the hood which is fast.
comment on: http://stackoverflow.com/a/611856
score: 1
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/9619034
type: Comment
comment on: http://stackoverflow.com/a/834038
has text: do you have any more details about this?
score: 2
type: AnswerComment

http://stackoverflow.com/a/594498
downvote count: 0
upvote count: 2
type: Answer
score: 2
has body: As I understand it, you're proposing using echo to write files like web.xml. It might be better to have your Ant script invoke a templating engine, such as Apache Velocity. Texen can be used to generate arbitrary text.
answers question: http://stackoverflow.com/q/594392

http://stackoverflow.com/a/382906
has comment: http://stackoverflow.com/comment/215535
downvote count: 0
answers question: http://stackoverflow.com/q/382886
type: Answer
has body: CheckStyle is another and FREE. CheckStyle:Indentation.
has comment: http://stackoverflow.com/comment/211599
upvote count: 1
score: 1

http://stackoverflow.com/a/605709
downvote count: 0
upvote count: 11
accepted answer of: http://stackoverflow.com/q/605592
answers question: http://stackoverflow.com/q/605592
type: AcceptedAnswer
type: Answer
has body: The short answer is no. Java doesn't allow you any control over what is swapped in and what is 'pinned' into RAM. Worrying about this sort of thing is usually a sign that there is something else wrong in your project. The OS will on the whole do a much better job of working out what should be swapped and what shouldn't. Your job is to write your software such that it doesn't try to second guess what underlying VM/OS is going to do, just concentrate on delivering your features and a good design.
score: 11

http://stackoverflow.com/a/737904
has body: in Pacman all of the ghost had a different chasing algorithm Blinky -> Chases. Will usually take the shortest route to you, and tends to follow. Pinky -> Ambushes. Tends to take a more roundabout way to pac-man. Deadly. (pinky and blinky tend to make different choice when choosing a direction , often caging the player in a corner) Inky -> Freak. This dude acts strangely. He moves about the board fairly randomly, but sometimes chases when he gets in close. Clyde -> Idiot. Moves randomly. Not much of a threat. The ghosts have an interesting pattern programmed into their movements: occasionally, they will simultaneously cease and desist their pursuit of Pac-Man and return to their respective corners of the maze, entering "scatter mode". there is a full description of the algo at the pacman dossier regards Guillaume
downvote count: 0
score: 1
type: Answer
answers question: http://stackoverflow.com/q/623095
upvote count: 1

http://stackoverflow.com/a/625342
score: 0
answers question: http://stackoverflow.com/q/625302
type: Answer
has body: is Jogle jar file in your classpath ? I see you have included the jars themselves in your jar... this unfortunately wil not work out of the box. Either get the jars out then place in your classpath (that can be part of your manifest also) or write your own classloader... http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html This is why it worked for William and not for you... he got the jogl from somewhere else and did not use the one within your jar.

subclipse
type: Tag
tags question: http://stackoverflow.com/q/589021
tag name: subclipse

http://stackoverflow.com/comment/348473
type: Comment
comment on: http://stackoverflow.com/a/535514
score: 0
type: AnswerComment
has text: He should update anyway, it seems like he's using the beta of _06.

http://stackoverflow.com/a/615560
downvote count: 0
has body: The default way class loaders work is to defer to the parent before attempting to lookup their own resources. So if a parent class loader has any manifest available, that's what you'll get. In fact, app servers don't necessarily do this, to allow applications to override versions of libraries. Further, class loaders can have multiple jars and hence multiple manifests. It may be able to get a resource URL of one of your uniquely named resource. Open a connection. Cast to JarURLConnection. Get the JarFile. Load the manifest from that. That may not work, particularly if Tomcat explodes the war. [Update] Of course, the war file itself isn't on the classpath. The classpath will have something like WEB-INF/lib/(.jar|.zip) and WEB-INF/classes/. Getting a resource from the ServletContext should work. Best solution: Do something different. :)
type: Answer
answers question: http://stackoverflow.com/q/615493
upvote count: 2
score: 2

http://stackoverflow.com/q/380406
tagged with: java
duplicate of: http://stackoverflow.com/q/2883181
has title: Why does Java code with an inner class generates a third SomeClass$1.class file?
score: 17
upvote count: 18
type: Question
has answer: http://stackoverflow.com/a/380468
answer count: 3
possible better answer: http://stackoverflow.com/a/2654699
has body: If I have an inner class, like this: public class Test { public class Inner { // code ... } public static void main(String[] args) { // code ... } } When I compile it, I expect it should generate two files: Test.class Test$Inner.class So why do I sometimes see classfiles like SomeClass$1.class, even though SomeClass does not contain an inner class called "1"?
has answer: http://stackoverflow.com/a/2654699
favorite count: 0
has answer: http://stackoverflow.com/a/380418
downvote count: 1
linked to: http://stackoverflow.com/q/2883181
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/208083
accepted answer: http://stackoverflow.com/a/380418

http://stackoverflow.com/comment/224402
score: 0
has text: Maybe you should report this as a bug to FindBugs folks?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/398179

http://stackoverflow.com/a/571923
type: Answer
score: 24
upvote count: 24
answers question: http://stackoverflow.com/q/571910
has body: Java EE is considered scalable because if you consider the EJB architecture and run on an appropriate application server, it includes facilities to transparently cluster and allow the use of multiple instances of the EJB to serve requests. If you managed things manually in plain-old-java, you would have to figure out all of this yourself, for example by opening ports, synchronizing states, etc. I am not sure you could define Google as a "large website". That would be like likening the internet to your office LAN. Java EE was not meant to scale to the global level, which is why sites like Amazon and Google use their own technologies (e.g., with use of MapReduce). There are many papers discussing the efficiency of Java EE scalability. For example this
downvote count: 0
has comment: http://stackoverflow.com/comment/95150415
has comment: http://stackoverflow.com/comment/5770733
has comment: http://stackoverflow.com/comment/5770782

http://stackoverflow.com/comment/28914947
type: Comment
score: 3
has text: "global variables" are not evil. They are there to be inherited. You can override the setting in your command line "local" version with no problems. More to the point this "global variable" as you term it is important for running java apps you might have installed via synaptic/aptitude/apt-get. Want localised versions? Use them.
comment on: http://stackoverflow.com/a/580901
type: AnswerComment

apache
tags question: http://stackoverflow.com/q/605408
tag name: apache
tags question: http://stackoverflow.com/q/547219
tags question: http://stackoverflow.com/q/359970
tags question: http://stackoverflow.com/q/478985
tags question: http://stackoverflow.com/q/430787
tags question: http://stackoverflow.com/q/535821
type: Tag
tags question: http://stackoverflow.com/q/617644
tags question: http://stackoverflow.com/q/605127
tags question: http://stackoverflow.com/q/477012

http://stackoverflow.com/q/612121
possible better answer: http://stackoverflow.com/a/612139
tagged with: java
has answer: http://stackoverflow.com/a/612139
has answer: http://stackoverflow.com/a/612577
type: Question
has answer: http://stackoverflow.com/a/612151
score: 2
downvote count: 0
tagged with: url
accepted answer: http://stackoverflow.com/a/612151
tagged with: security
answer count: 3
has title: What's the best way to secure a query string with Java?
favorite count: 0
upvote count: 2
has body: When a user signs up in our Struts application, we want to send them an email that includes a link to a different page. The link needs to include a unique identifier in its query string so the destination page can identify the user and react accordingly. To improve the security of this system, I'd like to first encrypt the query string containing the identifier and second set the link to expire--after it's been used and/or after a few days. What Java technologies/methods would you suggest I use to do this?
tagged with: encryption
type: AnsweredQuestion

http://stackoverflow.com/q/629315
upvote count: 24
type: Question
has answer: http://stackoverflow.com/a/629333
answer count: 6
has answer: http://stackoverflow.com/a/630030
has title: Dynamically refresh JTextArea as processing occurs?
downvote count: 0
has answer: http://stackoverflow.com/a/629439
accepted answer: http://stackoverflow.com/a/630030
favorite count: 0
possible better answer: http://stackoverflow.com/a/1581744
tagged with: multithreading
has answer: http://stackoverflow.com/a/1581744
tagged with: swing
has body: I am trying to create a very simple Swing UI that logs information onto the screen via a JTextArea as processing occurs in the background. When the user clicks a button, I want each call to: textArea.append(someString + "\n"); to immediately show up in the UI. At the moment, the JTextArea does not show all log information until the processing has completed after clicking the button. How can I get it to refresh dynamically?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/629317
has answer: http://stackoverflow.com/a/16815293
tagged with: java
score: 24

http://stackoverflow.com/a/642720
type: Answer
answers question: http://stackoverflow.com/q/642532
has body: I can tell by your ampersands that you are thinking in C. We don't really use pointers to functions in java. Generally, you would not use java reflection for this. As one of the other posters said - you would create an interface, and have objects that implemented that interface - either by directly implementing it, or with an adapter or anonymous class: interface Callable { void callme(); } Callable[] foo = new Callable[] { new Callable() { public void callme() {System.out.println("foo!");}}, new Callable() { public void callme() {System.out.println("bar!");}} }; for(Callable c: foo) { c.callme(); }
score: 0

http://stackoverflow.com/q/437663
downvote count: 0
favorite count: 0
score: 2
tagged with: jsf
upvote count: 2
has answer: http://stackoverflow.com/a/437752
type: Question
type: AnsweredQuestion
has title: Are selectOne and selectMany choices bounded by SelectItems?
tagged with: java
tagged with: parameter-spoofing
has body: Do the JSF selectOne and selectMany controls only allow submission of values defined in the given selectItems? I'm concerned about parameter spoofing, and if this was built-in, I wouldn't require a validator to ensure the selected value was one of the valid choices.
accepted answer: http://stackoverflow.com/a/437752
tagged with: validation
answer count: 1

http://stackoverflow.com/a/3564065
downvote count: 0
upvote count: 2
answers question: http://stackoverflow.com/q/531524
type: Answer
has body: If one is looking for a command-line-argument-like argument, how about wrapper.app.parameter.N (parameters for the application) and wrapper.java.additional.N (parameters for JVM) For example: wrapper.app.parameter.1=myargument Hope this helps somebody.
score: 2

http://stackoverflow.com/comment/266123
comment on: http://stackoverflow.com/a/444393
type: Comment
type: AnswerComment
score: 0
has text: What do you intend to do? That would be very helpful to know in order to give you the right answer.

http://stackoverflow.com/a/794103
has body: I have do that one time. We have to use a API provide by a third party vendor, and this API use a strange version of hibernate3.jar. So, we had to load this specific jar with a custom classloader in order to avoir "serial version UID" exception.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/585991

http://stackoverflow.com/comment/530604
type: AnswerComment
comment on: http://stackoverflow.com/a/469315
type: Comment
score: 9
has text: @Chris: only flag enums should be pluralized. That is, enumerations whose members are combined using the | operator.

http://stackoverflow.com/comment/1236153
score: 0
type: Comment
has text: Yes, MT4j certainly does allow to create new multitouch gestures as this is a very important requirement for multitouch applications. All you have to do is create a new so called input processor and register it with a component. Tutorials showing how to do that will be coming soon. Until then you can look at the source code of the existing gestures.
comment on: http://stackoverflow.com/a/1385610
type: AnswerComment

http://stackoverflow.com/comment/438515
type: AnswerComment
comment on: http://stackoverflow.com/a/625810
type: Comment
has text: I had some code (long gone) that parsed every class file in rt.jar (6000+). Using FileInputStream (wrapped with a BufferedIputStream) it took 30 seconds, with a memorry mapped file it too 4. Other than the way the bytes were read there was no difference in the code.
score: 0

http://stackoverflow.com/comment/370999
comment on: http://stackoverflow.com/a/559710
has text: Oh.. why did you take away the List <? super E>?
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/424602
type: Comment
has text: Why would atmospheric modeling or CFD be decimal?
comment on: http://stackoverflow.com/a/611722
type: AnswerComment
score: 0

http://stackoverflow.com/comment/296422
type: Comment
comment on: http://stackoverflow.com/a/479517
has text: Yeah, now he's a Java programmer, but he comes from C/Unix background. I'm trying to help him take a big step through python to jython.
type: AnswerComment
score: 0

http://stackoverflow.com/a/573628
has comment: http://stackoverflow.com/comment/121199733
has body: No, there's nothing like C#'s explicit interface implementation in Java. On the plus side, Java has covariant return types, so if you want to provide a more strongly typed implementation than the interface specifies, that's okay. For instance, this is fine: interface Foo { Object getBar(); } public class Test implements Foo { @Override public String getBar() { return "hi"; } } C# wouldn't allow that (prior to C# 9, which now supports covariant return types) - and one of the ways around it is typically to implement the interface explicitly and then have a more specific public method (usually called by the interface implementation).
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/573621
answers question: http://stackoverflow.com/q/573621
score: 32
type: Answer
upvote count: 32
has comment: http://stackoverflow.com/comment/121198206
has comment: http://stackoverflow.com/comment/121198612

http://stackoverflow.com/comment/451550
type: Comment
has text: Good advice. Saves a few lines over reading it yourself, as I described in my answer.
score: 0
comment on: http://stackoverflow.com/a/638348
type: AnswerComment

http://stackoverflow.com/comment/34205871
type: Comment
comment on: http://stackoverflow.com/a/517955
score: 6
has text: “an extended exponent range to represent intermediate results” is not “license to compute your floating-point calculations however they want”, and in practice, even `strictfp` computations make use of even an unhelpful 8087 FPU. It is only the case that a bit of care is required then. See http://stackoverflow.com/questions/18496560/how-do-java-runtimes-targeting-pre-sse2-processors-implement-floating-point-basi
type: AnswerComment

http://stackoverflow.com/a/486695
upvote count: 6
has comment: http://stackoverflow.com/comment/24231905
score: 4
has comment: http://stackoverflow.com/comment/304677
has comment: http://stackoverflow.com/comment/306729
downvote count: 2
has comment: http://stackoverflow.com/comment/24154384
has body: The only safe way to detect the other end has gone is to send heartbeats periodically and have the other end to timeout based on a lack of a heartbeat.
has comment: http://stackoverflow.com/comment/24232019
type: Answer
answers question: http://stackoverflow.com/q/485855

http://stackoverflow.com/comment/102404312
type: AnswerComment
type: Comment
has text: Cool, but this doesn't answer the question and should have been a comment.
score: 2
comment on: http://stackoverflow.com/a/7070786

http://stackoverflow.com/a/578942
type: AcceptedAnswer
downvote count: 0
has body: For Eclipse 3.4 at least you can do the following: 1) Go to Preferences -> Java -> Appearance -> Type Filters 2) Click Add, and enter java.lang.Object Now in code assist, the methods inherited directly from java.lang.Object will dissapear
has comment: http://stackoverflow.com/comment/72254676
has comment: http://stackoverflow.com/comment/392740
answers question: http://stackoverflow.com/q/578897
type: Answer
score: 29
accepted answer of: http://stackoverflow.com/q/578897
upvote count: 29
has comment: http://stackoverflow.com/comment/394412

http://stackoverflow.com/a/581917
has comment: http://stackoverflow.com/comment/393870
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/581450
has body: If I translate your enum into its class structure it will look approximately like this: public abstract class TestEnum { public static final TestEnum FOO = new FOO("foo") { public void foo() { helper(); // &lt;- compiler error } }; String name; TestEnum(String name) { this.name = name; } public abstract void foo(); private void helper(){ // do stuff (using this.name, so must not be static) } } The instance FOO is an anynomous class that extends TestEnum. That's why I believe you can't access helper(), because it is private. So this.helper() probably shouldn't work. I'm not sure why even super.helper() works, but maybe enum gives you private access to the parent. As for the static context error, I agree the error message doesn't seem to make sense.
downvote count: 0

http://stackoverflow.com/a/611429
has comment: http://stackoverflow.com/comment/7516124
answers question: http://stackoverflow.com/q/610333
has comment: http://stackoverflow.com/comment/13805605
has body: when in doubt, let java do the work for you: myStr.replaceAll(Pattern.quote("+"), replaceStr);
upvote count: 33
has comment: http://stackoverflow.com/comment/13791935
downvote count: 0
score: 33
type: Answer

http://stackoverflow.com/comment/21135436
has text: @Gray Ironic since it's supposed to be "Lite" :P
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/3120297
score: 4

http://stackoverflow.com/comment/207440
has text: Thank you very much, that was exactly what I was looking for! getValueIsAdjusting() should be false as you wrote.
comment on: http://stackoverflow.com/a/375308
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/499733
answer count: 3
possible better answer: http://stackoverflow.com/a/500372
has answer: http://stackoverflow.com/a/500372
favorite count: 0
has answer: http://stackoverflow.com/a/18296576
has body: How can I draw a filled rectangle in an applet with half opacity/transparency?
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
has answer: http://stackoverflow.com/a/499741
type: Question
has comment: http://stackoverflow.com/comment/315225
has title: How can I draw a filled rectangle in an applet with half opacity?
downvote count: 0
tagged with: applet
accepted answer: http://stackoverflow.com/a/499741

char
tags question: http://stackoverflow.com/q/537174
type: Tag
tags question: http://stackoverflow.com/q/404733
tag name: char
tags question: http://stackoverflow.com/q/635807

http://stackoverflow.com/a/621204
score: 3
has comment: http://stackoverflow.com/comment/434093
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/621117
upvote count: 3
answers question: http://stackoverflow.com/q/621117
has body: I'm not sure what's happening with the foreach loop, but you need to add the wildcard to your declaration of IterableEnumeration to accept the unspecified type returned from ZipFile.entries(). Replace private final Enumeration&lt;T&gt; enumeration; public IterableEnumeration(final Enumeration&lt;T&gt; e) { enumeration = e; } public static &lt;T&gt; Iterable&lt;T&gt; make(Enumeration&lt;T&gt; en) { return new IterableEnumeration&lt;T&gt;(en); } With private final Enumeration&lt;? extends T&gt; enumeration; public IterableEnumeration(final Enumeration&lt;? extends T&gt; e) { enumeration = e; } public static &lt;T&gt; Iterable&lt;T&gt; make(Enumeration&lt;? extends T&gt; en) { return new IterableEnumeration&lt;T&gt;(en); }

http://stackoverflow.com/comment/429594
type: AnswerComment
comment on: http://stackoverflow.com/a/615715
type: Comment
has text: Many people think that close on a file cannot throw an exception... http://stackoverflow.com/questions/588546/does-close-ever-throw-an-ioexception are you 100% certain that there are no cases that it would matter?
score: 0

http://stackoverflow.com/comment/21531658
has text: One thing that's not mentioned here, and caught me by surprise. The MessageDigest classes are NOT thread safe. If they're going to be used by different threads, just create a new one, instead of trying to reuse them.
score: 157
type: AnswerComment
comment on: http://stackoverflow.com/a/415956
type: Comment

http://stackoverflow.com/a/574360
has body: Oscar is bang on - you need the -classpath on the java command too. Another thing you can look at (it is overkill for what you are doing now, but you should still do it for the experience) is to create a JAR file. In the JAR file you can provide a manifest.mf file that tells the java command where to find the other JAR files as well as what the main class is. You would then run your program via "java -jar foo.jar" http://java.sun.com/docs/books/tutorial/deployment/jar/manifestindex.html http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html I believe that the following manifest.m file will do what you want (note you have to have a blank line at the end or it will not work): Main-Class: WizardGame Class-Path: slick.jar lwjgl.jar ibxm.jar That assumes that all JAR files (foo.jar and the other three) are in the same directory.
type: Answer
has comment: http://stackoverflow.com/comment/386195
upvote count: 4
downvote count: 0
has comment: http://stackoverflow.com/comment/386229
score: 4
answers question: http://stackoverflow.com/q/574351

http://stackoverflow.com/a/644648
upvote count: 1
answers question: http://stackoverflow.com/q/637960
type: Answer
downvote count: 0
score: 1
has body: You can use two different products on the same machine. Or you can run a single builds system across multiple machines. It is really up to the load you place on your CI.

http://stackoverflow.com/comment/194232
comment on: http://stackoverflow.com/a/364028
score: 0
type: AnswerComment
has text: Without seeing the code I can only guess, but I find it difficult to believe that the language is the bottleneck (and I'm a Java fan!). Sure you can get better performance and maintenance with Java, but a rewrite like you're describing sounds pretty scary and I can't see it being that much better!
type: Comment

http://stackoverflow.com/a/581716
type: Answer
upvote count: 4
has body: SortedSet&lt;T&gt; was designed assuming a very simple iteration model, forward only, thus finding the top n entries is easy but finding the last would require an expensive read through the iterator maintaining a window of the last n entries. NavigableSet&lt;T&gt; adding in 1.6 solves this (and the only SortedSet implementation from 1.4 TreeSet implements it so it is likely to be a drop in replacement for you). NavigableSet&lt;T&gt; set = new TreeSet&lt;T&gt;(); // add elements set.descendingIterator() // iterate over the last n entires as needed
downvote count: 0
answers question: http://stackoverflow.com/q/581677
has comment: http://stackoverflow.com/comment/395846
has comment: http://stackoverflow.com/comment/395849
score: 4

http://stackoverflow.com/q/359921
type: AnsweredQuestion
has title: Test class extending test class in dependency module
upvote count: 24
type: Question
has answer: http://stackoverflow.com/a/12299238
possible better answer: http://stackoverflow.com/a/1206760
tagged with: java
has answer: http://stackoverflow.com/a/1206760
score: 24
has answer: http://stackoverflow.com/a/360122
answer count: 3
has body: I've got a test class in a module that extends another test class in one of its dependency modules. How can I import the dependency's test code into the test scope of the dependent module? To illiterate, I've got two modules, "module-one" being a dependency of "module-two". SubTestCase is a subclass of TestCase. module-one \src\test\java\com\example\TestCase.java module-two \src\test\java\com\example\SubTestCase.java But the build is failing because the test code of "module-one" is not being imported into "module-two", just the main code.
downvote count: 0
tagged with: maven-2
favorite count: 0
accepted answer: http://stackoverflow.com/a/360122

audio
tags question: http://stackoverflow.com/q/597743
tags question: http://stackoverflow.com/q/533438
tags question: http://stackoverflow.com/q/538898
tags question: http://stackoverflow.com/q/562273
tags question: http://stackoverflow.com/q/407624
tags question: http://stackoverflow.com/q/471112
type: Tag
tags question: http://stackoverflow.com/q/512436
tag name: audio
tags question: http://stackoverflow.com/q/625928
tags question: http://stackoverflow.com/q/598344
tags question: http://stackoverflow.com/q/647252

http://stackoverflow.com/q/580568
type: Question
accepted answer: http://stackoverflow.com/a/580579
answer count: 2
has body: I want to write a Java program that'll access a few web pages that requires logging in. How would I keep the session cookie resulting from logging in so I can access those pages?
downvote count: 0
has title: How do I "log in" to a web app and access subsequent pages using Java?
possible better answer: http://stackoverflow.com/a/580581
favorite count: 0
has answer: http://stackoverflow.com/a/580581
upvote count: 2
has answer: http://stackoverflow.com/a/580579
type: AnsweredQuestion
score: 2
tagged with: cookies
tagged with: java
tagged with: http

http://stackoverflow.com/a/502987
has body: Take a look at this page. Try to see if the SimpleResultSet class is fine for your needs. If you combine its source into a standalone set of classes, it should do the trick.
downvote count: 0
answers question: http://stackoverflow.com/q/502318
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/q/629152
tagged with: java
tagged with: servlets
answer count: 2
downvote count: 0
tagged with: jsp
favorite count: 0
accepted answer: http://stackoverflow.com/a/629163
has body: SendRedirect or requestdispatch ?Which should be more preferred?Which is more efficient?
type: AnsweredQuestion
has title: sendRedirect or request Dispatch is more efficient?
upvote count: 3
possible better answer: http://stackoverflow.com/a/24324967
has answer: http://stackoverflow.com/a/24324967
type: Question
score: 3
has answer: http://stackoverflow.com/a/629163

http://stackoverflow.com/a/7403928
type: Answer
has body: Had negative experience with db4o (v. 8): indexing didn't work properly (exception etc.). So I didn't managed how to avoid creating duplicates in foreign tables when having object in object structure. More detailed explanation in my question. Hope one day it would be better.
score: 0
answers question: http://stackoverflow.com/q/371538

http://stackoverflow.com/comment/326177
score: 0
type: Comment
comment on: http://stackoverflow.com/a/512282
has text: Correct, the .jar doesn't execute, it reports an error message that reads, "Failed to load Main-Class manifest attribute from ...". Once I have the .jar converted to .dll I'm going to attempt to use it the same as the java coded example using the .jar.
type: AnswerComment

http://stackoverflow.com/q/560063
tagged with: database
accepted answer: http://stackoverflow.com/a/560438
has answer: http://stackoverflow.com/a/560301
type: AnsweredQuestion
tagged with: connection
possible better answer: http://stackoverflow.com/a/560301
type: Question
answer count: 2
has body: I'M NOT ASKING ABOUT THE CODE. I just want to know what are and all the steps involved in the connection other than coding. I'm using j2sdk1.4.0 and MySQL Server 4.1. Am very new to this area. Thanks in advance
tagged with: jdbc
has answer: http://stackoverflow.com/a/560438
tagged with: java
score: 0
tagged with: mysql
has title: What are the steps for connecting jdbc with mysql

http://stackoverflow.com/q/366438
answer count: 2
has title: Variable event in Java
has answer: http://stackoverflow.com/a/366511
favorite count: 0
score: 0
has body: I'm having a problem with a Klondike Solitaire I'm programming. It's almost finished but now when I try to compile (I'm using Dr. Java, yeah I know), it keeps popping up with 2 errors. Cannot find symbol: Variable event Cannot find symbol: Method "findbunki" (java.awt.Point) I've already imported java.awt, so that can't be it.
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/3937643
upvote count: 1
downvote count: 1
type: Question
tagged with: java
tagged with: compilation

http://stackoverflow.com/a/366116
upvote count: 3
type: Answer
score: 3
downvote count: 0
has body: Getting file extension from file.getOriginalFilename() works good.I think that is the better way.
answers question: http://stackoverflow.com/q/362972

http://stackoverflow.com/q/419157
favorite count: 0
has title: Is there a simple way to remove a TimeSeries from a displayed JFreeChart Chart?
has answer: http://stackoverflow.com/a/420996
type: Question
has body: I have a Swing application which uses JFreeChart to display one of a series of queries. Some of these queries have a composite TimeSeries key. Each component of this key can contain a few values, but when rendered makes a very noisy graph. I would like a simple way for the users to hide/show some of the TimeSeries in the displayed Chart component.
answer count: 2
upvote count: 1
tagged with: swing
tagged with: jfreechart
accepted answer: http://stackoverflow.com/a/420996
tagged with: java
possible better answer: http://stackoverflow.com/a/421617
has answer: http://stackoverflow.com/a/421617
type: AnsweredQuestion
tagged with: user-interface
downvote count: 0
score: 1

http://stackoverflow.com/a/386238
has body: I found the problem. Previously i was using j2ee.jar to import javax.mail. I removed j2ee.jar from the classpath and downloaded JavaMail 1.4.1 and put into my classpath two jars, smtp.jar and mailapi.jar. I use now smtps instead smtp Transport transport = session.getTransport("smtps"); Now Bill the Lizard's code works.
score: 20
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/386083
upvote count: 20

http://stackoverflow.com/a/402260
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/402247
has body: I used 'byte' a lot, in C/C++ code implementing functionality like image compression (i.e. running a compression algorithm over each byte of a black-and-white bitmap), and processing binary network messages (by interpreting the bytes in the message). However I have virtually never used 'float' or 'double'.
type: Answer
has comment: http://stackoverflow.com/comment/227511
score: 4

http://stackoverflow.com/a/438526
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/434855
downvote count: 0
has body: I would suggest creating a virtual machine (in vmware/virtualbox/whatever) with these specifications in terms of RAM and diskspace and then do some experiments. What is the bottleneck of the application - CPU usage? Graphics update speed? Memory usage for the JVM? Disk IO? If you want to use Linux, I would personally start with investigating Damn Small Linux. You will most likely need to find a JVM which runs well when embeddable, as the normal Sun JVM uses memory to gain speed.

http://stackoverflow.com/a/647505
answers question: http://stackoverflow.com/q/647116
upvote count: 42
downvote count: 0
score: 42
type: Answer
has body: First of all, it's worth remembering that all Java archive files (.jar/.war/etc...) are all basically just fancy.zip files, with a few added manifests and metadata. Second, to tackle this problem I personally use several tools which handle this problem on all levels: Jad + Jadclipse while working in IDE for decompiling .class files WinRAR, my favorite compression tool natively supports Java archives (again, see first paragraph). Beyond Compare, my favorite diff tool, when configured correctly can do on-the-fly comparisons between any archive file, including jars. Well worth a try. The advantage of all the aforementioned, is that I do not need to hold any other external tool which clutters my work environment. Everything I will ever need from one of those files can be handled inside my IDE or diffed with other files natively.

http://stackoverflow.com/a/555336
score: 19
has body: You're getting along there. basically, ask yourself the question "which code would change if I had to change some part of the program?" If it would change the way it looks without changing basic data, then it's in the view. If it is data that could be viewed in many ways, it's the model. And if it's how you play, then it's the control. So if it's whether you draw an "axe" with two blades or one, it's view. If it's how many hit points damage you inflict with an axe, it's model. And if it's whether you swing the axe by typing "s" or by right clicking, it's control.
downvote count: 0
answers question: http://stackoverflow.com/q/555283
upvote count: 19
type: Answer

http://stackoverflow.com/a/39711614
type: Answer
answers question: http://stackoverflow.com/q/363681
upvote count: 3
has comment: http://stackoverflow.com/comment/127172970
has comment: http://stackoverflow.com/comment/72220969
score: 3
has body: This will generate Random numbers list with range (Min - Max) with no duplicate. generateRandomListNoDuplicate(1000, 8000, 500); Add this method. private void generateRandomListNoDuplicate(int min, int max, int totalNoRequired) { Random rng = new Random(); Set&lt;Integer&gt; generatedList = new LinkedHashSet&lt;&gt;(); while (generatedList.size() &lt; totalNoRequired) { Integer radnomInt = rng.nextInt(max - min + 1) + min; generatedList.add(radnomInt); } } Hope this will help you.
downvote count: 0

http://stackoverflow.com/comment/250269
has text: agree with jjnguy. Why aren't you doing Random r = new Random(x) outside the loop, then just calling r.nextInt() over and over? it looks like you're doing a histogram of how often the numbers 0-7 appear, and you'd expect it to be relatively equal...
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/426350
score: 0

http://stackoverflow.com/a/364464
has comment: http://stackoverflow.com/comment/194394
answers question: http://stackoverflow.com/q/364454
has comment: http://stackoverflow.com/comment/195467
has comment: http://stackoverflow.com/comment/194381
upvote count: 53
score: 52
has comment: http://stackoverflow.com/comment/194383
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/6697252
type: Answer
has comment: http://stackoverflow.com/comment/194452
has comment: http://stackoverflow.com/comment/194774
downvote count: 1
has body: Typically, when implementing equals you can check to see whether the class of the argument is equal (or compatible) to the implementing class before casting it. Something like this: if (getClass() != obj.getClass()) return false; MyObj myObj = (MyObj) obj; Doing it this way will prevent the FindBugs warning. A side note to address a comment: Some people argue to use instanceof instead of getClass to check type safety. There is a big debate on that, which I was trying not to get into when I noted that you can check for class equality or compatibility, but I guess I can't escape it. It boils down to this - if you use instanceof you can support equality between instances of a class and instances of its subclass, but you risk breaking the symmetric contract of equals. Generally I would recommend not to use instanceof unless you know you need it and you know what you are doing. For more information see: http://www.artima.com/weblogs/viewpost.jsp?thread=4744 What issues should be considered when overriding equals and hashCode in Java? http://www.macchiato.com/columns/Durable5.html http://commons.apache.org/lang/api-release/org/apache/commons/lang/builder/EqualsBuilder.html (Apache common's implementation helper) http://www.eclipsezone.com/eclipse/forums/t92613.rhtml (Eclipse's default equals generator) NetBeans generator also uses getClass()
accepted answer of: http://stackoverflow.com/q/364454

http://stackoverflow.com/comment/41570420
comment on: http://stackoverflow.com/a/613484
type: AnswerComment
has text: Won't other success codes like "201 CREATED" fail here?
type: Comment
score: 6

http://stackoverflow.com/a/992224
type: AcceptedAnswer
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/626648
accepted answer of: http://stackoverflow.com/q/626648
score: 1
has body: IF u see this blog i think will never go to other webservices :) http://springkbase.blogspot.com/2009/06/spring-webservice-with-castor.html
upvote count: 1

http://stackoverflow.com/comment/309030
comment on: http://stackoverflow.com/a/493256
type: AnswerComment
type: Comment
has text: The only gotcha with the "essentially the same thing" approach is the use of null. Objects can be null, primitives can't. Try auto-unboxing a null. Not exactly obvious what the exception means.
score: 3

http://stackoverflow.com/comment/135449972
comment on: http://stackoverflow.com/a/647140
score: 1
type: AnswerComment
has text: @splashout Thank you for the update. I have included your comment in the answer for more visibility.
type: Comment

http://stackoverflow.com/a/585695
upvote count: 3
has body: You can add a MouseListener to a JTable and then handle the mouseClicked event. The following code shows a mouseClicked implementation that finds out what row was double clicked. You can then navigate to a panel using this information. public void mouseClicked(MouseEvent event) { if (event.getClickCount() == 2) { JTable source = (JTable)event.getSource(); int rowIndex = source.rowAtPoint(event.getPoint()); // get data from table model using row index // navigate to panel } }
type: AcceptedAnswer
type: Answer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/585650
score: 3
answers question: http://stackoverflow.com/q/585650

http://stackoverflow.com/a/26251419
has comment: http://stackoverflow.com/comment/71510335
downvote count: 0
has body: This question shows how to store passwords and other data in an encrypted file: Java 256-bit AES Password-Based Encryption
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/442862
score: 1

http://stackoverflow.com/comment/96371184
score: 0
comment on: http://stackoverflow.com/a/54794858
type: Comment
type: AnswerComment
has text: You're right, thus I mentioned it should only be used for practice. My point was casting a Number to primitive type won't work, using a wrapper class such as BigInteger, or Integer, or Number makes more sense. Or as VonC mentioned, `Number.toIntValue()`.

http://stackoverflow.com/q/580419
score: 21
upvote count: 21
tagged with: loops
has answer: http://stackoverflow.com/a/581375
type: Question
has answer: http://stackoverflow.com/a/583537
has answer: http://stackoverflow.com/a/580431
tagged with: java
accepted answer: http://stackoverflow.com/a/580426
has body: Okay, I tested this on an empty program, and just having a while(true){} running gave me >50% on my CPU. I have a game I'm working on that uses a while loop as it's main loop, and it's CPU is at 100 all the time. How can I get Java to repeat something over and over without eating up >50% of my CPU just to do the repeating?
has comment: http://stackoverflow.com/comment/392561
has answer: http://stackoverflow.com/a/580433
has answer: http://stackoverflow.com/a/598551
downvote count: 0
has comment: http://stackoverflow.com/comment/392563
favorite count: 0
answer count: 9
has answer: http://stackoverflow.com/a/580566
tagged with: cpu-usage
has title: How can I stop a Java while loop from eating >50% of my CPU?
has answer: http://stackoverflow.com/a/580850
has answer: http://stackoverflow.com/a/580426
has answer: http://stackoverflow.com/a/580832
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/580566

http://stackoverflow.com/a/16384039
downvote count: 0
type: Answer
has body: Been trying to come up with a nice solution to this myself that Revolves around creating an XSD for the config file - since in my mind the whole benefit of using XML is that you can strongly type the config file, in terms of datatypes, and which fields are mandatory/optional Will validate the XML against the XSD, so if a value is missing it'll throw an error out rather than your bean being injected with a 'null' Doesn't rely on spring annotations (like @Value - in my mind that's giving beans knowledge about their container + relationship with other beans, so breaks IOC) Will validate the spring XML against the XSD, so if you try to reference an XML field not present in the XSD, it'll throw out an error too The bean has no knowledge that its property values are being injected from XML (i.e. I want to inject individual properties, and not the XML object as a whole) What I came up with is as below, apologies this is quite long winded, but I like it as a solution since I believe it covers everything. Hopefully this might prove useful to someone. Trivial pieces first: The bean I want property values injected into: package com.ndg.xmlpropertyinjectionexample; public final class MyBean { private String firstMessage; private String secondMessage; public final String getFirstMessage () { return firstMessage; } public final void setFirstMessage (String firstMessage) { this.firstMessage = firstMessage; } public final String getSecondMessage () { return secondMessage; } public final void setSecondMessage (String secondMessage) { this.secondMessage = secondMessage; } } Test class to create the above bean and dump out the property values it got: package com.ndg.xmlpropertyinjectionexample; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public final class Main { public final static void main (String [] args) { try { final ApplicationContext ctx = new ClassPathXmlApplicationContext ("spring-beans.xml…
upvote count: 3
score: 3
answers question: http://stackoverflow.com/q/479855

http://stackoverflow.com/a/565827
upvote count: 1
answers question: http://stackoverflow.com/q/565742
has body: If you don't need the image data byte array you can encode directly to the file: String myFile="C:" + File.separator + "tmpfile.jpg"; File f = new File(myFile); FileOutputStream fos = null; try { fos = new FileOutputStream(f); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder( new BufferedOutputStream(fos)); encoder.encode(biFullView); } catch (SecurityException ee) { System.out.println("writeFile: caught security exception"); } catch (IOException ioe) { System.out.println("writeFile: caught i/o exception"); }finally{ if(fos != null) fos.close(); } If you need the byte array to perform other operations it's better to write it directly to the FileOutputStream: //... fos = new FileOutputStream(myFile)); fos.write(imageData, 0, imageData.length); //...
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/390177
type: Answer
score: 1
accepted answer of: http://stackoverflow.com/q/565742

http://stackoverflow.com/q/555977
tagged with: serial-communication
type: UnansweredQuestion
tagged with: multithreading
has answer: http://stackoverflow.com/a/555994
tagged with: swing
tagged with: java
type: Question
has title: JOptionPane popup window
answer count: 2
has answer: http://stackoverflow.com/a/556138
has body: I'm reading data from serial port for that I've created one window. When I click connect button I'll get another window showing message as "connected" with ok option and at the same time data starts coming but it wont dump until i click ok button of the front window. I want data should dump without clicking the ok button of the front window. How can I do that?
score: 0

http://stackoverflow.com/a/435220
upvote count: 3
score: 3
downvote count: 0
type: Answer
has body: the best would be to download the Eclipse J2EE package which already includes all the stuff you need to create axis2 web services: http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/ganymede/SR1/eclipse-jee-ganymede-SR1-win32.zip you could also install the WTP package via the update manager from the Ganymede update site
answers question: http://stackoverflow.com/q/430936

http://stackoverflow.com/q/622997
has title: Java castor using custom field handlers
type: Question
score: 3
tagged with: java
has body: I have been trying to write a custom field handler which returns the hash code of a java.awt.Image object when writing to XML and retrieves an image based on this hash code when binding the XML to an object. For some reason, I can't get this to work; castor, from what I can tell, simply instantiates the field handler and then doesn't call any of its methods. Can you give me a quick example of how to do this because I must be missing something simple! Cheers, Pete
answer count: 1
favorite count: 0
upvote count: 3
tagged with: field
has answer: http://stackoverflow.com/a/7795218
tagged with: http://stackoverflow.com/tag/xml
downvote count: 0
tagged with: castor
type: UnansweredQuestion

http://stackoverflow.com/comment/13952537
type: Comment
comment on: http://stackoverflow.com/a/6958439
score: 1
type: AnswerComment
has text: Yeah ... just make it more explicite for thoses who doesn't understand everything on the page he gave, or if ever the link dies ... or just to save some time to the next guys who find this page via Google. I didn't mean to steal one's good answer.

http://stackoverflow.com/a/938080
has comment: http://stackoverflow.com/comment/50639452
answers question: http://stackoverflow.com/q/449409
has comment: http://stackoverflow.com/comment/1641750
downvote count: 0
has comment: http://stackoverflow.com/comment/5953365
has comment: http://stackoverflow.com/comment/25950938
has body: public class JavaMemory { private final int dataSize = (int) (Runtime.getRuntime().maxMemory() * 0.6); public void f() { { byte[] data = new byte[dataSize]; //data = null; } byte[] data2 = new byte[dataSize]; } public static void main(String[] args) { JavaMemory jmp = new JavaMemory(); jmp.f(); } } Above program throws OutOfMemoryError. If you uncomment data = null;, the OutOfMemoryError is solved. It is always good practice to set the unused variable to null
type: Answer
upvote count: 6
score: 6

http://stackoverflow.com/a/535017
score: 153
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/64730648
has comment: http://stackoverflow.com/comment/41598406
has comment: http://stackoverflow.com/comment/92031037
type: Answer
accepted answer of: http://stackoverflow.com/q/535004
answers question: http://stackoverflow.com/q/535004
downvote count: 1
has comment: http://stackoverflow.com/comment/9700467
has body: How about just: Date expiry = new Date(Long.parseLong(date)); EDIT: as per rde6173's answer and taking a closer look at the input specified in the question , "1081157732" appears to be a seconds-based epoch value so you'd want to multiply the long from parseLong() by 1000 to convert to milliseconds, which is what Java's Date constructor uses, so: Date expiry = new Date(Long.parseLong(date) * 1000);
has comment: http://stackoverflow.com/comment/106478437
upvote count: 154

http://stackoverflow.com/comment/416132
has text: Oops... I would return a Predicate<Cat>.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/603844

http://stackoverflow.com/comment/70311077
type: AnswerComment
has text: @Mindwin Clonable might be more like the steak my Mom always made: burnt crispy --- nothing stringy about it! FWIW, my memory on this subject has not been refreshed since October.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/638179

http://stackoverflow.com/comment/416249
type: Comment
has text: Excellent, Kevin--then you just need to set the IDE classpath to reference the generated JARs and have the build update them when appropriate. It can be helpful to update the JARs only when the generated code has to change, using the relevant Ant task (uptodate?).
type: AnswerComment
comment on: http://stackoverflow.com/a/588607
score: 0

http://stackoverflow.com/a/443539
has comment: http://stackoverflow.com/comment/267122
has body: Unfortunately, this feature appears to be completely worthless at this time. It is easy to add a timestamp when signing a jar file, just add this parameter to the jarsigner command: -tsa https://timestamp.geotrust.com/tsa This is the URL to Thawte's timestamping server. Unfortunately, the Thawte timestamping CA cert is not included in the Java runtime's list of trusted CA certs, so it is effectively meaningless. That is, if you load the applet after the code signing certificate has expired, you get the "untrusted" warning dialog instead of the "trusted" one. There is a "workaround", of sorts, posted here, but it works by embedding the Thawte timestamping CA cert in the applet itself, and running keytool on the client to import the cert. I can't see how this would work though, since the user will already have seen the signed code dialog before this code can run. I'll keep looking for a solution, but I'm not hopeful. I can't imagine why a usable timestamping CA cert has not been included with the Java runtime after all this time.
upvote count: 4
score: 4
downvote count: 0
answers question: http://stackoverflow.com/q/435912
type: Answer

http://stackoverflow.com/comment/225169
type: QuestionComment
comment on: http://stackoverflow.com/q/399401
score: 0
has text: First of all configure hibernate to show the actual SQL query. That would be very helpful.
type: Comment

http://stackoverflow.com/comment/359472
comment on: http://stackoverflow.com/a/539629
type: Comment
has text: </quote> Perhaps I should've stopped there </quote> Reely, reely glad you didn't - I learned quite a lot from the code you presented - thanks :-)
score: 0
type: AnswerComment

http://stackoverflow.com/a/49241488
score: 0
has body: No, they don't both interpret byte code. Python only interprets bytecode if you are running with pypy. Otherwise it is compiled into C and interpreted at that level. Java compiles to bytecode.
has comment: http://stackoverflow.com/comment/86448776
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/106101465
downvote count: 1
answers question: http://stackoverflow.com/q/441824
has comment: http://stackoverflow.com/comment/134678238
has comment: http://stackoverflow.com/comment/86626127

http://stackoverflow.com/a/484108
score: 5
answers question: http://stackoverflow.com/q/483980
type: Answer
upvote count: 6
has body: Use PropertyUtils (from apache commons-beanutils) instead of BeanUtils. It has a getProperty(Object bean, String name) method that returns an Object instead of a String. See the JavaDoc for more information.
downvote count: 1

http://stackoverflow.com/a/402960
upvote count: 1
has comment: http://stackoverflow.com/comment/228213
score: 1
has comment: http://stackoverflow.com/comment/228206
has comment: http://stackoverflow.com/comment/232407
downvote count: 0
type: Answer
has body: I've used JEP with success a couple of years ago and it still seems to be actively developed. I believe they had a more permissive license back in those days, but it's probably cheaper than coding it yourself (depending on your exact needs and skills).
answers question: http://stackoverflow.com/q/402833

http://stackoverflow.com/a/542012
downvote count: 2
has comment: http://stackoverflow.com/comment/74827754
upvote count: 10
answers question: http://stackoverflow.com/q/541912
has comment: http://stackoverflow.com/comment/74809938
has body: In my experience, the "I" convention applies to interfaces that are intended to provide a contract to a class, particularly when the interface itself is not an abstract notion of the class. For example, in your case, I'd only expect to see IUser if the only user you ever intend to have is User. If you plan to have different types of users - NoviceUser, ExpertUser, etc. - I would expect to see a User interface (and, perhaps, an AbstractUser class that implements some common functionality, like get/setName()). I would also expect interfaces that define capabilities - Comparable, Iterable, etc. - to be named like that, and not like IComparable or IIterable.
type: Answer
score: 8

http://stackoverflow.com/comment/59774307
type: Comment
score: 2
comment on: http://stackoverflow.com/a/23308683
has text: This answer is a bit misleading as `JFreeSVG` creates SVGs, it doesn't render them, per their forum: "Rendering SVG within a Java application is a different problem, and not one that JFreeSVG attempts to solve." http://www.jfree.org/phpBB2/viewtopic.php?f=32&t=117136
type: AnswerComment

http://stackoverflow.com/comment/43597978
has text: @erickson Am still not clear with the query, Is it not true that, "file.encoding" is relevant when character based I/O streams are used(all subclasses of `class Reader` & `class Writer`)? Because `class FileInputStream` is byte based I/O stream, so why one should care about character set in byte-based I/O stream?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/361975

http://stackoverflow.com/q/440931
favorite count: 0
has title: How many multiple "Eclipse Projects" is considered too excessive for one actual development project?
score: 8
has answer: http://stackoverflow.com/a/440986
answer count: 9
upvote count: 8
has answer: http://stackoverflow.com/a/441000
has answer: http://stackoverflow.com/a/445459
has answer: http://stackoverflow.com/a/442763
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/445427
tagged with: java
tagged with: eclipse
type: Question
has answer: http://stackoverflow.com/a/441004
has answer: http://stackoverflow.com/a/1503034
has answer: http://stackoverflow.com/a/440955
possible better answer: http://stackoverflow.com/a/441004
accepted answer: http://stackoverflow.com/a/440955
has answer: http://stackoverflow.com/a/440987
downvote count: 0
has body: I'm currently working on a project that contains many different Eclipse projects referencing each other to make up one large project. Is there a point where a developer should ask themselves if they should rethink the way their development project is structured? NOTE: My project currently contains 25+ different Eclipse projects.

http://stackoverflow.com/comment/75643926
type: AnswerComment
has text: If you are writing whole lines in a thread and the order of lines is not important then it makes sense
comment on: http://stackoverflow.com/a/631669
type: Comment
score: 0

http://stackoverflow.com/a/587415
has comment: http://stackoverflow.com/comment/20896679
accepted answer of: http://stackoverflow.com/q/587404
has comment: http://stackoverflow.com/comment/400611
type: Answer
has comment: http://stackoverflow.com/comment/23767187
has body: You could write a method that takes an instance of an interface which defines a check(Cat) method, where that method can be implemented with whatever property-checking you want. Better yet, make it generic: public interface Checker&lt;T&gt; { public boolean check(T obj); } public class CatChecker implements Checker&lt;Cat&gt; { public boolean check(Cat cat) { return (cat.age == 3); // or whatever, implement your comparison here } } // put this in some class public static &lt;T&gt; Collection&lt;T&gt; findAll(Collection&lt;T&gt; coll, Checker&lt;T&gt; chk) { LinkedList&lt;T&gt; l = new LinkedList&lt;T&gt;(); for (T obj : coll) { if (chk.check(obj)) l.add(obj); } return l; } Of course, like other people are saying, this is what relational databases were made for...
has comment: http://stackoverflow.com/comment/399280
has comment: http://stackoverflow.com/comment/399288
score: 46
has comment: http://stackoverflow.com/comment/2398393
answers question: http://stackoverflow.com/q/587404
downvote count: 4
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/27241256
has comment: http://stackoverflow.com/comment/400607
upvote count: 50
has comment: http://stackoverflow.com/comment/27215463
has comment: http://stackoverflow.com/comment/399294

http://stackoverflow.com/q/578305
tagged with: java
tagged with: file
has title: Create a Java File object (or equivalent) using a byte array in memory (without a physical file)
type: Question
score: 8
has answer: http://stackoverflow.com/a/578335
has answer: http://stackoverflow.com/a/870556
tagged with: memory
accepted answer: http://stackoverflow.com/a/578335
has answer: http://stackoverflow.com/a/578356
downvote count: 0
possible better answer: http://stackoverflow.com/a/578324
favorite count: 0
has answer: http://stackoverflow.com/a/578324
upvote count: 8
answer count: 5
tagged with: io
tagged with: spring
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/578517
has body: I want to create a Java File object in memory (without creating a physical file) and populate its content with a byte array. Can this be done? The idea is to pass it to a Spring InputStreamSource. I'm trying the method below, but it returns saying "the byte array does not contain a file name.". MimeMessage message = mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message); helper.setFrom("no-reply@example.com", "xyz"); helper.setTo(email); helper.setText(body,true); helper.setSubject(subject); helper.addInline("cImage", new InputStreamResource(new ByteArrayInputStream(imageByteArr))); mailSender.send(message);

http://stackoverflow.com/a/590167
has comment: http://stackoverflow.com/comment/406058
has comment: http://stackoverflow.com/comment/78744555
accepted answer of: http://stackoverflow.com/q/590069
answers question: http://stackoverflow.com/q/590069
has body: I would use an array of T, a head and tail pointer, and add and get methods. Like: (Bug hunting is left to the user) // Hijack these for simplicity import java.nio.BufferOverflowException; import java.nio.BufferUnderflowException; public class CircularBuffer&lt;T&gt; { private T[] buffer; private int tail; private int head; @SuppressWarnings("unchecked") public CircularBuffer(int n) { buffer = (T[]) new Object[n]; tail = 0; head = 0; } public void add(T toAdd) { if (head != (tail - 1)) { buffer[head++] = toAdd; } else { throw new BufferOverflowException(); } head = head % buffer.length; } public T get() { T t = null; int adjTail = tail &gt; head ? tail - buffer.length : tail; if (adjTail &lt; head) { t = (T) buffer[tail++]; tail = tail % buffer.length; } else { throw new BufferUnderflowException(); } return t; } public String toString() { return "CircularBuffer(size=" + buffer.length + ", head=" + head + ", tail=" + tail + ")"; } public static void main(String[] args) { CircularBuffer&lt;String&gt; b = new CircularBuffer&lt;String&gt;(3); for (int i = 0; i &lt; 10; i++) { System.out.println("Start: " + b); b.add("One"); System.out.println("One: " + b); b.add("Two"); System.out.println("Two: " + b); System.out.println("Got '" + b.get() + "', now " + b); b.add("Three"); System.out.println("Three: " + b); // Test Overflow // b.add("Four"); // System.out.println("Four: " + b); System.out.println("Got '" + b.get() + "', now " + b); System.out.println("Got '" + b.get() + "', now " + b); // Test Underflow // System.out.println("Got '" + b.get() + "', now " + b); // Back to start, let's shift on one b.add("Foo"); b.get(); } } }
downvote count: 3
has comment: http://stackoverflow.com/comment/404893
has comment: http://stackoverflow.com/comment/918725
has comment: http://stackoverflow.com/comment/405102
has comment: http://stackoverflow.com/comment/404939
type: AcceptedAnswer
score: 22
has comment: http://stackoverflow.com/comment/920246
type: Answer
has comment: http://stackoverflow.com/comment/407621
upvote count: 25

http://stackoverflow.com/comment/3322978
score: 18
comment on: http://stackoverflow.com/a/1689769
type: AnswerComment
type: Comment
has text: Just read the hibernate docu ... for valid values, it says: "e.g." ... are there any other valid values?

http://stackoverflow.com/comment/48200568
comment on: http://stackoverflow.com/q/452969
has text: See http://stackoverflow.com/a/10675081/116891 for an example of using `importlib.import`, which was backported from python 3 to 2.7 (https://docs.python.org/2/library/importlib.html)
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/5206797
comment on: http://stackoverflow.com/a/1020035
type: Comment
score: 1
has text: I prefer your second example. For me it's less about whether the specific curly brace characters match up, & about a conceptual start-matches-end thing.
type: AnswerComment

http://stackoverflow.com/comment/401131
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/588583
has text: How do you deal with 'permgen full' errors that come from regenerating new classes every time you rebuild inside your tooling? Or do you not use any IDE or tools that stay running across builds?

http://stackoverflow.com/comment/335987
score: 2
comment on: http://stackoverflow.com/a/513392
has text: Yeah, just the results. And only because I might want to look for a specific test result after the unit tests have ran. I'm not sure why Eclipse can't order the test results as they're being run. Just use a SortedSet.
type: AnswerComment
type: Comment

http://stackoverflow.com/a/421806
score: 0
has comment: http://stackoverflow.com/comment/245949
has body: maybe check in a thread? try { InetAddress inetAddr = InetAddress.getByName(host); setOnline(); } catch (UnknownHostException e) { setOffline(); }
type: Answer
answers question: http://stackoverflow.com/q/421662

http://stackoverflow.com/a/638334
score: 0
answers question: http://stackoverflow.com/q/638301
has body: Java's supposed to set up the JAVA_HOME variable when it's installed. Use this to find the location of Java: if not "%JAVA_HOME%" == "" goto HasJavaHome :HasJavaHome set JAVA_HOME=... // Your new value goes here.
type: Answer
has comment: http://stackoverflow.com/comment/453111
has comment: http://stackoverflow.com/comment/451548
upvote count: 1
downvote count: 1

http://stackoverflow.com/q/384189
has answer: http://stackoverflow.com/a/384719
tagged with: jstl
tagged with: jsp
possible better answer: http://stackoverflow.com/a/409572
duplicate of: http://stackoverflow.com/q/5003142
downvote count: 0
has comment: http://stackoverflow.com/comment/234784
favorite count: 0
linked to: http://stackoverflow.com/q/5003142
tagged with: jdbc
has body: I'd like to swap out an sql:query for some Java code that builds a complex query with several parameters. The current sql is a simple select. &lt;sql:query var="result" dataSource="${dSource}" sql="select * from TABLE "> &lt;/sql:query> How do I take my Java ResultSet (ie. rs = stmt.executeQuery(sql);) and make the results available in my JSP so I can do this textbook JSP? To be more clear, I want to remove the above query and replace it with Java. &lt;% ResultSet rs = stmt.executeQuery(sql); // Messy code will be in some Controller %> &lt;c:forEach var="row" items="${result.rows}"> &lt;c:out value="${row.name}"/> &lt;/c:forEach> Do I set the session/page variable in the Java section or is there some EL trick that I can use to access the variable?
accepted answer: http://stackoverflow.com/a/2428468
answer count: 4
has title: How do I make a Java ResultSet available in my jsp?
type: AnsweredQuestion
score: 3
has answer: http://stackoverflow.com/a/409572
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/2428468
has answer: http://stackoverflow.com/a/404444
type: Question

http://stackoverflow.com/a/451077
has body: Video 4 Linux devices should be accessible through a device file (like /dev/video). So I think you can open the device you want to access as you would do with a normal file and then read the stream coming from it. To have more info about the devices, the video format etc... just check V4L web site
answers question: http://stackoverflow.com/q/447298
downvote count: 2
score: -2
upvote count: 0
type: Answer

http://stackoverflow.com/a/562455
has comment: http://stackoverflow.com/comment/16387751
answers question: http://stackoverflow.com/q/562404
has comment: http://stackoverflow.com/comment/16351863
has comment: http://stackoverflow.com/comment/16406584
score: 0
has body: Try the Java Beanshell. BeanShell is a small, free, embeddable Java source interpreter with object scripting language features, written in Java. BeanShell dynamically executes standard Java syntax and extends it with common scripting conveniences such as loose types, commands, and method closures like those in Perl and JavaScript.
has comment: http://stackoverflow.com/comment/16406482
type: Answer
has comment: http://stackoverflow.com/comment/16387734

http://stackoverflow.com/q/603013
has answer: http://stackoverflow.com/a/24016113
possible better answer: http://stackoverflow.com/a/8138687
has answer: http://stackoverflow.com/a/879604
has answer: http://stackoverflow.com/a/3021692
upvote count: 71
has answer: http://stackoverflow.com/a/37405037
has answer: http://stackoverflow.com/a/603065
tagged with: dump
has answer: http://stackoverflow.com/a/37387623
answer count: 10
favorite count: 0
has answer: http://stackoverflow.com/a/8138687
has answer: http://stackoverflow.com/a/18422541
tagged with: properties
accepted answer: http://stackoverflow.com/a/603055
tagged with: tostring
type: AnsweredQuestion
score: 71
has answer: http://stackoverflow.com/a/4272554
downvote count: 0
tagged with: reflection
has body: Is there a library that will recursively dump/print an objects properties? I'm looking for something similar to the console.dir() function in Firebug. I'm aware of the commons-lang ReflectionToStringBuilder but it does not recurse into an object. I.e., if I run the following: public class ToString { public static void main(String [] args) { System.out.println(ReflectionToStringBuilder.toString(new Outer(), ToStringStyle.MULTI_LINE_STYLE)); } private static class Outer { private int intValue = 5; private Inner innerValue = new Inner(); } private static class Inner { private String stringValue = "foo"; } } I receive: ToString$Outer@1b67f74[ intValue=5 innerValue=ToString$Inner@530daa ] I realize that in my example, I could have overriden the toString() method for Inner but in the real world, I'm dealing with external objects that I can't modify.
linked to: http://stackoverflow.com/q/3149951
tagged with: java
linked to: http://stackoverflow.com/q/37628
has title: Dumping a java object's properties
has answer: http://stackoverflow.com/a/603055
type: Question

http://stackoverflow.com/comment/283610
score: 0
has text: I usually have this class knocking about in each codebase I work on. I'd also add: a hashCode/equals implementation, and possibly a static isInstance() and cast() method.
type: Comment
comment on: http://stackoverflow.com/a/457673
type: AnswerComment

http://stackoverflow.com/comment/97976963
type: Comment
type: QuestionComment
score: 7
comment on: http://stackoverflow.com/q/613954
has text: The strongest argument I know *for* checked exceptions is that they weren't originally there in Java, and that when they were introduced they discovered hundreds of bugs in the JDK. This is somewhat prior to Java 1.0. I personally would not be without them, and disagree violently with Bruce Eckel and others on this.

http://stackoverflow.com/a/628212
upvote count: 3
score: 3
type: AcceptedAnswer
downvote count: 0
has body: One of the key factor which make my current Ternary Search Tree difficult to support case insensitive search is that, my underlying data structure is one-to-one mapping. Please look at the following test code : public void testPut() { System.out.println("put"); Name name0 = new Name("abc"); Name name1 = new Name("abc"); TernarySearchTree&lt;Name&gt; instance = new TernarySearchTree&lt;Name&gt;(); instance.put(name0.toString(), name0); instance.put(name1.toString(), name1); assertEquals(2, instance.matchPrefix("a").size()); // fail here. Result is 1 } What my current short-term solution is that, I am using TSTSearchEngine to wrap up the whole TernarySearchTree. TSTSearchEngine is comprised of (1) A TernarySearchTree, providing UPPER-CASE key to map. (2) A String-To-ArrayList map. Here is what happen when I perform : TSTSearchEngine&lt;Name&gt; engine = TSTSearchEngine&lt;Name&gt;(); engine.put(name0); // name0 is new Name("Abc"); engine.put(name1); // name0 is new Name("aBc"); (1) name0.toString() will be converted to UPPER-CASE ("ABC"). It will be inserted to TernarySearchTree. "ABC" will be both key and value for TernarySearchTree. (2) "ABC" will use as the key for map, to insert name0 into an array list. (3) name1.toString() will be converted to UPPER-CASE ("ABC"). It will be inserted to TernarySearchTree. S1 will be both key and value for TernarySearchTree. (4) "ABC" will use as the key for map, to insert name1 into an array list. When I try to engine.searchAll("a"); (1) TernarySearchTree will return "ABC". (2) "ABC" will be used as the key to access map. Map will return an array list, which is containing name0 and name1. This solution works. The sample code can be referred to Sample Code for New TSTSearchEngine However, this may not be an effective solution, as it requires two pass of search. I find out there is an implementation in C++ C++ Implementation of Case Insensitive Ternary Search Tree. Hence, there is an opportunity that C++ code can be ported over to …
accepted answer of: http://stackoverflow.com/q/618086
type: Answer
answers question: http://stackoverflow.com/q/618086

http://stackoverflow.com/a/570891
answers question: http://stackoverflow.com/q/570785
has body: Also, just before the call to sel.setVisible(true); pls invoke sel.pack(); Pls note that instead of setSize it is better to use setPreferredSize, which is leveraged during frame packing. Not directly relevant to your question, but still -- the use of a good layout manager is a huge time and frustration saviour when using Swing. MigLayout is simply an excellent one-stop layout manager.
score: 0
type: Answer

http://stackoverflow.com/a/9418812
has comment: http://stackoverflow.com/comment/43124751
has comment: http://stackoverflow.com/comment/20576578
upvote count: 138
has comment: http://stackoverflow.com/comment/43064117
has comment: http://stackoverflow.com/comment/43042488
has comment: http://stackoverflow.com/comment/25001978
has comment: http://stackoverflow.com/comment/25013366
has comment: http://stackoverflow.com/comment/24963529
type: Answer
has body: I know this question is quite old, but as new software comes out it does help to get some new links to projects that might be interesting for folks. imgscalr is pure-Java image resizing (and simple ops like padding, cropping, rotating, brighten/dimming, etc.) library that is painfully simple to use - a single class consists of a set of simple graphics operations all defined as static methods that you pass an image and get back a result. The most basic example of using the library would look like this: BufferedImage thumbnail = Scalr.resize(image, 150); And a more typical usage to generate image thumbnails using a few quality tweaks and the like might look like this: import static org.imgscalr.Scalr.*; public static BufferedImage createThumbnail(BufferedImage img) { // Create quickly, then smooth and brighten it. img = resize(img, Method.SPEED, 125, OP_ANTIALIAS, OP_BRIGHTER); // Let's add a little border before we return result. return pad(img, 4); } All image-processing operations use the raw Java2D pipeline (which is hardware accelerated on major platforms) and won't introduce the pain of calling out via JNI like library contention in your code. imgscalr has also been deployed in large-scale productions in quite a few places - the inclusion of the AsyncScalr class makes it a perfect drop-in for any server-side image processing. There are numerous tweaks to image-quality you can use to trade off between speed and quality with the highest ULTRA_QUALITY mode providing a scaled result that looks better than GIMP's Lancoz3 implementation.
has comment: http://stackoverflow.com/comment/19671060
answers question: http://stackoverflow.com/q/603283
score: 138
downvote count: 0
has comment: http://stackoverflow.com/comment/45188431
has comment: http://stackoverflow.com/comment/19699125
has comment: http://stackoverflow.com/comment/43066608
has comment: http://stackoverflow.com/comment/25046010
has comment: http://stackoverflow.com/comment/20527171
has comment: http://stackoverflow.com/comment/99213361

http://stackoverflow.com/a/5079330
downvote count: 0
answers question: http://stackoverflow.com/q/643280
has body: if you are using oracle 10g, and your number columns defined with number and no scale size create table EXAMPLE ( FILED1 NUMBER(2,0), FILED2 NUMBER ) while populating FIELD2, you will receive this exception. Check your table structure for number fields. i hope this may help you.
type: Answer
upvote count: 1
score: 1

http://stackoverflow.com/comment/308396
type: Comment
has text: Depends on what you want to do, but I'd say yes in most cases - it's specifically purposed to be used with JSP, as opposed to the generic Writer abstract class which you'd need to use to leverage polymorphism.
comment on: http://stackoverflow.com/a/492687
score: 1
type: AnswerComment

http://stackoverflow.com/comment/344658
type: Comment
comment on: http://stackoverflow.com/a/531297
score: 0
has text: Yes and the best way to write maintainable code is to write it straightforward (ie eager). Caching for performance tends to grealty complicate code, which is counterproductive if performance isn't evne an issue.
type: AnswerComment

database
tags question: http://stackoverflow.com/q/377745
tags question: http://stackoverflow.com/q/560710
tags question: http://stackoverflow.com/q/416432
tags question: http://stackoverflow.com/q/381373
tags question: http://stackoverflow.com/q/560063
tags question: http://stackoverflow.com/q/590899
tags question: http://stackoverflow.com/q/602800
tags question: http://stackoverflow.com/q/458879
tags question: http://stackoverflow.com/q/388206
type: Tag
tags question: http://stackoverflow.com/q/453545
tags question: http://stackoverflow.com/q/449557
tags question: http://stackoverflow.com/q/462923
tags question: http://stackoverflow.com/q/539288
tags question: http://stackoverflow.com/q/536073
tags question: http://stackoverflow.com/q/473088
tags question: http://stackoverflow.com/q/624468
tags question: http://stackoverflow.com/q/560679
tag name: database
tags question: http://stackoverflow.com/q/418146
tags question: http://stackoverflow.com/q/512595
tags question: http://stackoverflow.com/q/490288
tags question: http://stackoverflow.com/q/364472
tags question: http://stackoverflow.com/q/584497
tags question: http://stackoverflow.com/q/424696
tags question: http://stackoverflow.com/q/618919
tags question: http://stackoverflow.com/q/574984
tags question: http://stackoverflow.com/q/588103
tags question: http://stackoverflow.com/q/494724
tags question: http://stackoverflow.com/q/423704
tags question: http://stackoverflow.com/q/608923
tags question: http://stackoverflow.com/q/415779
tags question: http://stackoverflow.com/q/520595
tags question: http://stackoverflow.com/q/495376
tags question: http://stackoverflow.com/q/494860
tags question: http://stackoverflow.com/q/638421
tags question: http://stackoverflow.com/q/439958
tags question: http://stackoverflow.com/q/404275
tags question: http://stackoverflow.com/q/516364
tags question: http://stackoverflow.com/q/642241
tags question: http://stackoverflow.com/q/513343
tags question: http://stackoverflow.com/q/493947
tags question: http://stackoverflow.com/q/620551
tags question: http://stackoverflow.com/q/394627
tags question: http://stackoverflow.com/q/360026
tags question: http://stackoverflow.com/q/456532

http://stackoverflow.com/comment/108397159
type: Comment
comment on: http://stackoverflow.com/a/2326244
type: AnswerComment
has text: this is a misleading answer. PriorityQueue is a heap and does not 'maintain a sorted list'. the only way to get the sorted list from it is to drain the PriorityQueue which is destructive and is not the best or even feasible way.
score: 0

http://stackoverflow.com/q/467657
upvote count: 1
tagged with: swing
has answer: http://stackoverflow.com/a/469094
has answer: http://stackoverflow.com/a/467670
answer count: 4
tagged with: java
has answer: http://stackoverflow.com/a/467706
has body: Is it possible to write "pure" lightweight code in java? Swing is lightweight but even it has heavyweight components like JWindow, JFrame, JDialog, and JApplet. So even Swing applications are not 100 percent independent of the underlying OS Is it possible to have lightweight applications in java which are completely independent of the underlying OS for graphics display? Is it possible to write such code in java?
type: Question
downvote count: 0
has answer: http://stackoverflow.com/a/467705
favorite count: 0
score: 1
has title: Pure lightweight application in java
type: UnansweredQuestion

http://stackoverflow.com/a/643158
accepted answer of: http://stackoverflow.com/q/561858
score: 1
upvote count: 1
has body: In LiveCycle Administration Console simply go to Home > Services > Applications and Services > Service Management > ConvertPdfService The service timeout can be changed there. When testing with converting pdf (generated by iText) that contains 39k pages (13 initial, each cloned 3000 times, size ~15Mb) -final output PostScript file was ~1,25Gb. Whole work took about 2 hours. But it worked, no problems. (I guess this answer makes the question not-programming related, but hey.)
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/561858

http://stackoverflow.com/q/415649
tagged with: jsp
tagged with: spinner
favorite count: 0
tagged with: tld
has title: Read only spinner
possible better answer: http://stackoverflow.com/a/415675
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/415675
score: 3
tagged with: jsf
has answer: http://stackoverflow.com/a/506780
upvote count: 3
tagged with: java
has body: I am learning Jsf.Is there any method for making the spinners read only?I should change the value only using spinners and not directly typing the number.Can i implement that by setting attribute in the spinners.tld file?
type: Question
accepted answer: http://stackoverflow.com/a/506780
answer count: 2
downvote count: 0

http://stackoverflow.com/a/484255
has comment: http://stackoverflow.com/comment/66859550
has body: From the Javadocs: Typically, data is read from a PipedInputStream object by one thread and data is written to the corresponding PipedOutputStream by some other thread. Attempting to use both objects from a single thread is not recommended, as it may deadlock the thread. This may partially explain why it is not more commonly used. I'd assume another reason is that many developers do not understand its purpose / benefit.
has comment: http://stackoverflow.com/comment/300961
accepted answer of: http://stackoverflow.com/q/484119
has comment: http://stackoverflow.com/comment/301071
has comment: http://stackoverflow.com/comment/39912396
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/12002759
score: 57
upvote count: 57
answers question: http://stackoverflow.com/q/484119
type: Answer
has comment: http://stackoverflow.com/comment/84255856

http://stackoverflow.com/a/537825
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/537366
downvote count: 0
score: 4
answers question: http://stackoverflow.com/q/537366
type: Answer
has body: The documentation for Javadoc says that a list of paths is allowed. Ensure that you're using the correct path-separating character, either ';' or ':' depending on whether you're on Windows or UNIX (respectively). NOTE: If you're truly using java and not javadoc to execute your doclet, then check the implementation of your class. -docletpath is not a standard option to the java executable, so must be being interpreted by your doclet implementation. However, if you're using javadoc then the documentation I pointed to above says: If classpathlist contains multiple paths or jar files, they should be separated with a colon (:) on Solaris and a semi-colon (;) on Windows.
has comment: http://stackoverflow.com/comment/350259
upvote count: 4

http://stackoverflow.com/comment/75543062
type: Comment
score: 2
has text: Would like to know what explicit string or character value other than "ACTIVE" you do store in the database.
comment on: http://stackoverflow.com/a/492126
type: AnswerComment

http://stackoverflow.com/comment/371450
type: Comment
comment on: http://stackoverflow.com/a/559784
has text: Vector is a legacy class don't use. use ArrayList instead
score: 0
type: AnswerComment

http://stackoverflow.com/comment/29126609
type: AnswerComment
score: 1
has text: there are java shells that can run java code without separate (user visible) compile steps.
type: Comment
comment on: http://stackoverflow.com/a/441901

http://stackoverflow.com/comment/275504
type: Comment
comment on: http://stackoverflow.com/a/454913
type: AnswerComment
score: 47
has text: A JTextArea document SHOULD use only '\n'; its Views completely ignore '\r'. But if you're going to look for more than one kind of separator, you might as well look for all three: "\r?\n|\r".

http://stackoverflow.com/a/963648
answers question: http://stackoverflow.com/q/428073
type: Answer
upvote count: 11
downvote count: 0
score: 11
has body: What is the best/simplest library to use in order to read in values from this file? As you're asking for the simplest library, I feel obliged to add an approach quite different to that in Guillaume's top-voted answer. (Of the other answers, sjbotha's JDOM mention is closest to what I suggest). I've come to think that for XML handling in Java, using the standard JDK tools is certainly not the simplest way, and that only in some circumstances (such as not being able to use 3rd party libraries, for some reason) it is the best way. Instead, consider using a good XML library, such as XOM. Here's how to read an XML file into a nu.xom.Document object: import nu.xom.Builder; import nu.xom.Document; import java.io.File; [...] File file = new File("some/path"); Document document = new Builder().build(file); So, this was just a little bit simpler, as reading the file into org.w3c.dom.Document wasn't very complicated either, in the "pure JDK" approach. But the advantages of using a good library only start here! Whatever you're doing with your XML, you'll often get away with much simpler solutions, and less of your own code to maintain, when using a library like XOM. As examples, consider this vs. this, or this vs. this, or this post containing both XOM and W3C DOM examples. Others will provide counter-arguments (like these) for why sticking to Java's standard XML APIs may be worth it - these probably have merit, at least in some cases, although personally I don't subscribe to all of them. In any case, when choosing one way or the other, it's good to be aware of both sides of the story. (This answer is part of my evaluation of XOM, which is a strong contender in my quest for finding the best Java XML library to replace dom4j.)
has comment: http://stackoverflow.com/comment/772270

http://stackoverflow.com/q/477881
possible better answer: http://stackoverflow.com/a/477977
score: 2
type: AnsweredQuestion
tagged with: java
has title: Java: Allocate uninitialized block of memory?
type: Question
downvote count: 0
has body: Is there a way to allocate an uninitialized block of memory, such as an array that contains whatever garbage happened to be left behind, in Java? I want to do so to benchmark how fast Java's memory allocator/garbage collector can allocate/free blocks of memory.
has answer: http://stackoverflow.com/a/477949
answer count: 6
accepted answer: http://stackoverflow.com/a/477882
has answer: http://stackoverflow.com/a/477977
favorite count: 0
tagged with: memory-management
has answer: http://stackoverflow.com/a/478886
has answer: http://stackoverflow.com/a/477929
upvote count: 2
has answer: http://stackoverflow.com/a/477882
has answer: http://stackoverflow.com/a/477902

http://stackoverflow.com/comment/276387
score: 0
type: Comment
type: QuestionComment
has text: Very interesting question, and I did not know Java behaved this way. I tend to use equals() whenever I can, so I have been lucky enough to avoid this problem.
comment on: http://stackoverflow.com/q/456575

http://stackoverflow.com/comment/114184224
score: 0
type: Comment
has text: JPA libs as of 10/2020 throw runtime exception "not a managed entity"
comment on: http://stackoverflow.com/a/644777
type: AnswerComment

http://stackoverflow.com/a/499461
downvote count: 3
has body: My feeling is that the checked exception is a useful contract that should be used sparingly. The classic example of where I think a checked exception is a good idea is an InterruptedException. My feeling is that I do want to be able to stop a thread / process when I want it to stop, regardless of how long someone has specified to Thread.sleep(). So, trying to answer your specific question, is this something that you absolutely want to make sure that everyone deals with? To my mind, a situation where an Account doesn't have enough money is a serious enough problem that you have to deal with it. In response to Peter's comment: here's an example using InterruptedException as concrete case of an exception that should be handled and you need to have a useful default handler. Here is what I strongly recommend, certainly at my real job. You should at least do this: catch (InterruptedException ie) { Thread.currentThread().interrupt(); } That handler will ensure that the code catches the checked exception and does exactly what you want: get this thread to stop. Admittedly, if there's another exception handler / eater upstream, it's not impossible that it will handle the exception less well. Even so, FindBugs can help you find those. Now, reality sets in: you can't necessarily force everyone who writes an exception handler for your checked exception to handle it well. That said, at least you'll be able to "Find Usages" and know where it is used and give some advice. Short form: you're inflicting a load the users of your method if you use a checked exception. Make sure that there's a good reason for it, recommend a correct handling method and document all this extensively.
has comment: http://stackoverflow.com/comment/315022
type: Answer
has comment: http://stackoverflow.com/comment/315374
answers question: http://stackoverflow.com/q/499437
upvote count: 8
score: 5
has comment: http://stackoverflow.com/comment/315498

http://stackoverflow.com/a/546978
type: Answer
answers question: http://stackoverflow.com/q/545391
score: 2
downvote count: 0
has body: The way I deal with any variable I declare is to decide if it will change over the lifetime of the object (or class if it is static). If the answer is "no" then I make it final. Making it final forces you to give it a value when the object is created... personally I would do the following unless I knew that I would be changing what the point at: private final ItemMaster itemMaster; private final List components; // instance initialization block - happens at construction time { itemMaster = new ItemMaster(); components = new ArrayList(); } The way your code is right now you must check for null all the time because you didn't mark the variables as private (which means that any class in the same package can change the values to null).
upvote count: 2
has comment: http://stackoverflow.com/comment/361578
has comment: http://stackoverflow.com/comment/359586

http://stackoverflow.com/q/645464
favorite count: 0
has title: Which do you prefer: Java Web Start, or Java Applets?
has answer: http://stackoverflow.com/a/645545
answer count: 5
accepted answer: http://stackoverflow.com/a/645529
possible better answer: http://stackoverflow.com/a/649240
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/649240
tagged with: java
has answer: http://stackoverflow.com/a/5097998
has answer: http://stackoverflow.com/a/646745
type: Question
score: 5
upvote count: 5
has answer: http://stackoverflow.com/a/645529
tagged with: java-web-start
has body: Which do you think is better as a programmer, and as a end user, and why?
downvote count: 0
tagged with: applet

http://stackoverflow.com/comment/204284
type: Comment
comment on: http://stackoverflow.com/a/376354
type: AnswerComment
score: 0
has text: A lot of these items while are undefined, shouldn't ever be defined. And then there are others that are pitfalls and not undefined.

http://stackoverflow.com/a/465164
type: AcceptedAnswer
has body: If you are using a QueryParser object to parse your query, you can configure it to automatically assume the '+' operator that Aku spoke of in his answer (sorry Aku for not simply commenting, but comments apparently don't support code formatting). For example: String defaultField = ...; Analyzer analyzer = ...; QueryParser queryParser = new QueryParser(defaultField, analyzer); queryParser.setDefaultOperator(QueryParser.Operator.AND); Query query = queryParser.parse("Searching is fun");
score: 4
has comment: http://stackoverflow.com/comment/66301279
type: Answer
upvote count: 4
accepted answer of: http://stackoverflow.com/q/465118
downvote count: 0
answers question: http://stackoverflow.com/q/465118

http://stackoverflow.com/comment/1317744
comment on: http://stackoverflow.com/a/1466595
score: 0
type: AnswerComment
has text: sorry?? should I answer? please, don't spam lookin' for score.
type: Comment

http://stackoverflow.com/a/513935
has comment: http://stackoverflow.com/comment/46276948
has comment: http://stackoverflow.com/comment/15404047
type: Answer
has body: == tests object references, .equals() tests the string values. Sometimes it looks as if == compares values, because Java does some behind-the-scenes stuff to make sure identical in-line strings are actually the same object. For example: String fooString1 = new String("foo"); String fooString2 = new String("foo"); // Evaluates to false fooString1 == fooString2; // Evaluates to true fooString1.equals(fooString2); // Evaluates to true, because Java uses the same object "bar" == "bar"; But beware of nulls! == handles null strings fine, but calling .equals() from a null string will cause an exception: String nullString1 = null; String nullString2 = null; // Evaluates to true System.out.print(nullString1 == nullString2); // Throws a NullPointerException System.out.print(nullString1.equals(nullString2)); So if you know that fooString1 may be null, tell the reader that by writing System.out.print(fooString1 != null &amp;&amp; fooString1.equals("bar")); The following are shorter, but it’s less obvious that it checks for null: System.out.print("bar".equals(fooString1)); // "bar" is never null System.out.print(Objects.equals(fooString1, "bar")); // Java 7 required
upvote count: 796
has comment: http://stackoverflow.com/comment/85433552
has comment: http://stackoverflow.com/comment/47320289
downvote count: 0
has comment: http://stackoverflow.com/comment/89559628
has comment: http://stackoverflow.com/comment/37587768
has comment: http://stackoverflow.com/comment/124052474
has comment: http://stackoverflow.com/comment/58359031
score: 796
has comment: http://stackoverflow.com/comment/37768459
answers question: http://stackoverflow.com/q/513832

http://stackoverflow.com/comment/447102
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/632218
score: 0
has text: No, there shouldn't be any backslashes in the replacement string.

http://stackoverflow.com/comment/236751
has text: My point is this: fixing the "immediate error" is often misleading and unhelpful. I find that there are numerous standard mistakes, many of which are fundamental misconceptions. I prefer to address those fundamental issues which surface as an "immediate error" that's really confusing.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/409941
type: AnswerComment

http://stackoverflow.com/q/605828
accepted answer: http://stackoverflow.com/a/605832
type: Question
upvote count: 46
possible better answer: http://stackoverflow.com/a/605837
tagged with: java
has title: Does it matter what I choose for serialVersionUID when extending Serializable classes in Java?
answer count: 2
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/605832
tagged with: serialization
score: 46
has body: I'm extending a class (ArrayBlockingQueue) that implements the Serializable interface. Sun's documentation (and my IDE) advises me that I should set this value in order to prevent mischief: However, it is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpected InvalidClassExceptions during deserialization. Now, I couldn't care less about what value to put in there. Does it matter?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/605837

http://stackoverflow.com/comment/92904346
type: Comment
has text: so it's wrong to equal "sequence of bytes " with "binary"?how can I understand "sequence of bytes "? since the serilized format "class:O","c" will finally convert to binary ,can I think JSON etc format serializer work above binary format like Thrift ?
score: 0
comment on: http://stackoverflow.com/a/448233
type: AnswerComment

http://stackoverflow.com/a/377895
has body: In both cases the type info for the object o is determined at compile time.In the second instance, o is seen as being global to the for loop and in the first instance, the clever Java compiler knows that o will have to be available for as long as the loop lasts and hence will optimise the code in such a way that there wont be any respecification of o's type in each iteration. Hence, in both cases, specification of o's type will be done once which means the only performance difference would be in the scope of o. Obviously, a narrower scope always enhances performance, therefore to answer your question: no, there is no performance penalty for the first code snip; actually, this code snip is more optimised than the second. In the second snip, o is being given unnecessary scope which, besides being a performance issue, can be also a security issue.
score: 0
answers question: http://stackoverflow.com/q/377763
type: Answer

http://stackoverflow.com/a/467366
downvote count: 0
has body: Here's an example using GarbageCollectorMXBean to print out GC stats. Presumably you would call this method periodically, e.g. scheduling using a ScheduledExecutorService. public void printGCStats() { long totalGarbageCollections = 0; long garbageCollectionTime = 0; for(GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) { long count = gc.getCollectionCount(); if(count &gt;= 0) { totalGarbageCollections += count; } long time = gc.getCollectionTime(); if(time &gt;= 0) { garbageCollectionTime += time; } } System.out.println("Total Garbage Collections: " + totalGarbageCollections); System.out.println("Total Garbage Collection Time (ms): " + garbageCollectionTime); }
score: 58
type: Answer
upvote count: 58
has comment: http://stackoverflow.com/comment/72221356
has comment: http://stackoverflow.com/comment/72222045
has comment: http://stackoverflow.com/comment/72273711
has comment: http://stackoverflow.com/comment/72433469
answers question: http://stackoverflow.com/q/466878
has comment: http://stackoverflow.com/comment/285443
accepted answer of: http://stackoverflow.com/q/466878
has comment: http://stackoverflow.com/comment/285440
type: AcceptedAnswer

http://stackoverflow.com/comment/60790355
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/427101
has text: I appreciate the connection with multiplication, but it seems to break down if we move away from "bounds" known prior the outer level. If one has e.g. `for (shelf : library) {for (book : shelf) {for (page : book) {...}}}` that has a different "shape" than the one resulting from `xs`, `ys`, and `zs` being established outside the entire construct.

http://stackoverflow.com/comment/377959
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/564039
type: Comment
has text: Does the memory usage stay constant once you hit a high point or does it keep going up? If it keeps going up you either have a legitimate long-held objects ore you have a memory leak.

http://stackoverflow.com/a/16249959
upvote count: 15
has comment: http://stackoverflow.com/comment/30929877
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/368094
has body: On my machine I tried check it. My result: Calendar.getInstance().getTime() (*1000000 times) = 402ms new Date().getTime(); (*1000000 times) = 18ms System.currentTimeMillis() (*1000000 times) = 16ms Don't forget about GC (if you use Calendar.getInstance() or new Date())
score: 15

http://stackoverflow.com/q/634801
upvote count: 1
possible better answer: http://stackoverflow.com/a/634871
downvote count: 0
answer count: 3
tagged with: junit
has answer: http://stackoverflow.com/a/634863
has title: Why does a junit test fail in eclipse but pass from ant?
favorite count: 0
accepted answer: http://stackoverflow.com/a/634863
has answer: http://stackoverflow.com/a/634871
type: AnsweredQuestion
score: 1
tagged with: java
tagged with: eclipse
has body: I have a JUnit test that is checking to make sure that a customized xml serialization is working properly. The customized xml serialization is just a few custom converters for Xstream. The deserializers work, but for some reason in Eclipse 3.x, JUnit fails the serialization. In Ant on the command line, it works just fine. It also works just fine in Eclipse if I debug and step through the test case, but if put a break point after the failing testcase executes it fails still. What gives? Am I having a class path issue? Some additional information: Expected: origin 0.6.0 Stuff ./fake-file.xml <latitude deg="44" min="26" sec="37.640"/> <longitude deg="-57" min="-38" sec="-6.877"/> <ellipsoid-height value="-79.256" units="meters"/> <geoid-height value="0.000" units="meters"/> Actual: origin 0.6.0 Stuff ./fake-file.xml <latitude deg="44" min="26" sec="37.640"/> <longitude deg="-57" min="-38" sec="-6.877"/> <ellipsoid-height value="-79.256" units="meters"/> <geoid-height value="-79.256" units="meters"/> The code that writes the location fields: public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { ILatLonEllipsoidHeightPoint aLoc = (ILatLonEllipsoidHeightPoint) source; synchronized(aLoc) { writer.startNode(LATITUDE); writer.addAttribute(DEGREES, Integer.toString( PointUnitConversions.getLatitudeHours(aLoc.getLatitude()))); writer.addAttribute(MINUTES, Integer.toString( PointUnitConversions.getLatitudeMinutes(aLoc.getLatitude()))); writer.addAttribute(SECONDS, String.format("%.3f", PointUnitConversions.getLatitudeSeconds(aLoc.getLatitude()))); writer.endNode(); writer.startNode(LONGITUDE); writer.addAttribute(DEGREES, Integer.toString( PointUnitConversions.getLongitudeHours(aLoc.getLongitude()))); writer.addAttribute(MINUTES, Integer.toString( PointUnitConversions.getLongitudeMinutes(aLoc.getLongitude()))); writer.addAttribute(SECONDS, String.format("%.3f", PointUnitConversions.getLongitudeSeconds(aLoc.getLongitude()))); writer.en…
type: Question
has answer: http://stackoverflow.com/a/635020

http://stackoverflow.com/a/500595
type: Answer
answers question: http://stackoverflow.com/q/500508
downvote count: 2
score: 11
upvote count: 13
has comment: http://stackoverflow.com/comment/69169351
has body: Personally I don't use final on method parameters, because it adds too much clutter to parameter lists. I prefer to enforce that method parameters are not changed through something like Checkstyle. For local variables I use final whenever possible, I even let Eclipse do that automatically in my setup for personal projects. I would certainly like something stronger like C/C++ const.

http://stackoverflow.com/a/462422
answers question: http://stackoverflow.com/q/462373
has comment: http://stackoverflow.com/comment/52784618
type: Answer
has comment: http://stackoverflow.com/comment/55619046
downvote count: 1
score: -1
has body: so you are inside a for or while loop. Using break; will put you outside of the loop. As in, it will end. Continue; will tell it to run the next iteration. No point in using continue in if statement, but break; is useful. In switch...case, always use break; to end a case, so it does not executes another case.
upvote count: 0

http://stackoverflow.com/comment/49488557
type: Comment
comment on: http://stackoverflow.com/a/462648
score: 0
type: AnswerComment
has text: @NamshubWriter AFAIK this is because CAS can be mapped to atomic CAS ops on the underlying machine whereas volatile cannot be (in all cases). At least this was said when java.lang.atomic was introduced several years ago, so it needs not to be true anymore. Just google for it and I guess you'll find a lot of references.

http://stackoverflow.com/comment/448257
score: 9
type: AnswerComment
type: Comment
has text: Except, of course, if you're writing a desktop app and processing some user-specified text that does not have any encoding metadata - then the platform default encoding is your best guess as to what the user might be using.
comment on: http://stackoverflow.com/a/361981

http://stackoverflow.com/a/56672135
upvote count: 5
downvote count: 0
answers question: http://stackoverflow.com/q/454908
type: Answer
has body: The above answers did not help me on Android, thanks to the Pshemo response that worked for me on Android. I will leave some of Pshemo's answer here : split("\\\\n")
score: 5

http://stackoverflow.com/a/18695227
has body: Actually,there are three ways to avoid the Lazy Initialization Exception: Set the lazy property to false in the mapping file.I don’t recommend this approach because it will increment the database load and therefore, it will produce a decrease in performance. Keep the session open. Don't close the session before you have processed the data. If the session is open during the request you could get the associated graph but you need to be sure that the action takes within the same transaction. Eagerly fetch the associations. In the HQL query use the keyword "fetch" to retrieve the association. From my point of view this is the best solution to avoid the lazy initialization problem. In HQL, you just need to add the fetch keyword in the from clause to eagerly fetch an association. Here is an example: from Doctor doc left join fetch doc.patients where doc.name like ‘Doctor A%’ I have written a post about this issue, with some code examples and links to the github project: http://ignaciosuay.com/how-to-avoid-hibernate-lazy-initialization-exception/
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/631695
downvote count: 0
score: 1

http://stackoverflow.com/q/501277
type: AnsweredQuestion
has title: Why doesn't Java allow generic subclasses of Throwable?
has comment: http://stackoverflow.com/comment/316458
tagged with: language-design
tagged with: java
has comment: http://stackoverflow.com/comment/31947614
upvote count: 193
has comment: http://stackoverflow.com/comment/906426
type: Question
has answer: http://stackoverflow.com/a/46502318
accepted answer: http://stackoverflow.com/a/501309
answer count: 6
score: 192
has comment: http://stackoverflow.com/comment/316474
downvote count: 1
has answer: http://stackoverflow.com/a/501309
has body: According to the Java Language Sepecification, 3rd edition: It is a compile-time error if a generic class is a direct or indirect subclass of Throwable. I wish to understand why this decision has been made. What's wrong with generic exceptions? (As far as I know, generics are simply compile-time syntactic sugar, and they will be translated to Object anyway in the .class files, so effectively declaring a generic class is as if everything in it was an Object. Please correct me if I'm wrong.)
tagged with: generics
has answer: http://stackoverflow.com/a/501287
favorite count: 0
linked to: http://stackoverflow.com/q/30759692
possible better answer: http://stackoverflow.com/a/28408543
tagged with: exception
has answer: http://stackoverflow.com/a/67581271
has answer: http://stackoverflow.com/a/28408543
has answer: http://stackoverflow.com/a/501284

http://stackoverflow.com/comment/85983473
type: AnswerComment
comment on: http://stackoverflow.com/a/21793314
type: Comment
score: 2
has text: the best solution.

http://stackoverflow.com/comment/250384
score: 0
type: Comment
type: QuestionComment
has text: Unless you need built-in synchronization ArrayList would be a better choice than Vector
comment on: http://stackoverflow.com/q/426655

http://stackoverflow.com/a/640187
downvote count: 0
score: 5
has body: Netbeans has tomcat integration. By that I mean you can start and stop tomcat, deploy, profile and debug your app running in tomcat from the IDE. Best Practices for Apache Maven in NetBeans 6.x
answers question: http://stackoverflow.com/q/640161
type: Answer
upvote count: 5

http://stackoverflow.com/q/443499
has answer: http://stackoverflow.com/a/73377646
has answer: http://stackoverflow.com/a/25288414
upvote count: 255
has answer: http://stackoverflow.com/a/60849830
has answer: http://stackoverflow.com/a/78407622
has answer: http://stackoverflow.com/a/68043471
has answer: http://stackoverflow.com/a/548871
has answer: http://stackoverflow.com/a/987524
has answer: http://stackoverflow.com/a/36082630
has answer: http://stackoverflow.com/a/4149555
linked to: http://stackoverflow.com/q/60329223
has answer: http://stackoverflow.com/a/583634
accepted answer: http://stackoverflow.com/a/583634
favorite count: 0
tagged with: parsing
has answer: http://stackoverflow.com/a/45982024
answer count: 20
linked to: http://stackoverflow.com/q/21720759
score: 255
has answer: http://stackoverflow.com/a/34706883
has answer: http://stackoverflow.com/a/62851192
tagged with: collections
has answer: http://stackoverflow.com/a/8726007
has answer: http://stackoverflow.com/a/60937460
has comment: http://stackoverflow.com/comment/41943429
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/39444061
has title: Convert JSON to Map
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has body: What is the best way to convert a JSON code as this: { "data" : { "field1" : "value1", "field2" : "value2" } } in a Java Map in which one the keys are (field1, field2) and the values for those fields are (value1, value2). Any ideas? Should I use Json-lib for that? Or better if I write my own parser?
has answer: http://stackoverflow.com/a/32066515
has answer: http://stackoverflow.com/a/8339656
possible better answer: http://stackoverflow.com/a/8132308
has answer: http://stackoverflow.com/a/46947745
type: Question
has answer: http://stackoverflow.com/a/8132308

http://stackoverflow.com/comment/132326171
comment on: http://stackoverflow.com/a/435967
score: 1
type: AnswerComment
has text: Much appreciated for your time. Definitely helped me get a much clearer view on the subject. Thanks!
type: Comment

http://stackoverflow.com/q/507660
possible better answer: http://stackoverflow.com/a/10130618
has title: Problem with FTPClient class in java
has answer: http://stackoverflow.com/a/10130618
has comment: http://stackoverflow.com/comment/322129
downvote count: 0
score: 8
favorite count: 0
upvote count: 8
has answer: http://stackoverflow.com/a/507776
tagged with: ftp
type: AnsweredQuestion
tagged with: apache-commons
tagged with: java
accepted answer: http://stackoverflow.com/a/507776
type: Question
answer count: 2
has body: I'm using org.apache.commons.net.ftp.FTPClient and seeing behavior that is, well... perplexing. The method beneath intends to go through an FTPFile list, read them in and then do something with the contents. That's all working. What is not (really) working is that the FTPClient object does the following... 1) Properly retrieves and stores the FIRST file in the list 2) List item evaluates to NULL for x number of successive iterations of the loop (x varies on successive attempts 3) manages to retrieve exactly 1 more file in the list 4) reports that it is null for exactly 1 more file in the list 5) hangs indefinitely, reporting no further activity. public static String mergeXMLFiles(List&lt;FTPFile&gt; files, String rootElementNodeName, FTPClient ftp){ String ret = null; String fileAsString = null; //InputStream inStream; int c; if(files == null || rootElementNodeName == null) return null; try { System.out.println("GETTING " + files.size() + " files"); for (FTPFile file : files) { fileAsString = ""; InputStream inStream = ftp.retrieveFileStream(file.getName()); if(inStream == null){ System.out.println("FtpUtil.mergeXMLFiles() couldn't initialize inStream for file:" + file.getName()); continue;//THIS IS THE PART THAT I SEE FOR files [1 - arbitrary number (usually around 20)] and then 1 more time for [x + 2] after [x + 1] passes successfully. } while((c = inStream.read()) != -1){ fileAsString += Character.valueOf((char)c); } inStream.close(); System.out.println("FILE:" + file.getName() + "\n" + fileAsString); } } catch (Exception e) { System.out.println("FtpUtil.mergeXMLFiles() failed:" + e); } return ret; } has anyone seen anything like this? I'm new to FTPClient, am I doing something wrong with it?

http://stackoverflow.com/a/698636
has comment: http://stackoverflow.com/comment/32928786
downvote count: 0
answers question: http://stackoverflow.com/q/529309
upvote count: 2
type: Answer
score: 2
has body: For the archive, there's also AltovaXML, the free-as-in-beer, schema-aware XSLT 2.0 engine used in XMLSpy etc. Unfortunately, like XMLSpy, it's Windows only.

http://stackoverflow.com/q/481705
score: 21
tagged with: java
upvote count: 21
type: Question
tagged with: dependency-injection
tagged with: guice
answer count: 6
has answer: http://stackoverflow.com/a/542910
has answer: http://stackoverflow.com/a/525018
downvote count: 0
has body: I'm planning to start on a new project and am looking at the current state-of-the-art Java web frameworks. I decided to build my application around Guice, and am likely to use a very lightweight ORM like Squill/JEQUEL/JaQu or similar, but I can't decide on the web framework. Which one would fit best in such a lightweight environment? And which one integrates best with Guice?
favorite count: 0
has answer: http://stackoverflow.com/a/5437416
has answer: http://stackoverflow.com/a/481737
has title: Which Java Web Framework fits best with Google Guice?
has answer: http://stackoverflow.com/a/14005426
possible better answer: http://stackoverflow.com/a/483753
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/483753
accepted answer: http://stackoverflow.com/a/525018

http://stackoverflow.com/q/400994
type: Question
upvote count: 5
tagged with: java
has comment: http://stackoverflow.com/comment/19920965
accepted answer: http://stackoverflow.com/a/401013
has answer: http://stackoverflow.com/a/401205
downvote count: 0
possible better answer: http://stackoverflow.com/a/401018
tagged with: event-handling
has answer: http://stackoverflow.com/a/401018
tagged with: keyboard
favorite count: 0
has body: What is the correct way to separate between F1 and i.e. CTRL+F1 respective SHIFT-CTRL+F1 within an KeyListener registered behind i.e. a JButton? public void keyPressed(KeyEvent event) { int key = event.getKeyCode(); logger.debug("KeyBoard pressed char(" + event.getKeyChar() + ") code (" + key + ")"); } .. always gives me 112 for F1, 113 for F2 and so on. I understand that I can handle it by taking care of the keyPressed() respective for keyReleased for CTRL / SHIFT / ALT / etc on my own, but I hope that there is a better way. Many many thanks!!!
has answer: http://stackoverflow.com/a/401036
score: 5
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/401013
has title: Java: handling combined keyboard input

http://stackoverflow.com/q/632043
has body: If I have an XML document like <child attr1="blah"> blahblah <child> I want to get an XML string with the first child element. My output string would be <child attr1="blah"> blahblah <child> There are many approaches, would like to see some ideas. I've been trying to use Java XML APIs for it, but it's not clear that there is a good way to do this. thanks
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/632498
upvote count: 8
has answer: http://stackoverflow.com/a/632266
has answer: http://stackoverflow.com/a/632058
possible better answer: http://stackoverflow.com/a/10605329
has title: How do I extract child element from XML to a string in Java?
has answer: http://stackoverflow.com/a/10605329
score: 8
tagged with: http://stackoverflow.com/tag/xml
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/632266
has answer: http://stackoverflow.com/a/45588804
tagged with: java
has answer: http://stackoverflow.com/a/632049
has answer: http://stackoverflow.com/a/37894910
has answer: http://stackoverflow.com/a/46219900
type: Question
answer count: 8

http://stackoverflow.com/a/19000174
downvote count: 0
has body: You need to look up every class loader entry in the class path: String pkg = "org/apache/commons/lang"; ClassLoader cl = ClassLoader.getSystemClassLoader(); URL[] urls = ((URLClassLoader) cl).getURLs(); for (URL url : urls) { System.out.println(url.getFile()); File jar = new File(url.getFile()); // .... } If entry is directory, just look up in the right subdirectory: if (jar.isDirectory()) { File subdir = new File(jar, pkg); if (!subdir.exists()) continue; File[] files = subdir.listFiles(); for (File file : files) { if (!file.isFile()) continue; if (file.getName().endsWith(".class")) System.out.println("Found class: " + file.getName().substring(0, file.getName().length() - 6)); } } If the entry is the file, and it's jar, inspect the ZIP entries of it: else { // try to open as ZIP try { ZipFile zip = new ZipFile(jar); for (Enumeration&lt;? extends ZipEntry&gt; entries = zip .entries(); entries.hasMoreElements();) { ZipEntry entry = entries.nextElement(); String name = entry.getName(); if (!name.startsWith(pkg)) continue; name = name.substring(pkg.length() + 1); if (name.indexOf('/') &lt; 0 &amp;&amp; name.endsWith(".class")) System.out.println("Found class: " + name.substring(0, name.length() - 6)); } } catch (ZipException e) { System.out.println("Not a ZIP: " + e.getMessage()); } catch (IOException e) { System.err.println(e.getMessage()); } } Now once you have all class names withing package, you can try loading them with reflection and analyze if they are classes or interfaces, etc.
score: 3
answers question: http://stackoverflow.com/q/520328
has comment: http://stackoverflow.com/comment/38704598
has comment: http://stackoverflow.com/comment/44130746
upvote count: 3
type: Answer

refactoring
tags question: http://stackoverflow.com/q/538239
tags question: http://stackoverflow.com/q/424709
tags question: http://stackoverflow.com/q/594722
tags question: http://stackoverflow.com/q/579454
type: Tag
tags question: http://stackoverflow.com/q/610350
tag name: refactoring
tags question: http://stackoverflow.com/q/591228
tags question: http://stackoverflow.com/q/481813
tags question: http://stackoverflow.com/q/495208
tags question: http://stackoverflow.com/q/551578
tags question: http://stackoverflow.com/q/528911
tags question: http://stackoverflow.com/q/413292

http://stackoverflow.com/q/576901
tagged with: quickcheck
has answer: http://stackoverflow.com/a/576999
accepted answer: http://stackoverflow.com/a/576999
type: Question
has answer: http://stackoverflow.com/a/28270501
tagged with: testing
has answer: http://stackoverflow.com/a/18742878
has answer: http://stackoverflow.com/a/11853690
possible better answer: http://stackoverflow.com/a/580841
tagged with: haskell
has answer: http://stackoverflow.com/a/28271511
answer count: 11
has body: Quickcheck and its variants (even there is one in Java), seems to be interesting. However, apart from academic interest, is it really useful in a real application testing (Eg. a GUI application or Client/Server or even take StackOverflow itself)? Any experiences you had with similar test generators is appreciated.
score: 36
has answer: http://stackoverflow.com/a/577063
has answer: http://stackoverflow.com/a/1253976
favorite count: 0
has answer: http://stackoverflow.com/a/580204
has title: Have you used Quickcheck in a real project
has answer: http://stackoverflow.com/a/580191
type: AnsweredQuestion
upvote count: 36
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/580841
has answer: http://stackoverflow.com/a/6451839

http://stackoverflow.com/comment/330237
score: 0
type: AnswerComment
has text: enlightening answer, the WPF / JavaServer Faces comparison was a surprise, what is then XAML in the Java World? Also, is there a product(s) that solves the designer/developer dichotomy as well as Blend / Visual Studio?
comment on: http://stackoverflow.com/a/516294
type: Comment

netbeans
tags question: http://stackoverflow.com/q/413292
tags question: http://stackoverflow.com/q/416116
tags question: http://stackoverflow.com/q/398748
tags question: http://stackoverflow.com/q/590514
tags question: http://stackoverflow.com/q/572917
tags question: http://stackoverflow.com/q/607984
tags question: http://stackoverflow.com/q/437097
tags question: http://stackoverflow.com/q/456865
tags question: http://stackoverflow.com/q/409045
tags question: http://stackoverflow.com/q/586152
tags question: http://stackoverflow.com/q/445187
tags question: http://stackoverflow.com/q/615708
tags question: http://stackoverflow.com/q/531585
type: Tag
tags question: http://stackoverflow.com/q/520525
tags question: http://stackoverflow.com/q/628094
tags question: http://stackoverflow.com/q/626940
tags question: http://stackoverflow.com/q/515391
tags question: http://stackoverflow.com/q/467361
tags question: http://stackoverflow.com/q/525855
tags question: http://stackoverflow.com/q/453960
tags question: http://stackoverflow.com/q/611990
tags question: http://stackoverflow.com/q/460850
tags question: http://stackoverflow.com/q/613973
tags question: http://stackoverflow.com/q/509931
tags question: http://stackoverflow.com/q/412271
tags question: http://stackoverflow.com/q/532988
tags question: http://stackoverflow.com/q/389136
tags question: http://stackoverflow.com/q/582428
tags question: http://stackoverflow.com/q/552332
tags question: http://stackoverflow.com/q/504087
tags question: http://stackoverflow.com/q/495217
tags question: http://stackoverflow.com/q/570076
tags question: http://stackoverflow.com/q/631695
tags question: http://stackoverflow.com/q/642028
tags question: http://stackoverflow.com/q/530203
tag name: netbeans
tags question: http://stackoverflow.com/q/614892
tags question: http://stackoverflow.com/q/363329
tags question: http://stackoverflow.com/q/610884
tags question: http://stackoverflow.com/q/399929
tags question: http://stackoverflow.com/q/491059
tags question: http://stackoverflow.com/q/602537
tags question: http://stackoverflow.com/q/634185
tags question: http://stackoverflow.com/q/499162
tags question: http://stackoverflow.com/q/461011

http://stackoverflow.com/q/365946
has title: Is there an equivalent to BundleActivator for Eclipse fragment projects?
score: 4
tagged with: eclipse
upvote count: 4
has answer: http://stackoverflow.com/a/366622
answer count: 1
downvote count: 0
tagged with: eclipse-plugin
tagged with: eclipse-fragment
favorite count: 0
has body: I am building an Eclipse plug-in that provides a set of core features in the regular plug-in project. The optional features I am providing via fragment projects. But I need the fragments to register themselves with the main plug-in on start-up. I cannot have a Bundle-Activator in the fragment project. So I am wondering is there some alternate mechanism to declare an entry point or some call-back that I can hook? And if there is no alternative other than converting the fragment project to a regular plug-in project is there a downside that I need to be aware of? This is the solution I used based on the accepted answer: final IExtensionRegistry registry = Platform.getExtensionRegistry(); final IExtensionPoint extensionPoint = registry.getExtensionPoint("myextensionid"); final IExtension[] extensions = extensionPoint.getExtensions(); for (int j = 0; j &lt; extensions.length; ++j) { final IConfigurationElement[] points = extensions[j].getConfigurationElements(); for (int i = 0; i &lt; points.length; ++i) { if ("myelementname".equals(points[i].getName())) { try { final Object objImpl= points[i].createExecutableExtension("class"); objImplList.add(provider); } catch (CoreException e) { } } } }
has comment: http://stackoverflow.com/comment/275112
accepted answer: http://stackoverflow.com/a/366622
tagged with: java
type: Question
type: AnsweredQuestion

http://stackoverflow.com/q/545047
has body: This is a problem I keep on running into: I would like to have hibernate manage a single table that represents a collection of collections. For example: a Map of Maps List of Sets Map of Lists Example, I would like to be able to represent this: class OwningClass { Long entityId; Map&lt;String, List&lt;Element>> mapOfLists; } class Element { String data_1; boolean data_2; } as a single table: OWNER (Foreign key to the owner of this element) MAP_KEY (varchar(30) ) LIST_INDEX (int) ELEMENT_DATA_1 (varchar(1020) ELEMENT_DATA_2 (bit) It doesn't seem possible without a custom hibernate code, which I don't mind. But I was hoping someone had some guidance on what that custom code should look like. Should I extend AbstractPersistentCollection? CompositeUserType? Its possible to manage if multiple tables are o.k. but obviously that is lame from the db perspective.
answer count: 1
downvote count: 1
has title: Hibernate: Collections of Collections
favorite count: 0
has comment: http://stackoverflow.com/comment/90198474
upvote count: 21
tagged with: collections
type: AnsweredQuestion
tagged with: java
tagged with: hibernate
linked to: http://stackoverflow.com/q/475879
has answer: http://stackoverflow.com/a/51616749
accepted answer: http://stackoverflow.com/a/51616749
type: Question
score: 20

http://stackoverflow.com/comment/34884734
comment on: http://stackoverflow.com/a/14733855
type: Comment
has text: @maaartinus Well this is embarrassing, I have gotten *so* much better at writing benchmarks in the last 14 months. I'll edit the post now
score: 0
type: AnswerComment

http://stackoverflow.com/a/559784
has comment: http://stackoverflow.com/comment/371450
accepted answer of: http://stackoverflow.com/q/559779
score: 7
has body: Arrays are not classes in Java for a good reason - they map well onto people's understanding of how an array should work from experience with C-style languages. There are also performance reasons for making arrays low-level containers rather than objects. Because of this, sometimes there are performance benefits to using a primitive array rather than a Collection. If you want to use objects, you should just use a Collection (an ArrayList is an example of a collection). It can be clunky, but Collections provide the type of nice methodological access that you seem to want.
has comment: http://stackoverflow.com/comment/371516
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/69695204
upvote count: 10
type: Answer
has comment: http://stackoverflow.com/comment/371307
answers question: http://stackoverflow.com/q/559779
has comment: http://stackoverflow.com/comment/371350
downvote count: 3

http://stackoverflow.com/a/18433952
downvote count: 0
has body: I have written a collection of some Java DSP classes, e.g. IIR filters: Java DSP collection
type: Answer
answers question: http://stackoverflow.com/q/636686
upvote count: 10
has comment: http://stackoverflow.com/comment/34623714
score: 10

http://stackoverflow.com/q/369664
downvote count: 0
has answer: http://stackoverflow.com/a/369763
favorite count: 0
type: UnansweredQuestion
has title: How to discover the type of the NAT a given interface is behind
tagged with: python
has body: I would like to discover the type of the NAT (FullCone, Restricted Cone, Port Restricted cone, Symmetric) a given network interface is behind. I've tested different tools (http://freshmeat.net/projects/jstun/, http://code.google.com/p/boogu/) but they report different results for the same interface. I'm looking for a definitive answer in Python (or other languages, 2nd choice being Java, if nothing else is available).
has answer: http://stackoverflow.com/a/9662635
has answer: http://stackoverflow.com/a/18139611
tagged with: java
type: Question
score: 5
upvote count: 5
tagged with: discovery
tagged with: nat
answer count: 3

http://stackoverflow.com/comment/62879053
type: AnswerComment
score: 0
type: Comment
has text: You can do something like this: ${param["index_".concat(count.index)]}
comment on: http://stackoverflow.com/a/458706

http://stackoverflow.com/a/548083
type: Answer
has comment: http://stackoverflow.com/comment/360183
upvote count: 4
downvote count: 0
score: 4
has comment: http://stackoverflow.com/comment/873083
has comment: http://stackoverflow.com/comment/361221
has body: Does Java have something like this or do I just have to use if/else if/else or case statements? I think case statements ( with the switch in java ) is the equivalent. Additionally in OOP the switch could be coded once and then let polymorphism to the job. From : http://www.refactoring.com/catalog/replaceConditionalWithPolymorphism.html It depends on your requirements.
answers question: http://stackoverflow.com/q/548053

http://stackoverflow.com/a/487001
has body: If you can deploy servlets on the server providing the web service you might consider writing and deploying a simple Filter. You can use this to log both the inbound and the outbound traffic.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/486864

http://stackoverflow.com/comment/452052
type: AnswerComment
has text: Thank you. Been committing regularly for a while and it defiantly solved the problems.
comment on: http://stackoverflow.com/a/577880
type: Comment
score: 0

http://stackoverflow.com/a/411329
score: 8
upvote count: 8
has body: GWT is very much similar to Swing in its usage of Widgets, Panels and the EventListeners it provides. A different way to look at GWT is to think of Javascript and HTML as Assembly language and GWT as a sort of High level language which generates Javascript and HTML. With GWT its easy to develop desktop-like apps for the web using the same tools you would use for building a desktop app
type: Answer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/407506
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/407506

http://stackoverflow.com/a/604690
answers question: http://stackoverflow.com/q/604667
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/417805
score: 1
downvote count: 0
has body: Not really a data structure... but in the neighborhood of what you might need http://java.sun.com/javase/6/docs/api/java/util/concurrent/Semaphore.html?

http://stackoverflow.com/comment/53390868
type: QuestionComment
has text: Have you tried without the trailing star ? Eg /example/
score: 0
comment on: http://stackoverflow.com/q/459263
type: Comment

http://stackoverflow.com/comment/127384400
type: AnswerComment
type: Comment
score: 1
comment on: http://stackoverflow.com/a/562207
has text: Why is everything in Java so gross? Seriously?

http://stackoverflow.com/a/523214
answers question: http://stackoverflow.com/q/523107
upvote count: 3
downvote count: 0
type: Answer
score: 3
has body: I believe you can actually set the system property -Djava.awt.headless=true which will allow access to the graphic libraries without actually needing a display. See http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/ for more info.

http://stackoverflow.com/a/440477
downvote count: 0
has comment: http://stackoverflow.com/comment/263642
has comment: http://stackoverflow.com/comment/262619
has comment: http://stackoverflow.com/comment/264627
has body: I'd only use sleep() if there's no work to be done. For example, if you're doing something like polling a task queue periodically and there's nothing there, sleep for a while then check again, etc. If you're just trying to make sure you don't hog the CPU but you're still doing real work, you could call Thread.yield() periodically. That will relinquish control of the CPU and let other threads run, but it won't put you to sleep. If other processes don't need the CPU you'll get control back and continue to do your work. You can also set your thread to a low priority: myThread.setPriority(Thread.MIN_PRIORITY); As Ishmael said, don't do this in your main thread. Create a "worker thread" instead. That way your UI (GUI or CLI) will still be responsive.
type: Answer
score: 3
answers question: http://stackoverflow.com/q/440417
has comment: http://stackoverflow.com/comment/262554
upvote count: 3
has comment: http://stackoverflow.com/comment/262600

http://stackoverflow.com/comment/312642
comment on: http://stackoverflow.com/a/494651
type: Comment
has text: IIRC the JVM is in effect a CPU so what would be needed would be not a JVM based CLI VM but a CLI JIT that targets the JVM (more or less)
score: 0
type: AnswerComment

http://stackoverflow.com/a/636919
downvote count: 0
has comment: http://stackoverflow.com/comment/453348
has comment: http://stackoverflow.com/comment/25160798
answers question: http://stackoverflow.com/q/636550
type: Answer
has body: JDK 1.1 introduced Java Beans. Java Beans rely in reflection and introspection to determine what the properties of a Bean are (a Bean is a "component"). Properties are then displayed in a Property Sheet. By default beans use the following foormat: boolean isXXX() &lt;type&gt; getXXX() void setXXX(&lt;type&gt;) (going from memory on these next two... they are for indexed properties) &lt;type&gt; getXXX(int) void setXXX(&lt;type&gt;, int) You can override the defaults, but rather than do that most things just rely on the naming pattern. So show/hide didn't conform to the naming pattern and were replaced with setVisible(boolean) which did.
score: 27
has comment: http://stackoverflow.com/comment/453381
upvote count: 27

http://stackoverflow.com/q/444731
score: 2
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/445469
has comment: http://stackoverflow.com/comment/40950789
tagged with: java
type: Question
has title: Install of Tomcat 5.5 on Ubuntu (using apt) leaves CATALINA_HOME unset
downvote count: 0
tagged with: ubuntu
tagged with: tomcat
has answer: http://stackoverflow.com/a/445120
favorite count: 0
tagged with: linux
answer count: 3
possible better answer: http://stackoverflow.com/a/446662
has body: I'm setting up my development environment for writing web applications using Java, and I'm in need of some help. What I have done: Installation of Java SE 6 from Sun I installed (sudo apt-get install …) the following packages (one at a time as some of them requires user interaction) to get Java SE 6 from Sun: sun-java6-bin sun-java6-doc sun-java6-fonts sun-java6-javadb sun-java6-jdk sun-java6-jre sun-java6-plugin sun-java6-source . I also set JAVA_HOME by adding JAVA_HOME=”/usr/lib/jvm/java-6-sun/” to /etc/environment. Began installing and configuring Tomcat 5.5 I installed (sudo apt-get install …) the following packages: tomcat5.5 tomcat5.5-admin What I have at the moment: I'm able to connect to http://localhost:8180/admin and get the admin web application which I installed by installing the tomcat5.5-admin package. The Tomcat server is running as a deamon. My problems and questions: The environment variable $CATALINA_HOME doesn't seem to be defined. How should I define it? (The same way as my $JAVA_HOME maybe? But if so, which path should I assign it?) To deploy a war, can I just copy the JAR to $CATALINA_HOME/webapps? Or do I need to change the file permissions on the war? (Here I assume $CATALINA_HOME is set correctly.) What's the user and password I need for the admin web application I installed? How do I change them? Are there any best practices for Tomcat 5.5 on Ubuntu which I should think of?
has answer: http://stackoverflow.com/a/446662
upvote count: 2
has answer: http://stackoverflow.com/a/445469

http://stackoverflow.com/comment/273613
score: 0
type: AnswerComment
type: Comment
has text: @IainMH: that's what wc does anyway (reading the file, counting line-ending).
comment on: http://stackoverflow.com/a/453025

http://stackoverflow.com/q/368792
tagged with: security
tagged with: mbeans
answer count: 1
downvote count: 0
favorite count: 0
type: UnansweredQuestion
tagged with: jmx
has answer: http://stackoverflow.com/a/430580
has body: I've got some MBean operations that I need to secure. I would like the users to be required to log in as the server admin and I would like this to be setup programmaticly or, preferably by a config file in the WAR, when the app is deployed. I want to avoid requiring the admin to set this up as a deployment step. We're running glassfish, but platform neutral is preferred. However, glassfish specific config files would be fine.
has title: Securing MBeans operations
score: 1
tagged with: java
upvote count: 1
type: Question
tagged with: jakarta-ee

http://stackoverflow.com/comment/304123
comment on: http://stackoverflow.com/a/484287
score: 0
type: AnswerComment
type: Comment
has text: Perhaps you need to resolve the layout of your libraries then - sounds like you could address the problem by making sure that whatever classloader finds axis-ant.jar also has an axis.jar available to it.

http://stackoverflow.com/q/438312
has answer: http://stackoverflow.com/a/438320
type: Question
type: AnsweredQuestion
tagged with: java
tagged with: callable
possible better answer: http://stackoverflow.com/a/438379
has body: I need to run a callable at a specific time of day. One way to do it is to calculate the timediff between now and the desired time , and to use the executor.scheduleAtFixedRate . Have a better idea? executor.scheduleAtFixedRate(command, TIMEDIFF(now,run_time), period, TimeUnit.SECONDS))
has answer: http://stackoverflow.com/a/438379
tagged with: scheduling
downvote count: 0
has answer: http://stackoverflow.com/a/438318
favorite count: 0
has title: How to schedule a Callable to run on a specific time?
answer count: 4
score: 2
upvote count: 2
has answer: http://stackoverflow.com/a/859559
accepted answer: http://stackoverflow.com/a/438318

http://stackoverflow.com/comment/47095869
has text: @Mo the link is broken
score: 0
type: Comment
comment on: http://stackoverflow.com/a/598914
type: AnswerComment

http://stackoverflow.com/q/535463
has answer: http://stackoverflow.com/a/535486
answer count: 4
has answer: http://stackoverflow.com/a/535514
downvote count: 0
type: UnansweredQuestion
score: 1
has answer: http://stackoverflow.com/a/535937
has comment: http://stackoverflow.com/comment/348192
tagged with: java
has answer: http://stackoverflow.com/a/535519
type: Question
upvote count: 1
has body: I'm a beginner in Java. While running the java application I got below mentioned bug. Why has this bug occured? # # An unexpected error has been detected by Java Runtime Environment: # # Internal Error (exceptions.cpp:367), pid=2552, tid=2532 # Error: ExceptionMark destructor expects no pending exceptions # # Java VM: Java HotSpot(TM) Client VM (10.0-b22 mixed mode, sharing windows-x86) # If you would like to submit a bug report, please visit: # http://java.sun.com/webapps/bugreport/crash.jsp # --------------- T H R E A D --------------- Current thread (0x00385800): JavaThread "main" [_thread_in_vm, id=2532, stack(0x00390000,0x003e0000)] Stack: [0x00390000,0x003e0000] [error occurred during error reporting (printing stack bounds), id 0xc0000005] Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::StubRoutines (1) v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::StubRoutines (1) v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::StubRoutines (1) v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::Interpreter v ~BufferBlob::StubRoutines (1) --------------- P R O C E S S --------------- Java Threads: ( =&gt; current thread ) 0x029c6000 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=2648, stack(0x02c70000,0x02cc0000)] 0x029b8000 JavaThread "CompilerThread0" daemon [_thread_blocked, id=2876, stack(0x02c20000,0x02c70000)] …
has title: About bug details
favorite count: 0

http://stackoverflow.com/comment/7635964
type: AnswerComment
type: Comment
has text: +1 for mentioning the requirement that a `List` always adds at the end.
score: 8
comment on: http://stackoverflow.com/a/5745380

http://stackoverflow.com/comment/27778088
score: 1
comment on: http://stackoverflow.com/a/6992265
type: AnswerComment
has text: @Vegard: Nothing keeps you from passing a variable to the jOOQ API, and rebuild the SQL statement. Also, you can extract bind values in their order using http://www.jooq.org/javadoc/latest/org/jooq/Query.html#getBindValues(), or named bind values by their names using http://www.jooq.org/javadoc/latest/org/jooq/Query.html#getParams(). My answer just contains a very simplistic example... I'm not sure if this responds to your concerns, though?
type: Comment

http://stackoverflow.com/comment/23962657
type: Comment
score: 1
has text: -1: Misleading. He is fine without the I/O. This answer makes it appear like unit tests of this form need the I/O in order to guarantee correctness.
type: AnswerComment
comment on: http://stackoverflow.com/a/548719

http://stackoverflow.com/comment/294285
comment on: http://stackoverflow.com/a/477026
score: 0
type: Comment
has text: Although, in principle, I agree, some would argue that a call to CollectionUtils is less readable than a simple loop. Don't misunderstand me, there are some calls such as isEmpty that are very useful IMO.
type: AnswerComment

http://stackoverflow.com/a/627934
answers question: http://stackoverflow.com/q/625725
upvote count: 5
has comment: http://stackoverflow.com/comment/111642719
score: 5
downvote count: 0
has body: Problem solved by a workaround replacing the message listener by a receive() loop, but I'm still interested in how to disable a message listener and enable it shortly again.
type: Answer

http://stackoverflow.com/a/446043
downvote count: 0
answers question: http://stackoverflow.com/q/445911
has comment: http://stackoverflow.com/comment/1823037
score: 4
type: Answer
has comment: http://stackoverflow.com/comment/267431
has body: I've used such products and they are a pain. I personally wouldn't spend any money at all on a hardware scheme or a 3rd party protection scheme. Do not be tempted by a hardware based protection scheme. The only things that are certain: Any protection schemes will be cracked. You will annoy legitimate customers You will lose time supporting problems related to the protection There will be problems when a legitimate customer cannot use your product because of the protection. It is a better investment to use any time and funds that you would have spent on protection on improving the product or finding more customers. The golden rule of protection is to make it painless for your customers. Hardware protection schemes make life inconvenient for your customers and easier for those who've ripped you off, which clearly isn't right.
upvote count: 4

http://stackoverflow.com/a/438274
type: AcceptedAnswer
has body: You need to specify the printer resolution by means of attribute PrinterResolution. You should also know the source resolution so it is correctly converted such as: PrinterResolution pr = new PrinterResolution(300, 300, PrinterResolution.DPI);
downvote count: 0
has comment: http://stackoverflow.com/comment/58747277
type: Answer
accepted answer of: http://stackoverflow.com/q/438221
answers question: http://stackoverflow.com/q/438221
score: 4
upvote count: 4

semaphore
type: Tag
tags question: http://stackoverflow.com/q/607112
tag name: semaphore
tags question: http://stackoverflow.com/q/609963

http://stackoverflow.com/q/592262
has body: I am looking to open up a command prompt and pass in a copy command, some switches, and the source file plus destination. I've tried the code below but nothing appears to be happening. What am I not seeing? What could I be doing wrong? String line; line = "cmd COPY /Y C:\srcfolder\112.bin C:\destfolder"; Process p = Runtime.getRuntime().exec(line); p.waitFor();
has answer: http://stackoverflow.com/a/592311
type: Question
downvote count: 0
answer count: 7
possible better answer: http://stackoverflow.com/a/592283
favorite count: 0
has answer: http://stackoverflow.com/a/34837975
accepted answer: http://stackoverflow.com/a/592290
has comment: http://stackoverflow.com/comment/404102
has answer: http://stackoverflow.com/a/592378
has answer: http://stackoverflow.com/a/592290
has title: CMD file copy from Java
upvote count: 2
has answer: http://stackoverflow.com/a/592295
has answer: http://stackoverflow.com/a/592283
has answer: http://stackoverflow.com/a/592306
score: 2
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/a/477651
accepted answer of: http://stackoverflow.com/q/477055
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/477055
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: I don't think this is possible - you will have to use sockets. If you are on windows you could check if something like http://www.northcode.com/ enables you to achieve this.

http://stackoverflow.com/comment/61126205
type: AnswerComment
comment on: http://stackoverflow.com/a/398524
score: 0
type: Comment
has text: @jpganz18 it works out of the box for me. I'm not sure. This is the doc I've found https://www.jetbrains.com/help/idea/2016.1/properties-files.html?origin=old_help

http://stackoverflow.com/a/506464
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/407614
type: Answer
downvote count: 0
has body: If you are going to make heavy use of RMI, I would suggest having a look at Spring Remoting. It helps a lot in abstracting the remoting protocol, help you switch remoting implementation later if you need to (for example switch to Hessian, or SOAP). One thing to keep in mind if you use RMI or any other remote object protocol, is that you can generate a lot of traffic by calling methods on remote objects. It might not be obvious in your code that those objects are remote. It might generate performances problems. If you can, I would advise you to have a architecture more or less service oriented, where you call remote services to get data object, but not to have too much behaviour on those objects ...

http://stackoverflow.com/comment/199183
type: Comment
comment on: http://stackoverflow.com/a/370284
has text: Very useful link - had not seen that before; bookmarked for a closer look later.
score: 1
type: AnswerComment

http://stackoverflow.com/q/378066
has title: Best Practice for Spring MVC form-backing object tree initialization
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/473769
score: 7
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/379425
has answer: http://stackoverflow.com/a/379304
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/79348950
has answer: http://stackoverflow.com/a/473769
tagged with: spring
answer count: 4
tagged with: spring-mvc
possible better answer: http://stackoverflow.com/a/379307
upvote count: 7
has body: If I have a form-backing object that has a complicated object tree -- say a Person that has a Contact Info object that has an Address object that has a bunch of Strings -- it seems that the object needs to be fully populated with component objects before I can bind to it. So if I'm creating a new Person, I need to make sure it has all the component objects populated off the bat, and if I'm retrieving a Person from the database, I need to make sure that any objects that aren't populated from the database get populated with empty objects. First question, of course -- am I correct in my assumptions above? It does seem that if I try to bind to person.contactInfo.homeAddress.street and there is no ContactInfo, I get a null pointer exception. Second, what's the best way to initialize my object. I can think of a couple of approaches. One is to initialize all member objects at declaration: public class Person { String name; ContactInfo contactInfo = new ContactInfo(); //getters, setters, etc. } public class ContactInfo { String phone; Address homeAddress = new Address(); } and so forth. Another approach is to have a PersonFactory that initializes everything (or to have a factory method Person.getInstance that initializes everything). In the case of retrieving a Person from the database, the first approach will solve the issue (i.e. if this particular person doesn't have an address in the database, the object will still have an Address), but this will mean creating each object twice. Not sure how to handle this otherwise, except to make the DAO explicitly populate everything even if nothing has been retrieved from the database. Or to give the factory a method to go through the object and "fill in" anything that's missing. Suggestions?
has answer: http://stackoverflow.com/a/379307

http://stackoverflow.com/a/2549884
type: Answer
has body: As of v7.0, you can read all the MQMD fields as JMS message properties and can set many of them the same way. See: http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzaw.doc/jm41030_.htm Both the client and the WMQ server must be at v7.0 or higher to use this feature, though.
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/540764
upvote count: 2

http://stackoverflow.com/a/1365312
answers question: http://stackoverflow.com/q/359732
downvote count: 1
has body: They tell you because they still use ancient or generic (not language-aware) source code editors. If you use an editor with auto-indent, you will never make a mistake that could have been avoided by using curly brackets all the time.
type: Answer
upvote count: 4
score: 3

http://stackoverflow.com/a/1483454
has comment: http://stackoverflow.com/comment/47134103
has body: I had a really good experience with Avaje Ebean when I was writing a medium sized JavaSE application. It uses standard JPA annotations to define entities, but exposes a much simpler API (No EntityManager or any of that attached/detached entities crap). It also lets you easily use SQL queries or event plain JDBC calls when necessary. It also has a very nice fluid and type-safe API for queries. You can write things like: List&lt;Person&gt; boys = Ebean.find(Person.class) .where() .eq("gender", "M") .le("age", 18) .orderBy("firstName") .findList();
has comment: http://stackoverflow.com/comment/47134247
downvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/82923147
answers question: http://stackoverflow.com/q/452385
has comment: http://stackoverflow.com/comment/2988173
score: 20
has comment: http://stackoverflow.com/comment/3178728
upvote count: 21

http://stackoverflow.com/comment/385811
score: 1
has text: Just curious, this question already got 2 downvotes, why?
comment on: http://stackoverflow.com/q/573982
type: QuestionComment
type: Comment

seek
tags question: http://stackoverflow.com/q/467761
type: Tag
tag name: seek

http://stackoverflow.com/a/417300
has body: Truncation is done from the beginning of a message by default (differs from the printf in C, which does it from the end). The proper pattern should be: %.-5m EDIT: I just tried this, and log4j does not like that pattern. However, the supplied pattern will work fine in LOGBack, if you can make the switch over. If you cannot switch your logging provider, you could make a one-off modification to log4j. The interesting bit of code appears on lines 75-76 of org.apache.log4j.helpers.PatternConverter: if(len &gt; max) sbuf.append(s.substring(len-max)); This should read: if(len &gt; max) sbuf.append(s.substring(0,max)); You can simply make the modification and recompile the jar for your use, or you can subclass PatternConverter to perform the proper truncation. This will also require a new version of PatternLayout, which contains the createPatternParser method, which you will need to override in your subclass to instantiate your new version of PatternConverter. As a side note, be aware of the licensing ramifications of modifying open source code in your specific project.
score: 11
answers question: http://stackoverflow.com/q/417216
downvote count: 1
upvote count: 12
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/417216

http://stackoverflow.com/a/39137025
answers question: http://stackoverflow.com/q/562894
upvote count: 1
type: Answer
downvote count: 0
score: 1
has body: best way to handle this issue is to use a HashSet : ArrayList&lt;String&gt; listGroupCode = new ArrayList&lt;&gt;(); listGroupCode.add("A"); listGroupCode.add("A"); listGroupCode.add("B"); listGroupCode.add("C"); HashSet&lt;String&gt; set = new HashSet&lt;&gt;(listGroupCode); ArrayList&lt;String&gt; result = new ArrayList&lt;&gt;(set); Just print result arraylist and see the result without duplicates :)

http://stackoverflow.com/a/37340925
score: 1
upvote count: 1
has body: Run your program like so: java -Djavax.net.debug=all helloworld.java The switch is fully documented on the Oracle JSSE page Pros: Much simpler than other suggested solutions (requires no external software) Can also decrypt/dump TLS/SSL connections :) Cons: This will only work if you are using classes from java.net.* e.g. OutputStream or InputStream This will not work if you're using raw sockets. This is documented in the link. Believe this may only work on the Oracle JDK.
downvote count: 0
answers question: http://stackoverflow.com/q/590510
type: Answer

http://stackoverflow.com/a/526169
downvote count: 0
type: Answer
upvote count: 6
score: 6
has body: You may want to look into this class: http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSource.html This will make it easier for your service objects and data access objects to be ignorant that any notion of dynamic datasources exists. Typically you'd need to implement a servlet filter and use a ThreadLocal so that the DataSourceLookup implementation used by AbstractRoutingDataSource can easily gain access to the request parameters that dictate which DataSource is returned. If you really want to avoid that, you could implement a servlet filter which sets properties on a request-scoped bean and inject that bean into the DataSourceLookup implementation you've written. Request-scoped beans still use a ThreadLocal in their implementation but at least this way it's Spring's impl, not yours, and you don't need to worry about it. :) Similar approach is detailed in this blog entry from the Spring team: http://blog.springsource.com/2007/01/23/dynamic-datasource-routing/
answers question: http://stackoverflow.com/q/517353

http://stackoverflow.com/a/22658981
score: 0
has body: try this guide it works for me. it also guides you that how you can set "System.setOut(fileStream);", "System.setErr(fileStream);"
type: Answer
answers question: http://stackoverflow.com/q/626389

http://stackoverflow.com/comment/98656463
has text: Updating this comment in case someone else comes across this subject on a search. Derby most recent release was in March/2019. Here is their site info: https://db.apache.org/derby/
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/57352

http://stackoverflow.com/a/441162
downvote count: 0
type: Answer
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/440430
has body: Comparators are often hard to get exactly right, and the comparison key has to be generated for every comparison which for most sorting algorithms mean O(n log n). Another approach is to create (key, value) pairs for each item you need to sort, put them in a TreeMap, and then ask for the values as these are sorted according to the key. For instance import java.util.Arrays; import java.util.TreeMap; public class Bar { public static void main(String[] args) { TreeMap&lt;String, String&gt; m2 = new TreeMap&lt;String, String&gt;(); for (String string : Arrays.asList(new String[] { "#3", "#2", "#1" })) { String key = string.substring(string.length() - 1); String value = string; m2.put(key, value); } System.out.println(m2.values()); } } prints out [#1, #2, #3] You should easily be able to adapt the key calculation to your problem. This only calculates the key once per entry, hence O(n) - (but the sort is still O(n log n)). If the key calculation is expensive or n is large this might be quite measurable.

http://stackoverflow.com/a/16347963
downvote count: 0
has body: Are you still looking for an answer? It depends on your definition of started. If your definition of started is "Now its safe to stop" then you might want to verify if port 8005 is listening.
score: 2
answers question: http://stackoverflow.com/q/376279
upvote count: 2
type: Answer

http://stackoverflow.com/comment/299241
comment on: http://stackoverflow.com/a/481791
score: 3
type: AnswerComment
has text: You can make this method more general with Closeable public static void closeQuietly(Closeable closeable) {
type: Comment

http://stackoverflow.com/a/464537
score: 0
type: Answer
has body: In addition to the information given above: the JVM is free in how it uses OS threads. The Thread in your Java application might run in a seperate OS thread, or it might share that thread with other Threads. Check the documentation for the JVM you are using for additional information.
answers question: http://stackoverflow.com/q/464387

http://stackoverflow.com/q/501412
has body: I noticed today that auto-boxing can sometimes cause ambiguity in method overload resolution. The simplest example appears to be this: public class Test { static void f(Object a, boolean b) {} static void f(Object a, Object b) {} static void m(int a, boolean b) { f(a,b); } } When compiled, it causes the following error: Test.java:5: reference to f is ambiguous, both method f(java.lang.Object,boolean) in Test and method f(java.lang.Object,java.lang.Object) in Test match static void m(int a, boolean b) { f(a, b); } ^ The fix to this error is trivial: just use explicit auto-boxing: static void m(int a, boolean b) { f((Object)a, b); } Which correctly calls the first overload as expected. So why did the overload resolution fail? Why didn't the compiler auto-box the first argument, and accept the second argument normally? Why did I have to request auto-boxing explicitly?
score: 35
tagged with: autoboxing
has answer: http://stackoverflow.com/a/501438
accepted answer: http://stackoverflow.com/a/501451
tagged with: compiler-construction
favorite count: 0
tagged with: overloading
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/501450
possible better answer: http://stackoverflow.com/a/501440
tagged with: java
has answer: http://stackoverflow.com/a/501440
has title: Why does autoboxing make some calls ambiguous in Java?
has answer: http://stackoverflow.com/a/501439
has answer: http://stackoverflow.com/a/501451
type: Question
has answer: http://stackoverflow.com/a/9087369
upvote count: 35
downvote count: 0
answer count: 6

http://stackoverflow.com/a/624423
type: Answer
upvote count: 6
score: 2
has comment: http://stackoverflow.com/comment/29314766
has body: With a package.html file at the package level (i.e. in the directory for that package). This should be a fully-formed HTML file, with the &lt;html&gt; tag defined in it
answers question: http://stackoverflow.com/q/624422
has comment: http://stackoverflow.com/comment/437287
downvote count: 4
has comment: http://stackoverflow.com/comment/437291

http://stackoverflow.com/q/564899
type: Question
score: 20
has answer: http://stackoverflow.com/a/565024
has title: Choosing the initial capacity of a HashSet with an expected number of unique values and insertions
has answer: http://stackoverflow.com/a/564916
tagged with: java
tagged with: set
has answer: http://stackoverflow.com/a/23940391
has body: Ok, here's my situation: I have an Array of States, which may contain duplicates. To get rid of the duplicates, I can add them all to a Set. However when I create the Set, it wants the initial capacity and load factor to be defined, but what should they be set to? From googling, I have come up with: String[] allStates = getAllStates(); Set&lt;String&gt; uniqueStates = new HashSet&lt;String&gt;(allStates.length, 0.75); The problem with this, is that allStates can contain anwhere between 1 and 5000 states. So the Set will have capacity of over 5000, but only containing at most 50. So alternatively set the max size of the Set could be set to be the max number of states, and the load factor to be 1. I guess my questions really are: What should you set the initial capacity to be when you don't know how many items are to be in the Set? Does it really matter what it gets set to when the most it could contain is 50? Should I even be worrying about it?
answer count: 7
has answer: http://stackoverflow.com/a/565255
has answer: http://stackoverflow.com/a/565503
upvote count: 20
accepted answer: http://stackoverflow.com/a/565255
possible better answer: http://stackoverflow.com/a/564915
has answer: http://stackoverflow.com/a/14073244
has answer: http://stackoverflow.com/a/564915
type: AnsweredQuestion
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/32454155
type: Answer
has comment: http://stackoverflow.com/comment/68895528
answers question: http://stackoverflow.com/q/507602
upvote count: 9
has comment: http://stackoverflow.com/comment/68895772
downvote count: 0
has comment: http://stackoverflow.com/comment/68895401
has comment: http://stackoverflow.com/comment/68903788
has comment: http://stackoverflow.com/comment/68873984
score: 9
has comment: http://stackoverflow.com/comment/68896205
has comment: http://stackoverflow.com/comment/68934714
has comment: http://stackoverflow.com/comment/68895889
has body: As usual apache-commons has proper method MapUtils.putAll(Map, Object[]): For example, to create a color map: Map&lt;String, String&gt; colorMap = MapUtils.putAll(new HashMap&lt;String, String&gt;(), new String[][] { {"RED", "#FF0000"}, {"GREEN", "#00FF00"}, {"BLUE", "#0000FF"} });

http://stackoverflow.com/q/438146
has title: What are the possible values of the Hibernate hbm2ddl.auto configuration and what do they do
has answer: http://stackoverflow.com/a/10951187
has answer: http://stackoverflow.com/a/28428698
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/38894203
tagged with: java
tagged with: hibernate
has answer: http://stackoverflow.com/a/1689769
linked to: http://stackoverflow.com/q/6751090
type: Question
has answer: http://stackoverflow.com/a/61962252
linked to: http://stackoverflow.com/q/221379
has body: I really want to know more about the update, export and the values that could be given to hibernate.hbm2ddl.auto I need to know when to use the update and when not? And what is the alternative? These are changes that could happen over DB: new tables new columns in old tables columns deleted data type of a column changed a type of a column changed its attributes tables dropped values of a column changed In each case what is the best solution?
tagged with: hbm2ddl
has answer: http://stackoverflow.com/a/11130672
has answer: http://stackoverflow.com/a/23678638
upvote count: 1278
linked to: http://stackoverflow.com/q/3179765
answer count: 14
score: 1274
downvote count: 4
has answer: http://stackoverflow.com/a/46756282
has answer: http://stackoverflow.com/a/672490
favorite count: 0
has answer: http://stackoverflow.com/a/42576925
has answer: http://stackoverflow.com/a/38814972
has answer: http://stackoverflow.com/a/69203657
has answer: http://stackoverflow.com/a/43922047
has answer: http://stackoverflow.com/a/438286

http://stackoverflow.com/a/461124
upvote count: 2
has body: UPDATE: I missed the request for hyperlink support. Don't know how to do that w/o using the EditorPane. JTextArea does exactly what you've described. JTextArea textArea = new JTextArea(); JScrollPanel sPane = new JScrollPane(textArea);
has comment: http://stackoverflow.com/comment/279968
has comment: http://stackoverflow.com/comment/279937
type: Answer
score: 2
answers question: http://stackoverflow.com/q/461112
has comment: http://stackoverflow.com/comment/280039
downvote count: 0
has comment: http://stackoverflow.com/comment/279959
has comment: http://stackoverflow.com/comment/280049
has comment: http://stackoverflow.com/comment/281338
has comment: http://stackoverflow.com/comment/280020

arrays
tags question: http://stackoverflow.com/q/622628
type: Tag
tags question: http://stackoverflow.com/q/392324
tags question: http://stackoverflow.com/q/562894
tags question: http://stackoverflow.com/q/474896
tags question: http://stackoverflow.com/q/587584
tags question: http://stackoverflow.com/q/372250
tags question: http://stackoverflow.com/q/578798
tags question: http://stackoverflow.com/q/383888
tags question: http://stackoverflow.com/q/425439
tags question: http://stackoverflow.com/q/470198
tags question: http://stackoverflow.com/q/516565
tags question: http://stackoverflow.com/q/371839
tags question: http://stackoverflow.com/q/374339
tags question: http://stackoverflow.com/q/642897
tags question: http://stackoverflow.com/q/607587
tag name: arrays
tags question: http://stackoverflow.com/q/454921
tags question: http://stackoverflow.com/q/576855
tags question: http://stackoverflow.com/q/585587
tags question: http://stackoverflow.com/q/409784
tags question: http://stackoverflow.com/q/486197
tags question: http://stackoverflow.com/q/559779
tags question: http://stackoverflow.com/q/362367
tags question: http://stackoverflow.com/q/419858
tags question: http://stackoverflow.com/q/502178
tags question: http://stackoverflow.com/q/602356
tags question: http://stackoverflow.com/q/440430
tags question: http://stackoverflow.com/q/624929
tags question: http://stackoverflow.com/q/586284
tags question: http://stackoverflow.com/q/570338
tags question: http://stackoverflow.com/q/558839
tags question: http://stackoverflow.com/q/484392
tags question: http://stackoverflow.com/q/630808
tags question: http://stackoverflow.com/q/580743
tags question: http://stackoverflow.com/q/474451
tags question: http://stackoverflow.com/q/605226
tags question: http://stackoverflow.com/q/564392
tags question: http://stackoverflow.com/q/529085
tags question: http://stackoverflow.com/q/380632

http://stackoverflow.com/comment/39273700
type: Comment
type: QuestionComment
score: 1
has text: I think that the problem is that the bufferedReader reads the binary data as well, because it buffers the data. This means that nothing is left to be read from the InputStream - hence the empty byte array result.
comment on: http://stackoverflow.com/q/568616

http://stackoverflow.com/comment/236616
type: Comment
has text: Obviously, you have to have a font supporting the glyphs you need to display. A tool like BabelMap can help here.
comment on: http://stackoverflow.com/q/411631
score: 0
type: QuestionComment

http://stackoverflow.com/comment/3484354
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/547999
has text: @soru that's exactly what I said. Still not sure why you feel we are disagreeing. Did you possibly misread my post? "You must never optimize until you are sure you need it" == "you shouldn't mention performance as an issue at all until it has been established as the right thing to do."
type: Comment

http://stackoverflow.com/q/613954
has comment: http://stackoverflow.com/comment/428038
answer count: 33
has comment: http://stackoverflow.com/comment/80247362
has answer: http://stackoverflow.com/a/36627158
has comment: http://stackoverflow.com/comment/51863296
has answer: http://stackoverflow.com/a/20231597
has comment: http://stackoverflow.com/comment/109610534
has comment: http://stackoverflow.com/comment/73287183
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2462951
has comment: http://stackoverflow.com/comment/134705725
has answer: http://stackoverflow.com/a/614494
has comment: http://stackoverflow.com/comment/105449915
has body: For a number of years now I have been unable to get a decent answer to the following question: why are some developers so against checked exceptions? I have had numerous conversations, read things on blogs, read what Bruce Eckel had to say (the first person I saw speak out against them). I am currently writing some new code and paying very careful attention to how I deal with exceptions. I am trying to see the point of view of the "we don't like checked exceptions" crowd and I still cannot see it. Every conversation I have ends with the same question going unanswered... let me set it up: In general (from how Java was designed), Error is for things that should never be caught (VM has a peanut allergy and someone dropped a jar of peanuts on it) RuntimeException is for things that the programmer did wrong (programmer walked off the end of an array) Exception (except RuntimeException) is for things that are out of the programmer's control (disk fills up while writing to the file system, file handle limit for the process has been reached and you cannot open any more files) Throwable is simply the parent of all of the exception types. A common argument I hear is that if an exception happens then all the developer is going to do is exit the program. Another common argument I hear is that checked exceptions make it harder to refactor code. For the "all I am going to do is exit" argument I say that even if you are exiting you need to display a reasonable error message. If you are just punting on handling errors then your users won't be overly happy when the program exits without a clear indication of why. For the "it makes it hard to refactor" crowd, that indicates that the proper level of abstraction wasn't chosen. Rather than declare a method throws an IOException, the IOException should be transformed into an exception that is more suited for what is going on. I don't have an issue with wrapping Main with catch(Exception) (or in some cases catch(Throwable) to ensure that …
upvote count: 546
has answer: http://stackoverflow.com/a/1246039
has answer: http://stackoverflow.com/a/614122
has comment: http://stackoverflow.com/comment/428407
has answer: http://stackoverflow.com/a/8687448
downvote count: 6
linked to: http://stackoverflow.com/q/588546
has comment: http://stackoverflow.com/comment/51567934
has comment: http://stackoverflow.com/comment/23656413
has answer: http://stackoverflow.com/a/614269
has answer: http://stackoverflow.com/a/18391644
has comment: http://stackoverflow.com/comment/51632631
has answer: http://stackoverflow.com/a/73023605
tagged with: java
has answer: http://stackoverflow.com/a/31444217
has comment: http://stackoverflow.com/comment/27994018
has answer: http://stackoverflow.com/a/11329960
has answer: http://stackoverflow.com/a/614648
type: Question
has answer: http://stackoverflow.com/a/614181
has answer: http://stackoverflow.com/a/46649027
has answer: http://stackoverflow.com/a/614330
has comment: http://stackoverflow.com/comment/23655761
has comment: http://stackoverflow.com/comment/23656399
has answer: http://stackoverflow.com/a/7157273
has answer: http://stackoverflow.com/a/614046
has answer: http://stackoverflow.com/a/703944
has answer: http://stackoverflow.com/a/11782220
has comment: http://stackoverflow.com/comment/23655584
has answer: http://stackoverflow.com/a/614558
has comment: http://stackoverflow.com/comment/848137
has answer: http://stackoverflow.com/a/614057
favorite count: 0
has answer: http://stackoverflow.com/a/875399
has answer: http://stackoverflow.com/a/23987003
has answer: http://stackoverflow.com/a/876162
has answer: http://stackoverflow.com/a/615715
has comment: http://stackoverflow.com/comment/427035
has comment: http://stackoverflow.com/comment/23656632
has answer: http://stackoverflow.com/a/614174
has comment: http://stackoverflow.com/comment/126101240
tagged with: exception
has comment: http://stackoverflow.com/comment/51618734
has comment: http://stackoverflow.com/comment/427460
has comment: http://stackoverflow.com/comment/2463742
has answer: http://stackoverflow.com/a/614438
has answer: http://stackoverflow.com/a/7935358
has comment: http://stackoverflow.com/comment/75803081
has title: The case against checked exceptions
has comment: http://stackoverflow.com/comment/23659724
has comment: http://stackoverflow.com/comment/428464
has comment: http://stackoverflow.com/comment/97976963
has comment: http://stackoverflow.com/comment/23658186
has answer: http://stackoverflow.com/a/1694321
has answer: http://stackoverflow.com/a/614119
tagged with: checked-exceptions
has answer: http://stackoverflow.com/a/16485510
has answer: http://stackoverflow.com/a/614280
has answer: http://stackoverflow.com/a/16503128
score: 540

http://stackoverflow.com/a/479738
type: Answer
score: 124
upvote count: 124
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/479701
has body: Since Java Strings are based on char arrays and Java automatically checks array bounds, buffer overflows are only possible in unusual scenarios: If you call native code via JNI In the JVM itself (usually written in C++) The interpreter or JIT compiler does not work correctly (Java bytecode mandated bounds checks)
answers question: http://stackoverflow.com/q/479701

http://stackoverflow.com/a/497153
type: Answer
has comment: http://stackoverflow.com/comment/312891
answers question: http://stackoverflow.com/q/497025
has body: Use more than one set and do it in "rounds": /* very pseudo-code */ doFunction(Object o) { Set processed = new HashSet(); Set toProcess = new HashSet(); Set processNext = new HashSet(); toProcess.add(o); while (toProcess.size() &gt; 0) { for(it = toProcess.iterator(); it.hasNext();) { Object o = it.next(); doStuff(o); processNext.addAll(o.subObjects); } processed.addAll(toProcess); toProcess = processNext; toProcess.removeAll(processed); processNext = new HashSet(); } }
score: 0

http://stackoverflow.com/comment/329266
comment on: http://stackoverflow.com/a/515644
has text: +1 On using CSV which will be far more flexible and maintainable in the future (and not tied to one version of your implementation: serialVersionUID woes etc).
type: Comment
score: 1
type: AnswerComment

http://stackoverflow.com/comment/130039814
type: QuestionComment
type: Comment
has text: It's not about streams - it's about swimming. If you can swim one Stream, than you can swim any Stream you encounter.
score: 0
comment on: http://stackoverflow.com/q/507747

http://stackoverflow.com/q/587099
type: Question
tagged with: exception
upvote count: 6
has answer: http://stackoverflow.com/a/587108
answer count: 3
has answer: http://stackoverflow.com/a/587124
has title: Stop bash script if unchecked Java Exception is thrown
has body: I am running a java program from within a Bash script. If the java program throws an unchecked exception, I want to stop the bash script rather than the script continuing execution of the next command. How to do this? My script looks something like the following: #!/bin/bash javac *.java java -ea HelloWorld &gt; HelloWorld.txt mv HelloWorld.txt ./HelloWorldDir
tagged with: java
accepted answer: http://stackoverflow.com/a/587108
score: 6
tagged with: bash
type: AnsweredQuestion
downvote count: 0
possible better answer: http://stackoverflow.com/a/587567
favorite count: 0
has answer: http://stackoverflow.com/a/587567

http://stackoverflow.com/a/955066
has body: One more option is WinRun4J. There is an Eclipse Plugin for WinRun4J that allows you to export your application as a single executable with necessary jars/classes embedded. (full disclosure: I work on this project)
downvote count: 0
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/423938

http://stackoverflow.com/q/366562
type: AnsweredQuestion
downvote count: 0
tagged with: java
possible better answer: http://stackoverflow.com/a/366716
type: Question
tagged with: c#
score: 3
has answer: http://stackoverflow.com/a/366716
has title: Mono - sharing code on client and server . .
upvote count: 3
has body: We are trying to come up with our client and server standard and there is a big debate. One school of thought is C# client and java servers using some type of proprietary messsage library to share data objects (think XML like structure . .) The issue with this model is that there is lots of code that needs to be duplicated (validation, parsing) that could simply be reused if you went with C# on the server as well. If there is a big push to use linux machine then wouldn't mono support your goal . . anyone else have this dilemma?
accepted answer: http://stackoverflow.com/a/366674
favorite count: 0
has answer: http://stackoverflow.com/a/366565
tagged with: shared-libraries
has answer: http://stackoverflow.com/a/366674
answer count: 4
has answer: http://stackoverflow.com/a/366727

http://stackoverflow.com/comment/12528057
has text: When getting the selection from the package explorer, the elements are not instances if IFile. You need to perform JDT->resource conversions.
type: Comment
comment on: http://stackoverflow.com/a/586013
type: AnswerComment
score: 4

http://stackoverflow.com/a/1561623
has body: We solved this with the class below. Just call the authenticate method: import java.text.MessageFormat; import java.util.*; import javax.naming.*; import org.apache.log4j.Level; public class LdapGroupAuthenticator { public static final String DISTINGUISHED_NAME = "distinguishedName"; public static final String CN = "cn"; public static final String MEMBER = "member"; public static final String MEMBER_OF = "memberOf"; public static final String SEARCH_BY_SAM_ACCOUNT_NAME = "(SAMAccountName={0})"; public static final String SEARCH_GROUP_BY_GROUP_CN = "(&amp;(objectCategory=group)(cn={0}))"; /* * Prepares and returns CN that can be used for AD query * e.g. Converts "CN=**Dev - Test Group" to "**Dev - Test Group" * Converts CN=**Dev - Test Group,OU=Distribution Lists,DC=DOMAIN,DC=com to "**Dev - Test Group" */ public static String getCN(String cnName) { if (cnName != null &amp;&amp; cnName.toUpperCase().startsWith("CN=")) { cnName = cnName.substring(3); } int position = cnName.indexOf(','); if (position == -1) { return cnName; } else { return cnName.substring(0, position); } } public static boolean isSame(String target, String candidate) { if (target != null &amp;&amp; target.equalsIgnoreCase(candidate)) { return true; } return false; } public static boolean authenticate(String domain, String username, String password) { Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://1.2.3.4:389"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, domain + "\\" + username); env.put(Context.SECURITY_CREDENTIALS, password); DirContext ctx = null; String defaultSearchBase = "DC=DOMAIN,DC=com"; String groupDistinguishedName = "DN=CN=DLS-APP-MyAdmin-C,OU=DLS File Permissions,DC=DOMAIN,DC=com"; try { ctx = new InitialDirContext(env); // userName is SAMAccountName SearchResult sr = executeSearchSingleResult(ctx, SearchControls.SUBTREE_SCOPE, defaultSearchBas…
type: Answer
downvote count: 0
score: 23
has comment: http://stackoverflow.com/comment/2608784
accepted answer of: http://stackoverflow.com/q/570466
type: AcceptedAnswer
upvote count: 23
answers question: http://stackoverflow.com/q/570466

http://stackoverflow.com/comment/77266155
has text: Note that if you build the jar using the `Package required libraries into generated JAR` option in the export menu, Eclipse will use its jar-in-jar loader and the resource url will start with `rsrc:` (e.g. `rsrc:com/whatever/Foo.class`). Therefore, to be sure you're running from within a jar, you should check `if (resourcePath.startsWith("jar:") || resourcePath.startsWith("rsrc:"))`
type: AnswerComment
comment on: http://stackoverflow.com/a/482566
type: Comment
score: 1

http://stackoverflow.com/comment/459692
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/646302
type: Comment
has text: If index 4 is unselected then why would getSelectedIndex() return 4 and not -1?

http://stackoverflow.com/q/582126
has comment: http://stackoverflow.com/comment/1148342
tagged with: http
has answer: http://stackoverflow.com/a/4566126
has answer: http://stackoverflow.com/a/584081
type: Question
has title: Best way to upload multiple files from a browser
tagged with: flash
possible better answer: http://stackoverflow.com/a/584047
upvote count: 36
tagged with: upload
has answer: http://stackoverflow.com/a/584047
accepted answer: http://stackoverflow.com/a/595505
has answer: http://stackoverflow.com/a/582153
has comment: http://stackoverflow.com/comment/8339925
downvote count: 0
tagged with: silverlight
has comment: http://stackoverflow.com/comment/1182119
favorite count: 0
answer count: 9
has body: I'm working on a web application. There is one place where the user can upload files with the HTTP protocol. There is a choice between the classic HTML file upload control and a Java applet to upload the files. The classic HTML file upload isn't great because you can only select one file at a time, and it's quite hard to get any progress indication during the actual upload (I finally got it using a timer refreshing a progress indicator with data fetched from the server via an AJAX call). The advantage: it's always working. With the Java applet I can do more things: select multiple files at once (even a folder), compress the files, get a real progress bar, drag'n'drop files on the applet, etc... BUT there are a few drawbacks: it's a nightmare to get it to work properly on Mac Safari and Mac Firefox (Thanks Liveconnect) the UI isn't exactly the native UI and some people notice that the applet isn't as responsive as it should (could be my fault, but everything looks ok to me) there are bugs in the Java UrlConnection class with HTTPS, so I use the Apache common HTTP client to do the actual HTTP upload. It's quite big a package and slows down the download of the .jar file the Apache common HTTP client has sometimes trouble going through proxies the Java runtime is quite big I've been maintaining this Java applet for a while but now I'm fed up with all the drawbacks, and considering writing/buying a completely new component to upload theses files. Question If you had the following requirements: upload multiple files easily from a browser, through HTTP or HTTPS compress the files to reduce the upload time upload should work on any platform, with native UI must be able to upload huge files, up to 2gb at least you have carte blanche on the technology What technology/compontent would you use? Edit : Drag'n'Drop of files on the component would be a great plus. It looks like there are a lot of issues related to bugs with the Flash Player (swfupload known issues). Proper Mac sup…
has answer: http://stackoverflow.com/a/582142
has answer: http://stackoverflow.com/a/582145
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/582776
has answer: http://stackoverflow.com/a/595505
tagged with: java
has answer: http://stackoverflow.com/a/1696500
score: 36

http://stackoverflow.com/a/422914
has body: Ant properties do not work the way you expect: they are immutable, i.e. you cannot change a property's value after you have set it once. If you run ant -Dsome.other.property=commandlinedefinedpath the output will no longer show [echo] some.other.property=test1
answers question: http://stackoverflow.com/q/422848
type: Answer
accepted answer of: http://stackoverflow.com/q/422848
score: 8
downvote count: 0
upvote count: 8
type: AcceptedAnswer

http://stackoverflow.com/q/472626
answer count: 4
has body: I've been trying to grok the org.apache.commons.beanutils library for a method/idiom to evaluate for equality all properties between 2 instances i.e. a generic equals() method for beans. Is there a simple way to do this usnig this library? Or am I going about this the wrong way? Thanks.
has answer: http://stackoverflow.com/a/35104301
has title: how to generically compare entire java beans?
upvote count: 21
possible better answer: http://stackoverflow.com/a/472637
has comment: http://stackoverflow.com/comment/65783680
has answer: http://stackoverflow.com/a/472637
type: AnsweredQuestion
score: 21
tagged with: java
has answer: http://stackoverflow.com/a/472705
type: Question
downvote count: 0
tagged with: javabeans
favorite count: 0
linked to: http://stackoverflow.com/q/1741041
accepted answer: http://stackoverflow.com/a/472705
has answer: http://stackoverflow.com/a/472855

http://stackoverflow.com/a/1056229
downvote count: 1
upvote count: 16
has comment: http://stackoverflow.com/comment/38288681
answers question: http://stackoverflow.com/q/427750
score: 15
has comment: http://stackoverflow.com/comment/38305915
has body: I have to strongly disagree with this question. There is no justification for a mocking tool that limits design choices. It's not just static methods that are ruled out by EasyMock, EasyMock Class Extension, jMock, Mockito, and others. These tools also prevent you from declaring classes and methods final, and that alone is a very bad thing. (If you need one authoritative source that defends the use of final for classes and methods, see the "Effective Java" book, or watch this presentation from the author.) And "initialising collaborators rather than injecting them" often is the best design, in my experience. If you decompose a class that solves some complex problem by creating helper classes that are instantiated from that class, you can take advantage of the ability to safely pass specific data to those child objects, while at the same time hiding them from client code (which provided the full data used in the high-level operation). Exposing such helper classes in the public API violates the principle of information hiding, breaking encapsulation and increasing the complexity of client code. The abuse of DI leads to stateless objects which really should be stateful because they will almost always operate on data that is specific to the business operation. This is not only true for non-public helper classes, but also for public "business service" classes called from UI/presentation objects. Such service classes are usually internal code (to a single business application) that is inherently not reusable and have only a few clients (often only one) because such code is by nature domain/use-case specific. In such a case (a very common one, by the way) it makes much more sense to have the UI class directly instantiate the business service class, passing data provided by the user through a constructor. Being able to easily write unit tests for code like this is precisely what led me to create the JMockit toolkit. I wasn't thinking about legacy code, but about simplicity …
has comment: http://stackoverflow.com/comment/38306055
type: Answer

http://stackoverflow.com/a/640482
score: 4
answers question: http://stackoverflow.com/q/640464
type: Answer
has body: There's no pitfall. It will sleep for as long as you tell it to. There may or may not be a pitfall in the idea of your application falling asleep for a prolonged period of time.
upvote count: 4
has comment: http://stackoverflow.com/comment/454023
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/640464

http://stackoverflow.com/comment/443963
type: AnswerComment
type: Comment
has text: Ironically, I nearly included this possibility in my answer, but for some reason didn't in the end. That'll teach me - next time I'll post all ideas, no matter how silly :)
comment on: http://stackoverflow.com/a/631289
score: 4

arraylist
tags question: http://stackoverflow.com/q/580269
tags question: http://stackoverflow.com/q/566655
tags question: http://stackoverflow.com/q/505928
tags question: http://stackoverflow.com/q/489204
tags question: http://stackoverflow.com/q/459643
tags question: http://stackoverflow.com/q/599161
tags question: http://stackoverflow.com/q/399311
tags question: http://stackoverflow.com/q/558978
tags question: http://stackoverflow.com/q/642249
type: Tag
tags question: http://stackoverflow.com/q/562894
tag name: arraylist
tags question: http://stackoverflow.com/q/361723

http://stackoverflow.com/a/35518262
upvote count: 3
has body: I am linking to what essentially is the same discussion where Peter Lawrey is providing a good answer. Why I get a negative elapsed time using System.nanoTime()? Many people mentioned that in Java System.nanoTime() could return negative time. I for apologize for repeating what other people already said. nanoTime() is not a clock but CPU cycle counter. Return value is divided by frequency to look like time. CPU frequency may fluctuate. When your thread is scheduled on another CPU, there is a chance of getting nanoTime() which results in a negative difference. That's logical. Counters across CPUs are not synchronized. In many cases, you could get quite misleading results but you wouldn't be able to tell because delta is not negative. Think about it. (unconfirmed) I think you may get a negative result even on the same CPU if instructions are reordered. To prevent that, you'd have to invoke a memory barrier serializing your instructions. It'd be cool if System.nanoTime() returned coreID where it executed.
downvote count: 1
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/95860675
has comment: http://stackoverflow.com/comment/95857133
has comment: http://stackoverflow.com/comment/95857165
has comment: http://stackoverflow.com/comment/95822618
has comment: http://stackoverflow.com/comment/95822634
has comment: http://stackoverflow.com/comment/95860657
has comment: http://stackoverflow.com/comment/95823050
answers question: http://stackoverflow.com/q/510462

http://stackoverflow.com/comment/29314766
comment on: http://stackoverflow.com/a/624423
score: 7
type: AnswerComment
has text: This is the old way to do it. From Java 1.5 onwards you can use package-info.java
type: Comment

http://stackoverflow.com/comment/5953286
has text: Unless there's something seriously wrong in FtpClient, this can't be the real solution. read() should block only if available() returns 0, so instead of waiting in read() you'll be waiting in this loop and eating a lot more CPU.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/596967

http://stackoverflow.com/q/645746
upvote count: 28
has answer: http://stackoverflow.com/a/670988
has answer: http://stackoverflow.com/a/672449
has answer: http://stackoverflow.com/a/672862
favorite count: 0
has answer: http://stackoverflow.com/a/665928
downvote count: 2
has answer: http://stackoverflow.com/a/669512
tagged with: web-applications
possible better answer: http://stackoverflow.com/a/645856
has answer: http://stackoverflow.com/a/941597
has answer: http://stackoverflow.com/a/645856
has answer: http://stackoverflow.com/a/669571
type: AnsweredQuestion
tagged with: performance
tagged with: java
type: Question
tagged with: jakarta-ee
has title: How to improve productivity when developing Java EE based web applications
has answer: http://stackoverflow.com/a/671370
has answer: http://stackoverflow.com/a/668992
has answer: http://stackoverflow.com/a/672473
accepted answer: http://stackoverflow.com/a/669512
score: 26
has answer: http://stackoverflow.com/a/673116
has answer: http://stackoverflow.com/a/671464
has answer: http://stackoverflow.com/a/672954
has body: I'd like to know how you address the seemingly low productivity of Java EE-based web application development compared to other technology stacks (Seaside, Ruby on Rails, etc). The constraints are: The finished web application must be deployable on Java EE compliant application containers If possible, previous investment in Java-based solution should be preserved, i.e. native interoperability with Java-based systems and libraries should be possible Due to team structure, Java as implementation language is preferred, although less exotic JVM-based languages (i.e. Groovy) might be acceptable as well The resulting system needs to be architecturally sound The resulting system needs to be extensible and maintainable To not let this dwindle into a philosophical discussion, I'm only interested in suggestions that are based on practical experience. Possible examples include domain specific languages, frameworks and MDSD. If you point to an abstract class of solutions (like MDA / MDSD), please provide details on how you implemented it as well as information about common pitfalls and best practices. If you disagree on the assumption that Java EE-based web application development implies inferior productivity, I'd like to hear your reasoning as well. EDIT: As there are a lot less answers than I expected, I'll accept accounts of abortive attempts as well, basically extending the question to "How (not) to improve productivity when developing Java EE based web applications?".
answer count: 14

http://stackoverflow.com/q/571960
answer count: 6
has body: How can one quickly turn off all Log4J output using a log4j.properties file?
tagged with: logging
has title: Disabling Log4J Output in Java
has answer: http://stackoverflow.com/a/46060145
tagged with: java
has answer: http://stackoverflow.com/a/39014209
has answer: http://stackoverflow.com/a/571972
possible better answer: http://stackoverflow.com/a/6736961
score: 95
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/6736961
has answer: http://stackoverflow.com/a/572872
downvote count: 0
favorite count: 0
upvote count: 95
type: Question
accepted answer: http://stackoverflow.com/a/571972
has answer: http://stackoverflow.com/a/585350
tagged with: log4j

http://stackoverflow.com/comment/37782210
type: Comment
has text: Looks like it might be staying for now: http://bugs.java.com/view_bug.do?bug_id=8021946
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2924426

http://stackoverflow.com/q/392775
upvote count: 4
has body: How can I indicate syntax errors (e.g. an illegal sequence of tokens) in an eclipse editor plugin just like in the eclipse Java editor, i.e. by red wriggly underlines, a red marker on the scrollbar that you can jump to, and an explanatory message when you hover over either one? I'm writing an eclipse editor plugin for a custom file format (specifically, the "snake file format" of the Shark3D game engine). I have implemented a scanner to get syntax highlighting, and an outline. For the underlines, do I simply have the scanner return an IToken with a "wriggly underline" TextAttribute instead of the normal one, or is there a specific mechanism for marking syntax errors? How do I implement the scrollbar markers? Is IAnnotationModel the relevant interface here? If so, where do I register the implementation so that the markers appear? I've only found SourceViewerConfiguration.getAnnotationHover(), which would allow me to implement the hover behaviour, but only for the "annotation", which I suppose means the scrollbar markers - how do I implement the hover behaviour for the text itself? I'd be happy specific advice as well as an URL of a tutorial that covers this - the eclipse help documents and examples don't seem to. Edit: Markers are the best solutions to this. A working example of how to use them can be found in the plugin example code in org.eclipse.ui.examples.readmetool.AddReadmeMarkerAction
type: AnsweredQuestion
downvote count: 0
tagged with: eclipse-plugin
type: Question
accepted answer: http://stackoverflow.com/a/393326
favorite count: 0
score: 4
has title: How to show syntax errors in an eclipse editor plugin
answer count: 2
possible better answer: http://stackoverflow.com/a/393335
has answer: http://stackoverflow.com/a/393335
tagged with: java
has answer: http://stackoverflow.com/a/393326
tagged with: syntax-highlighting

http://stackoverflow.com/a/1329039
has body: The first thing I would check is the config for mod_nss. It is the odd one out, for it is yours and there is none in the world like it :-) Whereas if there was some huge bug in Firefox or mod_nss itself, I guess you'd have found out about it by now in your google quest. The fact that you've fiddled with the config (e.g. disabling SSL3, and various other random tweaks), is also suspicious. I'd back track to a very vanilla mod_nss config and see if that works. Then change things systematically towards your current config until you can reproduce the problem. By the sound of it the source of the error is somewhere in the cipher spec config of mod_nss and the related protocol negotiation stuff. So maybe you inadvertently changed something there when trying to turn off SSLv3 (incidentally, why disable SSL3? Normally people disable V2?). One other thing to check is that you're on the latest mod_nss and it's not a known bug in that. The fact that it manages to start the session and then fails later is interesting - it suggests that maybe it is trying to renegotiate the session and failing to negotiate ciphers at that point. So it might be the symmetric ciphers. Or it could simply be an implementation bug in your version of mod_nss that somehow garbles the protocol. One other idea, and this is a wild guess, is the browser is trying to resume a session which was negotiated with SSLv3 before you disabled it, and something breaks when trying to resume that session when V3 is turned off, or maybe mod_nss just doesn't implement it right. The java/tomcat stuff seems like a red herring as unless I've misunderstood your description, none of that is involved in the SSL handshake/protocol.
score: 0
answers question: http://stackoverflow.com/q/547219
type: Answer

http://stackoverflow.com/q/418146
answer count: 6
has answer: http://stackoverflow.com/a/420164
has title: Ideas on this alternative to ORM + RDBMS?
has comment: http://stackoverflow.com/comment/242815
has answer: http://stackoverflow.com/a/418505
has answer: http://stackoverflow.com/a/420214
tagged with: persistence
favorite count: 0
upvote count: 8
type: UnansweredQuestion
has body: I am currently developing a proof of concept for an alternative data store. The reason why is I need to enhance a read-mostly clustered webapp, but also because I want to free myself from the pain of the sometimes overly-complex ORM+RDBMS solution. Overall the idea is quite similar to a distributed cache with persistence (letting the cluster be the SoR), however: want to be able to retrieve any object along with its children, by id (providing class &amp; id) [only that to start off, as the main querying part is already resolved with lucene in my app]. need to have map of maps of types ( ~ tables in the relational world), and therein distributed maps of 'dehydrated' stored objects (flattening the object graph via reflection deep cloning) a bin log (like Prevayler, for example) for eventual recovery if whole cluster goes down development (and ability to refactor code / change structure) perhaps asynchronously processed for other purposes (reporting, whatever) eventually later on try to integrate a statically-typed query mechanism, like LINQ, Jaque or H2's JaQu / see ODBs / Lucene (?) it has to be transaction-aware (not sure "JTA type" though) I'm planning to implement this idea with Hazelcast (I love its super-simple API) or Terracotta (which I never used - but I'm aware of their 'sweet spot', medium-term data). If you will, my aim is to do more or less what Jonas once blogged about. Using one of these, stored data would roughly have to fit in the sum of the JVM heaps of the cluster. This should be pretty simple to scale, would avoid the relational impedance mismatch (ie save as with an ODB) and JDBC + I/O overhead. Do you know of other tools/frameworks or combination thereof already providing similar functionality, that I'm ignoring? Can you suggest other ways of tackling this 'getting rid of the DB'? What flaws do you already see in this idea? Concurrency-wise would it make sense to consider Scala instead of Java? How about non-relational data stores such as Couch D…
has answer: http://stackoverflow.com/a/418567
score: 7
tagged with: java
has answer: http://stackoverflow.com/a/482517
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/424087
tagged with: database

http://stackoverflow.com/a/483624
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/483173
has body: When you allocated the Shell: shell = new Shell(); some native resources were allocated along with it. You have to dispose of these resources before you exit your application: private void exit() { shell.dispose(); System.exit(0); } Of course, you have to provide the "shell" variable to your exit() method to do this. Note that I don't believe that you need to dispose the Display, since you didn't create it with "new Display()". But anything in SWT (except for a few items where this is documented in the JavaDoc) that you create with new you must dispose when you are finished with it. Otherwise you will leak native resources.
downvote count: 0

http://stackoverflow.com/comment/56297608
has text: It doesn't even matter whether or not you need to have a different TX attribute. If you simply want to factor your logic such that it makes sense for one method to call another you will run into this if for example you are passing entities (which need to remain in a managed state) or wish to exist with the same TX as the caller or you wish interceptors to be called. If you don't use the proxy none of those things will happen.
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/641009

http://stackoverflow.com/q/639592
has answer: http://stackoverflow.com/a/640561
linked to: http://stackoverflow.com/q/761194
tagged with: oop
has answer: http://stackoverflow.com/a/639731
tagged with: java
has answer: http://stackoverflow.com/a/639677
has title: Why are interfaces preferred to abstract classes?
has comment: http://stackoverflow.com/comment/455779
has answer: http://stackoverflow.com/a/647657
has answer: http://stackoverflow.com/a/639790
linked to: http://stackoverflow.com/q/479142
has comment: http://stackoverflow.com/comment/460787
has answer: http://stackoverflow.com/a/639621
possible better answer: http://stackoverflow.com/a/639731
has body: I recently attended an interview and they asked me the question "Why Interfaces are preferred over Abstract classes?" I tried giving a few answers like: We can get only one Extends functionality they are 100% Abstract Implementation is not hard-coded They asked me take any of the JDBC api that you use. "Why are they Interfaces?". Can I get a better answer for this?
has answer: http://stackoverflow.com/a/639602
score: 39
has answer: http://stackoverflow.com/a/639747
has answer: http://stackoverflow.com/a/639607
accepted answer: http://stackoverflow.com/a/639656
has answer: http://stackoverflow.com/a/639604
has answer: http://stackoverflow.com/a/13688184
tagged with: abstraction
has answer: http://stackoverflow.com/a/647446
has answer: http://stackoverflow.com/a/640481
has answer: http://stackoverflow.com/a/639640
upvote count: 39
has answer: http://stackoverflow.com/a/1796785
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/40471639
has answer: http://stackoverflow.com/a/639739
downvote count: 0
has answer: http://stackoverflow.com/a/6884376
has comment: http://stackoverflow.com/comment/453076
favorite count: 0
has answer: http://stackoverflow.com/a/639609
has comment: http://stackoverflow.com/comment/66433384
has answer: http://stackoverflow.com/a/745527
has comment: http://stackoverflow.com/comment/453049
type: Question
has comment: http://stackoverflow.com/comment/1684486
tagged with: interface
has comment: http://stackoverflow.com/comment/453263
has answer: http://stackoverflow.com/a/639656
has comment: http://stackoverflow.com/comment/25262960
has answer: http://stackoverflow.com/a/1600854
has answer: http://stackoverflow.com/a/639633
answer count: 23

http://stackoverflow.com/comment/376685
type: AnswerComment
comment on: http://stackoverflow.com/a/565469
type: Comment
has text: I havent used closures because i didnt understand them, but your comment is starting to connect some dots for me, thanks
score: 0

http://stackoverflow.com/a/673558
has comment: http://stackoverflow.com/comment/1632037
upvote count: 20
downvote count: 0
has body: As Martin mentioned, by default most JMS implementations will process message selectors on the client, unless they are part of a durable subscription, when most JMS implementations will process them on the server as well to avoid too many messages getting persisted when there's a significant reduction in the number of messages that get past the selector. Some systems (like SonicMQ) allow you to specify that message selectors should be processed on the server, which is a good option in a case where you have excess CPU available on your message brokers but not on your consumers. Bear in mind that while topic-based selection is usually faster, it can be quite cumbersome, because if you want to listen to 5 different things, you have to have 5 different MessageConsumers. Each of those in a naive driver implementation is a different thread, and that can start to add up. For that reason, it is often useful to support both from publication so that some clients can listen only to the topics that they want, and others can listen to the topic hierarchies they want (e.g. foo.#) with message selectors (or code-based selectors). However, you should always test against your application and your broker. Every broker handles the situation differently, and every application functions differently. You can't just say "always use technique X" because each technique for client-directed message processing has different tradeoffs. Benchmark, benchmark, benchmark. One thing to bear in mind with message selectors is that they aren't dynamically changeable, so you have the possibility of losing messages or having to manually manage a complicated switchover scenario. Imagine the following use case: You are listening to a message selector of the form (Ticker in ('CSCO', 'MSFT')) User wants to start listening to AAPL You have to shut down the old MessageConsumer and start a new one with a selector in the form (Ticker in ('CSCO, 'MSFT', 'AAPL')) During the switchover, you either lose messages (be…
score: 20
accepted answer of: http://stackoverflow.com/q/587899
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/587899
type: Answer

http://stackoverflow.com/a/618913
downvote count: 0
answers question: http://stackoverflow.com/q/618844
type: Answer
has body: I'd oppose the idea of storing error logs in a database. The logging system should be as simple as possible and not involve components that are not 100% necesary to write a log record. Things can get pretty complex when logging into a DB - e.g. you can having troubles logging any database-related errors (how to log errors that occured because DB not responding, e.g. because of a heavy load or a infrastructure error); other issue I'd see is a potential need to have separate transactions for logging, etc. On the other hand, having a reference ID for an error is not a bad idea, but again, this it also means to increase complexity of logging system ( e.g. how would you propagate the ref. ID through all layers of your application when a error occurs? ) In projects I'm involved to, the general guideline is to log errors as verbosely as possible, and to include as much context information as possible (to write the logs, we use a 'conventional' approach usually - log4j or simillar). Usually, this works well even for heavy loaded systems.
upvote count: 1
score: 1

http://stackoverflow.com/q/538752
tagged with: cpu-registers
favorite count: 0
has body: In C, I can allocate a register for a variable, for example: register int i = 0; I am aware that Java is an interpreted language, and is many many abstractions away from the CPU. Is there any mechanism available to even request (and if the architecture doesn't allow it, so what) that my variable remains in a register instead of moving to cache or main memory? I don't suppose there is any way, but I have been pleasantly surprised before. Thank you,
has answer: http://stackoverflow.com/a/538772
upvote count: 7
has comment: http://stackoverflow.com/comment/351126
has answer: http://stackoverflow.com/a/538764
possible better answer: http://stackoverflow.com/a/538764
downvote count: 0
has title: Java equivalent of register int?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/543345
has answer: http://stackoverflow.com/a/538768
accepted answer: http://stackoverflow.com/a/538768
score: 7
tagged with: java
has answer: http://stackoverflow.com/a/538767
tagged with: http://stackoverflow.com/tag/c
answer count: 6
has answer: http://stackoverflow.com/a/539097
has comment: http://stackoverflow.com/comment/351187
type: Question

http://stackoverflow.com/a/359777
type: Answer
score: 8
downvote count: 1
upvote count: 9
answers question: http://stackoverflow.com/q/359732
has body: Your main arguments against using braces are that they use additional lines and that they require additional indenting. Lines are (almost) free, minimizing the number of lines in your code shouldn't be an objective. And indentation is independent of brace usage. In your cascading 'using' example I still think you should be indenting them even when you omit the braces.

http://stackoverflow.com/a/5327537
has body: String s = "-1139627840"; BigInteger bg1 = new BigInteger(s); System.out.println(bg1.abs()); Alternatively: int i = -123; System.out.println(Math.abs(i));
downvote count: 0
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/493494

http://stackoverflow.com/a/10591089
answers question: http://stackoverflow.com/q/492184
upvote count: 9
has comment: http://stackoverflow.com/comment/109173964
type: Answer
downvote count: 0
score: 9
has body: I did this several years ago. The most reliable way to do this (i.e. with official Java APIs and no external dependencies) is to write a custom doclet to produce a list that can be read at runtime. You can run it from the command line like this: javadoc -d build -doclet com.example.ObjectListDoclet -sourcepath java/src -subpackages com.example or run it from ant like this: &lt;javadoc sourcepath="${src}" packagenames="*" &gt; &lt;doclet name="com.example.ObjectListDoclet" path="${build}"/&gt; &lt;/javadoc&gt; Here's the basic code: public final class ObjectListDoclet { public static final String TOP_CLASS_NAME = "com.example.MyClass"; /** Doclet entry point. */ public static boolean start(RootDoc root) throws Exception { try { ClassDoc topClassDoc = root.classNamed(TOP_CLASS_NAME); for (ClassDoc classDoc : root.classes()) { if (classDoc.subclassOf(topClassDoc)) { System.out.println(classDoc); } } return true; } catch (Exception ex) { ex.printStackTrace(); return false; } } } For simplicity, I've removed command line argument parsing and I'm writing to System.out rather than a file.

http://stackoverflow.com/comment/346817
score: 0
type: Comment
comment on: http://stackoverflow.com/q/533102
type: QuestionComment
has text: What I've heard so far seems to indicate that it's kind of a judgment call. However, most answers haven't focussed on the practical considerations. That's more what I'm looking for. Thanks for the help so far, though!

http://stackoverflow.com/comment/787871
type: AnswerComment
comment on: http://stackoverflow.com/a/473091
score: 0
type: Comment
has text: I wasn't the person downvoting you but I'm quite a bit allergic against commons.logging... I was using it exclusively until about three years ago and switched *all* the code under my fingers over to SLF4J in the meantime. I'd still consider a downvote of your answer crude, especially without a comment, but some people are like that :(

http://stackoverflow.com/a/8794812
answers question: http://stackoverflow.com/q/617414
type: Answer
score: 22
upvote count: 22
has body: As of Java 1.7 createTempDirectory(prefix, attrs) and createTempDirectory(dir, prefix, attrs) are included in java.nio.file.Files Example: File tempDir = Files.createTempDirectory("foobar").toFile();
downvote count: 0

http://stackoverflow.com/q/502494
has answer: http://stackoverflow.com/a/502605
has comment: http://stackoverflow.com/comment/317568
has answer: http://stackoverflow.com/a/502843
has comment: http://stackoverflow.com/comment/320218
has answer: http://stackoverflow.com/a/502591
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/502597
has body: I used Runtime.getRuntime().exec("_____") but it throws a IOException as below: java.io.IOException: CreateProcess: c:/ error=5 at java.lang.Win32Process.create(Native Method) at java.lang.Win32Process.&lt;init&gt;(Win32Process.java:63) at java.lang.Runtime.execInternal(Native Method I don't know whether I have the problem with specifying the path or something else. Can anyone please help me with the code.
has answer: http://stackoverflow.com/a/20647811
has comment: http://stackoverflow.com/comment/317554
has answer: http://stackoverflow.com/a/505512
has comment: http://stackoverflow.com/comment/317625
has answer: http://stackoverflow.com/a/502920
tagged with: java
score: 10
upvote count: 10
has answer: http://stackoverflow.com/a/502582
has answer: http://stackoverflow.com/a/17496176
duplicate of: http://stackoverflow.com/q/15218892
type: Question
has answer: http://stackoverflow.com/a/505557
answer count: 14
has title: Execute a Java program from our Java program
has answer: http://stackoverflow.com/a/15610368
has answer: http://stackoverflow.com/a/502581
downvote count: 0
has comment: http://stackoverflow.com/comment/319714
favorite count: 0
has answer: http://stackoverflow.com/a/9479959
has answer: http://stackoverflow.com/a/502867

http://stackoverflow.com/comment/26122314
has text: HelloWorld on my system always shows 28 * 65Mb anon blocks in pmap, that's 1.8GB VIRT! I assume that's mapped files now and nothing to worry about... thanks to @kdgregory. But does anybody know what they are? Given that they're all on the ByteBuffer Integer.MAX_VALUE boundary of 65Mb it may be one huge file? Is it all the JVM classes and native libs? /proc/*/fd doesn't seem to show much other than jre/lib/rt.jar, which is not even close. Probably JVM/OS dependent but would like to know more!
type: Comment
comment on: http://stackoverflow.com/a/561450
score: 0
type: AnswerComment

http://stackoverflow.com/comment/272042
score: 0
type: AnswerComment
has text: @Mark G: Inheritance restricts changes in implementation, so I don't regard allowing it as future-proofing at all. It *limits* future changes rather than allowing them.
comment on: http://stackoverflow.com/a/451219
type: Comment

http://stackoverflow.com/comment/66403444
type: Comment
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/2949496
has text: True, @Dmitry, but is that worth your downvote? Should the same problem with Spring be another question then? That's not how Stack Overflow works in my opinion, and apparently 18 upvoters found the answer to their problem given the title *"How to configure JPA for testing in Maven"*. Even more, the first paragraph in my answer is not about Spring, followed by _"When using JPA in Spring [...]"_.

http://stackoverflow.com/comment/22883893
score: 7
type: AnswerComment
comment on: http://stackoverflow.com/a/8592871
has text: Per the JVM spec the JVM is not required to provide full stack traces (optimization, inlining and all that) and you've already discovered that your heuristic changed between Oracle Java 5 and Oracle Java 6. There is nothing guaranteeing that any other JVM will behave as you expect in your code, so you are subtly relying on vendor specific behavior. Which is perfectly fine, as long as you are aware of that, but if - for instance - you need to deploy on an IBM JVM (which we must) or on a Zing instance you may have to revisit your heuristic.
type: Comment

http://stackoverflow.com/comment/11157558
score: 0
type: Comment
has text: I believe your context.xml file can control the automatic session creation if your <Context> tag contains a cookies attribute, e.g. <Context cookies="false">
comment on: http://stackoverflow.com/a/598923
type: AnswerComment

contains
tags question: http://stackoverflow.com/q/435023
tag name: contains
type: Tag
tags question: http://stackoverflow.com/q/549808

http://stackoverflow.com/q/426397
tagged with: newline
has answer: http://stackoverflow.com/a/426917
has comment: http://stackoverflow.com/comment/250183
has body: I am trying to parse the Linux /etc/passwd file in Java. I'm currently reading each line through the java.util.Scanner class and then using java.lang.String.split(String) to delimit each line. The problem is that the line: list:x:38:38:Mailing List Manager:/var/list:/bin/sh" is treated by the scanner as 3 different lines: list:x:38:38:Mailing List Manager... When I type this out into a new file that I didn't get from Linux, Scanner parses it properly. Is there something I'm not understanding about new lines in Linux? Obviously a work around is to parse it without using scanner, but it wouldn't be elegant. Does anyone know of an elegant way to do it? Is there a way to convert the file into one that would work with Scanner? Not even two days ago: Historical reason behind different line ending at different platforms EDIT Note from the original author: "I figured out I have a different error that is causing the problem. Disregard question"
favorite count: 0
has answer: http://stackoverflow.com/a/426404
tagged with: linux
answer count: 5
has title: Do line endings differ between Windows and Linux?
score: 32
has comment: http://stackoverflow.com/comment/250126
has answer: http://stackoverflow.com/a/426460
upvote count: 34
has answer: http://stackoverflow.com/a/426416
type: UnansweredQuestion
tagged with: java
downvote count: 2
type: Question
has answer: http://stackoverflow.com/a/426445

http://stackoverflow.com/comment/82238384
has text: @maaartinus There are cases where enum member names are used without the string coming from outside. For example, when you want to loop through all the members dynamically to do something with each. Furthermore, whether the string comes from outside or not is irrelevant. The developer has all the information they need, to know whether passing x string to "MyEnum#valueOf" will result in an error before passing it. Passing x string to "MyEnum#valueOf" anyway when it would have caused error, would clearly be a mistake on the developer's part.
comment on: http://stackoverflow.com/a/614174
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/374608
type: AnswerComment
has text: Works on Vista, passed it on to to be tested on Tomcat. thanks +1
score: 0
type: Comment
comment on: http://stackoverflow.com/a/559059

http://stackoverflow.com/a/536254
accepted answer of: http://stackoverflow.com/q/402302
answers question: http://stackoverflow.com/q/402302
has body: Add the property theme="simple" like
type: AcceptedAnswer
downvote count: 0
score: 6
type: Answer
upvote count: 6

http://stackoverflow.com/a/366869
answers question: http://stackoverflow.com/q/366861
type: Answer
has body: Have you verified that you can connect to the database on the server, with the name and password. Also if you are connecting via a url you should not need the following line. properties.setProperty("socket", "/Applications/MAMP/tmp/mysql/mysql.sock"); The above property seems specific to Os X. Are you running the server on os X?
has comment: http://stackoverflow.com/comment/196281
score: 0

http://stackoverflow.com/comment/101431382
score: 2
has text: @finnw, defensive programming is always a good thing when practicing software engineering. Vague references to bloat without specifics is not helpful to novice readers; the use of a `final Object`, which makes the locking mechanism explicit and encapsulated, is not even remotely bloat.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/442570

http://stackoverflow.com/a/471394
has comment: http://stackoverflow.com/comment/289071
score: 2
answers question: http://stackoverflow.com/q/471296
downvote count: 0
has body: Think of Nan as the equivalent of exception but uses a magic value within a calculation. Because a calculation failed - eg square root of a negative, divide by zero etc - it makes no sense in comparing them against anything else. After all if divide by zero is a nan is it equivalent to the square root of -2 or square root of -3 ? Nan allows a calculation that includes a step that returns an invalid answer to complete without introducing extra exceptions. To verify the answer is value simply test for non nandness ( is that's word if not I bags it) via Float.isNan() o equivalent.
upvote count: 2
type: Answer

http://stackoverflow.com/comment/205399
score: 0
type: AnswerComment
type: Comment
has text: lol. The reason is that this is a algorithm problem and you are suppose to find an answer that solves this without BigInts. BigInts is cheating ...
comment on: http://stackoverflow.com/a/377532

http://stackoverflow.com/comment/264860
score: 5
type: AnswerComment
comment on: http://stackoverflow.com/a/442868
has text: OK, so the file can only be read by the user running the program. Great. That solves nothing. :-) I, the user who we're trying to keep the password secret from, can read it just as easily as the app...
type: Comment

http://stackoverflow.com/comment/107309130
has text: Doesn't work if I want to integration test something that involves an asynchronous library call like Spring's `WebClient`
type: Comment
comment on: http://stackoverflow.com/a/21099588
score: 1
type: AnswerComment

http://stackoverflow.com/comment/436906
type: AnswerComment
comment on: http://stackoverflow.com/a/623783
has text: Yes this is my preferred approach when using Qt too. Very dynamic UI I will hand code, but I will try to stick to a designer for the rest. Transforming and XML file as the library changes should also be a lot faster than transforming C++ code describing a GUI.
type: Comment
score: 0

http://stackoverflow.com/a/9761922
answers question: http://stackoverflow.com/q/379551
type: Answer
has body: sample java code to split List public List&lt;List&lt;Long&gt;&gt; split(List&lt;Long&gt; list, int i ){ List&lt;List&lt;Long&gt;&gt; out = new ArrayList&lt;List&lt;Long&gt;&gt;(); int size = list.size(); int number = size/i; int remain = size % i; if(remain != 0){ number++; } for(int j=0; j &lt; number; j++){ int start = j * i; int end = start+ i; if(end &gt; list.size()){ end = list.size(); } out.add(list.subList(start, end)); } return out; }
has comment: http://stackoverflow.com/comment/35302838
score: 0

http://stackoverflow.com/a/7814080
has body: Flash now has the NumberFormatter() class as part of flash.globalization.* it will format numbers in the users locale http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/globalization/NumberFormatter.html you can also set the number of leading, or trailing zeros
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/9540304
downvote count: 0
answers question: http://stackoverflow.com/q/582151
type: Answer

http://stackoverflow.com/q/602939
has body: We have implemented a table-based editor with an SWT tree table. It pretty much does what we want it to, except that we can't find a way to ensure that the first few columns remain at their position when the user scrolls horizontally (so that one can identify the row being edited). There are a number of third-party table controls in various degrees of being incomplete or abandoned, and a snippet that shows how to use two tables (which get out of sync when they're being scrolled vertically). What's the best way to solve this?
type: UnansweredQuestion
tagged with: java
tagged with: swt
has answer: http://stackoverflow.com/a/620670
upvote count: 1
has answer: http://stackoverflow.com/a/907958
type: Question
has title: "Fixing" the first few columns in an SWT table to prevent them from scrolling horizontally
answer count: 2
downvote count: 0
score: 1
favorite count: 0

http://stackoverflow.com/q/489255
type: Question
has answer: http://stackoverflow.com/a/489361
has answer: http://stackoverflow.com/a/27761906
answer count: 6
tagged with: taskbar
downvote count: 0
has body: I'm developing a Swing application and I need to flash the Windows taskbar. I can't use frame.requestFocus() because I don't want to steal focus from any other application.
has answer: http://stackoverflow.com/a/489341
favorite count: 0
score: 8
upvote count: 8
has answer: http://stackoverflow.com/a/489351
has answer: http://stackoverflow.com/a/76429462
possible better answer: http://stackoverflow.com/a/489351
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/489341
tagged with: java
has title: How can I flash the Windows taskbar using Swing?
tagged with: swing
has answer: http://stackoverflow.com/a/36596096

http://stackoverflow.com/a/486908
score: 2
downvote count: 0
has body: Have you considered Ant? I have to admit I never tried, but always wanted to port my scripts to Ant. File operations are easy and there are even tasks to create SQL statements. Of course if your scripts are more like programs, i.e. many loop constructs, then this is not the way to go. Just a suggestion.
upvote count: 2
has comment: http://stackoverflow.com/comment/1549862
type: Answer
answers question: http://stackoverflow.com/q/484355

http://stackoverflow.com/comment/374812
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/562906
score: 0
has text: Ok, so from what I can tell, the loops add each 'row' to a Set. So am i correct in thinking that now all that remains to do is compare each Set to the size of table1 (and if Set's size is less than the size of table1's size then there are duplicates)?

http://stackoverflow.com/a/9696283
has body: The question is well answered. I wanted mention one tool I find useful - One-Jar. One-Jar handles resources more cleanly (by keeping all of them). This more useful if the code needs to process MANIFEST files. Sample XML copied from website.. <import file="one-jar-ant-task.xml"/> <src path="${lib.dir}" /> <fileset dir="${classes.dir}/lib"/> <src path="${src.dir}" /> <classpath path="${build.dir}/lib.jar"/> <fileset dir="${classes.dir}/src"/> <fileset file="${build.dir}/lib.jar" /> Now you can run the Hello One-JAR example using $ java -jar hello.jar
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/515428
downvote count: 0
score: 1

http://stackoverflow.com/a/22378884
upvote count: 1
downvote count: 0
has body: Download jansi-1.4.jar and Set classpath and Try This code 100% working : import org.fusesource.jansi.AnsiConsole; import static org.fusesource.jansi.Ansi.*; import static org.fusesource.jansi.Ansi.Color.*; public class SampleColour { public static void main(String[] args) { AnsiConsole.systemInstall(); System.out.println(ansi().fg(RED).a("Hello World").reset()); System.out.println("My Name is Raman"); AnsiConsole.systemUninstall(); } }
type: Answer
score: 1
answers question: http://stackoverflow.com/q/565252

http://stackoverflow.com/a/8506000
has body: For native binaries, wxWidgets is a convenient solution. I would tell you that is even better than Java for the user experience side. Even though you can make the presentation layer look pretty much the same for all platforms in Java, they all look like Java. On the other hand, wxWidgets make the user feel like a platform specific build (and it is, indeed), but you can use the same code to compile for several platforms (at least the major ones).
score: 1
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/389051
upvote count: 1

http://stackoverflow.com/q/514487
has title: Modify JVM args from inside the JVM
tagged with: jvm
favorite count: 0
has answer: http://stackoverflow.com/a/1652624
has body: Is there a way to modify the jvm args from inside of the jvm? Specifically, I want to be able to change the maximum heap size of the jvm from inside of it. Is this possible? Edit: I guess I should add the reason I wanted to do this. I have a few Java programs that are run on different machines/platforms. These programs have configurations that are sourced at runtime and are different depending on the machine/environment the program's running one. Some of these configurations can be changed at runtime and the various programs automatically update themselves as the configurations change. I wanted heap size to be one of these configuration parameters that is sourced at runtime like the rest of the configuration. If so, then the program could startup (with some default jvm args) then adjust itself based on the retrieved config.
has answer: http://stackoverflow.com/a/750870
type: UnansweredQuestion
score: 3
has answer: http://stackoverflow.com/a/514526
upvote count: 3
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/530801
tagged with: vmargs
has answer: http://stackoverflow.com/a/24087383
has answer: http://stackoverflow.com/a/514513
has answer: http://stackoverflow.com/a/514540
downvote count: 0
answer count: 7

http://stackoverflow.com/comment/444092
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/631484
has text: Are you decompressing the files to be processed by the java app or are they being written out to disk?

http://stackoverflow.com/comment/47026664
type: QuestionComment
has text: I'm voting to close this question as off-topic because it is not about programming.
type: Comment
score: 1
comment on: http://stackoverflow.com/q/587226

http://stackoverflow.com/comment/232208
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/407323
has text: Ok cool, yeah i only looked at execution time, as R. Bemrose pointed out in A the variable sticks around after the loop has completed. Did you profile results tell you anything about memory usage ?

http://stackoverflow.com/a/566438
score: 7
upvote count: 7
has comment: http://stackoverflow.com/comment/377800
has body: Absolutely: import java.lang.reflect.*; public class Test { public static void main(String args[]) throws Exception { Test test = new Test(); Method method = Test.class.getMethod("sayHello"); method.invoke(test); } public void sayHello() { System.out.println("Hello!"); } } If you have problems, post a specific question (preferrably with a short but complete program demonstrating the problem) and we'll try to sort it out.
downvote count: 0
has comment: http://stackoverflow.com/comment/377711
type: Answer
answers question: http://stackoverflow.com/q/566418

http://stackoverflow.com/a/403024
has body: That question was nicely answered in this one: Why does C++ compilation take so long? (as jalf pointed out in the comments section) Basically it's the missing modules concept of C++, and the aggressive optimization done by the compiler.
downvote count: 0
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/24643343
answers question: http://stackoverflow.com/q/402969
type: Answer
score: 16
upvote count: 16
accepted answer of: http://stackoverflow.com/q/402969

http://stackoverflow.com/a/4272554
has comment: http://stackoverflow.com/comment/35533572
upvote count: 13
has comment: http://stackoverflow.com/comment/28486384
has body: this will print out all fields (including arrays of objects) of an object. Fixed version of Ben Williams post from this thread Note: this method uses recursion so If you have a very deep object graph you may get a stack-overflow (no pun intended ;) IF so you need to use the VM parameter -Xss10m. If your using eclipse put it in run>runconfiguration>augments (tab) VM augment box and press apply import java.lang.reflect.Array; import java.lang.reflect.Field; public static String dump(Object o) { StringBuffer buffer = new StringBuffer(); Class oClass = o.getClass(); if (oClass.isArray()) { buffer.append("Array: "); buffer.append("["); for (int i = 0; i &lt; Array.getLength(o); i++) { Object value = Array.get(o, i); if (value.getClass().isPrimitive() || value.getClass() == java.lang.Long.class || value.getClass() == java.lang.Integer.class || value.getClass() == java.lang.Boolean.class || value.getClass() == java.lang.String.class || value.getClass() == java.lang.Double.class || value.getClass() == java.lang.Short.class || value.getClass() == java.lang.Byte.class ) { buffer.append(value); if(i != (Array.getLength(o)-1)) buffer.append(","); } else { buffer.append(dump(value)); } } buffer.append("]\n"); } else { buffer.append("Class: " + oClass.getName()); buffer.append("{\n"); while (oClass != null) { Field[] fields = oClass.getDeclaredFields(); for (int i = 0; i &lt; fields.length; i++) { fields[i].setAccessible(true); buffer.append(fields[i].getName()); buffer.append("="); try { Object value = fields[i].get(o); if (value != null) { if (value.getClass().isPrimitive() || value.getClass() == java.lang.Long.class || value.getClass() == java.lang.String.class || value.getClass() == java.lang.Integer.class || value.getClass() == java.lang.Boolean.class || value.getClass() == java.lang.Double.class || value.getClass() == java.lang.Short.class || value.getClass() == java.lang.Byte.class ) { buffer.append(value); } else { buffer.append(dump(value)); } } } catch (IllegalAccessExc…
type: Answer
downvote count: 0
score: 13
answers question: http://stackoverflow.com/q/603013

http://stackoverflow.com/comment/286339
comment on: http://stackoverflow.com/a/468494
type: Comment
has text: I couldn't find anything in the documentation about generating html and text from the same template. Am I missing something?
score: 0
type: AnswerComment

http://stackoverflow.com/q/590899
has answer: http://stackoverflow.com/a/590912
upvote count: 3
has answer: http://stackoverflow.com/a/590926
has answer: http://stackoverflow.com/a/590917
type: AnsweredQuestion
score: 3
has answer: http://stackoverflow.com/a/591110
has answer: http://stackoverflow.com/a/590932
tagged with: java
tagged with: database
type: Question
accepted answer: http://stackoverflow.com/a/590923
possible better answer: http://stackoverflow.com/a/590926
downvote count: 0
answer count: 6
favorite count: 0
has answer: http://stackoverflow.com/a/590923
tagged with: termination
has body: Suppose I have a Java application that opens a database connection. Normally I would add a connection.close() in a finally block, but this block wouldn't be executed in the case of a kill operation, or any other abnormal termination, would it? Are there any other precautions that I, as a programmer, can make in order to close the connection properly before the application exits?
has title: Handling abnormal Java program exits

http://stackoverflow.com/a/4049949
has comment: http://stackoverflow.com/comment/56155974
score: 171
type: Answer
answers question: http://stackoverflow.com/q/559839
has comment: http://stackoverflow.com/comment/90735359
has body: This website is pretty good but not specific to Java: http://bigocheatsheet.com/
downvote count: 3
upvote count: 174

http://stackoverflow.com/comment/8065719
type: Comment
score: 1
has text: @Ed: It's basically an extension of Java that adds new language constructs. It requires a special compiler (that is generally slower than the regular Java compiler) as well as (I think) a runtime component.
type: AnswerComment
comment on: http://stackoverflow.com/a/2026856

http://stackoverflow.com/a/397599
downvote count: 0
has body: Winner by Accuracy: java.lang.IllegalArgumentException
score: 12
type: Answer
upvote count: 12
answers question: http://stackoverflow.com/q/397581

http://stackoverflow.com/comment/81629547
type: Comment
comment on: http://stackoverflow.com/a/446671
has text: Thanks, but a usage example would be nice too
type: AnswerComment
score: 0

http://stackoverflow.com/a/9458969
upvote count: 81
downvote count: 1
has comment: http://stackoverflow.com/comment/52511168
has body: The link in Andy's answer is a great starting point for mapping collections of "non-Entity" objects in JPA 2, but isn't quite complete when it comes to mapping enums. Here is what I came up with instead. @Entity public class Person { @ElementCollection(targetClass=InterestsEnum.class) @Enumerated(EnumType.STRING) // Possibly optional (I'm not sure) but defaults to ORDINAL. @CollectionTable(name="person_interest") @Column(name="interest") // Column name in person_interest Collection&lt;InterestsEnum&gt; interests; }
has comment: http://stackoverflow.com/comment/23594152
answers question: http://stackoverflow.com/q/416208
has comment: http://stackoverflow.com/comment/23589639
score: 80
has comment: http://stackoverflow.com/comment/23143775
has comment: http://stackoverflow.com/comment/41722563
type: Answer

http://stackoverflow.com/comment/281015
score: 0
type: AnswerComment
type: Comment
has text: dont you want AbstractSender implements Sendable.
comment on: http://stackoverflow.com/a/462351

specifications
type: Tag
tag name: specifications
tags question: http://stackoverflow.com/q/471476

http://stackoverflow.com/q/575920
has answer: http://stackoverflow.com/a/10471185
has body: As I understand it, an interface is Java is intended to enforce a design by laying out methods for classes implementing the interface to fill in. Is this the idea with a Ruby module also? I see that just like with Interfaces in Java, you can't instantiate a module in Ruby.
has answer: http://stackoverflow.com/a/589246
downvote count: 0
favorite count: 0
tagged with: ruby
has title: Is a Ruby module equivalent to a Java Interface?
answer count: 5
tagged with: interface
has answer: http://stackoverflow.com/a/575927
tagged with: module
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/575931
accepted answer: http://stackoverflow.com/a/575931
tagged with: java
possible better answer: http://stackoverflow.com/a/589246
upvote count: 21
has answer: http://stackoverflow.com/a/589211
type: Question
score: 21

http://stackoverflow.com/a/379418
answers question: http://stackoverflow.com/q/379256
downvote count: 0
has body: There is also JNIWrapper
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/q/500623
has body: I've just spent the last two days reading up all the OSGi stuff I can get my hands on and I finally think I've got my head around it. I'm now trying to integrate it with an existing application for many reasons such as 3rd party plugins, automatic updates, not to mention that SOA just makes me happy. I now have a decision I'm struggling to make, which is weather My entire application should become an OSGi bundle installed by default in the container; or My application should launch an embedded OSGi container and interact with it for all the plugged services. I'd prefer 1, as this lets me update the application easily and the architecture would be consistent. Of course I expect to have to refactor the application into many smaller bundles. However 2 makes things much easier in the short term, but will become awkward in the future.
downvote count: 0
has answer: http://stackoverflow.com/a/530652
favorite count: 0
answer count: 5
tagged with: osgi
type: UnansweredQuestion
has title: Embedded OSGi or Application Bundle
has answer: http://stackoverflow.com/a/4062061
tagged with: java
has answer: http://stackoverflow.com/a/10847718
upvote count: 10
has answer: http://stackoverflow.com/a/501753
type: Question
has answer: http://stackoverflow.com/a/500974
score: 10

http://stackoverflow.com/a/560207
downvote count: 0
answers question: http://stackoverflow.com/q/559779
type: Answer
has body: I believe this is very hard to implement without breaking compatibility at many levels. JVM treats arrays little differently than other objects. Creation/initialization is different: no constructor is called for one thing. How would you want to add new methods? If by adding superclass, would you call its constructor? Arrays know type of element in runtime, generics don't. If you wanted to add new superclass for all arrays (like you suggested in original question), would you make it generic? Also keep in mind that arrays are covariant in Java, generics aren't. Arrays have fixed set of methods/fields specified in Java Language Specification (all methods from Objects, which are explicitely named in JLS, length field). Adding new members is likely to break existing clients depending on this. (i.e. arrays are not your random class) Array serialization would probably be affected too I am sure there are more implementation details which would make this extremly hard :-( Programs compiled to work with new methods would not work on older JVMs. What's worse, depending on implementation, programs compiled for old JVMs may not work with modified arrays on new JVMs. I would like to have methods directly in "Array class", I don't think it's possible to implement it now.
upvote count: 1
score: 1

http://stackoverflow.com/comment/384836
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/571910
score: 0
has text: Google's search engine is based on MapReduce algorithm (and a few others) which can and have been converted to other languages such as Java succesfully. I get your point though, just wanted to point that out :)

http://stackoverflow.com/comment/57323105
type: AnswerComment
comment on: http://stackoverflow.com/a/13111620
type: Comment
score: 1
has text: I think pointing out, that the length of an array can not be changed is an important detail!

http://stackoverflow.com/a/620335
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/619097
has body: In general, I try to use ui:repeat most of the time. When I was having c:set issues, I found this blog, which was very helpful and may apply in your case also. https://rogerkeays.com/jsf-c-foreach-vs-ui-repeat
downvote count: 0
type: Answer

http://stackoverflow.com/comment/394324
comment on: http://stackoverflow.com/q/582428
type: Comment
type: QuestionComment
has text: It cant find the methods. Are the jars configured correctly in the netbeans?
score: 0

http://stackoverflow.com/a/624554
answers question: http://stackoverflow.com/q/624207
type: Answer
upvote count: 1
score: 1
has body: Java arrays use a (Java, i.e. signed) int for access as per the languge spec, so it's impossible to have an String (which is backed by a char array) longer than Integer.MAX_INT But even that much is way too much to be processing in one chunk - it'll totally kill performance and make your program fail with an OutOfMemoryError on most machines if a sufficiently large String is ever encountered. What you should do is process any string in chunks of a sensible size, say a few megs at a time. Then there's no practical limit on the size you can deal with.
downvote count: 0

http://stackoverflow.com/a/48031989
type: Answer
upvote count: 6
answers question: http://stackoverflow.com/q/604424
has body: Use: public enum MyEnum { FIRST, SECOND, THIRD; public static Optional&lt;MyEnum&gt; fromString(String value) { try { return Optional.of(MyEnum.valueOf(value)); }catch(Exception e) { return Optional.empty(); } } }
score: 6
downvote count: 0

http://stackoverflow.com/comment/330224
type: Comment
type: QuestionComment
has text: According to your user history, you've never accepted an answer. Do you suppose you could start now? You even get 2 rep points and a free badge (the first time) out of the deal. :D
score: 1
comment on: http://stackoverflow.com/q/503721

http://stackoverflow.com/a/40246029
answers question: http://stackoverflow.com/q/557844
type: Answer
upvote count: 2
has body: I found this nice tail implementation. Author : amelandri Souce from : https://gist.github.com/amelandri/1376896 import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; /** * Java implementation of the Unix tail command * * @param args[0] File name * @param args[1] Update time (seconds). Optional. Default value is 1 second * * @author Luigi Viggiano (original author) http://it.newinstance.it/2005/11/19/listening-changes-on-a-text-file-unix-tail-implementation-with-java/ * @author Alessandro Melandri (modified by) * */ public class Tail { static long sleepTime = 1000; public static void main(String[] args) throws IOException { if (args.length &gt; 0){ if (args.length &gt; 1) sleepTime = Long.parseLong(args[1]) * 1000; BufferedReader input = new BufferedReader(new FileReader(args[0])); String currentLine = null; while (true) { if ((currentLine = input.readLine()) != null) { System.out.println(currentLine); continue; } try { Thread.sleep(sleepTime); } catch (InterruptedException e) { Thread.currentThread().interrupt(); break; } } input.close(); } else { System.out.println("Missing parameter!\nUsage: java JavaTail fileName [updateTime (Seconds. default to 1 second)]"); } } }
downvote count: 1
score: 1

http://stackoverflow.com/comment/37153391
type: AnswerComment
comment on: http://stackoverflow.com/a/509288
type: Comment
score: 7
has text: Much, much better answer than the one provided by skiphoppy, for multiple reasons: 1) This code is much, much shorter. 2) This code actually throws ClassCastException as expected. 3) This code does not do a full copy of the source map. 4) The loops can be easily wrapped in a separate method used in an assert, which would easily remove the performance hit in production code.

http://stackoverflow.com/a/442345
has body: Breaking compatibility would make sense if the JVM keeps the same. In that case the "new" Java would become a new, different language running on the JVM, such as those listed there. Fortunately, the way the JVM is designed guarantees interoperability between languages and versions, so I think the impact would be limited.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/442322

http://stackoverflow.com/a/611993
downvote count: 0
has body: The bridge between C and Java is expensive, so if you have to pass a lot of data back and forth there is no win in calling C over JNI. I have seen JNA listed as a reasonable alternative to JNI with a lot less pain to call methods in a DLL/shared library from Java in a reflection like way. I have not tried it yet. You may want to consider compiling your C code as a Linux MIPS binary which can be interpreted in Java. Reasonably fast, a bit hard to set up correctly. See http://nestedvm.ibex.org/ Also you may use a llvm backend to gcc to compile to lowlevel bytecodes which can then be interpreted in Java. THis is also the approach taken with the iPhone SDK afaik on Mac OS X. http://llvm.org/
upvote count: 3
has comment: http://stackoverflow.com/comment/424608
answers question: http://stackoverflow.com/q/611296
type: Answer
has comment: http://stackoverflow.com/comment/2635589
has comment: http://stackoverflow.com/comment/2634535
score: 3

http://stackoverflow.com/comment/310172
comment on: http://stackoverflow.com/a/494413
has text: It also looks like it's not really automatic; my first guess is that they do it manually. I'm listening to their integration webcast now.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/190334
score: 2
type: Comment
has text: thanks, but i do know the difference between continue and break. ;-) the thing is: i have two nested loops. and if a certain condition in the inner loop occurs, i want to "continue" the outer loop.
comment on: http://stackoverflow.com/a/359513
type: AnswerComment

http://stackoverflow.com/a/733035
downvote count: 0
score: 7
has body: My first take would be "never"... but perhaps it has its place. I agree with eljenso that it has been surpassed by competition. So for good efficient and simple object binding/mapping, JAXB is much better, or XStream. Much more convenient and even faster. EDIT 2019: also, Jackson XML, similar to JAXB in approach but using Jackson annotations
upvote count: 7
type: Answer
answers question: http://stackoverflow.com/q/521312
has comment: http://stackoverflow.com/comment/96876183

http://stackoverflow.com/comment/376010
type: Comment
type: QuestionComment
has text: True sqook, I did not see your edit, I had changed the original question.
comment on: http://stackoverflow.com/q/564759
score: 0

http://stackoverflow.com/a/564929
type: Answer
answers question: http://stackoverflow.com/q/564061
has body: We use java (amongst other things) to code a custom CMS for our news site, but we are probably an unusual case - one of the largest news sites on the web. Maybe java is the right answer for your client too - but it is more likely that they would get better value from buying in an existing solution, unless you can't find one that implements all the required features.
score: 0

http://stackoverflow.com/a/470974
answers question: http://stackoverflow.com/q/470690
has comment: http://stackoverflow.com/comment/288903
score: 5
type: Answer
downvote count: 1
upvote count: 6
has comment: http://stackoverflow.com/comment/66089939
has body: Here's a solution to managed your "distinct" issue, which is entirely overblown: Create a unit sphere and drop points on it with repelling charges. Run a particle system until they no longer move (or the delta is "small enough"). At this point, each of the points are as far away from each other as possible. Convert (x, y, z) to rgb. I mention it because for certain classes of problems, this type of solution can work better than brute force. I originally saw this approach here for tesselating a sphere. Again, the most obvious solutions of traversing HSL space or RGB space will probably work just fine.

http://stackoverflow.com/q/406963
accepted answer: http://stackoverflow.com/a/407397
has answer: http://stackoverflow.com/a/407005
has answer: http://stackoverflow.com/a/9639416
tagged with: gwt-ext
tagged with: gwt
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/406999
possible better answer: http://stackoverflow.com/a/407432
has title: How to display java applet inside GWT page?
tagged with: java
has body: I'm probably missing something simple here, but I can't find the answer elsewhere. I just want to display an applet in my GWT code. OS: Windows XP Java: JDK 1.6.0_10 Other: GWT, GWT-Ext 2.0.5 Here is the applet (obviously simplified for testing): package foo.applet; import javax.swing.JApplet; import java.awt.Graphics; public class HelloApplet extends JApplet { public void paint(Graphics g) { g.drawRect(0, 0, getSize().width - 1, getSize().height - 1); g.drawString("Hello world!", 5, 15); } } Here is the code calling it: package foo.applet; import com.google.gwt.user.client.ui.HTML; import com.gwtext.client.widgets.Panel; public class AppletPanel extends Panel { public AppletPanel() { HTML applet = new HTML(); applet.setHTML("&lt;applet name=\"HelloApplet\" code=\"HelloApplet.class\" width=\"300\" height=\"300\"" ); this.add(applet); } } When I launch the app in hosted mode, the jvm crashes (filed incident 1425130 with Sun). When I try to compile the GWT code for running in a browser, I get this: [ERROR] Errors in 'file:/C:/&lt;blah&gt;/applet/HelloApplet.java' [ERROR] Line 3: The import javax.swing cannot be resolved [ERROR] Line 4: The import java.awt cannot be resolved [ERROR] Line 6: JApplet cannot be resolved to a type [ERROR] Line 8: Graphics cannot be resolved to a type [ERROR] Line 11: The method getSize() is undefined for the type HelloApplet [ERROR] Line 12: The method getSize() is undefined for the type HelloApplet Obviously I'm missing some applet library, but I've grepped through all the jars in the jdk and tried including all of the ones that list JApplet or awt (plugin.jar, resources.jar, rt.jar, deploy.jar, javaws.jar). Also, I'm pretty sure once I solve this problem there's another one lurking right after it, but I'll save that for another question. Thanks! The legacy app is not an applet - it is a thick-client Swing application. We've hacked it to run as an applet because our customers want a browser client and this is the fastest way to get that d…
has answer: http://stackoverflow.com/a/2601570
type: Question
upvote count: 4
downvote count: 0
tagged with: applet
answer count: 6
score: 4
favorite count: 0
has answer: http://stackoverflow.com/a/407432
has answer: http://stackoverflow.com/a/407397

http://stackoverflow.com/q/564903
accepted answer: http://stackoverflow.com/a/564995
answer count: 3
has answer: http://stackoverflow.com/a/565009
favorite count: 0
has title: Will ConcurrentLinkedQueue#poll() ever block?
upvote count: 2
possible better answer: http://stackoverflow.com/a/564987
has answer: http://stackoverflow.com/a/564987
type: AnsweredQuestion
score: 2
has answer: http://stackoverflow.com/a/564995
has comment: http://stackoverflow.com/comment/376142
tagged with: java
has body: My thread runs forever and calls ConcurrentLinkedQueue#poll() after a ConcurrentLinkedQueue#peek(). But under some conditions, the thread seems to hang. I know this is a bit vague but can people confirm for me that the methods poll() or peek() will NEVER block. Thanks.
tagged with: concurrency
type: Question
downvote count: 0

http://stackoverflow.com/q/393510
tagged with: .net
has answer: http://stackoverflow.com/a/393743
favorite count: 0
has body: I developed in ASP.NET 2.0 for some time, and for slightly less time in Java/Spring/Hibernate. Right now I start developing new web-service and am confused with the choice of: .NET WCF 3.5 versus Java/Metro. From one side, WCF seems like a brilliantly developed solution, a masterpiece of software frameworks, with all the support for functional languages, easy wizards, simple architecture. The downside is that it seems to be running on Windows only (Mono doesn't support WCF) and doesn't integrate so beautifully with Ruby on Rails (through JRuby as Java does). And Java seems really outdated -- no operator overloading or generic arrays?! So, my main question is: would anyone here start a new project using Java or is it just a dying language for legacy software? PS. Both performance and database connectivity are major priorities so that leaves slow Perl, Ruby, or Python and database-unfriendly C++ out of the question. PPS. For presentation layer I'm using Ruby on Rails.
downvote count: 3
tagged with: wcf
has answer: http://stackoverflow.com/a/393801
accepted answer: http://stackoverflow.com/a/393801
answer count: 4
possible better answer: http://stackoverflow.com/a/394148
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/393750
score: -2
tagged with: java
has title: Would you recommend Java/Glassfish/Metro for brand-new project?
tagged with: glassfish
type: Question
tagged with: legacy
has answer: http://stackoverflow.com/a/394148
upvote count: 1

http://stackoverflow.com/comment/47047096
type: AnswerComment
score: 0
type: Comment
has text: `LineNumberReader`'s `lineNumber` field is an integer... Won't it just wrap for files longer than Integer.MAX_VALUE? Why bother skipping by a long here?
comment on: http://stackoverflow.com/a/5342096

http://stackoverflow.com/a/361981
downvote count: 1
score: 20
has body: I can't answer your original question but I would like to offer you some advice -- don't depend on the JVM's default encoding. It's always best to explicitly specify the desired encoding (i.e. "UTF-8") in your code. That way, you know it will work even across different systems and JVM configurations.
answers question: http://stackoverflow.com/q/361975
has comment: http://stackoverflow.com/comment/11622078
has comment: http://stackoverflow.com/comment/30846879
has comment: http://stackoverflow.com/comment/11621474
type: Answer
has comment: http://stackoverflow.com/comment/57579010
has comment: http://stackoverflow.com/comment/448257
upvote count: 21

http://stackoverflow.com/q/438458
favorite count: 0
tagged with: serial-port
has answer: http://stackoverflow.com/a/439458
has title: CANopen PDOs using the serial port
upvote count: 3
type: UnansweredQuestion
tagged with: can-bus
has answer: http://stackoverflow.com/a/26189273
tagged with: canopen
score: 3
tagged with: java
type: Question
answer count: 2
has body: I am trying to understand the CANopen protocol. For now, I do not have any CAN hardware nor the CANopen stack to experiment with. I would like to know how to write a Java program to simply interpret CANopen messages that are received at the RS-232 port. Are there CAN interfaces that are installed as a serial port? Will I be able to write a program to process CANopen messages? I want only to be able to receive and interpret messages. Is it as simple as creating a buffer for the input stream and then break up the transmission into separate messages according to the SOF and EOF? How do I know what is the SOF/EOF since it is only 1-bit long? Why is there a limit on the number of PDOs of a CAN node? How do I process the PDO to identify the node from which it is sent and the data type and value? Is the PDO a standard CAN frame?
downvote count: 0

http://stackoverflow.com/a/462430
has body: I want to force a class to use particular private fields (and methods) This part of your question is questionable: why do you think you want to do this? private members are not visible to subclasses, and interfaces define the public interface, so your only choice would be to use an abstract class...but I cannot think of any reason why anyone would ever want to do this
upvote count: 2
type: Answer
score: 1
answers question: http://stackoverflow.com/q/462198
downvote count: 1

http://stackoverflow.com/q/359426
downvote count: 0
favorite count: 0
type: UnansweredQuestion
has body: Does anyone know a simple load balance algorithm (formula) that relates users connected, cpu load, network load and memory usage? This will be used to compare various servers and assign to a new user the best at the moment. Thank You.
has answer: http://stackoverflow.com/a/359581
score: 3
upvote count: 3
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/8443677
tagged with: algorithm
tagged with: distributed
tagged with: load-balancing
has answer: http://stackoverflow.com/a/8443759
has title: Load Balance in Distributed Project
answer count: 3

http://stackoverflow.com/q/623282
tagged with: java
has body: I've built a small applet and I have all the .java class files. How can I now compile/build it so I can use it in an &lt;applet&gt; tag? An eclipse based method would be best. Also, I'm using some images in the applet. 1) Do I need to upload these images to my website 2) Right now I point to them using my local path e.g C:\java\project\images but its all kept in 1 class so i can change this string easily if I want. What should I change it to so it'll work in a web browser? 3) Do I need to upload all the .class files?
answer count: 2
downvote count: 0
tagged with: applet
has title: How to deploy an applet?
tagged with: build-process
favorite count: 0
has answer: http://stackoverflow.com/a/623586
possible better answer: http://stackoverflow.com/a/623306
has answer: http://stackoverflow.com/a/623306
type: AnsweredQuestion
upvote count: 3
accepted answer: http://stackoverflow.com/a/623586
type: Question
score: 3

http://stackoverflow.com/a/585087
accepted answer of: http://stackoverflow.com/q/585071
type: AcceptedAnswer
upvote count: 9
type: Answer
downvote count: 0
has body: Give a look to Firefox Pencil Extension, is a basic tool for GUI prototyping and simple sketching....
answers question: http://stackoverflow.com/q/585071
score: 9

http://stackoverflow.com/a/2601570
answers question: http://stackoverflow.com/q/406963
type: Answer
has body: A light-heavyweight app might mix GWT and JNLP. Then we could get the bigger jars onto people's machines rather transparently. As an example, I'd like to use the Batik toolkit or other SVG-related goodies to have SVG in my GWT app, rather than being forced to use only png or other raster formats. Tyro - you can also mail your thoughts on this to me at bob.futrelle@gmail.com
score: 0

http://stackoverflow.com/q/412271
has answer: http://stackoverflow.com/a/412704
has answer: http://stackoverflow.com/a/1303092
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/1303092
tagged with: java
type: Question
upvote count: 4
accepted answer: http://stackoverflow.com/a/412704
answer count: 2
has title: Applet with Gui Designer
tagged with: user-interface
downvote count: 0
tagged with: applet
score: 4
has body: I want to ask you if there is a possibility to program a Java Applet in netbeans 6.5 using the GUI Designer. When I was adding a new file to the source and choose Applet or JApplet, I found now Designer as in a JForm for instance.
favorite count: 0
tagged with: netbeans

http://stackoverflow.com/comment/90180509
has text: FYI, the terribly troublesome old date-time classes such as [`java.util.Date`](https://docs.oracle.com/javase/10/docs/api/java/util/Date.html), [`java.util.Calendar`](https://docs.oracle.com/javase/10/docs/api/java/util/Calendar.html), and `java.text.SimpleDateFormat` are now [legacy](https://en.wikipedia.org/wiki/Legacy_system), supplanted by the [*java.time*](https://docs.oracle.com/javase/10/docs/api/java/time/package-summary.html) classes built into Java 8 and later. See [*Tutorial* by Oracle](https://docs.oracle.com/javase/tutorial/datetime/TOC.html).
comment on: http://stackoverflow.com/a/428966
score: 4
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/3480047
type: AnswerComment
type: Comment
has text: Because you shouldn't mention performance as an issue at all until it has been established as the right thing to do. In this context, constructor for objects inside your type-checking/compilation 'world', reflection for things outside it. Performance is like price, just because something is expensive doesn't in itself make it better. A $10 digital watch probably tells the time as well or better than a $30,000 platinum chunk of bling.
comment on: http://stackoverflow.com/a/547999
score: 1

http://stackoverflow.com/comment/397319
has text: It doesn't seem to work like this. I would say Windows always has all the timezones in the registry (at least those it supports). The language/locale cannot determine the timezone sufficiently - especially with today's mobile computing.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/583141

http://stackoverflow.com/comment/73301277
type: QuestionComment
comment on: http://stackoverflow.com/q/574594
score: 1
has text: 2 examples: http://www.tugay.biz/2015/12/a-standalone-java-web-application-with.html http://www.tugay.biz/2016/11/how-did-i-create-executable-jar-with.html
type: Comment

http://stackoverflow.com/a/17613621
has comment: http://stackoverflow.com/comment/72744519
score: 80
type: Answer
has comment: http://stackoverflow.com/comment/58048728
has body: If you want any java process, not just ant or Tomcat, to pick up options like -Xmx use the environment variable _JAVA_OPTIONS. In bash: export _JAVA_OPTIONS="-Xmx1g"
has comment: http://stackoverflow.com/comment/47435198
answers question: http://stackoverflow.com/q/417152
upvote count: 80
downvote count: 0

http://stackoverflow.com/comment/336239
comment on: http://stackoverflow.com/a/451301
has text: SnakeYAML 1.0 is released. The remote MAven 2 repository can be found here: http://trac-hg.assembla.com/snakeyaml
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/a/389266
answers question: http://stackoverflow.com/q/389136
downvote count: 0
type: Answer
score: 1
upvote count: 1
has body: I don't use Netbeans, but I do know that Javascript is case-senstive, and that the global Yahoo object is YAHOO, not yahoo. So try it in all caps.

http://stackoverflow.com/q/426878
has answer: http://stackoverflow.com/a/54252158
has answer: http://stackoverflow.com/a/7146026
has answer: http://stackoverflow.com/a/427088
has comment: http://stackoverflow.com/comment/250645
tagged with: for-loop
answer count: 17
favorite count: 0
has answer: http://stackoverflow.com/a/426974
has answer: http://stackoverflow.com/a/32668762
has answer: http://stackoverflow.com/a/17066116
has answer: http://stackoverflow.com/a/31239670
has comment: http://stackoverflow.com/comment/250549
has answer: http://stackoverflow.com/a/426903
has answer: http://stackoverflow.com/a/68878323
has answer: http://stackoverflow.com/a/426884
has answer: http://stackoverflow.com/a/14931992
has answer: http://stackoverflow.com/a/426891
accepted answer: http://stackoverflow.com/a/426884
has answer: http://stackoverflow.com/a/10670101
score: 30
possible better answer: http://stackoverflow.com/a/427088
downvote count: 0
tagged with: java
tagged with: loops
has title: Is there any way to do n-level nested loops in Java?
has answer: http://stackoverflow.com/a/60498351
upvote count: 30
type: Question
type: AnsweredQuestion
tagged with: recursion
has body: In other words, can I do something like for() { for { for { } } } Except N times? In other words, when the method creating the loops is called, it is given some parameter N, and the method would then create N of these loops nested one in another? Of course, the idea is that there should be an "easy" or "the usual" way of doing it. I already have an idea for a very complicated one.
has answer: http://stackoverflow.com/a/42179870
has answer: http://stackoverflow.com/a/427101
has answer: http://stackoverflow.com/a/67761477

http://stackoverflow.com/comment/265462
type: Comment
has text: Given that the stuff you do outside of the synchronized block doesn't accessed shared data, of course.
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/442570

http://stackoverflow.com/a/502900
has body: You need to tell the control container ('d', in example.java) do get redrawn. Calling invalidate() should be enough (not sure, though). Anyway, this might help you.
has comment: http://stackoverflow.com/comment/319552
type: Answer
has comment: http://stackoverflow.com/comment/317874
score: 0
has comment: http://stackoverflow.com/comment/2235602
answers question: http://stackoverflow.com/q/502763

http://stackoverflow.com/q/399286
type: Question
tagged with: jakarta-ee
has title: favicon.ico in Java WAR file
accepted answer: http://stackoverflow.com/a/399773
answer count: 2
downvote count: 0
favorite count: 0
tagged with: favicon
tagged with: war
upvote count: 23
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/399335
has answer: http://stackoverflow.com/a/399773
has answer: http://stackoverflow.com/a/399335
tagged with: java
has body: Can anybody provide some instruction on how to setup a war file to show a favicon.ico in the browser address bar?
score: 23

http://stackoverflow.com/a/407661
upvote count: 21
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/407624
has body: For an audio application you often have only very small parts of code where most of the time is spent. In Java, you can always use the JNI (Java Native interface) and move your computational heavy code into a C-module (or assembly using SSE if you really need the power). So I'd say use Java and get your code working. If it turns out that you don't meet your performance goal use JNI. 90% of the code will most likely be glue code and application stuff anyway. But keep in mind that you loose some of the cross platform features that way. If you can live with that JNI will always leave you the door open for native code performance.
answers question: http://stackoverflow.com/q/407624
score: 21

http://stackoverflow.com/comment/60585215
has text: "Why can't I do this?" Answer: "because you can't".
comment on: http://stackoverflow.com/a/32815763
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/10021255
comment on: http://stackoverflow.com/a/462174
type: AnswerComment
has text: @fhucho, that depends on your use case, of course. Synchronized methods are generally several times slower than it's unsynchronized variants. There are some myth saying that synchronized method call is as much as 50 times slower than an unsynchronized method call, but modern JVMs lower this number to be more around 2-10 times in most cases. Still quite hefty, if you ask me. Check http://www.ibm.com/developerworks/java/library/j-threads1/index.html for further reading.
score: 0
type: Comment

http://stackoverflow.com/a/35939551
score: 9
answers question: http://stackoverflow.com/q/409784
has body: I came across this post in Vanilla #Java recently. It's not very convenient writing Arrays.toString(arr);, then importing java.util.Arrays; all the time. Please note, this is not a permanent fix by any means. Just a hack that can make debugging simpler. Printing an array directly gives the internal representation and the hashCode. Now, all classes have Object as the parent-type. So, why not hack the Object.toString()? Without modification, the Object class looks like this: public String toString() { return getClass().getName() + "@" + Integer.toHexString(hashCode()); } What if this is changed to: public String toString() { if (this instanceof boolean[]) return Arrays.toString((boolean[]) this); if (this instanceof byte[]) return Arrays.toString((byte[]) this); if (this instanceof short[]) return Arrays.toString((short[]) this); if (this instanceof char[]) return Arrays.toString((char[]) this); if (this instanceof int[]) return Arrays.toString((int[]) this); if (this instanceof long[]) return Arrays.toString((long[]) this); if (this instanceof float[]) return Arrays.toString((float[]) this); if (this instanceof double[]) return Arrays.toString((double[]) this); if (this instanceof Object[]) return Arrays.deepToString((Object[]) this); return getClass().getName() + "@" + Integer.toHexString(hashCode()); } This modded class may simply be added to the class path by adding the following to the command line: -Xbootclasspath/p:target/classes. Now, with the availability of deepToString(..) since Java 5, the toString(..) can easily be changed to deepToString(..) to add support for arrays that contain other arrays. I found this to be a quite useful hack and it would be great if Java could simply add this. I understand potential issues with having very large arrays since the string representations could be problematic. Maybe pass something like a System.outor a PrintWriter for such eventualities.
type: Answer
upvote count: 10
downvote count: 1

http://stackoverflow.com/a/600266
type: Answer
upvote count: 4
has body: The JavaMail API is a pig, and using it raw is a thankless task, in large because it doesn't behave as you'd expect. I'd recommend using Spring's API layer around it, it's much less stressful. It doesn't hide JavaMail completely, it just makes it more predictable and test-friendly.
downvote count: 0
score: 4
answers question: http://stackoverflow.com/q/599188

http://stackoverflow.com/a/31752006
has body: In Guava 15, we introduced EvictingQueue, which is a non-blocking, bounded queue that automatically evicts (removes) elements from the head of the queue when attempting to add elements to a full queue. This is different from conventional bounded queues, which either block or reject new elements when full. It sounds like this should suit your needs, and has a much simpler interface than using an ArrayDeque directly (it uses one under the hood though!). More information can be found here.
downvote count: 0
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/590069
score: 1

http://stackoverflow.com/comment/274909
comment on: http://stackoverflow.com/a/444594
type: AnswerComment
has text: It's a touch easier to do in Objective C, as it's easier to detect if an arbitrary object has a method you want to call (instead of method it's really called a "selector") which enables easy use of optional methods by a contained object (the wrapped objects are generally termed "delegates").
score: 0
type: Comment

http://stackoverflow.com/a/612151
answers question: http://stackoverflow.com/q/612121
has comment: http://stackoverflow.com/comment/425132
has comment: http://stackoverflow.com/comment/424973
accepted answer of: http://stackoverflow.com/q/612121
has body: I'm going to make some assumptions about your concerns: A user should not be able to guess another user's URL. Once used, a URL should not be reusable (avoiding session replay attacks.) Whether used or not, a URL shouldn't live forever, thus avoiding brute-force probing. Here's how I'd do it. Keep the user's ID and the expiration timestamp in a table. Concatenate these into a string, then make an SHA-1 hash out of it. Generate a URL using the SHA-1 hash value. Map all such URLs to a servlet that will do the validation. When someone sends you a request for a page with the hash, use it to look up the user and expiration. After the user has done whatever the landing page is supposed to do, mark the row in the database as "used". Run a job every day to purge rows that are either used or past their expiration date.
score: 4
upvote count: 4
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/424945
type: Answer

http://stackoverflow.com/q/526375
upvote count: 5
answer count: 2
downvote count: 0
has body: I have had no trouble getting the sockets working with localips, but once I made the code change to use public ips, I've consistently gotten java.net.ConnectException. I am using the port 8084, which as far as I know, is not used elsewhere In the command prompt, netstat -a | grep 8084 shows: File STDIN: TCP user-9114eb19a8:8084 user-9114eb19a8:0 LISTENING I have gone into my router and ensured that it is open I get my public ip using a request to http://www.whatismyip.org Server: serverSocket = new ServerSocket (8084); Client: socket = new Socket (hostaddr, 8084); //hostaddr is a string containing my public-IP //it works when the program is run on a localnetwork and I am using my local-ips
favorite count: 0
possible better answer: http://stackoverflow.com/a/526462
accepted answer: http://stackoverflow.com/a/526417
has answer: http://stackoverflow.com/a/526462
tagged with: sockets
has comment: http://stackoverflow.com/comment/339480
has comment: http://stackoverflow.com/comment/339472
type: AnsweredQuestion
has title: How do you get Java sockets working with public IPs?
has comment: http://stackoverflow.com/comment/339497
tagged with: java
has comment: http://stackoverflow.com/comment/339489
type: Question
score: 5
has answer: http://stackoverflow.com/a/526417

http://stackoverflow.com/comment/434173
type: AnswerComment
has text: "All you need is an IDE like IntelliJ, Eclipse or Netbeans, the JDK, the JEE download and a servlet container like Tomcat (or a full-blown application server like Glassfish or JBoss)" ... oh, is that *all*? ;)
comment on: http://stackoverflow.com/a/621230
type: Comment
score: 29

http://stackoverflow.com/comment/353986
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/541912
has text: "Where in most languages"? Which languages besides the .Net ones?
score: 70

http://stackoverflow.com/q/427452
type: UnansweredQuestion
upvote count: 23
tagged with: jakarta-ee
tagged with: transactions
tagged with: java
has answer: http://stackoverflow.com/a/12330628
has answer: http://stackoverflow.com/a/427493
has title: EJB Transactions in local method-calls
has body: In the following setup, does method B run in a (new) transaction? An EJB, having two methods, method A and method B public class MyEJB implements SessionBean public void methodA() { doImportantStuff(); methodB(); doMoreImportantStuff(); } public void methodB() { doDatabaseThing(); } } The EJB is container managed, with methodB in requires_new transaction, and method A in required transaction. thus: MyName * Required MyName methodB RequiresNew Now let another EJB call methodA with an EJB method call. methodA now runs in an transaction. Will the subsequent call to methodB from methodA run in the same transaction, or does it run in a new transaction? (mind, it's the actual code here. There is no explicit ejb-call to method B)
type: Question
tagged with: ejb
downvote count: 0
has answer: http://stackoverflow.com/a/427582
score: 23
favorite count: 0
answer count: 3

http://stackoverflow.com/comment/302899
score: 0
type: AnswerComment
type: Comment
has text: That would probably explain the apparent "randomness" of the test case passing and failing. Sometimes the instructions will happen in less than a millisecond, in which case your test will work.
comment on: http://stackoverflow.com/a/486423

http://stackoverflow.com/a/360862
has comment: http://stackoverflow.com/comment/2985805
has comment: http://stackoverflow.com/comment/192258
has comment: http://stackoverflow.com/comment/2985799
type: Answer
answers question: http://stackoverflow.com/q/359147
score: 0
has body: Generally you're fronting your application with Apache. If so, look into using Apache's mod_rewrite. http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

http://stackoverflow.com/comment/223797
comment on: http://stackoverflow.com/q/397581
score: 0
has text: Hence why I asked. There be a lot of subclasses, though: http://java.sun.com/javase/6/docs/api/java/lang/Exception.html
type: Comment
type: QuestionComment

http://stackoverflow.com/a/514519
has comment: http://stackoverflow.com/comment/328595
type: Answer
downvote count: 2
answers question: http://stackoverflow.com/q/514478
upvote count: 1
score: -1
has body: Reference typed arguments are passed as references to objects themselves (not references to other variables that refer to objects). You can call methods on the object that has been passed. However, in your code sample: public static void thisDoesntWork(String foo){ foo = "howdy"; } you are only storing a reference to the string "howdy" in a variable that is local to the method. That local variable (foo) was initialized to the value of the caller's foo when the method was called, but has no reference to the caller's variable itself. After initialization: caller data method ------ ------ ------ (foo) --&gt; "" &lt;-- (foo) After the assignment in your method: caller data method ------ ------ ------ (foo) --&gt; "" "hello" &lt;-- (foo) You have another issues there: String instances are immutable (by design, for security) so you can't modify its value. If you really want your method to provide an initial value for your string (or at any time in its life, for that matter), then have your method return a String value which you assign to the caller's variable at the point of the call. Something like this, for example: String foo = thisWorks(); System.out.println(foo);//this prints the value assigned to foo in initialization public static String thisWorks(){ return "howdy"; }
has comment: http://stackoverflow.com/comment/328920

http://stackoverflow.com/comment/200013
comment on: http://stackoverflow.com/a/369561
type: AnswerComment
score: 0
has text: I'm already using this one. Guess I should have been more specific.
type: Comment

http://stackoverflow.com/a/42462296
has comment: http://stackoverflow.com/comment/73921331
has comment: http://stackoverflow.com/comment/73921162
has body: Avoid legacy date-time classes The other Answers may be correct but are outdated. The troublesome old date-time classes in Java are now legacy, supplanted by the java.time classes. Likewise, the Joda-Time project, now in maintenance mode, advises migration to the java.time classes. Using java.time Instant two times (in seconds since epoch) In java.time, we represent moments on the timeline in UTC as Instant. I will assume that your epoch is the same as that of java.time, the first moment of 1970 in UTC (1970-01-01T00:00:00Z). Note that an Instant has a resolution of nanoseconds. A convenience factory method constructs a Instant from whole seconds, as asked in the Question. Instant start = Instant.ofEpochSecond( … ); Instant stop = Instant.ofEpochSecond( … ); Here we use the current moment and some minutes later. Instant start = Instant.now() ; Instant stop = start.plusSeconds( TimeUnit.MINUTES.toSeconds( 7L ) ) ; // Seven minutes as a number of seconds. Duration In java.time, a span of time unattached to the timeline is represented in two ways. For years-month-days, we have Period. For hours-minutes-seconds, we have Duration. Duration duration = Duration.between( start , stop ); Half-Open The elapsed time is calculated with the Half-Open approach. In this approach, the beginning is inclusive while the ending is exclusive. This approach is commonly used in date-time work. I believe using this approach consistently across your code base will help to eliminate errors and misunderstandings due to ambiguities, and will ease the cognitive load of your programming. ISO 8601 The ISO 8601 standard defines many practical formats for representing date-time values as text. These formats are designed to avoid ambiguity, be easy to parse by machine, and be intuitive to read by humans across cultures. The java.time classes use these formats by default when parsing &amp; generating strings. For a span of time unattached to the timeline, the standard defines a format of PnYnMnDTnHnM…
answers question: http://stackoverflow.com/q/635935
downvote count: 0
type: Answer
score: 13
upvote count: 13

http://stackoverflow.com/comment/400119
score: 0
comment on: http://stackoverflow.com/a/584656
type: AnswerComment
has text: 2) "statefullise" your API (break it) for use by your stateless users: your api seems "tech" oriented. Make use cases, and build a specific business, app-wide and long-lived statefull object for each scenario. At first call of the statefull object API, the user is registered. On subsequent calls,
type: Comment

http://stackoverflow.com/comment/222302
type: AnswerComment
has text: I think a switch where functionA and functonB get called would be much clearer code. This just moves the mapping of IDs to functions into the section of code where you're loading the map, instead of where you're calling the function.
comment on: http://stackoverflow.com/a/395823
type: Comment
score: 4

http://stackoverflow.com/a/406797
type: Answer
accepted answer of: http://stackoverflow.com/q/406053
downvote count: 0
answers question: http://stackoverflow.com/q/406053
has body: Same reason why some people like to prepend private data members with "m_" or name interfaces "IFoo". They believe it increases readability and clarity. Whether or not you agree with conventions like these is a matter of taste.
score: 7
upvote count: 7
type: AcceptedAnswer

http://stackoverflow.com/q/581013
has body: I am working on WCS 6.0 which makes use of the struts framework. The entry for one of the views(CategoryDisplayView) is defined as the following global forward in the struts config xml &lt;forward className="com.ibm.commerce.struts.ECActionForward" name="CategoryDisplayView/10001" path="/"/&gt; There is also an action mapping defined for the same which is as under &lt;action path="/CategoryDisplayView" type="com.ibm.commerce.struts.BaseAction"&gt; &lt;set-property property="credentialsAccepted" value="0:P,0:P,0:P,0:P,0:P,0:P,0:P,0:P,0:P,0:P,0:P,0:P,0:P"/&gt; &lt;set-property property="https" value="10151:1,11301:1,11301:1,13652:1,11351:1,11301:1,12601:1,12601:1"/&gt; &lt;/action&gt; The problem is that I can't find the path to the JSP. Where is wcs getting the path to the JSP for this view? and yes it is finding the correct path, but donno where from
has answer: http://stackoverflow.com/a/581541
accepted answer: http://stackoverflow.com/a/581541
type: Question
tagged with: struts
has title: Unable to find the path to JSP in struts
score: 0
answer count: 1
tagged with: wcs
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/q/373518
has answer: http://stackoverflow.com/a/373533
has answer: http://stackoverflow.com/a/373526
has body: Using the Java URL class, I can connect to an external HTTPS server (such as our production site), but using a local URL I get following exception. "SunCertPathBuilderException: unable to find valid certification path to requested target". How do I get a valid certification path? EDIT: I'm not using this URL to directly create a connection, I am passing the URL to an itext PDFReader, which is then having the connection issue.
has answer: http://stackoverflow.com/a/374739
has answer: http://stackoverflow.com/a/376489
tagged with: java
tagged with: certificate
tagged with: https
type: Question
has title: How do I use a local HTTPS URL in java?
score: 9
upvote count: 9
has answer: http://stackoverflow.com/a/373855
downvote count: 0
favorite count: 0
answer count: 5
type: UnansweredQuestion

http://stackoverflow.com/q/424849
type: Question
tagged with: graphics
type: AnsweredQuestion
has title: Painting a Canvas in an Applet
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/425062
tagged with: canvas
answer count: 3
possible better answer: http://stackoverflow.com/a/424935
downvote count: 0
has answer: http://stackoverflow.com/a/424935
tagged with: applet
has answer: http://stackoverflow.com/a/424874
favorite count: 0
accepted answer: http://stackoverflow.com/a/424874
has comment: http://stackoverflow.com/comment/248719
has body: I currently have a small Java program which I would like to run both on the desktop (ie in a JFrame) and in an applet. Currently all of the drawing and logic are handled by a class extending Canvas. This gives me a very nice main method for the Desktop application: public static void main(String[] args) { MyCanvas canvas = new MyCanvas(); JFrame frame = MyCanvas.frameCanvas(canvas); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); canvas.loop(); } Can I do something similar for the applet? Ideally MyCanvas would remain the same for both cases. Not sure if its important but I am drawing using BufferStrategy with setIgnoreRepaint(true). Edit: To clarify, my issue seems to be painting the canvas -- since all the painting is being done from the canvas.loop() call.
has comment: http://stackoverflow.com/comment/248847
upvote count: 1

http://stackoverflow.com/q/393948
has answer: http://stackoverflow.com/a/394134
tagged with: object-persistence
score: 4
tagged with: java
has answer: http://stackoverflow.com/a/394152
has body: I am developing a Java based desktop application. There are some data generated from the application object model that I need to persist (preferably to a file). There is also a requirement to protect the persisted file so that others can't derive the object model details from the data. What's the best strategy for doing these? I was in the impression that these requirements are very common for desktop apps. However, I haven't been able to found much useful info on it. Any suggestion appreciated.
possible better answer: http://stackoverflow.com/a/393957
accepted answer: http://stackoverflow.com/a/394134
has answer: http://stackoverflow.com/a/393957
upvote count: 4
downvote count: 0
has answer: http://stackoverflow.com/a/393986
tagged with: desktop
type: Question
has title: Object persistence strategy for desktop application
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/393991
favorite count: 0
answer count: 6
has answer: http://stackoverflow.com/a/394098

http://stackoverflow.com/comment/63428911
has text: @VassilenDontchev Can you please give some examples to show in which cases `HSSFFormulaEvaluator.evaluateAllFormulaCells(workbook);` will fail
type: Comment
comment on: http://stackoverflow.com/a/5601673
type: AnswerComment
score: 0

http://stackoverflow.com/comment/897277
type: AnswerComment
comment on: http://stackoverflow.com/a/1080551
score: 0
type: Comment
has text: Looks like a very nice tool - pity there's no trial version

http://stackoverflow.com/comment/59651585
type: QuestionComment
score: 2
comment on: http://stackoverflow.com/q/447898
has text: In case you're interested in a real world Java EE scenario where serialization is involved, head here: http://stackoverflow.com/q/2294551
type: Comment

http://stackoverflow.com/a/418416
type: Answer
has body: Are you using Swing and is your application extending SingleFrameApplication (e.g the default GUI app created in NetBeans). If so, the window state information is saved out - where depends on the platform. To stop this happening, you need to override the shutdown method in your class that extends SingleFrameApplication @Override protected void shutdown() { super.shutdown(); // remove this if you don't want the window state saved }
upvote count: 1
answers question: http://stackoverflow.com/q/417517
downvote count: 0
score: 1

http://stackoverflow.com/q/560797
upvote count: 37
tagged with: sdk
has answer: http://stackoverflow.com/a/560847
tagged with: environment-variables
has answer: http://stackoverflow.com/a/560810
downvote count: 0
answer count: 7
favorite count: 0
possible better answer: http://stackoverflow.com/a/560879
has answer: http://stackoverflow.com/a/560843
has answer: http://stackoverflow.com/a/560879
has answer: http://stackoverflow.com/a/10442162
has comment: http://stackoverflow.com/comment/70247774
has title: Why doesn't the Java SDK installer set JAVA_HOME?
accepted answer: http://stackoverflow.com/a/560847
type: AnsweredQuestion
has body: I always wondered why I have to manually set the JAVA_HOME environment variable after installing the Java SDK. JAVA_HOME=c:\Program Files\Java\jdk1.6.0_12 Visual Studio at least provides a batch file to set these kind of environment variables: call "c:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" Does Java have something similar? I'm trying to make a build script that should simply work after installing the Java SDK. I don't want people to mess with environment variables on their PC.
has answer: http://stackoverflow.com/a/78459912
tagged with: java
has answer: http://stackoverflow.com/a/561027
type: Question
score: 37

http://stackoverflow.com/comment/3706150
comment on: http://stackoverflow.com/q/615899
type: QuestionComment
score: 4
has text: This is not spam. jogl.dev.java.net contains a mac distro last updated 2008, and points you to jogamp.org. Jogamp.org ... I'm still trying to navigate it. Where's the "download jogl for osx" button?
type: Comment

http://stackoverflow.com/q/433945
tagged with: python
answer count: 6
score: 4
accepted answer: http://stackoverflow.com/a/434610
tagged with: java
tagged with: jfilechooser
possible better answer: http://stackoverflow.com/a/433967
has answer: http://stackoverflow.com/a/433967
has answer: http://stackoverflow.com/a/46476428
has title: JFileChooser for Python?
downvote count: 0
has comment: http://stackoverflow.com/comment/256955
has answer: http://stackoverflow.com/a/433977
linked to: http://stackoverflow.com/q/47066606
upvote count: 4
has answer: http://stackoverflow.com/a/434009
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/434610
has body: I was wondering if there is something similar to Java's JFileChooser for Python? JFileChooser is a graphical front end to choose a file. Preferably something that is already with Python. Maybe with Tkinter.
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/433964

load-balancing
tags question: http://stackoverflow.com/q/359426
type: Tag
tags question: http://stackoverflow.com/q/383920
tag name: load-balancing

http://stackoverflow.com/a/756028
answers question: http://stackoverflow.com/q/444909
upvote count: 2
downvote count: 0
has body: I recently found myself in a similar situation--I had some serialized objects that I had to read, the serialVersionUID of those objects was different than the newest version and, in my case, there were a couple of different serialVersionUIDs stored in the file for the same class (stored at different times, obviously). So I didn't have the luxury of modifying the class and setting its serialVersionUID; I actually had to go in and modify the stored data. What I figured out (by reading the java.io source code) is that an object gets serialized by first storing the class name (using writeUTF()) and then immediately after using writeLong() to save the serialVersionUID. My solution was to catch the exception then go back, look for the class name, and immediately after the class name replace the old serialVersionUID with the new.
type: Answer
score: 2

http://stackoverflow.com/a/506808
downvote count: 0
answers question: http://stackoverflow.com/q/505922
has comment: http://stackoverflow.com/comment/324069
has body: What you're looking at is a conditional construct, as Bryan said, and Java doesn't support them. The parenthesized expression immediately after the question mark can actually be any zero-width assertion, like a lookahead or lookbehind, and not just a reference to a capture group. (I prefer to call those back-assertions, to avoid confusion. A back-reference matches the same thing the capture group did, but a back-assertion just asserts that the capture group matched something.) I learned about conditionals when I was working in Perl years ago, but I've never missed them in Java. In this case, for example, a simple alternation will do the trick: (?i)&lt;a\s+[^&gt;]+&gt;\s*&lt;img\s+[^&gt;]+&gt;\s*&lt;/a]&gt;|&lt;img\s+[^&gt;]+&gt; One advantage of the conditional version is that you can capture the IMG tag with a single capture group: (?i)(&lt;a\s+[^&gt;]+&gt;\s*)?(&lt;img\s+[^&gt;]+&gt;)(?(1)\s*&lt;/a&gt;) In the alternation version you have to have a capturing group for each alternative, but that's not as important in Java as it is in Perl, with all its built-in regex magic. Here's how I would pluck the IMG tags in Java: Pattern p = Pattern.compile( "&lt;a\\s+[^&gt;]+&gt;\\s*(&lt;img\\s+[^&gt;]+&gt;)\\s*&lt;/a&gt;|(&lt;img\\s+[^&gt;]+&gt;)" Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(s); while (m.find()) { System.out.println(m.start(1) != -1 ? m.group(1) : m.group(2)); }
type: Answer
has comment: http://stackoverflow.com/comment/132929422
upvote count: 3
score: 3

http://stackoverflow.com/comment/26761365
comment on: http://stackoverflow.com/a/516060
has text: @Software Monkey I would like to say that this is wrong. Since while falling there is time to execute both blocks (except in rare cases when you are doing something really time intensive).
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/237268
type: Comment
has text: I am afraid I am not getting it. Can you please clarify what null checks you would use in this case before the changed getters of someObject?
comment on: http://stackoverflow.com/a/411598
type: AnswerComment
score: 0

http://stackoverflow.com/a/628670
has comment: http://stackoverflow.com/comment/441389
answers question: http://stackoverflow.com/q/628583
score: 0
has body: Just a reminder that you need to be careful if there will be any nesting. Regex just isn't very good at this. Consider the following snippet: (a,)b,(c,(d,)e,) Based on your question, you would only want to match comma b. The trick is that expressions are generally either completely greedy or completely un-greedy, with little middle ground. A greedy expression would see the ( at the very beginning of the segment and the ) at the very end and take everything inside them, regardless that there are closing parentheses elsewhere. Nothing would be matched. An ungreedy expression would take only the smallest set possible, starting from the beginning. It would match comma b, but also see this segment as one unit: (c,(d,). Then it would proceed to also match comma e, because it's already taken the last (. There are some engines that allow you to handle the nesting levels, but the expressions are usually ugly and hard to maintain: best to just avoid the feature unless you really understand it well.
type: Answer

http://stackoverflow.com/comment/319859
comment on: http://stackoverflow.com/a/502283
has text: Your statement "...then of course you are modifying the object itself" is misleading. Of course you are modifying SOME object, but without the code/documentation for "getCookie()" you don't know if you're getting the actual cookie or just a copy of it.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/362666
has text: Yes - but why is an investibility decision the responsibility of the customer? It seems insane to me that if I want to add a new product to the system, I would need to go and start adding/modifying customer classes...?
type: Comment
comment on: http://stackoverflow.com/a/551014
score: 0
type: AnswerComment

http://stackoverflow.com/q/409563
has answer: http://stackoverflow.com/a/409577
has answer: http://stackoverflow.com/a/409574
has body: I'm stuck deciding how to handle exceptions in my application. Much if my issues with exceptions comes from 1) accessing data via a remote service or 2) deserializing a JSON object. Unfortunately I can't guarantee success for either of these tasks (cut network connection, malformed JSON object that is out of my control). As a result, if I do encounter an exception I simply catch it within the function and return FALSE to the caller. My logic is that all the caller really cares about is if the task was successful, not why it is wasn't successful. Here's some sample code (in JAVA) of a typical method) public boolean doSomething(Object p_somthingToDoOn) { boolean result = false; try{ // if dirty object then clean doactualStuffOnObject(p_jsonObject); //assume success (no exception thrown) result = true; } catch(Exception Ex) { //don't care about exceptions Ex.printStackTrace(); } return result; } I think this approach is fine, but I'm really curious to know what the best practices are for managing exceptions (should I really bubble an exception all the way up a call stack?). In summary of key questions: Is it okay to just catch exceptions but not bubble them up or formally notifying the system (either via a log or a notification to the user)? What best practices are there for exceptions that don't result in everything requiring a try/catch block? Follow Up/Edit Thanks for all the feedback, found some excellent sources on exception management online: Best Practices for Exception Handling | O'Reilly Media Exception Handling Best Practices in .NET Best Practices: Exception Management (Article now points to archive.org copy) Exception-Handling Antipatterns It seems that exception management is one of those things that vary based on context. But most importantly, one should be consistent in how they manage exceptions within a system. Additionally watch out for code-rot via excessive try/catches or not giving a exception its respect (an exception is warning the system, what e…
has answer: http://stackoverflow.com/a/409571
downvote count: 1
has answer: http://stackoverflow.com/a/409678
has answer: http://stackoverflow.com/a/409893
has answer: http://stackoverflow.com/a/409583
possible better answer: http://stackoverflow.com/a/409574
favorite count: 0
has answer: http://stackoverflow.com/a/409605
has answer: http://stackoverflow.com/a/410138
has title: Best practices for exception management in Java or C#
tagged with: exception
has comment: http://stackoverflow.com/comment/67570978
has answer: http://stackoverflow.com/a/409617
has answer: http://stackoverflow.com/a/409884
answer count: 15
upvote count: 120
type: AnsweredQuestion
tagged with: java
tagged with: error-handling
type: Question
has answer: http://stackoverflow.com/a/410199
tagged with: c#
has answer: http://stackoverflow.com/a/409588
has answer: http://stackoverflow.com/a/409614
accepted answer: http://stackoverflow.com/a/409571
has answer: http://stackoverflow.com/a/409870
score: 119
has answer: http://stackoverflow.com/a/4868280

http://stackoverflow.com/q/632229
tagged with: bufferedimage
has answer: http://stackoverflow.com/a/29177957
type: Question
upvote count: 20
answer count: 6
has body: I have a servlet based application that is serving images from files stored locally. I have added logic that will allow the application to load the image file to a BufferedImage and then resize the image, add watermark text over the top of the image, or both. I would like to set the content length before writing out the image. Apart from writing the image to a temporary file or byte array, is there a way to find the size of the BufferedImage? All files are being written as jpg if that helps in calculating the size.
has answer: http://stackoverflow.com/a/43414903
score: 20
downvote count: 0
has answer: http://stackoverflow.com/a/4944536
has title: How to calculate java BufferedImage filesize
favorite count: 0
possible better answer: http://stackoverflow.com/a/4944536
has answer: http://stackoverflow.com/a/632239
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/632239
has answer: http://stackoverflow.com/a/632240
tagged with: java
has answer: http://stackoverflow.com/a/632281

http://stackoverflow.com/a/470095
downvote count: 0
has comment: http://stackoverflow.com/comment/297489
upvote count: 2
type: Answer
score: 2
has body: I don't know if it's possible, since I've never used it. But as far as I can tell the API doesn't support the documentation element. However, you could use the @XMLElement annotation to give your member a more descriptive name. //Example: Code fragment public class USPrice { @XmlElement(name="itemprice") public java.math.BigDecimal price; } &lt;!-- Example: Local XML Schema element --&gt; &lt;xs:complexType name="USPrice"/&gt; &lt;xs:sequence&gt; &lt;xs:element name="itemprice" type="xs:decimal" minOccurs="0"/&gt; &lt;/sequence&gt; &lt;/xs:complexType&gt;
answers question: http://stackoverflow.com/q/470001

http://stackoverflow.com/a/584047
has comment: http://stackoverflow.com/comment/397033
type: Answer
has comment: http://stackoverflow.com/comment/397636
upvote count: 6
downvote count: 1
has comment: http://stackoverflow.com/comment/396450
has body: I implemented something very recently in Silverlight. Basically uses HttpWebRequest to send a chunk of data to a GenericHandler. On the first post, 4KB of data is sent. On the 2nd chunk, I send another 4K chunk. When the 2nd chunk is received, I calculate the round trip it took between first and 2nd chunk and so now the 3rd chunk when sent will know to increase speed. Using this method I can upload files of ANY size and I can resume. Each post I send along this info: [PARAMETERS] [FILEDATA] Here, parameters contain the following: [Chunk #] [Filename] [Session ID] After each chunk is received, I send a response back to my Silverlight saying how fast it took so that it can now send a larger chunk. Hard to put my explaination without code but that's basically how I did it. At some point I will put together a quick writeup on how I did this.
score: 5
answers question: http://stackoverflow.com/q/582126

http://stackoverflow.com/comment/258088
score: 1
has text: I assumed it's "Is there a universal document format converter which supports DOC, DOCX, PDF, ODT, RDF, DocBook and TXT which is not a printer driver, online service or GUI tool?" and answered based on that.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/435238

http://stackoverflow.com/comment/9495364
type: Comment
comment on: http://stackoverflow.com/a/7795218
score: 0
type: AnswerComment
has text: Actualy that's just an example from my project, slightly modified. Of course you should change type attribute to apropriate and implement method convertUponSet

http://stackoverflow.com/a/7502716
upvote count: 5
downvote count: 0
type: Answer
has body: Here is another way to pad to the right: // put the number of spaces, or any character you like, in your paddedString String paddedString = "--------------------"; String myStringToBePadded = "I like donuts"; myStringToBePadded = myStringToBePadded + paddedString.substring(myStringToBePadded.length()); //result: myStringToBePadded = "I like donuts-------";
answers question: http://stackoverflow.com/q/388461
score: 5

http://stackoverflow.com/a/405339
has body: Provide enough tests so that you feel comfortable - based on your knowledge of the implementation. I don't treat unit testing as completely black-box testing. If you know that the base class never calls any virtual methods (or at least none that are overridden) then note that fact but don't effectively duplicate the unit tests that you've already got. Unit testing can certainly be taken to extremes - it's always worth balancing the value you're getting from it with the effort it's costing you.
upvote count: 5
downvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/405333
score: 4

http://stackoverflow.com/comment/9093648
score: 0
type: Comment
comment on: http://stackoverflow.com/a/489990
has text: +1 The above post (@MichaelHaren) is funny, but this is a lot more fun outside-the-box way. :)
type: AnswerComment

http://stackoverflow.com/a/497185
upvote count: 1
answers question: http://stackoverflow.com/q/497176
downvote count: 0
has body: You can have additional methods. Your problem seems to be the naming of your variables!!
type: Answer
score: 1

http://stackoverflow.com/comment/241718
score: 0
type: Comment
has text: DCL is relevant in that it points out that the compiler and/or JMM may do unexpected things. The two code snippets, as posted, do (essentially) the same thing, albeit with different bytecode. Naively adding code before or after the synchronized block (as in the OP) may not be thread-safe.
comment on: http://stackoverflow.com/a/416228
type: AnswerComment

http://stackoverflow.com/comment/333513
score: 0
type: Comment
comment on: http://stackoverflow.com/a/520011
has text: @Jon: sure. Although this sounds like something I would probably do with an altogether different pattern (composition, or a decorator).
type: AnswerComment

http://stackoverflow.com/comment/138519478
comment on: http://stackoverflow.com/a/574650
has text: See also Maven Central https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-assembly-plugin/3.7.1
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/88223845
type: AnswerComment
type: Comment
has text: @jjurm `.thenComparing(Person::getLastName, Comparator.nullsFirst(Comparator.naturalOrder()))` - first field selector, then comparator
score: 7
comment on: http://stackoverflow.com/a/25501226

http://stackoverflow.com/a/561450
has comment: http://stackoverflow.com/comment/108662212
has comment: http://stackoverflow.com/comment/2917651
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/26122314
has comment: http://stackoverflow.com/comment/113378820
has comment: http://stackoverflow.com/comment/108482344
has comment: http://stackoverflow.com/comment/4025842
has comment: http://stackoverflow.com/comment/3981754
has comment: http://stackoverflow.com/comment/4025849
has comment: http://stackoverflow.com/comment/42171698
type: Answer
has comment: http://stackoverflow.com/comment/42205041
has comment: http://stackoverflow.com/comment/26194849
has body: This has been a long-standing complaint with Java, but it's largely meaningless, and usually based on looking at the wrong information. The usual phrasing is something like "Hello World on Java takes 10 megabytes! Why does it need that?" Well, here's a way to make Hello World on a 64-bit JVM claim to take over 4 gigabytes ... at least by one form of measurement. java -Xms1024m -Xmx4096m com.example.Hello Different Ways to Measure Memory On Linux, the top command gives you several different numbers for memory. Here's what it says about the Hello World example: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 2120 kgregory 20 0 4373m 15m 7152 S 0 0.2 0:00.10 java VIRT is the virtual memory space: the sum of everything in the virtual memory map (see below). It is largely meaningless, except when it isn't (see below). RES is the resident set size: the number of pages that are currently resident in RAM. In almost all cases, this is the only number that you should use when saying "too big." But it's still not a very good number, especially when talking about Java. SHR is the amount of resident memory that is shared with other processes. For a Java process, this is typically limited to shared libraries and memory-mapped JARfiles. In this example, I only had one Java process running, so I suspect that the 7k is a result of libraries used by the OS. SWAP isn't turned on by default, and isn't shown here. It indicates the amount of virtual memory that is currently resident on disk, whether or not it's actually in the swap space. The OS is very good about keeping active pages in RAM, and the only cures for swapping are (1) buy more memory, or (2) reduce the number of processes, so it's best to ignore this number. The situation for Windows Task Manager is a bit more complicated. Under Windows XP, there are "Memory Usage" and "Virtual Memory Size" columns, but the official documentation is silent on what they mean. Windows Vista and Windows 7 add more columns, and they're ac…
score: 725
has comment: http://stackoverflow.com/comment/64682065
upvote count: 725
accepted answer of: http://stackoverflow.com/q/561245
answers question: http://stackoverflow.com/q/561245

http://stackoverflow.com/comment/54631018
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/444568
score: 0
has text: @ujay68: UriBuilder treats curly brace as template delimiters. Have you tried `UriBuilder.fromPath("http://www.query.example/").queryParam("key", "{val}").build("{val}")`?

http://stackoverflow.com/q/450557
has answer: http://stackoverflow.com/a/46589476
type: Question
has answer: http://stackoverflow.com/a/971703
has answer: http://stackoverflow.com/a/7776526
linked to: http://stackoverflow.com/q/25649105
has answer: http://stackoverflow.com/a/451341
score: 13
has answer: http://stackoverflow.com/a/46648616
has answer: http://stackoverflow.com/a/477686
downvote count: 0
favorite count: 0
has title: Custom spring scopes?
has answer: http://stackoverflow.com/a/450614
answer count: 9
has body: Anyone know of any other custom spring scopes than Servlet Context Scope and ThreadScope ? If you've made some closed-source custom scope I'd really also be interested in hearing what it does and how it worked out for you. (I'd imagine someone would make a WindowScope in a desktop app ?) I'm open to all use cases, I'm looking to expand my horizon here.
type: UnansweredQuestion
tagged with: spring
has answer: http://stackoverflow.com/a/2387153
upvote count: 13
has answer: http://stackoverflow.com/a/27518972
tagged with: java

http://stackoverflow.com/q/640161
has answer: http://stackoverflow.com/a/640199
has answer: http://stackoverflow.com/a/640293
has answer: http://stackoverflow.com/a/640935
has answer: http://stackoverflow.com/a/9013607
answer count: 10
tagged with: maven-2
favorite count: 0
has answer: http://stackoverflow.com/a/640182
has title: What is the best IDE for developing in Tomcat?
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/640246
has body: Recently I've been doing a bunch of work developing servlets for deployment in Tomcat 5.5. My current IDE is Eclipse Ganymede with WTP. I've been very unhappy with the Tomcat integration, as the configuration is constantly breaking and needing tweaking. I was wondering if anyone could recommend another IDE that handles this integration better. I am particularly interested in what people think of IntelliJ's support for Tomcat. Note I am also using Maven 2, and it's pretty essential to have Maven support as well.
has comment: http://stackoverflow.com/comment/109086250
has answer: http://stackoverflow.com/a/640257
upvote count: 9
has answer: http://stackoverflow.com/a/640187
has answer: http://stackoverflow.com/a/640373
tagged with: java
tagged with: servlets
score: 9
type: Question
has answer: http://stackoverflow.com/a/640958
downvote count: 0
tagged with: tomcat

http://stackoverflow.com/comment/240559
has text: Unfortunate - combining this compile target approach with a Factory producer is probably the right way to go; unless you want to get into plugin mechanisms.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/412720

http://stackoverflow.com/a/437115
answers question: http://stackoverflow.com/q/435640
has comment: http://stackoverflow.com/comment/260758
has body: Hmm.. well when I want to listen to a Queue I usually do something like this. (Imports from javax.jms) Queue queue; // Connect to ActiveMQ ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(messageBrokerURL); connection = factory.createConnection(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // List to Dummy Queue queue = session.createQueue("DUMMY"); messageConsumer = session.createConsumer(queue); messageConsumer.setMessageListener(queueHandler); // Start the connection connection.start(); And make sure that your Handler implements MessageListener.
score: 0
type: Answer

http://stackoverflow.com/q/421419
has answer: http://stackoverflow.com/a/421447
downvote count: 2
has answer: http://stackoverflow.com/a/421659
has answer: http://stackoverflow.com/a/421465
has answer: http://stackoverflow.com/a/421444
favorite count: 0
answer count: 9
tagged with: hash
has answer: http://stackoverflow.com/a/13413618
has answer: http://stackoverflow.com/a/421888
score: 11
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/245460
possible better answer: http://stackoverflow.com/a/421659
has title: Good choice for a lightweight checksum algorithm?
has answer: http://stackoverflow.com/a/421453
tagged with: java
accepted answer: http://stackoverflow.com/a/421453
has answer: http://stackoverflow.com/a/19838895
tagged with: checksum
type: Question
has answer: http://stackoverflow.com/a/19342327
has comment: http://stackoverflow.com/comment/246208
has body: I find myself needing to generate a checksum for a string of data, for consistency purposes. The broad idea is that the client can regenerate the checksum based on the payload it recieves and thus detect any corruption that took place in transit. I am vaguely aware that there are all kinds of mathematical principles behind this kind of thing, and that it's very easy for subtle errors to make the whole algorithm ineffective if you try to roll it yourself. So I'm looking for advice on a hashing/checksum algorithm with the following criteria: It will be generated by Javascript, so needs to be relatively light computationally. The validation will be done by Java (though I cannot see this actually being an issue). It will take textual input (URL-encoded Unicode, which I believe is ASCII) of a moderate length; typically around 200-300 characters and in all cases below 2000. The output should be ASCII text as well, and the shorter it can be the better. I'm primarily interested in something lightweight rather than getting the absolute smallest potential for collisions possible. Would I be naive to imagine that an eight-character hash would be suitable for this? I should also clarify that it's not the end of the world if corruption isn't picked up at the validation stage (and I do realise that this will not be 100% reliable), though the rest of my code is markedly less efficient for every corrupt entry that slips through. Edit - thanks to all that contributed. I went with the Adler32 option and given that it was natively supported in Java, extremely easy to implement in Javascript, fast to calculate at both ends and have an 8-byte output it was exactly right for my requirements. (Note that I realise that the network transport is unlikely to be responsible for any corruption errors and won't be folding my arms on this issue just yet; however adding the checksum validation removes one point of failure and means we can focus on other areas should this reoccur.)
has comment: http://stackoverflow.com/comment/245575
tagged with: javascript
upvote count: 13

http://stackoverflow.com/comment/371059
type: Comment
has text: Not sure if you're taking the mickey there, Bill :-) It's a repost of someones question as I would have written it, hopefully to educate them. Which is why I wiki'd it - no rep-whoring for me.
comment on: http://stackoverflow.com/q/559779
score: 0
type: QuestionComment

http://stackoverflow.com/q/564699
has answer: http://stackoverflow.com/a/3767585
answer count: 12
has answer: http://stackoverflow.com/a/26281136
has answer: http://stackoverflow.com/a/3767589
has comment: http://stackoverflow.com/comment/81810091
downvote count: 2
type: Question
tagged with: c#
upvote count: 9
has answer: http://stackoverflow.com/a/3767631
has answer: http://stackoverflow.com/a/564706
score: 7
tagged with: java
has answer: http://stackoverflow.com/a/564729
has answer: http://stackoverflow.com/a/564727
has answer: http://stackoverflow.com/a/564752
has body: In C++ I can't use a method if I declare it after the calling method. Does this order matter in other languages like Java or C#?
has title: Does the order of declaration matter in Java/C#?
has answer: http://stackoverflow.com/a/47704786
has answer: http://stackoverflow.com/a/564790
favorite count: 0
has answer: http://stackoverflow.com/a/564724
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/564718

http://stackoverflow.com/a/530635
downvote count: 1
answers question: http://stackoverflow.com/q/530208
score: 0
type: Answer
has body: I dont use enum much, i prefer named constants but i'll assume going from "ACE" to "14" is trivial i'm too lazy to write real java code (beside you actually have to do your homework ^^) check if the list has 5 cards convert card names to a card number list named array sort the list array for i=1 to 4 if not (array[i] + 1) % 13 == (array[i+1]) % 13 then it is not a straight The % operator is called modulo so (15 % 13) == 2 I use this operator whenever I face the "wrap over" challenge Edit : After re-reading your question my solution cannot work out of the box. You should reorder your enum so that TWO == 0
upvote count: 1

http://stackoverflow.com/a/969157
type: Answer
has body: You can run commands using edtFTPj/PRO, as well as performing file transfers via SFTP. It's Java.
score: 0
answers question: http://stackoverflow.com/q/570450

http://stackoverflow.com/a/362406
has comment: http://stackoverflow.com/comment/57553082
has comment: http://stackoverflow.com/comment/57557050
answers question: http://stackoverflow.com/q/362384
upvote count: 7
type: Answer
has comment: http://stackoverflow.com/comment/192688
has comment: http://stackoverflow.com/comment/57541064
has body: I would read the bytes one by one, and combine them into a long value. That way you control the endianness, and the communication process is transparent.
has comment: http://stackoverflow.com/comment/57553222
downvote count: 4
has comment: http://stackoverflow.com/comment/3697366
has comment: http://stackoverflow.com/comment/30897886
score: 3
has comment: http://stackoverflow.com/comment/375905
has comment: http://stackoverflow.com/comment/194179
has comment: http://stackoverflow.com/comment/57541183
has comment: http://stackoverflow.com/comment/30942541

http://stackoverflow.com/a/22816300
answers question: http://stackoverflow.com/q/421951
score: 7
downvote count: 0
type: Answer
has body: It seems that LLJVM can also meet your requirement. LLJVM: Source code is first compiled to LLVM intermediate representation (IR) by a frontend such as llvm-gcc or clang. LLVM IR is then translated to Jasmin assembly code, linked against other Java classes, and then assembled to JVM bytecode.
upvote count: 7

http://stackoverflow.com/comment/266205
score: 0
type: AnswerComment
has text: Thanks for the response. I'm looking to compile it with Pattern.match(input String).find(). So, to me a single regex will suit better. Can you please advise? Thanks much
type: Comment
comment on: http://stackoverflow.com/a/444635

http://stackoverflow.com/a/499229
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/499070
has body: There are many reasons why sc.write() would not send some or all of the data. You have to check the return value and/or the number of bytes remaining in the buffer. for (int n=0; n&lt;20; n++){ ByteBuffer bb = encoder.encode(CharBuffer.wrap(msg+'\0')); if(sc.write(bb) &gt; 0 &amp;&amp; bb.remaining() == 0) { // all data sent } else { // could not send all data. } bb.rewind(); }
type: Answer
score: 7
upvote count: 7
accepted answer of: http://stackoverflow.com/q/499070

http://stackoverflow.com/a/3018647
has comment: http://stackoverflow.com/comment/3095293
score: 0
type: Answer
has body: User Interface Design by Joel Spolsky. You can read it in one afternoon.
answers question: http://stackoverflow.com/q/556478

http://stackoverflow.com/q/538674
tagged with: java
possible better answer: http://stackoverflow.com/a/538832
score: 10
has answer: http://stackoverflow.com/a/2476147
has answer: http://stackoverflow.com/a/579791
upvote count: 10
has answer: http://stackoverflow.com/a/6800519
type: Question
has title: How to put Google Adsense in GWT
answer count: 8
has answer: http://stackoverflow.com/a/630500
has answer: http://stackoverflow.com/a/538832
downvote count: 0
favorite count: 0
tagged with: adsense
has body: Do anyone know how to put Google adsense ads inside a GWT web application?
has answer: http://stackoverflow.com/a/542878
accepted answer: http://stackoverflow.com/a/542878
tagged with: gwt
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/11940576
has answer: http://stackoverflow.com/a/4571435

http://stackoverflow.com/a/362880
score: 4
has body: This is a good link which can give you a little in depth information: http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html
has comment: http://stackoverflow.com/comment/193727
answers question: http://stackoverflow.com/q/362740
type: Answer
upvote count: 4
downvote count: 0

http://stackoverflow.com/a/562804
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/562796
score: 3
upvote count: 3
accepted answer of: http://stackoverflow.com/q/562796
has body: Java 1.5 should work. The Groovy docs state that you need at least 1.4. I use Groovy with Java 1.5, and everything works fine as far as I can tell.

http://stackoverflow.com/a/558736
downvote count: 2
has comment: http://stackoverflow.com/comment/3212509
has body: I don't know of anything that is exactly what you are asking for, but there is an alternative to SQLite that you may find useful if your architecture requirements are flexible. It may be worth checking out db4o: Android db4o Code comparison examples
score: 10
answers question: http://stackoverflow.com/q/371538
upvote count: 12
type: Answer
has comment: http://stackoverflow.com/comment/3217311

http://stackoverflow.com/a/62899371
upvote count: 1
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/458756
has body: You can use JNA now - see https://github.com/tulskiy/jkeymaster I've had this working fairly easily on a Windows 10 laptop - I haven't personally tested on other platforms - apparently it also works for MacOS and 'X11-based systems (in theory, only tested on some Linux distros and PCBSD)'. It's shouldn't be difficult to setup - you will need slf4j to get it to run. You shouldn't need to build the jar. As an example, this code effectively disables the 'f' key and logs the fact that you pressed it. import com.tulskiy.keymaster.common.Provider; import com.tulskiy.keymaster.common.HotKeyListener; import com.tulskiy.keymaster.common.HotKey; import javax.swing.*; // ... Provider provider = Provider.getCurrentProvider(false); provider.register(KeyStroke.getKeyStroke("F"), new HotKeyListener() { public void onHotKey(HotKey hotKey) { System.out.println(hotKey); } }); I hope this helps someone

http://stackoverflow.com/comment/669834
has text: You didn't get it. GA didn't perform at all, the neural networks did. GA was just to evolve the nets (adjusting weights) based to their success. I played against the best individual and it was pretty good. There was no detectable pattern in it's logic. I also datamined 500k hands from one poker client, and made models from few of the best players (with neural networks). The best individual did beat these as well. The average BB was around 1.5 after one million hands.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/834038
score: 1

http://stackoverflow.com/a/632269
has body: What is your polynomial? If you're "processing" it, I'm envisioning some sort of tree of sub-expressions being generated at some point, and would think that it would be much simpler to use that to generate your string than to re-parse the raw expression with a regex. Just throwing a different way of thinking out there. I'm not sure what else is going on in your app.
has comment: http://stackoverflow.com/comment/445306
has comment: http://stackoverflow.com/comment/445265
upvote count: 3
has comment: http://stackoverflow.com/comment/445243
type: Answer
has comment: http://stackoverflow.com/comment/445414
score: 3
downvote count: 0
answers question: http://stackoverflow.com/q/632204
has comment: http://stackoverflow.com/comment/445334

snmp
tags question: http://stackoverflow.com/q/619253
tag name: snmp
type: Tag

http://stackoverflow.com/comment/2947226
type: Comment
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/360291
has text: Create a BufferedReader using the InputStream to read the content into a string variable

http://stackoverflow.com/comment/44802467
type: Comment
has text: I'm with @aboveyou00--this is a horrendous solution for strings with spaces, including the example provided by leo. A solution for padding a string on the left or the right should not alter the input string as it appears in the output, unless the input string's original padding causes it to exceed the specified padding length.
comment on: http://stackoverflow.com/a/6185386
score: 5
type: AnswerComment

http://stackoverflow.com/a/418779
upvote count: 0
has body: You can also add an "UnhandledExceptionHandler" to your Application's Thread. This will catch 'uncaught' exception, like an out of memory error, and you will at least have an idea where the exception was thrown. Usually this not were the problem is but the 'new' that couldn't be satisfied. As a rule I always add the UnhandledExceptionHandler to a Thread if nothing else to add logging.
downvote count: 1
score: -1
answers question: http://stackoverflow.com/q/418272
type: Answer

http://stackoverflow.com/comment/88764983
type: Comment
has text: @Ariel interesting that you mention that because I was just talking to someone else about that today lol.
type: AnswerComment
comment on: http://stackoverflow.com/a/32276153
score: 0

http://stackoverflow.com/a/41273686
has comment: http://stackoverflow.com/comment/77885780
has comment: http://stackoverflow.com/comment/72129463
has body: A different approach using Java 8 IntStream and Collections.shuffle import java.util.stream.IntStream; import java.util.ArrayList; import java.util.Collections; public class Main { public static void main(String[] args) { IntStream range = IntStream.rangeClosed(5,10); ArrayList&lt;Integer&gt; ls = new ArrayList&lt;Integer&gt;(); //populate the ArrayList range.forEach(i -&gt; ls.add(new Integer(i)) ); //perform a random shuffle using the Collections Fisher-Yates shuffle Collections.shuffle(ls); System.out.println(ls); } } The equivalent in Scala import scala.util.Random object RandomRange extends App{ val x = Random.shuffle(5 to 10) println(x) }
upvote count: 7
has comment: http://stackoverflow.com/comment/72129428
downvote count: 1
type: Answer
score: 6
answers question: http://stackoverflow.com/q/363681

http://stackoverflow.com/comment/29235163
type: Comment
has text: BeanShell is actively maintained as beanshell 2 - https://code.google.com/p/beanshell2/
comment on: http://stackoverflow.com/a/2636083
score: 1
type: AnswerComment

http://stackoverflow.com/q/536478
has answer: http://stackoverflow.com/a/537368
tagged with: swing
accepted answer: http://stackoverflow.com/a/536509
has comment: http://stackoverflow.com/comment/8625740
type: Question
tagged with: algorithm
tagged with: java
answer count: 2
score: 2
downvote count: 0
tagged with: string
favorite count: 0
has answer: http://stackoverflow.com/a/536509
has body: I'm looking for a simple java lib/src to highlight differences between two Strings, case-sensitive. A html output would be great, but I would be happy to get the indexes of the diffs, something like: diff("abcd","aacd") &gt; [2,2] diff("maniac", "brainiac") &gt; ["man",brain"] or [0,3] or something like that The idea is to higlight typos or such in a swing program, since the input shold follow strict conventions.
tagged with: diff
has title: Java simple String diff util
has comment: http://stackoverflow.com/comment/350524
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/349010
possible better answer: http://stackoverflow.com/a/537368
upvote count: 2

http://stackoverflow.com/q/605226
has title: boolean[] vs. BitSet: Which is more efficient?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/605451
possible better answer: http://stackoverflow.com/a/608177
tagged with: java
tagged with: bitsets
tagged with: memory
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/51421736
answer count: 8
tagged with: performance
has answer: http://stackoverflow.com/a/608346
score: 76
tagged with: arrays
has body: What is more efficient in terms of memory and CPU usage — an array of booleans or a BitSet? Specific BitSet methods are not used, only get/set/clear (==, =, Arrays.fill respectively for an array).
has answer: http://stackoverflow.com/a/605241
upvote count: 77
has answer: http://stackoverflow.com/a/608177
favorite count: 0
has answer: http://stackoverflow.com/a/19788757
accepted answer: http://stackoverflow.com/a/605451
has answer: http://stackoverflow.com/a/606790
has answer: http://stackoverflow.com/a/605239

http://stackoverflow.com/a/627556
type: Answer
downvote count: 1
score: -1
upvote count: 0
has body: Regular expressions need delimiters. The " sign is simply used to declare a string and therefor is not valid as a delimiter. Your second example has delimiters, so it works.
has comment: http://stackoverflow.com/comment/441424
answers question: http://stackoverflow.com/q/627545

http://stackoverflow.com/comment/77888568
type: AnswerComment
has text: Exactly... it's completely unused. I would initialise it directly to the rand: `int index = rand.nextInt(i.Length);`
score: 0
type: Comment
comment on: http://stackoverflow.com/a/424548

http://stackoverflow.com/a/593567
type: Answer
answers question: http://stackoverflow.com/q/593478
has body: i had to read the book: https://java-generics-book.dev.java.net/
score: 0

http://stackoverflow.com/q/535929
has comment: http://stackoverflow.com/comment/9233244
possible better answer: http://stackoverflow.com/a/535942
tagged with: junit
has answer: http://stackoverflow.com/a/535934
has body: Is there a way to know the number of test methods in a test case? What I want to do is have a test case which tests several scenarios and for all these i would be doing the data setUp() only once. Similarly I would like to do the cleanup (tearDown()) once at the end of all the test methods. The current approach i am using is to maintain a counter for the number of test methods that are present in the file and decrement them in the tearDown method and do the cleanup when the count reaches 0. But this counter needs to be taken care of whenever new test methods are added.
has answer: http://stackoverflow.com/a/26751558
has answer: http://stackoverflow.com/a/29943800
favorite count: 0
upvote count: 7
has title: To find the number of test methods in a JUnit TestCase
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/535934
score: 7
tagged with: java
has answer: http://stackoverflow.com/a/540614
type: Question
has answer: http://stackoverflow.com/a/535977
has answer: http://stackoverflow.com/a/536145
has answer: http://stackoverflow.com/a/535942
downvote count: 0
answer count: 7

http://stackoverflow.com/comment/372760
comment on: http://stackoverflow.com/q/561245
score: 0
type: QuestionComment
type: Comment
has text: ahhhh, devil is in the details

http://stackoverflow.com/comment/45268138
type: Comment
has text: This looks promising to me. But I found one problem here. I have created a local group "Test". Under this I manually added the current user. And when I ran above code it did not show me the "Test" group. Any pointer would really help me on this.
comment on: http://stackoverflow.com/a/2599980
score: 0
type: AnswerComment

http://stackoverflow.com/a/1877872
downvote count: 0
score: 4
has body: Mergesort is a lot slower for random array based data, as long as it fits in ram. This is the first time I see it debated. qsort the shortest subarray first. switch to insertion sort below 5-25 elements do a normal pivot selection Your qsort is very slow because it tries to partition and qsort arrays of length 2 and 3.
type: Answer
answers question: http://stackoverflow.com/q/497794
has comment: http://stackoverflow.com/comment/34203793
upvote count: 4

http://stackoverflow.com/comment/65175426
has text: One note that may be mentioned is that this will not get escaped in `{@code }` blocks and if a code or pre-formatted output is desired that it must exist within a `` block instead.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/631839
type: Comment

http://stackoverflow.com/a/384072
type: AcceptedAnswer
type: Answer
answers question: http://stackoverflow.com/q/383995
upvote count: 4
has body: I'm not quite exactly sure what you are asking. Normally, you put all of the drawing functionality in the paint() method. However, you generally want to keep any long running work off of the AWT dispatch thread which is the same thread that your buttons' actionPerformed() method is invoked on. To keep your program responsive, you may want to delegate it to a SwingWorker. If your app is not being shown, it is likely because you have not called pack() and show() (in that order) during your JPanel's initialization. Generally, you should do this as the last thing in your init() method. Adding components afterward or changing your components state anywhere but in the AWT thread after this may cause AWT to get mad at you and throw an exception. If you are asking how to draw the points themselves, you should look into Graphics.drawPolyline() and the related methods, which you should call from within your paint() method. If you're asking how to draw them from within the button handler, you don't. You call repaint() and let the object repaint itself on its own time. Also, in your case, I wouldn't bother subclasing JButton. Just implement actionListener. In you init() method, just create two buttons and register your listeners with them. This also means that you don't have to override their constructors. Also, you mask submit during your init() method: it is never referenced and neither is bpanel. Also, I would use a separate X and Y array rather than trying to combine them into a single matrix. You don't need to declare matrix to be public since the inner classes can already see it anyway. In fact, you can (and probably should) declare all of the fields to be private. You also have way too many magic numbers floating around and you are fighting Swing way too much: just let it do it's job laying all your stuff out. You should also try show the smallest possible problem that will allow us to answer your problem: this one sort of flows all over the place and is hard to follow. …
accepted answer of: http://stackoverflow.com/q/383995
downvote count: 0
score: 4

http://stackoverflow.com/q/513343
tagged with: settings
answer count: 4
possible better answer: http://stackoverflow.com/a/513449
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/513353
has answer: http://stackoverflow.com/a/513449
tagged with: java
has body: I'm trying to find the best way to save the state of a simple application. From a DB point-of-view there are 4/5 tables with date fields and relationships off course. Because the app is simple, and I want the user to have the option of moving the data around (usb pen, dropbox, etc), I wanted to put all data in a single file. What is the best way/lib to do this? XML usually is the best format for this (readability &amp; openness), but I haven't found any great lib for this without doing SAX/DOM.
upvote count: 10
type: Question
has answer: http://stackoverflow.com/a/513414
score: 10
tagged with: database
accepted answer: http://stackoverflow.com/a/513353
tagged with: state
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/10556219
has title: Best way to save data in a Java application?

http://stackoverflow.com/q/480683
accepted answer: http://stackoverflow.com/a/482686
has answer: http://stackoverflow.com/a/943353
tagged with: java
tagged with: bayesian
score: 17
answer count: 3
has body: In other answers at Stackoverflow it's been suggested that Weka is good, but there are others (Classifier4j, jBNC, Naiban). Does anyone have actual experience with these?
possible better answer: http://stackoverflow.com/a/482722
downvote count: 0
has answer: http://stackoverflow.com/a/482722
favorite count: 0
tagged with: spam-prevention
has answer: http://stackoverflow.com/a/482686
type: AnsweredQuestion
tagged with: classification
tagged with: machine-learning
upvote count: 17
type: Question
has title: What's the best open-source Java Bayesian spam filter library?

http://stackoverflow.com/a/601958
upvote count: 3
score: 3
answers question: http://stackoverflow.com/q/601804
downvote count: 0
has comment: http://stackoverflow.com/comment/414402
type: Answer
has comment: http://stackoverflow.com/comment/414460
has body: The equivalent .NET IL to complement coobird's answer: For C# code: string s = "This is a really long long long long long" + " long long long long long long long long long long long long " + " long long long long long long long long long string for example."; Console.WriteLine(s); A debug compilation produces: .method public hidebysig static void Main(string[] args) cil managed { .custom instance void [mscorlib]System.STAThreadAttribute::.ctor() .maxstack 1 .locals init ( [0] string str) L_0000: ldstr "This is a really long long long long long long long long long long long long long long long long long long long long long long long long long long string for example." L_0005: stloc.0 L_0006: ldloc.0 L_0007: call void [mscorlib]System.Console::WriteLine(string) L_000c: ret } So, as you can see, it's one string.

http://stackoverflow.com/comment/282570
has text: and as the Jon Skeet article points out, valueOf(foo) protects you in any future refactoring should the primitive's type need to be changed... Integer.toString(foo) does not provide this protection.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/463961
type: Comment

http://stackoverflow.com/comment/394652
type: Comment
has text: Except you can't rethrow a Throwable without declaring "throws Throwable"!!
comment on: http://stackoverflow.com/a/582175
type: AnswerComment
score: 0

http://stackoverflow.com/a/367673
has comment: http://stackoverflow.com/comment/199566
score: 109
has body: Since getEntries returns a raw List, it could hold anything. The warning-free approach is to create a new List&lt;SyndEntry&gt;, then cast each element of the sf.getEntries() result to SyndEntry before adding it to your new list. Collections.checkedList does not do this checking for you&mdash;although it would have been possible to implement it to do so. By doing your own cast up front, you're "complying with the warranty terms" of Java generics: if a ClassCastException is raised, it will be associated with a cast in the source code, not an invisible cast inserted by the compiler.
type: AcceptedAnswer
type: Answer
upvote count: 109
has comment: http://stackoverflow.com/comment/199465
downvote count: 0
has comment: http://stackoverflow.com/comment/2891311
accepted answer of: http://stackoverflow.com/q/367626
answers question: http://stackoverflow.com/q/367626

http://stackoverflow.com/comment/889332
has text: Every class the application programmer writes has a "super" (java.lang.Object doesn't, but the application programmer doesn't write that.)
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/586578
type: Comment

http://stackoverflow.com/a/461822
upvote count: 0
type: Answer
score: -4
has comment: http://stackoverflow.com/comment/292377
answers question: http://stackoverflow.com/q/461398
has body: No answer to your question but a suggestion: It's always better to place the fix enum value in the first place in the compare statement and the variable part in the second place. Because, if in any circumstance the variable part delivers NULL you won't get a NullPointerException. In your example it will look like this ... if (AnswerStatus.NOT_ASSESSED == ans.getStatus()) ... MISTAKE: Of course I make a mistake and mixed two things with each other. If you use the equals method to compare a fixed enum value with a variable containing this enum it's good to compare the constant enum value with the variable and not vic versa. For example: write if (AnswerStatus.NOT_ASSESSED.equals(ans.getStatus())) instead of if (ans.getStatus().equals(AnswerStatus.NOT_ASSESSED)) because, this could harm a NullPointerException if ans.getStatus() == null.
downvote count: 4

http://stackoverflow.com/comment/351878
comment on: http://stackoverflow.com/a/539510
score: 1
type: AnswerComment
type: Comment
has text: Completely agree. I usually try to avoid statics and privates altogether for just this reason. I think that most of the other answers have missed the point.

http://stackoverflow.com/a/646021
downvote count: 1
type: Answer
score: 41
upvote count: 42
has comment: http://stackoverflow.com/comment/35675258
has comment: http://stackoverflow.com/comment/459545
has body: parseInt() is just going to throw an exception if the parsing can't complete successfully. You can instead use Integers, the corresponding object type, which makes things a little bit cleaner. So you probably want something closer to: Integer s = null; try { s = Integer.valueOf(startField.getText()); } catch (NumberFormatException e) { // ... } if (s != null) { ... } Beware if you do decide to use parseInt()! parseInt() doesn't support good internationalization, so you have to jump through even more hoops: try { NumberFormat nf = NumberFormat.getIntegerInstance(locale); nf.setParseIntegerOnly(true); nf.setMaximumIntegerDigits(9); // Or whatever you'd like to max out at. // Start parsing from the beginning. ParsePosition p = new ParsePosition(0); int val = format.parse(str, p).intValue(); if (p.getIndex() != str.length()) { // There's some stuff after all the digits are done being processed. } // Work with the processed value here. } catch (java.text.ParseFormatException exc) { // Something blew up in the parsing. }
accepted answer of: http://stackoverflow.com/q/646012
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/646012

http://stackoverflow.com/a/466486
answers question: http://stackoverflow.com/q/465994
has body: Not sure if I should be answering my own question, but here goes with what I found seems to work now. The key is GLPbuffer, which is an offscreen GLAutoDrawable and can be created without a visible component heirarchy. This article was helpful in getting it to work. I'll leave off accepting this answer until I've confirmed it's fully functional. I should also say that the answer came from this forum, not my own meagre brain.
upvote count: 5
score: 5
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/465994

http://stackoverflow.com/q/512266
type: Question
has answer: http://stackoverflow.com/a/512328
has answer: http://stackoverflow.com/a/514348
has answer: http://stackoverflow.com/a/513071
has answer: http://stackoverflow.com/a/512335
upvote count: 9
has answer: http://stackoverflow.com/a/514323
has answer: http://stackoverflow.com/a/512673
tagged with: java
has answer: http://stackoverflow.com/a/512359
has comment: http://stackoverflow.com/comment/326759
has title: Java multiply operation behavior
has comment: http://stackoverflow.com/comment/326823
has comment: http://stackoverflow.com/comment/326135
has answer: http://stackoverflow.com/a/514386
accepted answer: http://stackoverflow.com/a/512335
tagged with: integer-overflow
favorite count: 0
score: 8
possible better answer: http://stackoverflow.com/a/512338
has answer: http://stackoverflow.com/a/512338
answer count: 10
has comment: http://stackoverflow.com/comment/326068
type: AnsweredQuestion
tagged with: overflow
has answer: http://stackoverflow.com/a/512440
has body: I wrote a method to convert a given number from days to milliseconds: private long expireTimeInMilliseconds; ... public void setExpireTimeInDays(int expireTimeInDays) { expireTimeInMilliseconds = expireTimeInDays * 24 * 60 * 60 * 1000; } I had a hard time to figure out what I did wrong. Now my question: Is that error so obvious ? The corrected method: private long expireTimeInMilliseconds; ... public void setExpireTimeInDays(int expireTimeInDays) { expireTimeInMilliseconds = ((long) expireTimeInDays) * 24 * 60 * 60 * 1000; } If I don't convert the integer to long before calculating, I get a complete wrong result.
has comment: http://stackoverflow.com/comment/326686
downvote count: 1

http://stackoverflow.com/a/464695
answers question: http://stackoverflow.com/q/462094
downvote count: 0
has body: This is actually a symptom of a bad form of inheritance, called implementation inheritance. Either the original class wasn't designed to be inherited, and thus chose to use a private constructor, or that the entire API is poorly designed. The fix for this isn't to figure out a way to inherit, but to see if you can compose the object instead of inheriting, and do so via interfaces. I.e., class Foo is now interface Foo, with a FooImpl. Then interface bar can extend Foo, with a BarImpl, which has no relation to FooImpl. Inside BarImpl, you could if you wish to do some code reuse, have a FooImpl inside as a member, but that's entirely up to the implementation, and will not be exposed.
type: Answer
score: 7
upvote count: 7

tail
tags question: http://stackoverflow.com/q/557844
tag name: tail
type: Tag

http://stackoverflow.com/comment/264497
type: AnswerComment
has text: If granularity is an issue, synchronized(this) might not be applicable, true. But: the required granularity is very often exactly granularity provided by synchronized instance methods, and we do see that synchronized methods in Java are rather common.
type: Comment
comment on: http://stackoverflow.com/a/442570
score: 0

http://stackoverflow.com/a/503598
upvote count: 1
answers question: http://stackoverflow.com/q/503578
downvote count: 0
type: Answer
has body: You might consider saving it to a file, then reading it in on the other end. It might also be similarly slow (especially if a network is involved), but it's worth a shot. You might also consider converting it to a blob of binary data, then passing it, and converting it back. I have a sneaking suspicion that with that bad performance it's passing each element of the array in its own transaction rather than all at once. -Adam
score: 1

http://stackoverflow.com/q/541802
has title: How do I make controls autosizing in Qt designer?
has answer: http://stackoverflow.com/a/5854411
tagged with: qt-jambi
tagged with: user-interface
answer count: 4
favorite count: 0
accepted answer: http://stackoverflow.com/a/542476
upvote count: 1
has body: I'm using Qt Jambi 4.4 for a project I'm working on (and designing the windows in the Qt Designer eclipse plugin). One of the windows I'd like to use is a preview window which is basically just a window with a QWebView on it. How can I make it so that the QWebView resizes as the window does? I've set the sizePolicy to expanding for both Horizontal and Vertical position. What else do I need to do? (also bear in mind that I'm a newbie to both Java and eclipse and need to be talked to in stupid people terms on both of those subjects) UPDATE Just to illustrate the point, here are a couple of screenshots (I've made the window background bright just to illustrate my point): alt text http://img13.imageshack.us/img13/2103/screenshot2oi7.jpg alt text http://img152.imageshack.us/img152/6250/screenshot1mz9.jpg
tagged with: qt
type: AnsweredQuestion
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/622688
has answer: http://stackoverflow.com/a/541881
type: Question
downvote count: 0
possible better answer: http://stackoverflow.com/a/541881
has answer: http://stackoverflow.com/a/542476

http://stackoverflow.com/comment/308260
comment on: http://stackoverflow.com/a/492233
has text: Yup, code compiled under Java 1.4 will run just fine under 1.5. So you could just run everything under Java 1.5 or even 1.6.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/494479
score: 5
upvote count: 5
type: Answer
has body: By using MemoryMXBean (retrieved by calling ManagementFactory.getMemoryMXBean()) as well as Runtime.getRuntime()'s methods: .totalMemory(), .maxMemory() and .freeMemory(). Note that this is not an exact art: while creating a new object, other temporary ones may be allocated, which will not give you an accurate measurement. As we know, java garbage collection is not guaranteed so you can't necessarily do that to eliminate dead objects. If you research, you'll see that most code that attempts to do these measurements will have loops of Runtime.gc() calls and sleeps etc to try and ensure that the measurement is accurate. And this will only work on certain JVM implementations... On an app server/deployed application, you will likely only get gross measurements/usage changes as the heap is allocated and the gc fires, but it should be enough. [I'm presuming that you wouldn't implement gc()'s and sleeps in production code :)]
downvote count: 0
answers question: http://stackoverflow.com/q/494457

http://stackoverflow.com/a/442872
has comment: http://stackoverflow.com/comment/264781
has body: Never hard-code passwords into your code. This was brought up recently in the Top 25 Most Dangerous Programming Mistakes: Hard-coding a secret account and password into your software is extremely convenient -- for skilled reverse engineers. If the password is the same across all your software, then every customer becomes vulnerable when that password inevitably becomes known. And because it's hard-coded, it's a huge pain to fix. You should store configuration information, including passwords, in a separate file that the application reads when it starts. That is the only real way to prevent the password from leaking as a result of decompilation (never compile it into the binary to begin with). For more information about this common mistake, you can read the CWE-259 article. The article contains a more thorough definition, examples, and lots of other information about the problem. In Java, one of the easiest ways to do this is to use the Preferences class. It is designed to store all sorts of program settings, some of which could include a username and password. import java.util.prefs.Preferences; public class DemoApplication { Preferences preferences = Preferences.userNodeForPackage(DemoApplication.class); public void setCredentials(String username, String password) { preferences.put("db_username", username); preferences.put("db_password", password); } public String getUsername() { return preferences.get("db_username", null); } public String getPassword() { return preferences.get("db_password", null); } // your code here } In the above code, you could call the setCredentials method after showing a dialog askign for the username and password. When you need to connect to the database, you can just use the getUsername and getPassword methods to retrieve the stored values. The login credentials will not be hard-coded into your binaries, so decompilation will not pose a security risk. Important Note: The preference files are just plain text XML files. Make sure you take a…
accepted answer of: http://stackoverflow.com/q/442862
has comment: http://stackoverflow.com/comment/264894
has comment: http://stackoverflow.com/comment/50717705
has comment: http://stackoverflow.com/comment/264761
has comment: http://stackoverflow.com/comment/264772
has comment: http://stackoverflow.com/comment/265827
has comment: http://stackoverflow.com/comment/265031
has comment: http://stackoverflow.com/comment/264878
type: AcceptedAnswer
downvote count: 1
has comment: http://stackoverflow.com/comment/75135993
has comment: http://stackoverflow.com/comment/264776
has comment: http://stackoverflow.com/comment/90431006
score: 126
upvote count: 127
type: Answer
has comment: http://stackoverflow.com/comment/81217867
answers question: http://stackoverflow.com/q/442862
has comment: http://stackoverflow.com/comment/264771

http://stackoverflow.com/comment/1660350
type: Comment
comment on: http://stackoverflow.com/a/602099
type: AnswerComment
has text: only if the serialization process is disk-bound. it doesn't seem to be on my system; it seems to be cpu-bound, so compression will just slow it down further.
score: 0

http://stackoverflow.com/comment/251956
comment on: http://stackoverflow.com/a/427929
has text: That article is **horrible**. Approach 1 is the only valid answer - yet somehow the author insists he agrees with the advice not to test private methods but does it anyway. Either his utility methods should be moved into their own class and made public, or they're tested by existing class tests.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/15894349
type: AnswerComment
has text: Why is it important to close the output stream before the input stream ?
score: 0
type: Comment
comment on: http://stackoverflow.com/a/647673

http://stackoverflow.com/a/587486
upvote count: 10
score: 10
has comment: http://stackoverflow.com/comment/399354
downvote count: 0
has comment: http://stackoverflow.com/comment/26299212
answers question: http://stackoverflow.com/q/587458
type: Answer
has body: Since Java only supports single inheritance, that is not possible. Have a look at WP: Mixin. EDIT: Because of the comments about interfaces: The cool thing about mixins is that you can combine them without writing the combination's code. With interfaces you have to implement the combination's functionality yourself (except one class you can extend)!
has comment: http://stackoverflow.com/comment/399345

http://stackoverflow.com/a/602089
score: 0
has body: Why not export it from Excel in some format that is not proprietary? If the data is not too complex, even CSV might do the trick.
type: Answer
answers question: http://stackoverflow.com/q/601795

http://stackoverflow.com/a/11598303
score: 7
upvote count: 7
has body: int result = 0; String val = BigInteger.valueOf(2).pow(1000).toString(); for(char a : val.toCharArray()){ result = result + Character.getNumericValue(a); } System.out.println("val ==&gt;" + result); It's pretty simple if you know how to use the biginteger.
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/377361

http://stackoverflow.com/comment/36961535
has text: @TofuBeer -- Because the Java library designers, chose to put all kinds of unrecoverable low-level failures as _checked exceptions_ when they clearly should have been _unchecked_. FileNotFound is the only IOException which should be checked, for example. With regard to JDBC -- only connecting to the database, can reasonably be considered a _contingency_. All other SQLExceptions should have been _failures_ and unchecked. Error handling should correctly be at the "business" or "request" level -- see the "throw early, catch late" best practice. Checked exceptions are a barrier to that.
type: AnswerComment
score: 4
comment on: http://stackoverflow.com/a/614648
type: Comment

http://stackoverflow.com/comment/75880759
type: Comment
comment on: http://stackoverflow.com/a/380828
score: 0
type: AnswerComment
has text: @CygnusX1 throws a `cannot be cast` exception.

http://stackoverflow.com/q/591411
type: Question
tagged with: guice
has answer: http://stackoverflow.com/a/591425
has answer: http://stackoverflow.com/a/10527995
has answer: http://stackoverflow.com/a/591435
favorite count: 0
has answer: http://stackoverflow.com/a/53122317
score: 48
answer count: 5
possible better answer: http://stackoverflow.com/a/591435
has answer: http://stackoverflow.com/a/591432
accepted answer: http://stackoverflow.com/a/591432
type: AnsweredQuestion
downvote count: 0
upvote count: 48
tagged with: java
has title: Java error: Found interface ... but class was expected
has body: I am getting a strange runtime error from my code: "Found interface [SomeInterface] but class was expected" How can this happen? How can an interface get instantiated? Update: (In response to some answers) I am compiling and running against the same set of libraries, but I am using Guice to inject a Provider for this particular Interface. The problem went away when I bound an implementation to the interface (seems like the @ImplementedBy annotation was not enough). I was more interested in the mechanics through which Guice managed to actually instantiate an interface.

http://stackoverflow.com/a/75872895
answers question: http://stackoverflow.com/q/605696
score: 0
has body: All these answers are either too much code or don't address if the url ends in a / or what if it ends in a ///. This is what I used. And I send it into a chooser save dialog so &quot;&quot; just means they have to type in a name. if(remoteURL!=null) { String[] urlParts=remoteURL.split(&quot;/&quot;); String filename=urlParts[urlParts.length-1]; }
type: Answer

http://stackoverflow.com/a/618359
accepted answer of: http://stackoverflow.com/q/618276
has body: It seems like, "Yes, it is", except: Similar effects could be achieved with varargs as suggested by Paul Whelan or by defining an extra type carrying the parameters as fields with the proper default values as suggested by Jon Skeet. Boris Pavlović adds that his type could be an inner static class to keep things neatly in the right place. Cons (Note that this whole question is not about any serious implications, just about convenient tweaks): Varargs seem most suitable for passing a variable-length list of values that have very similar form and mostly equivalent meaning, such as a list of names. If used for the purpose stated in the question, the method would have to perform various checks on the list in order to interpret it, which seems not more, but less convenient. A special type carrying the parameters seems most useful if the resulting type could be of other uses than just being passed to one particular method, or when it is a more complex set of parameters. If there's 2-4 parameters and some may have default values, it still seems a little more convenient to overload, but that might be a matter of personal taste.
type: AcceptedAnswer
score: 0
type: Answer
answers question: http://stackoverflow.com/q/618276

http://stackoverflow.com/q/492184
has answer: http://stackoverflow.com/a/492224
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/492210
has answer: http://stackoverflow.com/a/65248356
has answer: http://stackoverflow.com/a/18175299
has answer: http://stackoverflow.com/a/493902
has answer: http://stackoverflow.com/a/492376
tagged with: class
has answer: http://stackoverflow.com/a/29619080
has answer: http://stackoverflow.com/a/60543994
has comment: http://stackoverflow.com/comment/108771340
has answer: http://stackoverflow.com/a/10591089
has comment: http://stackoverflow.com/comment/8975067
downvote count: 0
possible better answer: http://stackoverflow.com/a/495851
has comment: http://stackoverflow.com/comment/8975066
favorite count: 0
has answer: http://stackoverflow.com/a/495851
accepted answer: http://stackoverflow.com/a/492210
tagged with: subclass
has answer: http://stackoverflow.com/a/493865
tagged with: interface
has answer: http://stackoverflow.com/a/5735629
has answer: http://stackoverflow.com/a/32764587
has answer: http://stackoverflow.com/a/67206914
answer count: 18
has answer: http://stackoverflow.com/a/49946388
upvote count: 240
has title: How do you find all subclasses of a given class in Java?
has comment: http://stackoverflow.com/comment/128830514
has answer: http://stackoverflow.com/a/45604272
tagged with: java
has answer: http://stackoverflow.com/a/42008683
score: 240
has comment: http://stackoverflow.com/comment/321662
has body: How does one go about and try to find all subclasses of a given class (or all implementors of a given interface) in Java? As of now, I have a method to do this, but I find it quite inefficient (to say the least). The method is: Get a list of all class names that exist on the class path Load each class and test to see if it is a subclass or implementor of the desired class or interface In Eclipse, there is a nice feature called the Type Hierarchy that manages to show this quite efficiently. How does one go about and do it programmatically?
has answer: http://stackoverflow.com/a/45479267
type: Question

format
tags question: http://stackoverflow.com/q/382886
tag name: format
tags question: http://stackoverflow.com/q/412615
type: Tag
tags question: http://stackoverflow.com/q/567516

http://stackoverflow.com/comment/354435
score: 0
type: AnswerComment
has text: Edited to add an explanation.
comment on: http://stackoverflow.com/a/542258
type: Comment

http://stackoverflow.com/q/632933
has answer: http://stackoverflow.com/a/632994
favorite count: 0
upvote count: 5
answer count: 3
tagged with: http://stackoverflow.com/tag/pdf
has answer: http://stackoverflow.com/a/4571559
downvote count: 0
has comment: http://stackoverflow.com/comment/2505074
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2509291
type: Question
has body: What is the best way to generate a PCL output file from an existing PDF file in java?
tagged with: java
has title: Generate PCL from PDF in Java
score: 5
tagged with: printer-control-language

http://stackoverflow.com/comment/239273
type: Comment
has text: It may well be that people realized that the scope of the JSR is too narrow, and left it to be handled by tools. Seems like this is now a feature of JSR 308: Annotations on Java Types.
comment on: http://stackoverflow.com/a/411477
type: AnswerComment
score: 0

http://stackoverflow.com/a/465303
upvote count: 7
has comment: http://stackoverflow.com/comment/283737
has comment: http://stackoverflow.com/comment/284036
score: 7
has body: Beyond the obvious question of why on God's green earth you're using Java 1.3 (when Java 1.4 is no longer supported), localhost is localhost. It's not impacted by whatever IP address your modem (GPRS or otherwise) assigns you. It's fine.
has comment: http://stackoverflow.com/comment/287376
downvote count: 0
has comment: http://stackoverflow.com/comment/283623
type: Answer
has comment: http://stackoverflow.com/comment/283675
has comment: http://stackoverflow.com/comment/285202
has comment: http://stackoverflow.com/comment/286843
has comment: http://stackoverflow.com/comment/283696
answers question: http://stackoverflow.com/q/465284

http://stackoverflow.com/comment/201742
type: Comment
has text: I am using whatever the default GC is for the Windows client JVM (command line is just javaw -jar xxx).
comment on: http://stackoverflow.com/a/373038
score: 0
type: AnswerComment

http://stackoverflow.com/a/1988860
has body: Try the following: http://www.jfileupload.com/products/jbatchupload/index.html [Disclosure: This is my site] Can upload thousands of files and folders.
type: Answer
answers question: http://stackoverflow.com/q/438455
score: 0

http://stackoverflow.com/comment/2803247
comment on: http://stackoverflow.com/a/407323
type: Comment
has text: +1 for **actually testing it**, not just an opinion/theory the OP could have made up himself.
score: 149
type: AnswerComment

http://stackoverflow.com/comment/359586
comment on: http://stackoverflow.com/a/546978
score: 0
type: AnswerComment
has text: Or just private final ItemMaster itemMaster = new ItemMaster(); private final List components = new ArrayList();
type: Comment

http://stackoverflow.com/comment/280717
comment on: http://stackoverflow.com/q/462094
type: Comment
score: 0
type: QuestionComment
has text: Is there a reason for Foo(){} being private instead of being protected?

http://stackoverflow.com/a/509700
upvote count: 1
type: Answer
has body: you could use an embedded Database e.g. HSQLDB or H2 Database and : test if the Annotation Mapping is "correct" (as in the SessionFactory can be started) use some "small" schema.sql to test constrains (e.g. String length, foreign key) take an early look at the SQL Statements to spot some weird mappings and/or use an integration database (either remote or build locally with backups from production) and : make some performance or real data tests
answers question: http://stackoverflow.com/q/452631
downvote count: 0
score: 1

http://stackoverflow.com/comment/372826
has text: Ah, you are right. http://en.wikipedia.org/wiki/DV There is compression on each frame, though. Are you decompressing each frame correctly?
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/561585

http://stackoverflow.com/comment/431496
type: Comment
comment on: http://stackoverflow.com/a/602639
type: AnswerComment
score: 0
has text: This is pretty much the standard for a low-level filter: subtraction and thresholding. A large number of machine vision systems are built entirely upon this simple filter (and only sometimes, something more complex). Of course, reliable thresholding relies on consistent lighting ;)

http://stackoverflow.com/a/450432
answers question: http://stackoverflow.com/q/449558
has body: Once you setup Eclipse for Java development using the Sun JDK in Preferences->Java->Installed JREs, you can attach the Sun javadoc archive file to the JRE in question. Just make sure that you pick the JDK installation directory as the root of the JRE. Eclipse will automatically attach to the src archive there. Then when you make a Java project, you can use the package explorer to browse through the classes and read the javadoc by expanding the JRE System Library entry in your new project. The majority of the api is in the rt.jar.
score: 4
type: Answer
upvote count: 4
downvote count: 0

http://stackoverflow.com/a/393994
accepted answer of: http://stackoverflow.com/q/393968
score: 36
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/127572801
has body: Assuming 2 Set objects a and b AND(intersection of two sets) a.retainAll(b); OR(union of two sets) a.addAll(b); XOR either roll your own loop: foreach item if(a.contains(item) and !b.contains(item) || (!a.contains(item) and b.contains(item))) c.add(item) or do this: c.addAll(a); c.addAll(b); a.retainAll(b); //a now has the intersection of a and b c.removeAll(a); See the Set documentation and this page. For more.
type: Answer
upvote count: 36
answers question: http://stackoverflow.com/q/393968
downvote count: 0
has comment: http://stackoverflow.com/comment/220909

http://stackoverflow.com/comment/402610
comment on: http://stackoverflow.com/a/590932
score: 0
type: AnswerComment
type: Comment
has text: finalize typically will not run in normal application shutdown. (And Windows 95(!) wont close your sockets after an abnormal exit!)

http://stackoverflow.com/q/580962
downvote count: 0
tagged with: java
tagged with: mysql
tagged with: import
type: Question
has body: I have used an application to import some data from a text file to mysql. I have used the following code. try { stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); stmt1= (Statement) conn.createStatement(); int deleteRows = stmt1.executeUpdate("delete from powerdata where dateformat &lt; dateformat_sub(now(), interval 8 month)"); query = "LOAD DATA LOCAL INFILE \"E:\\powerdata.txt\" INTO TABLE powerdata set dateformat=str_to_date(date, '%m/%d/%Y' '%H:%i:%s');"; int Update= stmt.executeUpdate(query); } But the query to load the data from text to mysql is null. Can anybody tell me where I have made a mistake?
answer count: 2
has comment: http://stackoverflow.com/comment/392842
upvote count: 2
has title: problem while importing the data from text to mysql
tagged with: load-data-infile
favorite count: 0
has answer: http://stackoverflow.com/a/581086
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/392843
has answer: http://stackoverflow.com/a/608513
tagged with: text
score: 2

http://stackoverflow.com/a/431780
answers question: http://stackoverflow.com/q/428256
score: 0
has body: GridBagLayout, of course. If the form is just this, then you done need more than one JPanel. (If you have buttons, you probably need one more, depending on where/how they are) Field 0 - 4 and 9 will have gridwidth set to 4, others the default (1, but you need not set it to 1) The 'spaces' between groups of fields can be achieved via insets. (For this layout, at least) I would not suggest third party layout managers. GridBagLayout is not complex. It just takes (a li'l bit of) time to get used to it. Visual Editor + Eclipse can do these for you easily. (I am not very comfortable with Netbeans and its swing development. Tried it, but never fell in love. Maybe, I am too much addicted to Eclipse)
type: Answer

http://stackoverflow.com/q/401464
score: 24
possible better answer: http://stackoverflow.com/a/401476
type: Question
has answer: http://stackoverflow.com/a/401498
answer count: 8
has title: Java Object Reuse
has answer: http://stackoverflow.com/a/402047
upvote count: 24
has answer: http://stackoverflow.com/a/401972
favorite count: 0
has answer: http://stackoverflow.com/a/401472
accepted answer: http://stackoverflow.com/a/401472
has answer: http://stackoverflow.com/a/401597
has answer: http://stackoverflow.com/a/401528
has answer: http://stackoverflow.com/a/401476
type: AnsweredQuestion
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/401502
has body: Should Java Objects be reused as often as it can be reused ? Or should we reuse it only when they are "heavyweight", ie have OS resources associated with it ? All old articles on the internet talk about object reuse and object pooling as much as possible, but I have read recent articles that say new Object() is highly optimized now ( 10 instructions ) and Object reuse is not as big a deal as it used to be. What is the current best practice and how are you people doing it ?

http://stackoverflow.com/a/625788
type: Answer
answers question: http://stackoverflow.com/q/616958
score: 1
upvote count: 1
type: AcceptedAnswer
downvote count: 0
has body: I suspect the reason for accessing the whole model might be related to list size computation. What you could try is to add some breakpoint in your model getElementAt() method. I suggest you do it this way: if (index == 100) { System.out.println("Something");//Put the breakpoint on this line } The 100 constant is a value &lt; getSize() but bigger than the initial visible number of rows (that way you won't have a break for all visible rows). When you enter this breakpoint take a look at where your model was called from, this may give you some hints. You could post the stack trace here for us to try and help you further.
accepted answer of: http://stackoverflow.com/q/616958

http://stackoverflow.com/a/50983439
has body: Here is my understanding of interface advantage. Correct me if I am wrong. Imagine we are developing OS and other team is developing the drivers for some devices. So we have developed an interface StorageDevice. We have two implementations of it (FDD and HDD) provided by other developers team. Then we have a OperatingSystem class which can call interface methods such as saveData by just passing an instance of class implemented the StorageDevice interface. The advantage here is that we don't care about the implementation of the interface. The other team will do the job by implementing the StorageDevice interface. package mypack; interface StorageDevice { void saveData (String data); } class FDD implements StorageDevice { public void saveData (String data) { System.out.println("Save to floppy drive! Data: "+data); } } class HDD implements StorageDevice { public void saveData (String data) { System.out.println("Save to hard disk drive! Data: "+data); } } class OperatingSystem { public String name; StorageDevice[] devices; public OperatingSystem(String name, StorageDevice[] devices) { this.name = name; this.devices = devices.clone(); System.out.println("Running OS " + this.name); System.out.println("List with storage devices available:"); for (StorageDevice s: devices) { System.out.println(s); } } public void saveSomeDataToStorageDevice (StorageDevice storage, String data) { storage.saveData(data); } } public class Main { public static void main(String[] args) { StorageDevice fdd0 = new FDD(); StorageDevice hdd0 = new HDD(); StorageDevice[] devs = {fdd0, hdd0}; OperatingSystem os = new OperatingSystem("Linux", devs); os.saveSomeDataToStorageDevice(fdd0, "blah, blah, blah..."); } }
type: Answer
answers question: http://stackoverflow.com/q/504904
score: 0
has comment: http://stackoverflow.com/comment/88962130

http://stackoverflow.com/comment/210434
score: 1
type: Comment
has text: Sorting them isn't really a solution; if the text contains "R13" it will be changed to "R23". You want the regex to match what you tell it to and nothing else. Word boundaries would do that in this case: /\b(R1|R2|R3|R12|R21)\b/
comment on: http://stackoverflow.com/q/381066
type: QuestionComment

http://stackoverflow.com/a/717128
has comment: http://stackoverflow.com/comment/5026003
answers question: http://stackoverflow.com/q/505284
score: 1
has comment: http://stackoverflow.com/comment/5021870
downvote count: 0
has comment: http://stackoverflow.com/comment/5021798
type: Answer
has comment: http://stackoverflow.com/comment/529210
has comment: http://stackoverflow.com/comment/5028205
upvote count: 1
has body: Though I've been in the Industry since 1975, I'm no longer sure what a "mainframe" is. My current development machine has four 3GHZ processors in it, 8GB of RAM, and 750GB of disk space (RAID 1, so it's really double that), and two 19-inch flatscreen monitors. That's because I'm there on a contract. The employees all have much more powerful boxes than mine. I understand that the server machines, especially the database servers, are much faster. Mainframe?

http://stackoverflow.com/q/556060
tagged with: java
tagged with: image
type: Question
has answer: http://stackoverflow.com/a/556355
has answer: http://stackoverflow.com/a/747934
has title: Generate Images for formulas in Java
has comment: http://stackoverflow.com/comment/367790
has answer: http://stackoverflow.com/a/556097
score: 4
tagged with: formula
has comment: http://stackoverflow.com/comment/367920
has body: I'd like to generate an image file showing some mathematical expression, taking a String like "(x+a)^n=∑_(k=0)^n" as input and getting a more (human) readable image file as output. AFAIK stuff like that is used in Wikipedia for example. Are there maybe any java libraries that do that? Or maybe I use the wrong approach. What would you do if the requirement was to enable pasting of formulas from MS Word into an HTML-document? I'd ask the user to just make a screenshot himself, but that would be the lazy way^^ Edit: Thanks for the answers so far, but I really do not control the input. What I get is some messy Word-style formula, not clean latex-formatted one. Edit2: http://www.panschk.de/text.tex Looks a bit like LaTeX doesn't it? That's what I get when I do clipboard.getContents(RTFTransfer.getInstance()) after having pasted a formula from Word07.
answer count: 4
favorite count: 0
has comment: http://stackoverflow.com/comment/367856
has comment: http://stackoverflow.com/comment/367913
has answer: http://stackoverflow.com/a/556106
has comment: http://stackoverflow.com/comment/367675
possible better answer: http://stackoverflow.com/a/556097
upvote count: 4
has comment: http://stackoverflow.com/comment/367749
type: AnsweredQuestion
downvote count: 0
accepted answer: http://stackoverflow.com/a/747934

http://stackoverflow.com/q/475843
favorite count: 0
has answer: http://stackoverflow.com/a/477063
possible better answer: http://stackoverflow.com/a/475849
tagged with: fluent-interface
type: AnsweredQuestion
tagged with: oop
downvote count: 0
has title: Separate decode/encode interfaces or in one interface
has answer: http://stackoverflow.com/a/475861
tagged with: java
has answer: http://stackoverflow.com/a/476031
accepted answer: http://stackoverflow.com/a/476031
has answer: http://stackoverflow.com/a/475916
has answer: http://stackoverflow.com/a/475849
type: Question
answer count: 8
score: 3
has answer: http://stackoverflow.com/a/475875
has body: I'm creating an implementation that performs conversion from one form to another. The design problem I am facing now is whether the Encoder and Decoder API should be in one interface or in separate ones. e.g. Apache MINA uses separate interfaces I am currently doing something like this: interface Convertor { A encode( B b ); B decode( A a ); } The rationale for putting them in one interface is that you can centralize the implementations and fix any protocol changes in one place. Any thoughts on this ?
upvote count: 3
tagged with: api
has answer: http://stackoverflow.com/a/475884
has answer: http://stackoverflow.com/a/475881

http://stackoverflow.com/comment/49795606
type: AnswerComment
comment on: http://stackoverflow.com/a/513637
type: Comment
has text: which tool did you use to measure memory fragmentation and does fragmentation even make a speed difference for ram?
score: 0

http://stackoverflow.com/q/562570
tagged with: java
has answer: http://stackoverflow.com/a/562949
type: Question
answer count: 1
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/373762
upvote count: 3
type: UnansweredQuestion
has body: I'm writing regression tests for a in-house library (where the creators are looong gone) and I'm trying to validate the environment. A couple of the tests keep failing with that NameNotFoundException only when the jndi name is "complex". This is a stand alone app and is not running with any web containers. The app uses a preference file and there is no LDAP involved. The environment is Java v1.4, and the app is installed with all the necessary libraries local to it. (lib dir with jndi.jar, jms.jar ... etc). Simple, right ? Due to the complexity of the library and how it futzes around with lots of objects, I have a simple test and then ramp up the complexity adding in each piece as a separate test. Setup: File: c:\data\eclipse\workspace\APP\testfiles\jndi\jms\label\.bindings In file there is this entry: QReply/FactoryName=com.ibm.mq.jms.MQQueueFactory UnitTest Class: "simple" test has Hashtable ht = new Hashtable(); ht.put(Context.PROVIDER_URL, "file:/data/eclipse/workspace/APP/testFiles/jndi/jms/label/"); ht.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory"); ht.put(Context.SECURITY_AUTHENTICATION, "none"); Context ctx; try { ctx = new InitialContext(ht); String jndiName = "QReply"; logger.debug("testFindRemoteObject_Simple", "Invoking InitialContext.lookup(\"" + jndiName + "\")"); Object remoteObject = ctx.lookup(jndiName); assertTrue(remoteObject != null); } catch (NamingException e) { e.printStackTrace(); fail(e.getMessage()); } This passes. Because I was having so much trouble with the library I created another test that matches the actual data passed in; the Provider URL is shortened and the jndi name picks up a "path". "Actual" data unit test: final Hashtable ht = new Hashtable(); ht.put(Context.PROVIDER_URL, "file:/data/eclipse/workspace/APP/testFiles/jndi/"); ht.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory"); ht.put(Context.SECURITY_AUTHENTICATION, "none"); Context ctx; try { ctx = new Initi…
has title: JNDI failing with NameNotFoundException
score: 3
tagged with: jndi

http://stackoverflow.com/comment/252578
type: AnswerComment
comment on: http://stackoverflow.com/a/425507
type: Comment
has text: Seems like HTTP push is only used in webcams and some experiments. The code is also not that complicated. I would only say make sure that connection failures are handled correctly and don't assume that all the information will arrive correctly. Any browser api should handle that correctly too.
score: 0

http://stackoverflow.com/comment/305471
type: Comment
has text: JINI doesn't specify _anything_ about a communications protocol. that is it's best feature. Using JINI over RMI would work, but is a lot less interesting than over run-time networks.
comment on: http://stackoverflow.com/a/489448
score: 0
type: AnswerComment

http://stackoverflow.com/a/483230
type: Answer
has body: The answer of Jon Skeet is a good one. In addition to that, I want to encourage you to check the whole trip from browser to database, because sometimes the problem is in a really awkward place. In my case, the problem was caused by a bug in the RequestDumperValve in Tomcat.
upvote count: 1
answers question: http://stackoverflow.com/q/482466
downvote count: 0
score: 1

http://stackoverflow.com/a/650258
has body: Presumably somewhere in your code you are getting a warning. Listen to your compiler. To get details add -Xlint (in particular -Xlint:unchecked) to your javac commandline (or do your development environment's equivalent).
score: 0
type: Answer
answers question: http://stackoverflow.com/q/646899

http://stackoverflow.com/a/512523
type: Answer
upvote count: 51
has body: I started digging myself and I found one potential advantage of using setUp(). If any exceptions are thrown during the execution of setUp(), JUnit will print a very helpful stack trace. On the other hand, if an exception is thrown during object construction, the error message simply says JUnit was unable to instantiate the test case and you don't see the line number where the failure occurred, probably because JUnit uses reflection to instantiate the test classes. None of this applies to the example of creating an empty collection, since that will never throw, but it is an advantage of the setUp() method.
answers question: http://stackoverflow.com/q/512184
score: 51
downvote count: 0

http://stackoverflow.com/a/22271384
downvote count: 0
type: Answer
has body: Use a JToggleButton. More specifically, use the setIcon and setSelectedIcon methods. Using this approach, you'll avoid reinventing the wheel. Example: import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.JToggleButton; import javax.swing.SwingUtilities; import javax.swing.UIManager; final class JToggleButtonDemo { public static final void main(final String[] args) { SwingUtilities.invokeLater(new Runnable(){ @Override public void run() { createAndShowGUI(); } }); } private static final void createAndShowGUI(){ final JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new FlowLayout()); // For presentation purposes only. final JToggleButton button = new JToggleButton(UIManager.getIcon("OptionPane.informationIcon")); button.setSelectedIcon(UIManager.getIcon("OptionPane.errorIcon")); frame.add(button); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }
answers question: http://stackoverflow.com/q/632376
score: 1
upvote count: 1

http://stackoverflow.com/comment/293361
type: AnswerComment
type: Comment
has text: I disagree; if another user were using this class without looking at my source, and got a NullPointerException, he'd think there was a bug in *my* code. But an IllegalArgumentException shows that he has broken the contract implied by the javadoc (even though I failed to state it explicitly).
comment on: http://stackoverflow.com/a/474612
score: 27

http://stackoverflow.com/a/506380
answers question: http://stackoverflow.com/q/506154
type: Answer
score: 2
has body: Do not forget that: you may need to read stdout/stderr of a java program you may have to set/update environment variable and PATH before executing your java command CreateProcess: c:\j2sdk1.4.0\bin\helloworld error=2 means Win32's CreateProcess returns a 2 as error code when it cannot find the command you specify; more specifically, when the command does not refer to an executable file on its lookup path. Look at this SO question for a more complete "Runtime.getRuntime().exec()" code, and also to this snippet. This code creates a shell (as in Runtime.getRuntime().exec("cmd /K")), in which you write on sdtin whatever command you want to execute. The interest of this approach is to reuse the shell process to benefit from a previous command: it you execute a 'cd', then execute a 'dir', the latter command would display the content of the directory referenced by the cd command. The same would be true for PATH settings, just before using javac or java.
downvote count: 0
upvote count: 2

http://stackoverflow.com/a/622851
upvote count: 4
answers question: http://stackoverflow.com/q/622832
has body: Firstly, split out the concept of a pixel, which is just concerned with representation, with a tile, which is an actual game object with constraints it places on the game. I find a good way to disentangle things like this is to start out sketching out the rough API of what you want. Something like: public class Board { public Board (int width, int height){.. } public boolean isOccupied(int x, int y){.. } public void moveTo(Point from, Point to) { .. (maybe throws an exception for outofbounds ) where all internal units of the board are in tiles, not pixels. Then pixel information can be derived from the board independantly from the tile representation with a bit of internal multiplication- public Point getPixelPosition(int xTilePos, int yTilePos, int pixelsPerTile).. The tiles can be internally represented as a 2d array or a single array, in which case you'd use some kind of internal representation scheme to map your array to the board squares, thus the mod arithmetic.
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/435754
downvote count: 0
accepted answer of: http://stackoverflow.com/q/622832
type: Answer
has comment: http://stackoverflow.com/comment/435798
score: 4
has comment: http://stackoverflow.com/comment/435737
has comment: http://stackoverflow.com/comment/435757
has comment: http://stackoverflow.com/comment/435710

http://stackoverflow.com/comment/31145629
has text: The proper idiom would have been a directive that would catch any specified exceptions thrown by nested subroutine calls and rethrow them wrapped in a `RuntimeException`. Note that a routine could simultaneously be declared as `throws IOException` and yet also specify that any `IOException` thrown from a nested call should be considered unexpected and wrapped.
type: AnswerComment
type: Comment
score: 2
comment on: http://stackoverflow.com/a/20231597

http://stackoverflow.com/a/479120
upvote count: 4
has comment: http://stackoverflow.com/comment/296136
score: 2
has comment: http://stackoverflow.com/comment/296192
has comment: http://stackoverflow.com/comment/296216
has comment: http://stackoverflow.com/comment/296122
has comment: http://stackoverflow.com/comment/296167
has comment: http://stackoverflow.com/comment/296137
downvote count: 2
has body: I like: What does this return? private int foo() { try { return 1; } catch (Exception e) { return 2; } finally { return 3; } } Answer: 3
answers question: http://stackoverflow.com/q/479112
type: Answer
has comment: http://stackoverflow.com/comment/296102

http://stackoverflow.com/a/537635
has comment: http://stackoverflow.com/comment/350087
has comment: http://stackoverflow.com/comment/350113
has comment: http://stackoverflow.com/comment/353520
downvote count: 1
has comment: http://stackoverflow.com/comment/350050
answers question: http://stackoverflow.com/q/537595
has comment: http://stackoverflow.com/comment/350495
has comment: http://stackoverflow.com/comment/353844
has comment: http://stackoverflow.com/comment/350065
has comment: http://stackoverflow.com/comment/350055
has comment: http://stackoverflow.com/comment/12087271
has comment: http://stackoverflow.com/comment/350672
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/352859
has comment: http://stackoverflow.com/comment/350192
accepted answer of: http://stackoverflow.com/q/537595
has comment: http://stackoverflow.com/comment/350305
score: 55
type: Answer
upvote count: 56
has comment: http://stackoverflow.com/comment/350302
has body: Best advice I ever got as an undergraduate was from my languages professor, who told me (paraphrasing here): "Don't memorize languages; don't marry yourself to a language. They're just tools. They all do the same basic things. Instead of learning a specific language, learn the foundations of good software development. Then you'll be able to take any language and be successful with it." I feared learning new languages before he told me that. Afterwords, I took his advice to heart and it's made all the difference. Languages are just tools in your toolbox. If you can program and write good software in one language, you can do it in another.
has comment: http://stackoverflow.com/comment/350078

http://stackoverflow.com/comment/72570664
has text: I changed it to ISO-8859-1, but still got a compile error about "unmappable character for encoding UTF8".
comment on: http://stackoverflow.com/a/1858497
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/399551
tagged with: jsf
tagged with: java
type: Question
has title: avoid javax.servlet.ServletException
answer count: 1
tagged with: jsp
upvote count: 3
has answer: http://stackoverflow.com/a/408010
has comment: http://stackoverflow.com/comment/225339
accepted answer: http://stackoverflow.com/a/408010
has body: I am getting a javax.servlet.servletException while executing the following code.... "&lt;%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> "&lt;%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> "&lt;%@ taglib uri="http://jakarta.apache.org/tiles" prefix="tiles"%> tiles:importAttribute scope="request" /> h:panelGrid columns="2" > &lt;f:facet name="header"&gt; &lt;f:subview id="header"&gt; &lt;tiles:insert attribute="header" flush="false" /&gt; &lt;/f:subview&gt; &lt;/f:facet&gt; &lt;f:subview id="menu"&gt; &lt;tiles:insert attribute="menu" flush="false" /&gt; &lt;/f:subview&gt; &lt;f:subview id="content"&gt; &lt;tiles:insert attribute="content" flush="false" /&gt; &lt;/f:subview&gt;
favorite count: 0
downvote count: 0
type: AnsweredQuestion
score: 3

http://stackoverflow.com/q/519882
answer count: 5
upvote count: 3
has answer: http://stackoverflow.com/a/520047
has answer: http://stackoverflow.com/a/519906
type: Question
has title: parsing XML that contain XML in elements, Can this be done
score: 3
accepted answer: http://stackoverflow.com/a/519991
has body: I have a 'complex item' that is in XML, Then a 'workitem' (in xml) that contains lots of other info, and i would like this to contain a string that contains the complex item in xml. for example: &lt;inouts name="ClaimType" type="complex" value="&lt;xml string here&gt;"/&gt; However, trying SAX and other java parsers I cannot get it to process this line, it doesn't like the &lt; or the "'s in the string, I have tried escaping, and converting the " to '. Is there anyway around this at all?? Or will I have to come up with another solution? Thanks
tagged with: java
possible better answer: http://stackoverflow.com/a/519906
has comment: http://stackoverflow.com/comment/336207
downvote count: 0
has comment: http://stackoverflow.com/comment/333919
has answer: http://stackoverflow.com/a/520564
favorite count: 0
has answer: http://stackoverflow.com/a/519913
has answer: http://stackoverflow.com/a/519991
tagged with: http://stackoverflow.com/tag/xml
type: AnsweredQuestion

http://stackoverflow.com/a/636749
downvote count: 0
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/813537
has body: If your time-spans cross daylight-saving (summer-time) boundaries, do you want to report the number of days? For example, 23:00 to 23:00 the next day is always a day but may be 23, 24 or 25 hours depending on whether the you cross a daylight-savings transition. If you care about that, make sure you factor it into your choice.
type: Answer
answers question: http://stackoverflow.com/q/635935

http://stackoverflow.com/comment/55825043
score: 1
type: AnswerComment
has text: is it possible to get this component with its declared name ? I mean component's variable name .
comment on: http://stackoverflow.com/a/33826431
type: Comment

http://stackoverflow.com/a/371836
has body: I've found that simply browsing around in the source code (ctrl-click on a name if you're using NetBeans) has been really helpful. If I see a method appear in the completion dialog that I'm not familiar with, I'll just click "Go to source" and look around until I'm comfortable with it.
upvote count: 1
downvote count: 1
score: 0
answers question: http://stackoverflow.com/q/370259
type: Answer

http://stackoverflow.com/a/750870
answers question: http://stackoverflow.com/q/514487
type: Answer
score: 0
has body: As noted by others, this is generally only possible by having a bootstrap program (Java or other language) that invokes the main JVM with the right parameters. That said, are you sure this is necessary? You mention "maximum heap size". If you are referring to the -Xmx parameter: This is just a limit the VM may never exceed. It does not mean the VM will really use that much, it will do with less if it can. So you can always set -Xmx to the maximum the system can handle, and let the JVM decide how much it really needs. Why do you think you need to set it dynamically?

http://stackoverflow.com/a/491558
has comment: http://stackoverflow.com/comment/345429
type: AcceptedAnswer
downvote count: 1
has comment: http://stackoverflow.com/comment/355700
has comment: http://stackoverflow.com/comment/353007
upvote count: 12
type: Answer
score: 11
has body: This page describes how to and lists some plugins that will allow you to detect Java with JavaScript: http://www.pinlady.net/PluginDetect/JavaDetect.htm Other than that, try out this snippet as well: if (navigator.javaEnabled()) { //Java is enabled }
accepted answer of: http://stackoverflow.com/q/491541
answers question: http://stackoverflow.com/q/491541

http://stackoverflow.com/q/459479
has answer: http://stackoverflow.com/a/459513
tagged with: xdoclet
has body: Question from a C-guy who has to work with some java code that is connected to my C-code via JNI. I have to work on the build-system, and I'm trying to change that from a shell-script to a proper makefile. For the C-part that's easy, but the java side somehow involves xdoclet stuff. I haven't yet found out what xdoclet is all about, and I want to understand it all. I did my Google research, but I have no idea what that thing does. For me it seems like you only have a chance to understand the official documentation if you're already familiar with the problem and you have 10 years of java work under your belt. Could you please - for dummies - explain what does xdoclet does? Btw - also I've mentioned C. I'm into object oriented programming as well. There is no need to explain the basics of classes or inheritance (if required to understand xdoclet) to me. Edit: It's been for IT things roughly a decade ago that I've asked this question. I still have no idea what xdoclet is, but the question got over a thousand views. I would like to see some java guy to chime in and finally clear things up.
has title: What is xdoclet? (from a C-programmer point of view)
score: 2
has comment: http://stackoverflow.com/comment/279389
upvote count: 2
has comment: http://stackoverflow.com/comment/279008
type: UnansweredQuestion
tagged with: java
type: Question
tagged with: java-native-interface
has comment: http://stackoverflow.com/comment/278703
tagged with: http://stackoverflow.com/tag/c
answer count: 1
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/3034779
score: 1
upvote count: 1
has body: I am a programmer who has done C++, Java and now C# development. Here is my answer to the initial question: WCF = EJBS/J2EE server (e.g. JBoss) WPF = Swing (JavaFX) JBoss = I don't think WCF needs a server, just runs in the .net runtime. Not sure about this though, still learning. JVM vs CLR: CLR can do everything JVM can, but CLR can also: run unmanaged code, separate one process into multiple logical ones (AppDomains). Has very good C++ intergration compared to java, CLR is just better. Language c# is also better than java (Lambda's, delegetes, Expression trees, references, structs, extension methods, partial classes, generic without boxing. They did a very good job here!) but only runs on windows. WF=don't know if it exist, might Linq = Currently cannot be implemented in Java because you need: Lambda's, Expression trees and extension methods ADO.net dataservices: I don't know of something simular in java but this could be easily implemented. Probably exists in some opensourse project. Having done both this is my conclusion about how they relate: .net is easier to learn, very much so, yet equally powerful. The reason for this is because there naming of methods in api's is more consistent, there solutions are better integerated and some api's are designed much better (WPF is an example of this, can't say this for other api's, still learning). Because of this .net programmers will cost less. Developing an app in c# will be 1.5 to 2 times faster than in Java. There IDE (visual studio) feels better. You can extend it in 20 minutes, no shit! Trying to understand the eclypse extension mechanisms is not an easy task! Eclipse code refactoring functionality win's one leg. Visual studio win's on many others. (Commercial plugins may be available?) When using .Net you may have to pay licences, for the operating system, and for IIS. For the database you could get away with MySQL. For java you will not have to pay licences. However in reality you mays still have to. Serious app…
answers question: http://stackoverflow.com/q/515397
downvote count: 0
type: Answer

http://stackoverflow.com/a/603783
score: 4
upvote count: 4
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/603766
has comment: http://stackoverflow.com/comment/418208
has body: Unfortunately there is no way of getting data out of a HashMap in any recognizable order. You have to either put all the values into a TreeSet with a Comparator that uses the fileID, or put them into an ArrayList and sort them with Collections.sort, again with a Comparator that compares the way you want. The TreeSet method doesn't work if there are any duplicates, and it may be overkill since you're not going to be adding things to or removing things from the Set. The Collections.sort method is a good solution for instances like this where you're going to take the whole HashSet, sort the results, and then toss away the sorted collection as soon as you've generated the result.

http://stackoverflow.com/q/561231
tagged with: swing
has answer: http://stackoverflow.com/a/561288
type: Question
tagged with: java
tagged with: jtable
answer count: 3
has answer: http://stackoverflow.com/a/561295
downvote count: 0
possible better answer: http://stackoverflow.com/a/561288
favorite count: 0
has body: Whats the relationship between a JTable, TableModel and TableData? If i just modify the TableData, does that also change the data display on the JTable component or I have to call some method to sync the two. I have looked at this, but it does not explicitly tell or show me the relationship in terms of updates
has answer: http://stackoverflow.com/a/561277
accepted answer: http://stackoverflow.com/a/561277
upvote count: 6
type: AnsweredQuestion
has title: Relationship between JTable, TableModel & TableData
score: 6

http://stackoverflow.com/comment/238255
comment on: http://stackoverflow.com/a/413323
type: AnswerComment
score: 0
has text: That's a good suggestion, although it can actually be a bit more complicated,as with a convoluted enough codebase you can actually have entirely dead method chains - more like unused objects in a running JVM, it needs to be dealt with as a graph.
type: Comment

http://stackoverflow.com/comment/33856018
has text: This method will make the access more difficult, but by no means will protect anything. Even if the data is encrypted on file, the code can still be decompiled (and that is my main problem at this moment). So, i have to put sensible data on file, encrypt, and obfuscate the code that deal with encryption/decryption...
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/442868
type: Comment

http://stackoverflow.com/a/41735301
downvote count: 0
upvote count: 3
type: Answer
has body: I have created a method to get a unique integer in a given range. /* * minNum is the minimum possible random number * maxNum is the maximum possible random number * numbersNeeded is the quantity of random number required * the give method provides you with unique random number between min &amp; max range */ public static Set&lt;Integer&gt; getUniqueRandomNumbers( int minNum , int maxNum ,int numbersNeeded ){ if(minNum &gt;= maxNum) throw new IllegalArgumentException("maxNum must be greater than minNum"); if(! (numbersNeeded &gt; (maxNum - minNum + 1) )) throw new IllegalArgumentException("numberNeeded must be greater then difference b/w (max- min +1)"); Random rng = new Random(); // Ideally just create one instance globally // Note: use LinkedHashSet to maintain insertion order Set&lt;Integer&gt; generated = new LinkedHashSet&lt;Integer&gt;(); while (generated.size() &lt; numbersNeeded) { Integer next = rng.nextInt((maxNum - minNum) + 1) + minNum; // As we're adding to a set, this will automatically do a containment check generated.add(next); } return generated; }
answers question: http://stackoverflow.com/q/363681
score: 3

http://stackoverflow.com/q/454464
type: UnansweredQuestion
has title: Felix/OSGi: How to use SCR components that are not OSGi services?
has body: Apache Felix's SCR allows to declare (via annotations or XML) components that will then be instantiated, hooked up to their dependencies, and registered as OSGi services. It is also possible to skip the service registration part, and just have SCR create the component (by specifying @scr.component, but omitting @scr.service). I was thinking this might be useful just for the dependency-injection (within the bundle), but how does one consume the components? Services can be injected using scr.reference, but this does not work for non-services (or does it)? Accessing the SCR API directly works, but directly talking to container services kind of defeats the purpose of DI.
tagged with: java
has answer: http://stackoverflow.com/a/457726
type: Question
tagged with: dependency-injection
score: 0
answer count: 1
tagged with: apache-felix
tagged with: osgi

http://stackoverflow.com/a/590512
type: Answer
upvote count: 2
score: 2
has body: You can call Component.setName on it, or JComponent.putClientProperty, or subclass or use the JLabel object as a key is a Map of some sort. But probably the way to go is to keep hold of a reference to the original object, so you can write clean, direct code that doesn't have to look the component up.
downvote count: 0
answers question: http://stackoverflow.com/q/590473

http://stackoverflow.com/a/477939
score: 4
answers question: http://stackoverflow.com/q/471112
type: Answer
upvote count: 4
downvote count: 0
has body: Have a look here: Openjava sound demo They use FloatControl gainControl; // for volume /** * Set the volume to a value between 0 and 1. */ public void setVolume(double value) { // value is between 0 and 1 value = (value&lt;=0.0)? 0.0001 : ((value&gt;1.0)? 1.0 : value); try { float dB = (float)(Math.log(value)/Math.log(10.0)*20.0); gainControl.setValue(dB); } catch (Exception ex) { ex.printStackTrace(); } } /** * Fade the volume to a new value. To shift volume while sound is playing, * ie. to simulate motion to or from an object, the volume has to change * smoothly in a short period of time. Unfortunately this makes an annoying * clicking noise, mostly noticeable in the browser. I reduce the click * by fading the volume in small increments with delays in between. This * means that you can't change the volume very quickly. The fade has to * to take a second or two to prevent clicks. */ float currDB = 0F; float targetDB = 0F; float fadePerStep = .1F; // .1 works for applets, 1 is okay for apps boolean fading = false; public void shiftVolumeTo(double value) { // value is between 0 and 1 value = (value&lt;=0.0)? 0.0001 : ((value&gt;1.0)? 1.0 : value); targetDB = (float)(Math.log(value)/Math.log(10.0)*20.0); if (!fading) { Thread t = new Thread(this); // start a thread to fade volume t.start(); // calls run() below } } /** * Run by thread, this will step the volume up or down to a target level. * Applets need fadePerStep=.1 to minimize clicks. * Apps can get away with fadePerStep=1.0 for a faster fade with no clicks. */ public void run() { fading = true; // prevent running twice on same sound if (currDB &gt; targetDB) { while (currDB &gt; targetDB) { currDB -= fadePerStep; gainControl.setValue(currDB); try {Thread.sleep(10);} catch (Exception e) {} } } else if (currDB &lt; targetDB) { while (currDB &lt; targetDB) { currDB += fadePerStep; gainControl.setValue(currDB); try {Thread.sleep(10);} catch (Exception e) {} } } fading = false; currDB = targetDB; // now sound is at t…
accepted answer of: http://stackoverflow.com/q/471112
type: AcceptedAnswer

http://stackoverflow.com/comment/2775499
has text: @Berlin Brown - The problem is how it is presented. Good question: "Is the Java API a good or bad example of API design and why?" Bad question: "Is the Java API poorly designed and why?"
type: Comment
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/567987

http://stackoverflow.com/q/474320
has title: In Java, how can I construct a "proxy wrapper" around an object which invokes a method upon changing a property?
tagged with: java
possible better answer: http://stackoverflow.com/a/474357
tagged with: proxy-classes
has body: I'm looking for something similar to the Proxy pattern or the Dynamic Proxy Classes, only that I don't want to intercept method calls before they are invoked on the real object, but rather I'd like to intercept properties that are being changed. I'd like the proxy to be able to represent multiple objects with different sets of properties. Something like the Proxy class in Action Script 3 would be fine. Here's what I want to achieve in general: I have a thread running with an object that manages a list of values (numbers, strings, objects) which were handed over by other threads in the program, so the class can take care of creating regular persistent snapshots on disk for the purpose of checkpointing the application. This persistor object manages a "dirty" flag that signifies whether the list of values has changed since the last checkpoint and needs to lock the list while it's busy writing it to disk. The persistor and the other components identify a particular item via a common name, so that when recovering from a crash, the other components can first check if the persistor has their latest copy saved and continue working where they left off. During normal operation, in order to work with the objects they handed over to the persistor, I want them to receive a reference to a proxy object that looks as if it were the original one, but whenever they change some value on it, the persistor notices and acts accordingly, for example by marking the item or the list as dirty before actually setting the real value. Edit: Alternatively, are there generic setters (like in PHP 5) in Java, that is, a method that gets called if a property doesn't exist? Or is there a type of object that I can add properties to at runtime?
type: Question
upvote count: 4
has answer: http://stackoverflow.com/a/4172709
downvote count: 0
score: 4
has answer: http://stackoverflow.com/a/474357
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/475252
tagged with: design-patterns
has answer: http://stackoverflow.com/a/474365
accepted answer: http://stackoverflow.com/a/474365
type: AnsweredQuestion

http://stackoverflow.com/comment/334665
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/521144
has text: @LicenseQ: As I say, that's not related to the actual size IMO. Will update answer to explain.
score: 0

http://stackoverflow.com/comment/380634
has text: If you look through the API docs, not a great deal is actually deprecated.
type: AnswerComment
comment on: http://stackoverflow.com/a/568015
score: 0
type: Comment

http://stackoverflow.com/a/586720
score: 0
type: Answer
answers question: http://stackoverflow.com/q/582493
has body: It works very nice. IMHO you should use Mono from the development site (www.go-mono.com) rather than version provided with your distribution. Also you could try dry-running it with VMWare machine that is also avaliable on the official site.

http://stackoverflow.com/a/412175
upvote count: 8
type: Answer
downvote count: 0
score: 8
answers question: http://stackoverflow.com/q/407016
has body: Firstly, Saving the PID on *nix: $ ./yourprogram &amp; $ echo $! &gt; /var/run/yourpid yourpid will now contain yourpgram's PID, and /var/run is the proper place to put it. The above can be put in your "start" script. The "stop" script can look at yourpid to know what to kill. If you want to be more elegant and stop your app properly, you can look at the source code for Tomcat's org.apache.catalina.startup.Catalina.java on how to implement proper shutdown hooks. Secondly, above "stop" and "start" scripts can then be put in /etc/init.d/mystopstartscript: #!/bin/bash # processname: yourprogram # pidfile: /var/run/yourpid case $1 in start) sh /some/where/start.sh ;; stop) sh /some/where/stop.sh ;; restart) sh /some/where/stop.sh sh /some/where/start.sh ;; esac exit 0 This is a fairly home-grown solution, with ideas mostly taken from good 'ol Tomcat, but I hope it helps :)

http://stackoverflow.com/comment/289056
type: Comment
comment on: http://stackoverflow.com/a/467782
score: 0
has text: I don't see it as abuse any more than yours and you're right, they're my votes - this was a genuinely useful answer since it gave an answer and a rationale (a little brief for my liking, but still it's there). That's my reason for the upvote, you need to look at the smileys a little closer :-).
type: AnswerComment

http://stackoverflow.com/a/448168
has comment: http://stackoverflow.com/comment/269323
has body: You could grab the entrySet instead, to avoid needing the key class: private String dataToString(){ Map data = (HashMap&lt;MyClass.Key, String&gt;) getData(); String toString = ""; for( Map.Entry entry: data.entrySet() ) { toString += entry.getKey() + ": " + entry.getValue(); } return toString; }
upvote count: 5
score: 5
has comment: http://stackoverflow.com/comment/269237
downvote count: 0
has comment: http://stackoverflow.com/comment/269220
type: Answer
answers question: http://stackoverflow.com/q/448122

http://stackoverflow.com/a/389201
downvote count: 0
upvote count: 2
has body: I think SpringSource's acquisition of Covalent Technologies puts them in a better position to help anyone using the Spring/Tomcat stack. The Tomcat optimizations that come along with Spring dm Server might be worth as much or more than the OSGi features.
type: Answer
answers question: http://stackoverflow.com/q/381071
score: 2

http://stackoverflow.com/a/593717
has body: We are using grails + on the web layer + java with hibernate and spring on the service layer. It's the classic three layers (web, logic, data) where the web is grails and the logic is implemented in java. As is usual in java, we use bean objects that represents the data between different layers. It works pretty well and it was the best solution for our case as the bean objects were already there, as well as the database structure. From our experience, I think grails has a great value as the web presentation layer, but I would stick with java to write the business rules and to persist the application data - as grails "is" java, all the grails-java integration is pretty straight-forward. We use eclipse to develop the grails application and it's poor integration, as people said in here. But, as a suggestion from other developer, we run the grails application from the command-line and only use eclipse to save the source files, and it works pretty well, as the application is updated on the fly. I yet don't feel comfortable for using grails in other places than in the presentation layer.
has comment: http://stackoverflow.com/comment/1233648
answers question: http://stackoverflow.com/q/397228
type: Answer
score: 7
upvote count: 7
downvote count: 0

http://stackoverflow.com/q/634963
has body: I saw this question, but the answers there are not very relevant. A friend needs a bank of solved recursion problems to help him study for a test tomorrow. He learned the issue theoretically, but is having problems grasping how to actually solve recursion problems. Do you know a good source of solved recursion problems (preferably in C, but can be in a C-style language as well) available on the net? Note - examples in functional languages will not help much here. My friend is in a study race to pass his test tomorrow, and I'm sure switching languages will just confuse him at this point (it might be educational on other, less stressed times).
has answer: http://stackoverflow.com/a/9886603
favorite count: 0
has comment: http://stackoverflow.com/comment/449839
has comment: http://stackoverflow.com/comment/448168
tagged with: c++
possible better answer: http://stackoverflow.com/a/634988
has answer: http://stackoverflow.com/a/635263
score: 11
downvote count: 1
tagged with: recursion
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2584035
has answer: http://stackoverflow.com/a/635098
accepted answer: http://stackoverflow.com/a/635098
tagged with: java
tagged with: http://stackoverflow.com/tag/c
type: Question
has comment: http://stackoverflow.com/comment/448832
has answer: http://stackoverflow.com/a/635091
upvote count: 12
has answer: http://stackoverflow.com/a/634988
has comment: http://stackoverflow.com/comment/448226
answer count: 7
has answer: http://stackoverflow.com/a/635034
has title: A good bank of recursion solutions in C/C++/Java/C#

http://stackoverflow.com/a/639388
has body: This looks like a line from a CSV file, parsing it through any reasonable CSV library would automatically deal with this issue for you. At least by reading the quoted value into a single 'field'.
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/639264
downvote count: 0
type: Answer

http://stackoverflow.com/q/451182
has answer: http://stackoverflow.com/a/451219
has body: Is there any other method of stopping inheritance of a class apart from declaring it as final or by declaring its constructor as private?
answer count: 9
has title: Stopping inheritance without using final
has comment: http://stackoverflow.com/comment/271927
has comment: http://stackoverflow.com/comment/271944
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/271926
has answer: http://stackoverflow.com/a/451272
has answer: http://stackoverflow.com/a/451229
has comment: http://stackoverflow.com/comment/271906
has answer: http://stackoverflow.com/a/47943024
tagged with: java
has answer: http://stackoverflow.com/a/451200
has comment: http://stackoverflow.com/comment/271954
has comment: http://stackoverflow.com/comment/271964
type: Question
linked to: http://stackoverflow.com/q/16661595
score: 9
has answer: http://stackoverflow.com/a/452748
downvote count: 2
has answer: http://stackoverflow.com/a/451189
has answer: http://stackoverflow.com/a/451234
has comment: http://stackoverflow.com/comment/271967
has answer: http://stackoverflow.com/a/79278939
upvote count: 11
tagged with: inheritance
has comment: http://stackoverflow.com/comment/271956
has comment: http://stackoverflow.com/comment/132326553
has comment: http://stackoverflow.com/comment/271824
has comment: http://stackoverflow.com/comment/271866
favorite count: 0

http://stackoverflow.com/a/6678179
has body: public static Random RANDOM = new Random(System.nanoTime()); public static final float random(final float pMin, final float pMax) { return pMin + RANDOM.nextFloat() * (pMax - pMin); }
type: Answer
answers question: http://stackoverflow.com/q/363681
downvote count: 3
upvote count: 21
score: 18

http://stackoverflow.com/comment/442639
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/629618
has text: Growl and Snarl seem to be impressive tools and seem to be easily used from an application without much effort with a nice result. However the need to install the tool on every client pc might be a no go for our customer.
type: Comment

http://stackoverflow.com/q/371607
answer count: 3
has answer: http://stackoverflow.com/a/12954446
has answer: http://stackoverflow.com/a/371614
tagged with: http://stackoverflow.com/tag/xml
type: AnsweredQuestion
upvote count: 3
possible better answer: http://stackoverflow.com/a/12954446
type: Question
score: 3
has title: How to tell Java which StringEscapeUtils.escapeXML() to use?
tagged with: java
has answer: http://stackoverflow.com/a/371630
accepted answer: http://stackoverflow.com/a/371630
downvote count: 0
tagged with: jsp
favorite count: 0
has body: I'm trying to use the StringEscapeUtils.escapeXML() function from org.apache.commons.lang... There are two versions of that function, one which expects (Writer, String) and one which just expects (String).... http://commons.apache.org/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeXml(java.lang.String) I'm trying to use the version that just expects the String parameter without the Writer, but Java is complaining that I've not given it a Writer. How do I use this in my program so that I don't need a Writer? String escXml = StringEscapeUtils.escapeXml(attr.get()); xml = xml.concat("&lt;"+attr.getID()+"&gt;"+escXml+"&lt;/"+attr.getID()+"&gt;"); I've also tried just doing it inline in the string itself. xml = xml.concat("&lt;"+attr.getID()+"&gt;"+StringEscapeUtils.escapeXml(attr.get())+"&lt;/"+attr.getID()+"&gt;"); Both of these attempts have given me the error about it expecting the Writer though. Can anyone help me with this? Thanks, Matt

http://stackoverflow.com/comment/450798
has text: swtich would have been a dream.. it was nested if/elses... written in C++ code by COBOL programmers... I quit not long after that.
comment on: http://stackoverflow.com/a/633582
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/316644
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/416789
type: Comment
has text: I'm not sure if you're also notified when it's a followup answer instead of comment, so here we go ;)

http://stackoverflow.com/a/415261
score: 3
has body: It sounds like your testing at too high a level. Consider mocking the web service interface and writing other unit tests on the data layer that access the database. Some more detail here might make this question easier to answer, for example the situation you're trying to test. I would normally expect the results of a unit test not to change, or at least to be within a range that you're expecting
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/415244
upvote count: 3

http://stackoverflow.com/comment/292240
comment on: http://stackoverflow.com/a/474567
has text: Close. you mean a/b < c/d <=> ad < bc for bd>0. (I got it right the first time in my code comments!)
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/468440
upvote count: 2
type: Answer
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/3736237
answers question: http://stackoverflow.com/q/468328
has body: For systems with a lot of simple forms, I've tended to go the XML route - define XML files for the information and any work flow for each form create XSLT to generate Java/XHTML/whatever code to run the forms on desktop PC/mobile/web also create XSLT to generate source code data objects etc. You can use XForms and implementations thereof, but usually I've been working in places where buying in solutions takes longer than building your own simple XSLT. It generally takes a week to get everything up and running if there aren't too many specialised widgets in the forms. If you make your own code generators, you have full control. If you find you want to switch all your forms from scrolling up/down to be presented in columns, then there is just one place you have to change, rather than changing each form's implementation. (though you could make a framework to abstract form information from presentation in Java, it's not well suited to such declarative programming)

jersey
tags question: http://stackoverflow.com/q/583973
tag name: jersey
type: Tag

http://stackoverflow.com/comment/2083390
has text: Could you provide the full class?
comment on: http://stackoverflow.com/a/626096
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/a/646448
upvote count: 1
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/633600
has body: The page has not loaded properly when you are clicking on it. Check for different elements on the page to be sure that the page has loaded. Also, wait for the link to appear and be visible before you click on it.

http://stackoverflow.com/a/19465966
downvote count: 0
score: 1
type: Answer
has body: I had to implement a filter for slow connections to Servlets so basically I wrapped the servlet output stream into a QueueOutputStream which will add every byte (in small buffers), into a queue, and then output those small buffers to a 2nd output stream, so in a way this acts as input/output stream, IMHO this is better than JDK pipes which won't scale that well, basically there is too much context switching in the standard JDK implementation (per read/write), a blocking queue is just perfect for a single producer/consumer scenario: import java.io.IOException; import java.io.OutputStream; import java.util.concurrent.*; public class QueueOutputStream extends OutputStream { private static final int DEFAULT_BUFFER_SIZE=1024; private static final byte[] END_SIGNAL=new byte[]{}; private final BlockingQueue&lt;byte[]&gt; queue=new LinkedBlockingDeque&lt;&gt;(); private final byte[] buffer; private boolean closed=false; private int count=0; public QueueOutputStream() { this(DEFAULT_BUFFER_SIZE); } public QueueOutputStream(final int bufferSize) { if(bufferSize&lt;=0){ throw new IllegalArgumentException("Buffer size &lt;= 0"); } this.buffer=new byte[bufferSize]; } private synchronized void flushBuffer() { if(count&gt;0){ final byte[] copy=new byte[count]; System.arraycopy(buffer,0,copy,0,count); queue.offer(copy); count=0; } } @Override public synchronized void write(final int b) throws IOException { if(closed){ throw new IllegalStateException("Stream is closed"); } if(count&gt;=buffer.length){ flushBuffer(); } buffer[count++]=(byte)b; } @Override public synchronized void write(final byte[] b, final int off, final int len) throws IOException { super.write(b,off,len); } @Override public synchronized void close() throws IOException { flushBuffer(); queue.offer(END_SIGNAL); closed=true; } public Future&lt;Void&gt; asyncSendToOutputStream(final ExecutorService executor, final OutputStream outputStream) { return executor.submit( new Callable&lt;Void&gt;() { @Override public Void c…
answers question: http://stackoverflow.com/q/364936
upvote count: 1

http://stackoverflow.com/comment/278744
score: 0
type: AnswerComment
type: Comment
has text: Yet this still occurs when action is present, if the action URL includes a query string.
comment on: http://stackoverflow.com/a/459507

http://stackoverflow.com/a/17167743
has comment: http://stackoverflow.com/comment/26675154
has comment: http://stackoverflow.com/comment/48287171
score: 229
has body: Instead of reinventing the wheel, how about using Apache commons-io: import org.apache.commons.io.FilenameUtils; public class FilenameUtilTest { public static void main(String[] args) throws Exception { URL url = new URL("http://www.example.com/some/path/to/a/file.xml?foo=bar#test"); System.out.println(FilenameUtils.getBaseName(url.getPath())); // -&gt; file System.out.println(FilenameUtils.getExtension(url.getPath())); // -&gt; xml System.out.println(FilenameUtils.getName(url.getPath())); // -&gt; file.xml } }
has comment: http://stackoverflow.com/comment/67853763
has comment: http://stackoverflow.com/comment/54351596
downvote count: 5
upvote count: 234
answers question: http://stackoverflow.com/q/605696
has comment: http://stackoverflow.com/comment/92847757
accepted answer of: http://stackoverflow.com/q/605696
has comment: http://stackoverflow.com/comment/50293010
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/88486619
has comment: http://stackoverflow.com/comment/35507365
type: Answer
has comment: http://stackoverflow.com/comment/35405444
has comment: http://stackoverflow.com/comment/84017527
has comment: http://stackoverflow.com/comment/51332529
has comment: http://stackoverflow.com/comment/92848217
has comment: http://stackoverflow.com/comment/83766536

http://stackoverflow.com/a/33424282
upvote count: 4
score: 2
has comment: http://stackoverflow.com/comment/127172926
has body: Random number from the range [min..max] inclusive: int randomFromMinToMaxInclusive = ThreadLocalRandom.current() .nextInt(min, max + 1);
downvote count: 2
answers question: http://stackoverflow.com/q/363681
type: Answer

http://stackoverflow.com/a/377825
type: Answer
has comment: http://stackoverflow.com/comment/2320987
score: 7
has body: Actually, if you remove the final keyword the constants stop being compile-time constants and then your configuration will work like you want. However, it is strongly suggested that if this is indeed some sort of configuration you are trying to do, you should move to to a more manageable way than constants in some class file.
upvote count: 8
answers question: http://stackoverflow.com/q/377819
downvote count: 1

http://stackoverflow.com/q/560836
has answer: http://stackoverflow.com/a/1699285
downvote count: 0
score: 7
has comment: http://stackoverflow.com/comment/12416955
tagged with: java
has answer: http://stackoverflow.com/a/631048
type: Question
has answer: http://stackoverflow.com/a/5489632
linked to: http://stackoverflow.com/q/2369851
has body: I have a web application which is running on jetty. Continues builds are built on hudson. I would like to make a hot deploy on demand from hudson. I found cargo plugin which should be able to do so but cargo's web doesn't show any complete example how to do it - for remote jetty server - may be I miss it? What do you suggest? Do you have any other better solution? thank you, Vitek
answer count: 3
upvote count: 7
favorite count: 0
has title: What is a best solution for hot deploy to Jetty?
type: UnansweredQuestion
tagged with: jetty
has comment: http://stackoverflow.com/comment/1575048
tagged with: deployment

http://stackoverflow.com/comment/312895
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/497105
score: 0
has text: That's true. But you could argue that telling a novice about this sort of minor issue may put them on the wrong path. :-)

http://stackoverflow.com/a/439817
upvote count: 2
type: Answer
score: 2
accepted answer of: http://stackoverflow.com/q/439721
answers question: http://stackoverflow.com/q/439721
has body: You can't control which one is used by your MIDlet, it's decided by the implementation of the KVM (and thus by the producer). Usually, when the device has two separate heaps it uses one to keep "common" data and the other to keep media like pictures or video clips, but again, it's up to the producer, you can't force an object to be allocated on a heap instead of another via J2ME
has comment: http://stackoverflow.com/comment/262021
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/287082

http://stackoverflow.com/a/469446
type: Answer
has comment: http://stackoverflow.com/comment/75098190
has body: the easiest way to do this is to put in some test code which writes the object to a file. then, look at the size of the file. or, if you don't want to write to disk (and your objects are not going to blow out memory): ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bout); oos.writeObject(theObjectIWantTheSizeOf); oos.close(); System.out.println("The object size is: " + bout.toByteArray().length:
downvote count: 1
accepted answer of: http://stackoverflow.com/q/468562
answers question: http://stackoverflow.com/q/468562
score: 0
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/287431

http://stackoverflow.com/a/637995
has body: You can check PriorityQueue or PriorityBlockingQueue. I don't think either of them allow you to modify the priority. But you can always remove an element and add it back with modified priority.
upvote count: 4
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/637913
score: 4

http://stackoverflow.com/q/605696
has answer: http://stackoverflow.com/a/605737
has answer: http://stackoverflow.com/a/605881
has answer: http://stackoverflow.com/a/1856542
has comment: http://stackoverflow.com/comment/418502
has answer: http://stackoverflow.com/a/51221150
has answer: http://stackoverflow.com/a/28280175
has answer: http://stackoverflow.com/a/44285041
upvote count: 183
has answer: http://stackoverflow.com/a/605727
has answer: http://stackoverflow.com/a/605746
tagged with: url
has answer: http://stackoverflow.com/a/19716225
has answer: http://stackoverflow.com/a/75872895
favorite count: 0
score: 182
has comment: http://stackoverflow.com/comment/418017
has answer: http://stackoverflow.com/a/39142179
possible better answer: http://stackoverflow.com/a/605746
linked to: http://stackoverflow.com/q/8393849
has comment: http://stackoverflow.com/comment/417920
has answer: http://stackoverflow.com/a/54623329
has answer: http://stackoverflow.com/a/60640685
has comment: http://stackoverflow.com/comment/13900405
has comment: http://stackoverflow.com/comment/18510335
has comment: http://stackoverflow.com/comment/48287148
has answer: http://stackoverflow.com/a/47183212
has answer: http://stackoverflow.com/a/17167743
tagged with: parsing
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/57788089
has comment: http://stackoverflow.com/comment/417957
has comment: http://stackoverflow.com/comment/14365383
has answer: http://stackoverflow.com/a/605844
has answer: http://stackoverflow.com/a/73057493
has answer: http://stackoverflow.com/a/17122026
has comment: http://stackoverflow.com/comment/417884
has answer: http://stackoverflow.com/a/47253488
has answer: http://stackoverflow.com/a/26810644
linked to: http://stackoverflow.com/q/4050087
tagged with: file
has answer: http://stackoverflow.com/a/33871029
downvote count: 1
has answer: http://stackoverflow.com/a/35429735
has answer: http://stackoverflow.com/a/605860
type: Question
has answer: http://stackoverflow.com/a/19314042
has answer: http://stackoverflow.com/a/31469017
has answer: http://stackoverflow.com/a/41244248
has answer: http://stackoverflow.com/a/25370132
tagged with: filenames
has body: In Java, given a java.net.URL or a String in the form of http://www.example.com/some/path/to/a/file.xml , what is the easiest way to get the file name, minus the extension? So, in this example, I'm looking for something that returns "file". I can think of several ways to do this, but I'm looking for something that's easy to read and short.
tagged with: java
has answer: http://stackoverflow.com/a/6450978
accepted answer: http://stackoverflow.com/a/17167743
has title: Get file name from URL
answer count: 29

http://stackoverflow.com/comment/249099
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/417093
has text: Using GWT is really no different then using jQuery or Prototype. If there is a bug in the library you are using, it will make your life difficult. The same problems exist for GWT. The difference is that GWT has Google's developers backing it up, not just the few people behind the other libraries.
type: Comment

http://stackoverflow.com/a/485074
answers question: http://stackoverflow.com/q/485023
type: Answer
has body: Here's a pretty extensive article on that very subject. I don't think you'll have a holy grail here though. I would also suggest trying to encode/decode the received text in some standard ways (uuencode, base64)
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/301626
downvote count: 0

http://stackoverflow.com/a/501457
has comment: http://stackoverflow.com/comment/317400
score: 1
has comment: http://stackoverflow.com/comment/316657
has comment: http://stackoverflow.com/comment/316645
has comment: http://stackoverflow.com/comment/317565
upvote count: 1
type: AcceptedAnswer
has body: I'm not 100% sure how the java regex-engine works, but I can't possibly imagine that an entity would cause your problems. You should first try to simply remove your brackets, since you're replacing the entire expression, and not extracting anything. What might be causing it though is if your entity is actually translated to a new-line, it might be the case that your regex won't catch it unless you're explicitly doing a multiline match. You could also try doing [.\n]* instead of your .* This might be a bid greedy though, and the backtracking to much for the matcher to handle. Unfortunately, I don't have any java stuff installed on this machine, so I can't really try it and test it. One other possibility would be to actively look for the next opening angle bracket, like so: [^&lt;]* EDIT: As you suggested, i tried your link and the following worked perfectly: Expression: &lt;My:tag&gt;[^&lt;]*&lt;/My:tag&gt; Replacement: &lt;My:tag&gt; new_stuff &lt;/My:tag&gt; Test string: &lt;My:tag&gt;value_1 22&amp;#xA;value_2 54&amp;#xA;value_3 11&lt;/My:tag&gt;
type: Answer
has comment: http://stackoverflow.com/comment/316630
accepted answer of: http://stackoverflow.com/q/501435
downvote count: 0
answers question: http://stackoverflow.com/q/501435

http://stackoverflow.com/comment/292095
has text: This is not true if, for example, a = 1, b = 3, c = -2, d = -3. If b and d are positive then it is true that a/b < c/d if and only if ad < bc.
comment on: http://stackoverflow.com/a/474567
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/7743921
score: 0
has text: whwere should I add the -Dlog4j.debug ?
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/610740

http://stackoverflow.com/q/445455
score: 12
answer count: 3
upvote count: 12
accepted answer: http://stackoverflow.com/a/445925
has body: According to google and some other sources (e.g., http://www.enterprisedt.com/publications/oracle/result_set.html), if I want to call a stored-function that returns a ref cursor, I need to write something like this in order to access the ResultSet: String query = "begin ? := sp_get_stocks(?); end;"; CallableStatement stmt = conn.prepareCall(query); // register the type of the out param - an Oracle specific type stmt.registerOutParameter(1, OracleTypes.CURSOR); // set the in param stmt.setFloat(2, price); // execute and retrieve the result set stmt.execute(); ResultSet rs = (ResultSet)stmt.getObject(1); Is there anyway to do it without introducing the compile-time dependency on Oracle. Is there a generic alternative to OracleTypes.CURSOR?
downvote count: 0
favorite count: 0
possible better answer: http://stackoverflow.com/a/446034
tagged with: oracle-database
has answer: http://stackoverflow.com/a/446034
has answer: http://stackoverflow.com/a/78548912
has title: Using Oracle ref cursor in Java without Oracle dependency
has answer: http://stackoverflow.com/a/445925
type: Question
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/6541971
tagged with: java

http://stackoverflow.com/a/632641
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/632567
has comment: http://stackoverflow.com/comment/446647
has body: The W3C have been working towards defining a standard for XML fragment interchange. I'm mentioning it not because it's a solution to your problem, but it's definitely relevant to see that there's discussion of how to handle such things. In the .NET world you can work with XML fragments and, for example, validate them against a schema. This suggests that it is worth searching for similar support in the Java libraries. If you want to transform such fragments with XSLT, a very common approach is to put a wrapper element around them, which can then act as the root of the DOM.
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/632567
type: Answer

http://stackoverflow.com/a/399074
has comment: http://stackoverflow.com/comment/225040
has comment: http://stackoverflow.com/comment/9956839
downvote count: 10
answers question: http://stackoverflow.com/q/398953
has comment: http://stackoverflow.com/comment/41967347
has comment: http://stackoverflow.com/comment/238567
has comment: http://stackoverflow.com/comment/9967599
has comment: http://stackoverflow.com/comment/226269
has comment: http://stackoverflow.com/comment/9950023
has body: No no no, with all due respect to Josh Bloch, never throw an AssertionError unless it's from an assertion. If you want an AssertionError here, throw it with assert(false). Then someone reading the code can find it later. Even better, define your own exception, say CantInstantiateUtilityClass. then you'll have code that says try { // some stuff } catch (CantInstantiateUtilityClass e) { // react } so that the reader of the catcher knows what happened. Let me just note that the standard still defines AssertionError as the result of a failed assertion, not as what some beginner thinks ought to be thrown in place of a well-defined informative exception. Sadly, good exception discipline is perhaps the least encouraged skill in Java programming.
type: Answer
has comment: http://stackoverflow.com/comment/226366
has comment: http://stackoverflow.com/comment/224925
has comment: http://stackoverflow.com/comment/9964746
has comment: http://stackoverflow.com/comment/224951
score: 2
has comment: http://stackoverflow.com/comment/235217
has comment: http://stackoverflow.com/comment/226370
has comment: http://stackoverflow.com/comment/226330
has comment: http://stackoverflow.com/comment/224924
has comment: http://stackoverflow.com/comment/9956813
has comment: http://stackoverflow.com/comment/9950045
upvote count: 12
has comment: http://stackoverflow.com/comment/226336
has comment: http://stackoverflow.com/comment/41999032

http://stackoverflow.com/q/589919
has title: Does Java pass by reference?
linked to: http://stackoverflow.com/q/498747
favorite count: 0
duplicate of: http://stackoverflow.com/q/40480
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/402733
has body: Does Java really support passing by reference? If it doesn't, why do we have the == operator for finding two objects with the same reference?
answer count: 4
has answer: http://stackoverflow.com/a/589932
downvote count: 2
has answer: http://stackoverflow.com/a/594480
has answer: http://stackoverflow.com/a/594699
tagged with: pass-by-reference
type: Question
upvote count: 12
has answer: http://stackoverflow.com/a/589938
tagged with: java
score: 10

http://stackoverflow.com/comment/11285903
type: QuestionComment
comment on: http://stackoverflow.com/q/640022
has text: Embed Jetty instead. However, there is [tomcat-embed](http://code.google.com/p/tomcat-embed/).
score: 0
type: Comment

http://stackoverflow.com/q/474535
has answer: http://stackoverflow.com/a/476543
has answer: http://stackoverflow.com/a/474615
tagged with: math
has answer: http://stackoverflow.com/a/29185540
tagged with: java
has answer: http://stackoverflow.com/a/508824
has answer: http://stackoverflow.com/a/474768
has answer: http://stackoverflow.com/a/34654461
type: Question
possible better answer: http://stackoverflow.com/a/474577
linked to: http://stackoverflow.com/q/3881
has comment: http://stackoverflow.com/comment/27348980
has comment: http://stackoverflow.com/comment/292497
has answer: http://stackoverflow.com/a/474576
has answer: http://stackoverflow.com/a/474577
has body: I'm trying to work with fractions in Java. I want to implement arithmetic functions. For this, I will first require a way to normalize the functions. I know I can't add 1/6 and 1/2 until I have a common denominator. I will have to add 1/6 and 3/6. A naive approach would have me add 2/12 and 6/12 and then reduce. How can I achieve a common denominator with the least performance penalty? What algorithm is best for this? Version 8 (thanks to hstoerr): Improvements include: the equals() method is now consistent with the compareTo() method final class Fraction extends Number { private int numerator; private int denominator; public Fraction(int numerator, int denominator) { if(denominator == 0) { throw new IllegalArgumentException("denominator is zero"); } if(denominator &lt; 0) { numerator *= -1; denominator *= -1; } this.numerator = numerator; this.denominator = denominator; } public Fraction(int numerator) { this.numerator = numerator; this.denominator = 1; } public int getNumerator() { return this.numerator; } public int getDenominator() { return this.denominator; } public byte byteValue() { return (byte) this.doubleValue(); } public double doubleValue() { return ((double) numerator)/((double) denominator); } public float floatValue() { return (float) this.doubleValue(); } public int intValue() { return (int) this.doubleValue(); } public long longValue() { return (long) this.doubleValue(); } public short shortValue() { return (short) this.doubleValue(); } public boolean equals(Fraction frac) { return this.compareTo(frac) == 0; } public int compareTo(Fraction frac) { long t = this.getNumerator() * frac.getDenominator(); long f = frac.getNumerator() * this.getDenominator(); int result = 0; if(t&gt;f) { result = 1; } else if(f&gt;t) { result = -1; } return result; } } I have removed all previous versions. My thanks to: Dave Ray cletus duffymo James Milhous Oscar Reyes Jason S Francisco Canedo Outlaw Programmer Beska
has answer: http://stackoverflow.com/a/474940
score: 104
has answer: http://stackoverflow.com/a/13107973
has comment: http://stackoverflow.com/comment/32381646
has answer: http://stackoverflow.com/a/474556
has title: Best way to represent a fraction in Java?
has answer: http://stackoverflow.com/a/21981754
favorite count: 0
has answer: http://stackoverflow.com/a/54539955
has comment: http://stackoverflow.com/comment/312315
has answer: http://stackoverflow.com/a/474760
has answer: http://stackoverflow.com/a/474598
has answer: http://stackoverflow.com/a/474580
has answer: http://stackoverflow.com/a/474567
has comment: http://stackoverflow.com/comment/32381888
has comment: http://stackoverflow.com/comment/292471
answer count: 26
has answer: http://stackoverflow.com/a/474552
has comment: http://stackoverflow.com/comment/301340
has comment: http://stackoverflow.com/comment/333765
has answer: http://stackoverflow.com/a/474612
has answer: http://stackoverflow.com/a/474551
tagged with: fractions
accepted answer: http://stackoverflow.com/a/474612
downvote count: 0
has answer: http://stackoverflow.com/a/611798
has answer: http://stackoverflow.com/a/474834
upvote count: 104
has answer: http://stackoverflow.com/a/475456
has comment: http://stackoverflow.com/comment/333826
has answer: http://stackoverflow.com/a/474560
has answer: http://stackoverflow.com/a/474579
has answer: http://stackoverflow.com/a/16241893
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/312320

http://stackoverflow.com/comment/77146125
type: Comment
score: 2
has text: ``getStackTrace()[2]`` is wrong, it has to be ``getStackTrace()[3]`` because: [0] dalvik.system.VMStack.getThreadStackTrace [1] java.lang.Thread.getStackTrace [2] Utils.getCurrentClassAndMethodNames [3] The function a() calling this one
comment on: http://stackoverflow.com/a/33473330
type: AnswerComment

serialization
tags question: http://stackoverflow.com/q/475655
tags question: http://stackoverflow.com/q/567516
tags question: http://stackoverflow.com/q/581246
tags question: http://stackoverflow.com/q/602079
tags question: http://stackoverflow.com/q/522202
tags question: http://stackoverflow.com/q/528664
tags question: http://stackoverflow.com/q/462077
tags question: http://stackoverflow.com/q/589732
tags question: http://stackoverflow.com/q/364535
tags question: http://stackoverflow.com/q/447898
tags question: http://stackoverflow.com/q/515631
tags question: http://stackoverflow.com/q/507738
tags question: http://stackoverflow.com/q/375605
tags question: http://stackoverflow.com/q/441272
tags question: http://stackoverflow.com/q/444909
tag name: serialization
tags question: http://stackoverflow.com/q/627389
tags question: http://stackoverflow.com/q/438875
tags question: http://stackoverflow.com/q/361570
tags question: http://stackoverflow.com/q/396569
tags question: http://stackoverflow.com/q/419796
type: Tag
tags question: http://stackoverflow.com/q/368442
tags question: http://stackoverflow.com/q/561286
tags question: http://stackoverflow.com/q/441196
tags question: http://stackoverflow.com/q/441151
tags question: http://stackoverflow.com/q/364178
tags question: http://stackoverflow.com/q/605828
tags question: http://stackoverflow.com/q/440087
tags question: http://stackoverflow.com/q/647779
tags question: http://stackoverflow.com/q/456367
tags question: http://stackoverflow.com/q/414020

http://stackoverflow.com/a/518390
type: Answer
score: -1
has body: Geneva looks like a Meta-Directory. Normally you don't access a Meta-Directory directly but instead access a directory it manages. You can do this with an LDAP library.
downvote count: 1
upvote count: 0
answers question: http://stackoverflow.com/q/518349

http://stackoverflow.com/a/32778102
answers question: http://stackoverflow.com/q/547169
has body: Sairam is right here, By calling System.exit(0) we can terminate eclipse JVM and can see Shutdown hook results
score: 0
type: Answer

http://stackoverflow.com/q/580686
favorite count: 0
has answer: http://stackoverflow.com/a/580738
has answer: http://stackoverflow.com/a/580784
has title: Validation Framework in Java
score: 4
type: UnansweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/1112991
has answer: http://stackoverflow.com/a/6100937
tagged with: frameworks
has body: We are currently in the process of refactoring our plugin API**(JDK 1.4 compliant)** which is shipped to our clients in the form of a jar file(ie, no need to have javascripts to be generated and so forth). This is a very lightweight plugin so that we have kept away as many dependent jars as possible like Spring. During this process we started to understand the need to have a proper validation methodology which is faciliated by some validation Framework. Strangly, I couldnt find much options in these lines (like other open source projects)apart from a few such as Commons Validator,Drools and Spring support. Drools seems to be so complex for my needs. However Commons validator looks prehistoric in its style of validation. I cannot use annotation based validation cause it has to be JDK 1.4 and would prefer something that could be externalized thereby not requiring to compile classes again in case of changes. Are there better options available?
answer count: 6
type: Question
upvote count: 4
has answer: http://stackoverflow.com/a/599349
tagged with: validation
downvote count: 0
has answer: http://stackoverflow.com/a/584279

http://stackoverflow.com/a/519845
has body: Just a wild guess (as I haven't used RMI since a while), since Java 1.5 RMI Stub classes are no longer needed. They're automatically generated. This might be the reason netbeans removes them. You can try remove the rmic ant tasks references from you're build.xml.
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/515391
score: 1
downvote count: 0

http://stackoverflow.com/comment/298629
comment on: http://stackoverflow.com/a/481850
has text: It seems the jasper2 task supports the "fork" element, can you set that to true and try using a jvmarg?
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/465025
downvote count: 0
has body: If you want to take a screenshot of a specific window of another non-Java application code, I think you'll have to write some native (i.e. non-Java) code. Interaction between Java apps and non-Java apps at such a level is difficult.
type: Answer
answers question: http://stackoverflow.com/q/464593
upvote count: 1
score: 1

http://stackoverflow.com/comment/401602
comment on: http://stackoverflow.com/a/586252
score: 0
type: AnswerComment
has text: Thanks for your reply - it looks nice, but I don't I'll use it. It adds an extra layer to log4j (MyLogger implementation and its factory), which is difficult to enforce developers to use, without adding much benefits. We might use your Error definition and define an ObjectRenderer for it,
type: Comment

http://stackoverflow.com/comment/196063
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/359306
has text: have a look at http://wiki.metawerx.net/wiki/Web.xml.ServletMapping, it should give you an idea of what I meant =8-)
score: 0

http://stackoverflow.com/q/397667
has comment: http://stackoverflow.com/comment/223850
has answer: http://stackoverflow.com/a/397672
downvote count: 0
has answer: http://stackoverflow.com/a/397874
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/398426
has answer: http://stackoverflow.com/a/397673
has comment: http://stackoverflow.com/comment/223976
score: 2
answer count: 8
has comment: http://stackoverflow.com/comment/223873
has body: This is my first question in this forum... I have a file with numerous data fields (both numeric and characters) in the file. I want to delimit the file with set of delimiter length like 2,5,1,9,6 etc. (Alternatively: I have a list of field lengths such as 2,5,1,9,6, and I want to insert comma delimiters in (a copy of) the source string after each field.) For example, if my file is like this: 9483trdcvge245621jde then I need to insert commas at 2,5,1,9,6 etc. and the output will be: 94,83trd,c,vge245621,jde, I need to do this in JAVA Please help me to solve this issue. Thanks in advance
tagged with: java
has answer: http://stackoverflow.com/a/397671
type: Question
upvote count: 2
has answer: http://stackoverflow.com/a/397722
has answer: http://stackoverflow.com/a/397842
has comment: http://stackoverflow.com/comment/223847
favorite count: 0
has title: To add commas in file
has answer: http://stackoverflow.com/a/397686

http://stackoverflow.com/a/557833
upvote count: 3
answers question: http://stackoverflow.com/q/557746
has body: Honestly, unless the program actually needs data from the server to function (as fred-o stated that World of Warcraft needs; and is true), then there is nothing you can do client side that will be completely fool proof. All 3 ideas you had could be circumvented easily. The server/login one might be a bit harder, but I've even seen cracks go so far as to locally create a dummy login server so the program thinks it's being authenticated. The only true way to prevent piracy is to have some server-side logic that the program NEEDS to run. For example - you're making software that resizes images (i know, i know). If the raw image was shipped off to your server and resized there and then sent back to the client (as opposed to the client doing the resizing), then you would be safe because your server can easily be protected with a login system of some sort. And without a valid username or password (or if they tried to generate a fake one), the program would be useless. If you implement client side functionality, it can be reached, no matter what you do.
score: 3
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/374335

http://stackoverflow.com/a/539389
has body: I have been using JRebel and it's a life saver as far as modifying code and dynamically updating the app server. Paid for itself the first day. (we have a 7 minute compile/deploy/restart cycle)
type: Answer
upvote count: 2
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/538261

http://stackoverflow.com/a/13059084
has body: This is probably what you're looking for in terms of thread safety &amp; "prettyness" when trying to consume everything in the queue: for (YourObject obj = queue.poll(); obj != null; obj = queue.poll()) { } This will guarantee that you quit when the queue is empty, and that you continue to pop objects off of it as long as it's not empty.
downvote count: 0
upvote count: 8
answers question: http://stackoverflow.com/q/616484
type: Answer
score: 8

http://stackoverflow.com/a/436181
score: 0
type: Answer
answers question: http://stackoverflow.com/q/423924
has body: Interceptor can be made BeanFactoryAware and SessionFactory can be obtained using the bean factory from which current session can be obtained. Since it seemed like a bad design because of the circular dependency and making the Interceptor aware of Spring container, i used ThreadLocal as suggested by Nicholas

http://stackoverflow.com/comment/52511168
type: Comment
has text: I had to add the joinColumn parameter to make it work `@CollectionTable(name="person_interest", joinColumns = {@JoinColumn(name="person_id")})`
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/9458969

http://stackoverflow.com/comment/93885083
comment on: http://stackoverflow.com/a/31114423
score: 0
type: AnswerComment
has text: FYI, the terribly troublesome old date-time classes such as [`java.util.Date`](https://docs.oracle.com/javase/10/docs/api/java/util/Date.html), [`java.util.Calendar`](https://docs.oracle.com/javase/10/docs/api/java/util/Calendar.html), and `java.text.SimpleDateFormat` are now [legacy](https://en.wikipedia.org/wiki/Legacy_system), supplanted by the [*java.time*](https://docs.oracle.com/javase/10/docs/api/java/time/package-summary.html) classes built into Java 8 and later. See [*Tutorial* by Oracle](https://docs.oracle.com/javase/tutorial/datetime/TOC.html).
type: Comment

http://stackoverflow.com/a/34026037
has comment: http://stackoverflow.com/comment/56435347
has comment: http://stackoverflow.com/comment/65926241
downvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/67170256
has body: I prefer use wait and notify. It is simple and clear. @Test public void test() throws Throwable { final boolean[] asyncExecuted = {false}; final Throwable[] asyncThrowable= {null}; // do anything async new Thread(new Runnable() { @Override public void run() { try { // Put your test here. fail(); } // lets inform the test thread that there is an error. catch (Throwable throwable){ asyncThrowable[0] = throwable; } // ensure to release asyncExecuted in case of error. finally { synchronized (asyncExecuted){ asyncExecuted[0] = true; asyncExecuted.notify(); } } } }).start(); // Waiting for the test is complete synchronized (asyncExecuted){ while(!asyncExecuted[0]){ asyncExecuted.wait(); } } // get any async error, including exceptions and assertationErrors if(asyncThrowable[0] != null){ throw asyncThrowable[0]; } } Basically, we need to create a final Array reference, to be used inside of anonymous inner class. I would rather create a boolean[], because I can put a value to control if we need to wait(). When everything is done, we just release the asyncExecuted.
score: 1
upvote count: 2
answers question: http://stackoverflow.com/q/631598

http://stackoverflow.com/comment/3837475
comment on: http://stackoverflow.com/a/586889
has text: How the layout is created depends on what type/kind of graph you want to build. My graphs where very structured and could be calculated using a grid with x,y coordinates. I created methods for addNode and connectNodes which did some calculation.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/619937
answers question: http://stackoverflow.com/q/618276
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/434494
has body: To make this simpler, I created an annotation for default values and an annotation processor that generates a superclass with the overloaded methods. For example: protected void process( Processor processor, String item, @Default("Processor.Size.LARGE") Size size, @Default("red") String color, @Default("1") int quantity) { ... } which generates (in a generated superclass) protected void process(sample.Processor processor, java.lang.String item) { process(processor, item, Processor.Size.LARGE, "red", 1); } protected void process(sample.Processor processor, java.lang.String item, sample.Processor.Size size) { process(processor, item, size, "red", 1); } protected void process(sample.Processor processor, java.lang.String item, sample.Processor.Size size, java.lang.String color) { process(processor, item, size, color, 1); } protected abstract void process(sample.Processor processor, java.lang.String item, sample.Processor.Size size, java.lang.String color, int quantity) ; See http://code.google.com/p/javadude/wiki/Annotations -- Scott
downvote count: 0
type: Answer

http://stackoverflow.com/a/13471200
has body: There has been very little discussion about switching environments. Most projects I've worked on it was a real issue to inject dependencies depending on the environment we are working on. With xml config it's pretty straightforward with Spring EL, and I am not aware of any nice solution with annotations. I've just figured out one: @Value("#{${env} == "production" ? realService : dummyService}") private SomeService service; It should be working, but not a nice solution imho.
has comment: http://stackoverflow.com/comment/18465783
score: 6
type: Answer
upvote count: 6
answers question: http://stackoverflow.com/q/633158
downvote count: 0

http://stackoverflow.com/a/555380
type: Answer
score: 1
upvote count: 1
has body: My interpretation of the Java3D post is that they are adding a new scene graph, not replacing their current one, in order to more effectively mesh with JavaFX, which is targeted at webapps. I've used Java3D in the past and liked it, so I would recommend trying to contact the devs and ask what their plans are with respect to whatever app you're building.
answers question: http://stackoverflow.com/q/555347
downvote count: 0
has comment: http://stackoverflow.com/comment/10768843
has comment: http://stackoverflow.com/comment/10690617

http://stackoverflow.com/comment/87451627
comment on: http://stackoverflow.com/q/362424
type: Comment
type: QuestionComment
has text: In case parent has constructor: https://stackoverflow.com/questions/20807148/how-to-call-a-specific-parent-constructor-from-anonymous-inner-class
score: 1

http://stackoverflow.com/a/598748
score: 1
answers question: http://stackoverflow.com/q/598344
has body: You could also try looking into using JMF which is a bit hairy but works a bit better that javax.sound.sampled stuff. There's quite a few tutorials on the JMF page which describe how to record from line in or mic channels.
downvote count: 0
type: Answer
upvote count: 1

http://stackoverflow.com/comment/39727008
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/405402
has text: Why do you say that the system class loader never unloads any classes? It seems that only the **bootstrap** class loader do not unload classes http://stackoverflow.com/a/453073/632951
type: Comment

http://stackoverflow.com/comment/290717
type: AnswerComment
has text: Huh, I didn't even have an idea that the concurrency issues I was concerned about go down that deep towards the hardware. Thanks.
type: Comment
score: 0
comment on: http://stackoverflow.com/a/473118

http://stackoverflow.com/comment/302592
type: Comment
type: QuestionComment
has text: More info is needed. What is your environment, is it an standalone application a framework, a JavaEE container? Do you use a connection pool?
comment on: http://stackoverflow.com/q/485984
score: 0

http://stackoverflow.com/a/462128
has body: Ah yes, you need to get the FileSystemView object and use getSystemDisplayName. (I once implemented a Filesystem browser in Java). It's not perfect though but it will get you the name. From the documentation: Name of a file, directory, or folder as it would be displayed in a system file browser. Example from Windows: the "M:\" directory displays as "CD-ROM (M:)" The default implementation gets information from the ShellFolder class.
accepted answer of: http://stackoverflow.com/q/462110
answers question: http://stackoverflow.com/q/462110
type: Answer
has comment: http://stackoverflow.com/comment/61248703
score: 12
upvote count: 12
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/450728
score: 0
type: Comment
type: QuestionComment
has text: @Steve: Correct, but I assume (unless otherwise described) that the equals() is composition of the some (if not all) of the fields in class. It's naive, but most of the time true.
comment on: http://stackoverflow.com/q/636360

http://stackoverflow.com/comment/207518
comment on: http://stackoverflow.com/q/376903
type: Comment
has text: I want to use it as a distributed lock. I could use a database to indicate that a transaction is in progress (but I believe that's an anti-pattern). Usecase: War1 starts a tx, stores it in cache. This prevents same tx from starting. War2 invalidates tx based on external event.
type: QuestionComment
score: 0

http://stackoverflow.com/comment/115576477
score: 6
type: AnswerComment
comment on: http://stackoverflow.com/a/2022161
has text: it would be great if someone somewhere could detail the changes this executable makes so that someone could choose to repeat it manually without exetuting some random strangers compiled code.
type: Comment

http://stackoverflow.com/q/411517
has answer: http://stackoverflow.com/a/411599
tagged with: java
has answer: http://stackoverflow.com/a/411526
has answer: http://stackoverflow.com/a/411618
has answer: http://stackoverflow.com/a/411523
possible better answer: http://stackoverflow.com/a/411599
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/411523
answer count: 4
type: AnsweredQuestion
score: 2
has body: I'm working on a java SE 1.5+ swing application, in conjunction with others. I'm wondering what the best way of managing string resources is. I understand the principles behind resource bundles etc. I'd like to avoid having one property file for every class that needs a string, as this seems a bit of overkill. Especially when you have a lot of classes that may only make a single reference to a string (say in an error handler). On the other hand it makes it easier when collaborating with others as you reduce the risk of merge conflicts. It seems particularly cumbersome to have to load resource bundles, every time you need to display simple user feedback, likewise in error handlers, when many classes are involved. What is the most effective way to manage strings in a fairly large application with hundreds of classes, many of which aren't GUI related, but need to pass informative messages back up to the GUI when exceptions occur. I'm using NetBeans which generally creates a property file for each GUI class, for all text relating to buttons, labels etc.
upvote count: 2
has title: Management of Java string resources
type: Question

http://stackoverflow.com/a/613648
has body: I like Eddie's answer, but I would temper it with this observation - it depends on the skill set you ave in house. If you;'ve got a bunch of Java pros, then it makes sense to use Java. If you have a bunch of C-programmers, then the chouice is obvious. One other comment though : are you sure TAM doesn't do .NET?
type: Answer
answers question: http://stackoverflow.com/q/613063
score: 0

http://stackoverflow.com/comment/424386
type: Comment
type: AnswerComment
has text: maybe it's the device. The device is using a COM/Serial port wrapped with a USB interface. It's a strange interface.
comment on: http://stackoverflow.com/a/611777
score: 0

http://stackoverflow.com/q/570229
has title: Hibernate HQL Query : How to set a Collection as a named parameter of a Query?
has answer: http://stackoverflow.com/a/7961862
score: 69
answer count: 3
upvote count: 69
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/570287
type: AnsweredQuestion
tagged with: java
tagged with: hibernate
has answer: http://stackoverflow.com/a/570263
tagged with: hql
type: Question
possible better answer: http://stackoverflow.com/a/570263
accepted answer: http://stackoverflow.com/a/570287
has body: Given the following HQL Query: FROM Foo WHERE Id = :id AND Bar IN (:barList) I set :id using the Query object's setInteger() method. I would like to set :barList using a List of objects, but looking at the Hibernate documentation and list of methods I cannot see an obvious choice of which to use. Any ideas?

http://stackoverflow.com/a/5731227
upvote count: 6
answers question: http://stackoverflow.com/q/464098
has body: Also if a deadlock/livelock happens inside try block. Here's the code that demonstrates it: public class DeadLocker { private static class SampleRunnable implements Runnable { private String threadId; private Object lock1; private Object lock2; public SampleRunnable(String threadId, Object lock1, Object lock2) { super(); this.threadId = threadId; this.lock1 = lock1; this.lock2 = lock2; } @Override public void run() { try { synchronized (lock1) { System.out.println(threadId + " inside lock1"); Thread.sleep(1000); synchronized (lock2) { System.out.println(threadId + " inside lock2"); } } } catch (Exception e) { } finally { System.out.println("finally"); } } } public static void main(String[] args) throws Exception { Object ob1 = new Object(); Object ob2 = new Object(); Thread t1 = new Thread(new SampleRunnable("t1", ob1, ob2)); Thread t2 = new Thread(new SampleRunnable("t2", ob2, ob1)); t1.start(); t2.start(); } } This code produces the following output: t1 inside lock1 t2 inside lock1 and "finally" never gets printed
has comment: http://stackoverflow.com/comment/18792637
downvote count: 0
score: 6
type: Answer

http://stackoverflow.com/comment/52483334
type: AnswerComment
comment on: http://stackoverflow.com/a/643754
type: Comment
score: 2
has text: This seems to be incorrect as the QT Jambi website shows a release version 4.8.6 in 2015.

http://stackoverflow.com/comment/86132980
type: AnswerComment
type: Comment
has text: If you're not gonna have autoboxing at least you should allow for creating Lists with primitive types, this just makes turning a char[] into a List<Character> way more difficult than it should.
comment on: http://stackoverflow.com/a/517769
score: 0

http://stackoverflow.com/a/573186
downvote count: 0
accepted answer of: http://stackoverflow.com/q/557663
answers question: http://stackoverflow.com/q/557663
score: 20
type: AcceptedAnswer
type: Answer
has body: This problem is not easy to fully solve in general. For example, you also have to take type parameters of the containing class into account if it's an inner class,... Because reflection over generic types is so hard using just what Java itself provides, I wrote a library that does the hard work: gentyref. See http://code.google.com/p/gentyref/ For your example, using gentyref, you can do: Type myType = MyClass.class; // get the parameterized type, recursively resolving type parameters Type baseType = GenericTypeReflector.getExactSuperType(myType, BaseInterface.class); if (baseType instanceof Class&lt;?&gt;) { // raw class, type parameters not known // ... } else { ParameterizedType pBaseType = (ParameterizedType)baseType; assert pBaseType.getRawType() == BaseInterface.class; // always true Type typeParameterForBaseInterface = pBaseType.getActualTypeArguments()[0]; System.out.println(typeParameterForBaseInterface); }
upvote count: 20

http://stackoverflow.com/a/560765
score: 1
answers question: http://stackoverflow.com/q/560679
downvote count: 0
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/372231
has body: For my (Perl-driven) website, I am using MySQL on two servers with database replication. Each MySQL server is slave and master at the same time. I did this for redudancy, not for performance, but the setup has worked fine for the past 3 years, we had almost no downtime at all during this period. Regarding Kent's question / comment: I am using the standard replication that comes with MySQL. Regarding the failover mechanism: I am using DNSMadeEasy.com's failover functionality. I have a Perl script run every 5 minutes via cron that checks if replication is still running (and also lots of other things such as server load, HDD sanity, RAM usage, etc.). During normal operation, the faster of the two servers delivers all web pages. If the script detects that something is wrong with the server (or if the server is just plain down), DNSMadeEasy switches DNS entries so that the secondary server becomes primary. Once the "real" primary server is back up, MySQL automatically catches up on missing database changes and DNSMadeEasy automatically switches back.

http://stackoverflow.com/comment/361169
type: AnswerComment
comment on: http://stackoverflow.com/a/549353
has text: +1. Tests should be "repeatable"... use a diverse set of values testing boundary conditions as well.. a RowTest should fit your need.
score: 0
type: Comment

http://stackoverflow.com/comment/62374931
type: AnswerComment
comment on: http://stackoverflow.com/a/531598
type: Comment
has text: Hi, I have used it this configuration and it worked. but the problem is its append port with URL like https://www. mydomain.com:8443 do you have idea how to remove this with achieving https..?
score: 0

http://stackoverflow.com/q/427755
has comment: http://stackoverflow.com/comment/5019771
tagged with: junit
downvote count: 0
favorite count: 0
has body: Before asking question, let me explain the current setup: I have an service interface, say Service, and one implementation, say ServiceImpl. This ServiceImpl uses some other services. All the services are loaded as bean by spring. Now, I want to write junit test cases for the ServiceImpl. For the same, I use the applicationContext to get the Service bean and then call different methods on it to test them. All looks fine for the public methods but how do I write test cases for private methods? Because we might not have the same private methods for different implementations? Can anyone help me here on what should be preferred way of writing test cases?
answer count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/427809
has answer: http://stackoverflow.com/a/60210608
score: 2
upvote count: 2
tagged with: java
tagged with: unit-testing
type: Question
has answer: http://stackoverflow.com/a/427929
has title: How should you write junit test cases for multiple implementation of the same interface?
has answer: http://stackoverflow.com/a/427937
has answer: http://stackoverflow.com/a/427811

http://stackoverflow.com/a/423720
score: 1
has body: I guess it depends among other things on what you are using for accessing the database. With plain old JDBC you could do with ints, while an ORM could silently convert them to Integers anyway. And Integer would allow you to handle nulls.
upvote count: 1
answers question: http://stackoverflow.com/q/423704
type: Answer
downvote count: 0

http://stackoverflow.com/comment/270549
has text: I do it that way, too *thumbs up*
score: 0
type: Comment
comment on: http://stackoverflow.com/a/448347
type: AnswerComment

http://stackoverflow.com/a/57973354
type: Answer
downvote count: 0
score: 1
has body: Found this answer, and I was able to achieve that: I was able to resolve this issue by setting the 'evaluation time' property to 'group' on the text field that contained my $V{PAGE_NUMBER} variable.
answers question: http://stackoverflow.com/q/435385
upvote count: 1
has comment: http://stackoverflow.com/comment/133022007

http://stackoverflow.com/comment/6338505
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/472360
has text: I'm getting the same behavior. My input XML is all one line, no whitespace, and my output XML has every element in a new line, but without indents. _Edit:_ Just saw this somewhere else, and it worked: `Transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");` Of course, you can change the "2" to whatever indent amount you want. =)

http://stackoverflow.com/comment/10963502
score: 0
type: AnswerComment
type: Comment
has text: Have to override the canvas's (JPanel) getPreferredSize to return the desired size. @Override public Dimension getPreferredSize() { return dimension; }
comment on: http://stackoverflow.com/a/8789601

http://stackoverflow.com/q/586409
possible better answer: http://stackoverflow.com/a/586808
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/586808
tagged with: large-files
has answer: http://stackoverflow.com/a/586515
accepted answer: http://stackoverflow.com/a/586515
type: AnsweredQuestion
has body: I need to perform a simple grep and other manipulations on large files in Java. I am not that familiar with the Java NIO utilities, but I am assuming that is what I need to use. What resources or helpful tips do you have for reading/writing large files. Also, I am working on a SWT application and need to display parts of that data within a text area on a GUI.
tagged with: java
has comment: http://stackoverflow.com/comment/398204
tagged with: nio
type: Question
has title: What are some tips for processing large files in Java
has answer: http://stackoverflow.com/a/586762

http://stackoverflow.com/a/567593
type: Answer
downvote count: 2
score: 13
has comment: http://stackoverflow.com/comment/378930
has comment: http://stackoverflow.com/comment/5493853
has body: Exceptions are not free... so they are expensive :-) The book Effective Java covers this in good detail. Item 39 Use exceptions only for exceptional conditions. Item 40 Use exceptions for recoverable conditions The author found that exceptions resulted in the code tunning 70 times slower for his test case on his machine with his particular VM and OS combo.
upvote count: 15
has comment: http://stackoverflow.com/comment/115841360
answers question: http://stackoverflow.com/q/567579
has comment: http://stackoverflow.com/comment/378897
has comment: http://stackoverflow.com/comment/115828317

http://stackoverflow.com/q/472522
has title: JasperReport - taking too much resources
has answer: http://stackoverflow.com/a/473002
accepted answer: http://stackoverflow.com/a/473002
type: AnsweredQuestion
downvote count: 0
score: 1
possible better answer: http://stackoverflow.com/a/472532
type: Question
tagged with: jasper-reports
tagged with: java
has body: so, problem is when we are showing to user created document in JasperReport Dialog. User can press print icon and sent it to printer. It seems to take too much resources on client's computer on all three levels: creating report, showing report on screen and sending it to printer. One example PC is AMD Duron 800MHz with 256MB of RAM so we need to see if we can do some optimizations for better user experience. It also takes significant resources on 'normal' computer with 2GHz processor and 1GB RAM so I need to see if there is an option to tune JasperReport to behave less gready on resources.
answer count: 2
upvote count: 1
has answer: http://stackoverflow.com/a/472532
favorite count: 0

http://stackoverflow.com/comment/361620
type: Comment
has text: nice answer but the pidgeons guarantees the plus 1 :)
comment on: http://stackoverflow.com/a/540514
score: 0
type: AnswerComment

http://stackoverflow.com/q/578431
has title: Accessing the content of a JAX-WS Dispatch Response
type: UnansweredQuestion
tagged with: web-services
score: 2
has answer: http://stackoverflow.com/a/593203
downvote count: 0
tagged with: java
has body: I'm trying to access a web service with JAX-WS using: Dispatch&lt;Source&gt; sourceDispatch = null; sourceDispatch = service.createDispatch(portQName, Source.class, Service.Mode.PAYLOAD); Source result = sourceDispatch.invoke(new StreamSource(new StringReader(req))); System.out.println(sourceToXMLString(result)); where: private static String sourceToXMLString(Source result) { String xmlResult = null; try { TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //transformer.setOutputProperty(OutputKeys.ENCODING, "utf-8"); OutputStream out = new ByteArrayOutputStream(); StreamResult streamResult = new StreamResult(); streamResult.setOutputStream(out); transformer.transform(result, streamResult); xmlResult = streamResult.getOutputStream().toString(); } catch (TransformerException e) { e.printStackTrace(); } return xmlResult; } What is the proper way to access the contents of the response, eg. get the content of a specific element in the response? All the available examples just print the full XML response :(
tagged with: jax-ws
type: Question
upvote count: 2
answer count: 1
favorite count: 0

http://stackoverflow.com/comment/66089939
type: AnswerComment
type: Comment
score: 1
has text: That's what my YUV-based solution does but for a 3D box (not cube).
comment on: http://stackoverflow.com/a/470974

http://stackoverflow.com/a/509330
answers question: http://stackoverflow.com/q/509318
type: Answer
score: 3
downvote count: 0
has body: Try this: java HelloWorldSwing Rather than: java start/HelloWorldSwing The argument to the java compiler ( javac ) is a file ( that's why start/HelloWorldSwing.java probably worked ) but the argument to the Java interpreter ( java ) is a class name. That's why you don't append the .class in the command line, and since there is no class named start/HelloWorldSwing You get that error message ( NoClassDefFoundError ), that reads "There is not class definition found with that name ). To keep thing easier, compile and run your first programs from the same directory where your .java files are.
upvote count: 3
has comment: http://stackoverflow.com/comment/323627

http://stackoverflow.com/a/433981
accepted answer of: http://stackoverflow.com/q/433973
has body: Obviously the database calls are causing delays. Isn't it an option to create smaller batches and test if that helps?? Maybe you could parallelize the algorithm as well to have a queue somewhere taking results and another thread cleaning out that queue? edit: There are also some other problem areas: Database optimalization (model) Database server configuration Disk speed All these factors should be taken into account
type: Answer
downvote count: 0
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/433973
type: AcceptedAnswer

http://stackoverflow.com/comment/1232810
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/629833
type: Comment
has text: @Andreas: Thanks for coming back and saying so - I'm glad to hear that GJC is helping :)

http://stackoverflow.com/a/440283
answers question: http://stackoverflow.com/q/440160
score: 0
has body: If you use Google Analytics, this post might be helpful (see the forum thread for more details).
type: Answer

http://stackoverflow.com/a/7521439
score: 1
upvote count: 1
downvote count: 0
type: Answer
has body: Current project home: http://jogamp.org/jogl/www/
answers question: http://stackoverflow.com/q/615899

http://stackoverflow.com/a/518554
has comment: http://stackoverflow.com/comment/137397032
answers question: http://stackoverflow.com/q/517704
score: 2
downvote count: 0
type: Answer
has body: I think you're making things way harder than they need to be. JTree has several "add_foo_Listener" methods on it. Implement one of those (TreeSelectionListener looks about right), and then you've got the currently selected node. Implement a MouseListener so that you can detect the right-click event (and add it to the JTree, since JTree's a Component), and then you should have everything you need to post a context-sensitive menu. Check out this tutorial for more details.
upvote count: 2

http://stackoverflow.com/a/4982006
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/453388
score: 2
has body: With the date4j library: int numDaysBetween = oneDate.numDaysFrom(anotherDate);
upvote count: 2

http://stackoverflow.com/comment/17087875
type: Comment
comment on: http://stackoverflow.com/a/382381
type: AnswerComment
has text: -1 for that's an unprofessional answer. Yes, it's easy to run away from problems and legacy code, but at StackOverflow I'd expect to find actual tips and solutions instead of silly answers like "pretend you've never seen it". But I appreciate sense of humor. Really.
score: 0

http://stackoverflow.com/comment/326462
type: AnswerComment
has text: I'm no guru, but c# inner classes can always exist independent of an instance of the outer class. I'm not aware of a construct in c# that only allows an inner class to exist via its outer class, except perhaps making it private so that only the outer class can use it.
comment on: http://stackoverflow.com/a/512704
type: Comment
score: 2

http://stackoverflow.com/comment/297831
score: 0
type: Comment
has text: Is that true? As the instance on the end of the reference is immutable, I'm not sure how you could actually change it... is it just crossed wires over whether it's an array instance or not?
type: AnswerComment
comment on: http://stackoverflow.com/a/478433

http://stackoverflow.com/comment/438434
score: 1
type: AnswerComment
has text: the assests dir needs to be where the .class file is
comment on: http://stackoverflow.com/a/625742
type: Comment

http://stackoverflow.com/comment/6913908
has text: @Robert Zaremba Have you ever tried to implement garbage collection with LLVM? I have. You basically must do it all yourself (they don't even provide a simple garbage collector, though there is an outdated example floating around). LLVM just provides intrinsics for your code to hook into the GC. As opposed to the JVM, which provides a built-in mandatory garbage collector which automatically works on all objects.
score: 17
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/454787

http://stackoverflow.com/a/516604
answers question: http://stackoverflow.com/q/516593
upvote count: 5
type: Answer
downvote count: 0
score: 5
has body: Yes. All ints are binary anyway, so it doesn't matter how you declare them. int hex = 0xff; hex++; // hex is now 0x100, or 256 int hex2 = 255; hex2++; // hex2 is now 256, or 0x100

http://stackoverflow.com/a/13181501
score: 10
downvote count: 2
has body: First set path on cmd(command prompt): set path="C:\Program Files\Java\jre6\bin" then type java -jar yourProgramname.jar
upvote count: 12
answers question: http://stackoverflow.com/q/394616
type: Answer

http://stackoverflow.com/q/462297
has answer: http://stackoverflow.com/a/462322
answer count: 12
has answer: http://stackoverflow.com/a/462325
linked to: http://stackoverflow.com/q/4829631
has title: How to use Class<T> in Java?
has answer: http://stackoverflow.com/a/463291
linked to: http://stackoverflow.com/q/31693
upvote count: 306
type: AnsweredQuestion
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/462347
possible better answer: http://stackoverflow.com/a/19545123
type: Question
has answer: http://stackoverflow.com/a/19545123
has answer: http://stackoverflow.com/a/462305
has body: There's a good discussion of Generics and what they really do behind the scenes over at this question, so we all know that Vector&lt;int[]&gt; is a vector of integer arrays, and HashTable&lt;String, Person&gt; is a table of whose keys are strings and values Persons. However, what stumps me is the usage of Class&lt;&gt;. The java class Class is supposed to also take a template name, (or so I'm being told by the yellow underline in eclipse). I don't understand what I should put in there. The whole point of the Class object is when you don't fully have the information about an object, for reflection and such. Why does it make me specify which class the Class object will hold? I clearly don't know, or I wouldn't be using the Class object, I would use the specific one.
has answer: http://stackoverflow.com/a/17931873
has answer: http://stackoverflow.com/a/78853358
linked to: http://stackoverflow.com/q/1368166
tagged with: class
accepted answer: http://stackoverflow.com/a/462322
score: 306
has answer: http://stackoverflow.com/a/13273981
has answer: http://stackoverflow.com/a/56732881
tagged with: templates
has answer: http://stackoverflow.com/a/2183921
tagged with: generics
favorite count: 0
has answer: http://stackoverflow.com/a/43317950

home-directory
tags question: http://stackoverflow.com/q/585534
type: Tag
tag name: home-directory

http://stackoverflow.com/a/457675
answers question: http://stackoverflow.com/q/457629
downvote count: 0
score: 18
type: Answer
has body: I almost always end up defining n-Tuple classes when I code in Java. For instance: public class Tuple2&lt;T1,T2&gt; { private T1 f1; private T2 f2; public Tuple2(T1 f1, T2 f2) { this.f1 = f1; this.f2 = f2; } public T1 getF1() {return f1;} public T2 getF2() {return f2;} } I know it's a bit ugly, but it works, and you just have to define your tuple types once. Tuples are something Java really lacks. EDIT: David Hanak's example is more elegant, as it avoids defining getters and still keeps the object immutable.
upvote count: 18

http://stackoverflow.com/a/551014
type: Answer
has comment: http://stackoverflow.com/comment/362588
has comment: http://stackoverflow.com/comment/362626
upvote count: 2
has comment: http://stackoverflow.com/comment/362767
has comment: http://stackoverflow.com/comment/362829
downvote count: 2
has comment: http://stackoverflow.com/comment/364547
has body: Case statements can almost always be replaced with polymorphism And also boolean investable = customer.isInvestable(); Since the call to isInvestable is polymorphic, the actual algorithm used to make the call is determined by the type of customer. I think you are both wrong. What if this is just the "investibility" logic for a customer wishing for a business loan. Perhaps the innvestibility decision of a customer for another product is really quite different, and possibly not based on a "category" but where they live, whether they are married, what job sector they work in? Also, what if there are new products coming out all the time, each with different investibility decisions and I don't want to be updating my core Customer class every time this happens? Like I said, I'm not saying switch is always fine - but equally it can be perfectly legitimate. If used well, it can be an extremely clear way of writing application logic.
has comment: http://stackoverflow.com/comment/362666
score: 0
has comment: http://stackoverflow.com/comment/362642
answers question: http://stackoverflow.com/q/550919

http://stackoverflow.com/comment/367072
comment on: http://stackoverflow.com/a/554792
score: 0
type: AnswerComment
type: Comment
has text: That's another thing I detest about reading Java code...the hundreds and hundreds of lines of useless CRAP code written by IDEs.

http://stackoverflow.com/comment/76220975
has text: Is this Kotlin language?
type: AnswerComment
comment on: http://stackoverflow.com/a/41461544
type: Comment
score: 1

http://stackoverflow.com/comment/3146113
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/1662916
score: 1
has text: Would really love get a troubleshoot using BoneCP as a Tomcat Datasource. The main problem I had with this was that it required BoneCP Classes in tomcat's lib dir, as well as the log4j and google classes. Doing this made the connection pools work - (it hadn't worked while in WAR) - however it conflicted with the log4j setting of Tomcat and prevented any log output at all from the application, which was a dealbreaker...

http://stackoverflow.com/comment/210819
score: 0
type: Comment
has text: I deleted my post, to clean up things. That was a misunderstanding becuase I haven't read the question well. Stupid me.
type: AnswerComment
comment on: http://stackoverflow.com/a/382909

http://stackoverflow.com/q/416266
has answer: http://stackoverflow.com/a/416278
has answer: http://stackoverflow.com/a/10281746
favorite count: 0
has answer: http://stackoverflow.com/a/70750704
has body: I'm a beginner in Java. Please suggest which collection(s) can/should be used for maintaining a sorted list in Java. I have tried Map and Set, but they weren't what I was looking for.
has answer: http://stackoverflow.com/a/52700466
has answer: http://stackoverflow.com/a/51834052
linked to: http://stackoverflow.com/q/73925525
answer count: 21
has answer: http://stackoverflow.com/a/41757813
upvote count: 175
has title: Sorted collection in Java
has answer: http://stackoverflow.com/a/416289
has answer: http://stackoverflow.com/a/10283509
has answer: http://stackoverflow.com/a/416505
has answer: http://stackoverflow.com/a/2326244
score: 173
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/26685127
has answer: http://stackoverflow.com/a/5745380
downvote count: 2
has answer: http://stackoverflow.com/a/41370488
has answer: http://stackoverflow.com/a/13633422
has answer: http://stackoverflow.com/a/33387877
tagged with: collections
has answer: http://stackoverflow.com/a/45753119
has answer: http://stackoverflow.com/a/56748112
tagged with: java
linked to: http://stackoverflow.com/q/15606219
type: Question
has answer: http://stackoverflow.com/a/40882970
has answer: http://stackoverflow.com/a/416281
has answer: http://stackoverflow.com/a/416280
has answer: http://stackoverflow.com/a/22359719
tagged with: sorting

hql
tag name: hql
tags question: http://stackoverflow.com/q/518267
tags question: http://stackoverflow.com/q/586185
tags question: http://stackoverflow.com/q/586871
type: Tag
tags question: http://stackoverflow.com/q/586077
tags question: http://stackoverflow.com/q/489360
tags question: http://stackoverflow.com/q/432347
tags question: http://stackoverflow.com/q/602397
tags question: http://stackoverflow.com/q/570229

http://stackoverflow.com/a/521225
upvote count: 6
accepted answer of: http://stackoverflow.com/q/520907
downvote count: 1
answers question: http://stackoverflow.com/q/520907
score: 5
type: AcceptedAnswer
has body: Strings and bytes are two completely different things, so wanting to split a String into bytes is as meaningless as wanting to split a painting into verses. What is it that you actually want to do? To convert between strings and bytes, you need to specify an encoding that can encode all the characters in the String. Depending on the encoding and the characters, some of them may span more than one byte. You can either split the String into chunks of 1024 characters and encode those as bytes, but then each chunk may be more than 1024 bytes. Or you can encode the original string into bytes and then split them into chunks of 1024, but then you have to make sure to append them as bytes before decoding the whole into a String again, or you may get garbled characters at the split points when a character spans more than 1 byte. If you're worried about memory usage when the String can be very long, you should use streams (java.io package) to to the en/decoding and splitting, in order to avoid keeping the data in memory several times as copies. Ideally, you should avoid having the original String in one piece at all and instead use streams to read it in small chunks from wherever you get it from.
type: Answer

http://stackoverflow.com/a/498233
has comment: http://stackoverflow.com/comment/77761876
type: Answer
downvote count: 4
answers question: http://stackoverflow.com/q/498217
has comment: http://stackoverflow.com/comment/77771362
score: 10
has comment: http://stackoverflow.com/comment/315544
has body: You should not really catch an exception and throw a new one as general as "new Exception". Instead, if you wish to bubble up the exception just do the following: try { // Do some stuff here } catch (DivideByZeroException e) { System.out.println("Can't divide by Zero!"); } catch (IndexOutOfRangeException e) { // catch the exception System.out.println("No matching element found."); } catch (Throwable e) { throw e; // rethrow the exception/error that occurred } It is not good practise, I believe, to catch an exception and throw a new exception instead of the one that was raised to your code block, unless you raise a useful custom exception that provides enough context to elude to the cause of the original exception.
has comment: http://stackoverflow.com/comment/316003
upvote count: 14

http://stackoverflow.com/q/393528
has answer: http://stackoverflow.com/a/10478121
has body: I am making a game server for a turn based game. Not a web based server, but a process-based one. I want it to be scalable and I want the development process to go as smoothly as possible. I haven't used Java in forever and I need to brush up on my skills, so I really have no idea what is out there framework or tool-wise. Right now it looks like I am going to use Terracotta due to its clustering capabilities. I was just wondering if anything besides this that would make developing a TCP based game server easier?
has answer: http://stackoverflow.com/a/393745
possible better answer: http://stackoverflow.com/a/393745
favorite count: 0
has title: Good tools/frameworks to develop a game server in Java?
upvote count: 6
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/482586
tagged with: java
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/395052
score: 5
tagged with: frameworks
accepted answer: http://stackoverflow.com/a/395052

http://stackoverflow.com/q/508428
upvote count: 8
has body: I have an xml document object that I need to convert into a string. Is there as simple way to do this?
has comment: http://stackoverflow.com/comment/322741
has answer: http://stackoverflow.com/a/508446
possible better answer: http://stackoverflow.com/a/508445
score: 8
tagged with: http://stackoverflow.com/tag/xml
has answer: http://stackoverflow.com/a/508445
has title: is there a simple way to convert my XML object back to String in java?
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/508446
has answer: http://stackoverflow.com/a/508620
type: Question
answer count: 3
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/447988
answers question: http://stackoverflow.com/q/446663
type: Answer
downvote count: 0
score: 21
has body: At my last job I went a little deeper in the enum version: public enum Messages { @Error @Text("You can''t put a {0} in a {1}") XYZ00001_CONTAINMENT_NOT_ALLOWED, ... } @Error, @Info, @Warning are retained in the class file and are available at runtime. (We had a couple of other annotations to help describe message delivery as well) @Text is a compile-time annotation. I wrote an annotation processor for this that did the following: Verify that there are no duplicate message numbers (the part before the first underscore) Syntax-check the message text Generate a messages.properties file that contains the text, keyed by the enum value. I wrote a few utility routines that helped log errors, wrap them as exceptions (if desired) and so forth. I'm trying to get them to let me open-source it... -- Scott
has comment: http://stackoverflow.com/comment/51841471
upvote count: 21

http://stackoverflow.com/a/413152
downvote count: 0
type: Answer
has body: If you're after another JPA provider (Hibernate is one of these) then take a look at EclipseLink. It's far more fully-featured than the JPA 1.0 reference implementation of TopLink Essentials. In fact, EclipseLink will be the JPA 2.0 reference implementation shipped with Glassfish V3 Final. JPA is good because you can use it both inside and outside a container. I've written Swing clients that use JPA to good effect. It doesn't have the same stigma and XML baggage that EJB 2.0/2.1 came with. If you're after an even lighter weight solution then look no further than ibatis, which I consider to be my persistence technology of choice for the Java platform. It's lightweight, relies on SQL (it's amazing how much time ORM users spend trying to make their ORM produce good SQL) and does 90-95% of what JPA does (including lazy loading of related entities if you want). Just to correct a couple of points: JPA is the peristence layer of EJB, not built on EJB; Any decent JPA provider has a whole lot of caching going on and it can be hard to figure it all out (this would be a good example of "Why is Simplicity So Complex?"). Unless you're doing something you haven't indicatd, exceptions shouldn't be an issue for your managed objects. Runtime exceptions typically rollback transactions (if you use Spring's transaction management and who doesn't do that?). The provider will maintain cached copies of loaded or persisted objects. This can be problematic if you want to update outside of the entity manager (requiring an explicit cache flush or use of EntityManager.refresh()).
answers question: http://stackoverflow.com/q/413131
score: 7
upvote count: 7

http://stackoverflow.com/comment/44752927
comment on: http://stackoverflow.com/a/10817635
type: Comment
has text: I got your point. But, I am wondering, Does the statement `System.setProperty` change the default trust store or not ? Your mentioned in your answer that it is not possible to use the trust store define in the code since he/she already using the default one. Is that really true ? Then what is the point of `System.setProperty` if the default store is not changeable ?
type: AnswerComment
score: 0

http://stackoverflow.com/comment/856467
type: Comment
score: 4
has text: More info: data binding currently requires the pro license, $745 per developer.
type: AnswerComment
comment on: http://stackoverflow.com/a/531190

http://stackoverflow.com/q/544732
tagged with: java
has comment: http://stackoverflow.com/comment/1464433
type: Question
has body: My understanding is that APPLET is deprecated and OBJECT is the preferred tag to use for Java applets. Is this correct? A lot of Java applet examples, both on the web and in books, still seem to use the APPLET tag. Are there any browser compatibility issues that OBJECT suffers from (compared to APPLET)? Also, can you provide an example of proper OBJECT tag usage for Java applets?
upvote count: 3
tagged with: http://stackoverflow.com/tag/html
answer count: 1
tagged with: applet
has answer: http://stackoverflow.com/a/544736
favorite count: 0
type: UnansweredQuestion
has title: Which HTML tag is the proper one to use for Java applets (APPLET, EMBED, OBJECT)?
score: 3
downvote count: 0

spring
tags question: http://stackoverflow.com/q/562652
tags question: http://stackoverflow.com/q/633158
tags question: http://stackoverflow.com/q/522202
tags question: http://stackoverflow.com/q/628963
tags question: http://stackoverflow.com/q/525408
tags question: http://stackoverflow.com/q/496080
tags question: http://stackoverflow.com/q/520041
tags question: http://stackoverflow.com/q/450557
tags question: http://stackoverflow.com/q/612656
tags question: http://stackoverflow.com/q/436920
tags question: http://stackoverflow.com/q/418197
tags question: http://stackoverflow.com/q/546447
tags question: http://stackoverflow.com/q/425049
tags question: http://stackoverflow.com/q/381071
tags question: http://stackoverflow.com/q/486011
tags question: http://stackoverflow.com/q/500637
tags question: http://stackoverflow.com/q/589563
tags question: http://stackoverflow.com/q/554963
tags question: http://stackoverflow.com/q/457814
type: Tag
tags question: http://stackoverflow.com/q/429089
tags question: http://stackoverflow.com/q/435023
tags question: http://stackoverflow.com/q/361529
tags question: http://stackoverflow.com/q/444623
tags question: http://stackoverflow.com/q/540729
tags question: http://stackoverflow.com/q/479855
tags question: http://stackoverflow.com/q/553546
tags question: http://stackoverflow.com/q/556110
tags question: http://stackoverflow.com/q/415896
tags question: http://stackoverflow.com/q/448246
tags question: http://stackoverflow.com/q/474712
tags question: http://stackoverflow.com/q/578305
tags question: http://stackoverflow.com/q/544049
tags question: http://stackoverflow.com/q/375656
tags question: http://stackoverflow.com/q/639757
tags question: http://stackoverflow.com/q/581655
tags question: http://stackoverflow.com/q/455659
tags question: http://stackoverflow.com/q/516948
tags question: http://stackoverflow.com/q/561188
tags question: http://stackoverflow.com/q/530923
tags question: http://stackoverflow.com/q/474159
tags question: http://stackoverflow.com/q/404275
tags question: http://stackoverflow.com/q/643280
tags question: http://stackoverflow.com/q/385195
tags question: http://stackoverflow.com/q/473627
tags question: http://stackoverflow.com/q/595554
tags question: http://stackoverflow.com/q/495792
tags question: http://stackoverflow.com/q/559155
tags question: http://stackoverflow.com/q/634448
tags question: http://stackoverflow.com/q/507556
tags question: http://stackoverflow.com/q/467235
tags question: http://stackoverflow.com/q/602319
tags question: http://stackoverflow.com/q/516771
tags question: http://stackoverflow.com/q/374886
tags question: http://stackoverflow.com/q/510876
tags question: http://stackoverflow.com/q/517353
tags question: http://stackoverflow.com/q/360520
tags question: http://stackoverflow.com/q/628416
tag name: spring
tags question: http://stackoverflow.com/q/560867
tags question: http://stackoverflow.com/q/627807
tags question: http://stackoverflow.com/q/378066
tags question: http://stackoverflow.com/q/490354
tags question: http://stackoverflow.com/q/624468
tags question: http://stackoverflow.com/q/534199
tags question: http://stackoverflow.com/q/610628
tags question: http://stackoverflow.com/q/413799
tags question: http://stackoverflow.com/q/544215
tags question: http://stackoverflow.com/q/531096
tags question: http://stackoverflow.com/q/429010
tags question: http://stackoverflow.com/q/431107
tags question: http://stackoverflow.com/q/631596
tags question: http://stackoverflow.com/q/502994
tags question: http://stackoverflow.com/q/556238
tags question: http://stackoverflow.com/q/407492
tags question: http://stackoverflow.com/q/453925
tags question: http://stackoverflow.com/q/490595
tags question: http://stackoverflow.com/q/487826
tags question: http://stackoverflow.com/q/564515
tags question: http://stackoverflow.com/q/431635

http://stackoverflow.com/q/471013
has answer: http://stackoverflow.com/a/471117
possible better answer: http://stackoverflow.com/a/471035
upvote count: 1
has answer: http://stackoverflow.com/a/3670577
has answer: http://stackoverflow.com/a/471035
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/471040
tagged with: java
has answer: http://stackoverflow.com/a/13749051
has answer: http://stackoverflow.com/a/471025
type: Question
downvote count: 0
has answer: http://stackoverflow.com/a/29248050
has body: For a program I am writing, I need to ask a user for an integer between 1 and 8. I've tried multiple (cleaner) ways of doing this but none of them worked, so I'm left with this: int x = 0; while (x &lt; 1 || x &gt; 8) { System.out.print("Please enter integer (1-8): "); try { x = Integer.parseInt(inputScanner.next()); } catch(NumberFormatException e) { x = 0; } } Where inputScanner is a Scanner. Surely there is a better way?
accepted answer: http://stackoverflow.com/a/471025
answer count: 7
score: 1
has title: Easier way to guarantee integer input through Scanner?
tagged with: user-input
tagged with: parsing
tagged with: integer
favorite count: 0
tagged with: java.util.scanner

http://stackoverflow.com/comment/16483055
type: Comment
comment on: http://stackoverflow.com/a/405366
type: AnswerComment
has text: Or, since it seems you have an instance of Calendar anyway, you can call `time.get(Calendar.HOUR)`....
score: 0

http://stackoverflow.com/a/511510
type: Answer
has body: I think Staale's answer is a good start but I would add... Use JavaFX if 1) If you're interested in developing the application for mobile or TV (note this has yet to be released) 2) If you're working with a graphic designer who is creating the appearance of the application in photoshop and you want to be able to import their look directly. 3) If making the GUI filthy rich is important to you. (so if you want a panel to fade in or out, or slide upon demand) Use Swing if 1) You're creating an application mainly for the desktop. 2) Performance matters and you know what you are doing (so if you're writing an IDE, Swing would be a better choice) 3) You're looking for a RPC (rich client platform) to build upon.
upvote count: 5
score: 5
accepted answer of: http://stackoverflow.com/q/511202
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/511202

http://stackoverflow.com/comment/360546
type: Comment
has text: Nice try, but this is the only "logging.properties" I have.
comment on: http://stackoverflow.com/a/546582
score: 0
type: AnswerComment

http://stackoverflow.com/q/551872
has answer: http://stackoverflow.com/a/551921
upvote count: 10
type: Question
accepted answer: http://stackoverflow.com/a/551921
score: 10
possible better answer: http://stackoverflow.com/a/552021
has answer: http://stackoverflow.com/a/552021
answer count: 2
downvote count: 0
favorite count: 0
has body: I write Eclipse plugins and export some classes as an API while wanting to restrict access to other classes. I follow the common Eclipse practice of separating these classes into a ".internal" subpackage. However, then I can't use "package" or default level access on these classes since many of them need to be used by the classes I'm exporting. What is the best practice for preventing or discouraging users of my API from using these classes for their own purposes? Is there an automatic checker? I admit that I've dabbled in using some of Eclipse's internal classes when I had no choice :) Clarification: I have a similar need with non-plugin code.
tagged with: package
has title: Best practice for controlling access to a ".internal" package
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/comment/316344
score: 0
comment on: http://stackoverflow.com/q/500857
type: Comment
has text: So you've also read that c't article? :)
type: QuestionComment

http://stackoverflow.com/comment/3445136
score: 7
type: AnswerComment
type: Comment
has text: Better than ever! Working on my 4th enterprise Grails project; employs parallelised grid-processing for large volumes of XML processing, upgrades much less painful (though yet to take the jump to 1.3), plugins getting better, IDEs very good now. At a recent meeting a .Net programmer was telling me how Grails and Groovy is one of the most unlucky Java secrets that hasn't got the attention it deserves. With SpringSource on board however the sense of our benefiting from an innovative, intuitive and evolving platform is truly upon us.
comment on: http://stackoverflow.com/a/397308

http://stackoverflow.com/comment/254145
has text: I don't know but it annoys the hell out of me; for example it is much harder to write network code this way.
comment on: http://stackoverflow.com/q/430346
type: QuestionComment
score: 154
type: Comment

http://stackoverflow.com/q/367467
has answer: http://stackoverflow.com/a/367686
has title: How do I directly read the timezone files included in the JRE distribution?
answer count: 2
possible better answer: http://stackoverflow.com/a/367686
favorite count: 0
score: 2
has body: Timezone information for Java are kept in a folder called "zi". For eg. C:\Program Files\Java\jdk6\jre\lib\zi files in this folder are in binary format. But it is very important for me to see exactly what they say. Can anyone share a way, to read these files, or are they Sun proprietary?
tagged with: timezone
upvote count: 3
has answer: http://stackoverflow.com/a/367508
accepted answer: http://stackoverflow.com/a/367508
downvote count: 1
type: Question
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/q/464874
has answer: http://stackoverflow.com/a/29454703
score: 140
has comment: http://stackoverflow.com/comment/66164990
tagged with: utf-8
has title: "unmappable character for encoding" warning in Java
has answer: http://stackoverflow.com/a/76819859
accepted answer: http://stackoverflow.com/a/464886
upvote count: 140
possible better answer: http://stackoverflow.com/a/1619098
has answer: http://stackoverflow.com/a/1619098
has answer: http://stackoverflow.com/a/52914447
has body: I'm currently working on a Java project that is emitting the following warning when I compile: /src/com/myco/apps/AppDBCore.java:439: warning: unmappable character for encoding UTF8 [javac] String copyright = "� 2003-2008 My Company. All rights reserved."; I'm not sure how SO will render the character before the date, but it should be a copyright symbol, and is displayed in the warning as a question mark in a diamond. It's worth noting that the character appears in the output artifact correctly, but the warnings are a nuisance and the file containing this class may one day be touched by a text editor that saves the encoding incorrectly... How can I inject this character into the "copyright" string so that the compiler is happy, and the symbol is preserved in the file without potential re-encoding issues?
has answer: http://stackoverflow.com/a/10786268
has answer: http://stackoverflow.com/a/1858497
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/31030192
tagged with: java
has answer: http://stackoverflow.com/a/21755671
has answer: http://stackoverflow.com/a/3092933
has answer: http://stackoverflow.com/a/61215319
linked to: http://stackoverflow.com/q/23399865
tagged with: ascii
type: Question
has answer: http://stackoverflow.com/a/464886
tagged with: encoding
downvote count: 0
answer count: 13
favorite count: 0
has answer: http://stackoverflow.com/a/43702160
has answer: http://stackoverflow.com/a/32555356

http://stackoverflow.com/comment/384578
type: Comment
comment on: http://stackoverflow.com/a/565369
has text: I am not expecting it to abort very frequently however the calculation is very large; so if user decides to do something else i.e. somehow want to ignore the result then I think so it is better to stop that server process.
type: AnswerComment
score: 0

http://stackoverflow.com/a/611568
has body: If this is Windows-only, and they're already in a DLL, perhaps JNA would be of use. (if the performance hit for function calls through JNA isn't too bad)
type: Answer
score: 0
answers question: http://stackoverflow.com/q/611296

http://stackoverflow.com/comment/383961
comment on: http://stackoverflow.com/q/571874
type: QuestionComment
has text: Strange... what do you want the file for?
score: 0
type: Comment

http://stackoverflow.com/comment/13803899
score: 18
has text: Although this is the top-rated answer, it is referring to the wrong section of the Specification; 9.1.1.1 is describing the `abstract` keyword on the declaration of the interface itself, not on its members. @Will's answer below is correct and also contains valid link sources.
type: Comment
comment on: http://stackoverflow.com/a/641549
type: AnswerComment

http://stackoverflow.com/comment/27962840
has text: Interfaces would not lead to code duplication, if you have two objects with the same functionality that implies the same API and hence same interface. Abstract classes are implementation details, while interfaces are a general contract you expose to the programmer using your API.
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/639656

http://stackoverflow.com/comment/369493
type: Comment
comment on: http://stackoverflow.com/a/558021
has text: Hey subes! Thank you for the response. Yes, actually a dig further in other forums and the problem was the compiler. So, since the C++ code is available I recompile it with my gcc version, but then I've got _ZNSs4_Rep20_S_empty_rep_storageE :-( :-( I'll try to get that g++ in my installation. Tnx
type: AnswerComment
score: 0

http://stackoverflow.com/comment/319176
type: AnswerComment
comment on: http://stackoverflow.com/a/504005
type: Comment
has text: Re "some part of the Java standard": http://java.sun.com/docs/books/jls/third_edition/html/statements.html says: "Every local variable declaration statement is immediately contained by a block." The ones in the for statement don't have braces around them, therefore they aren't in a block.
score: 0

http://stackoverflow.com/q/587404
has answer: http://stackoverflow.com/a/17334343
has body: I have some complicated object, such as a Cat, which has many properties, such as age, favorite cat food, and so forth. A bunch of Cats are stored in a Java Collection, and I need to find all the Cats that are aged 3, or those whose favorite cat food is Whiskas. Surely, I can write a custom method that finds those Cats with a specific property, but this gets cumbersome with many properties; is there some generic way of doing this?
has answer: http://stackoverflow.com/a/10027050
linked to: http://stackoverflow.com/q/767372
has answer: http://stackoverflow.com/a/16546548
has answer: http://stackoverflow.com/a/588452
favorite count: 0
duplicate of: http://stackoverflow.com/q/122105
answer count: 20
has answer: http://stackoverflow.com/a/16726677
has answer: http://stackoverflow.com/a/20422425
has answer: http://stackoverflow.com/a/18509924
has answer: http://stackoverflow.com/a/587429
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/587494
score: 91
has answer: http://stackoverflow.com/a/16727596
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/587453
linked to: http://stackoverflow.com/q/122105
tagged with: collections
has answer: http://stackoverflow.com/a/12565456
has comment: http://stackoverflow.com/comment/17964311
possible better answer: http://stackoverflow.com/a/588452
type: Question
has answer: http://stackoverflow.com/a/2780944
has title: Finding all objects that have a given property inside a collection
has answer: http://stackoverflow.com/a/587474
has answer: http://stackoverflow.com/a/587415
accepted answer: http://stackoverflow.com/a/587415
has comment: http://stackoverflow.com/comment/23767214
has answer: http://stackoverflow.com/a/2416642
linked to: http://stackoverflow.com/q/93417
upvote count: 91
has answer: http://stackoverflow.com/a/38686012
has comment: http://stackoverflow.com/comment/31468948
has answer: http://stackoverflow.com/a/588436
has answer: http://stackoverflow.com/a/587436
has answer: http://stackoverflow.com/a/587463

http://stackoverflow.com/q/601795
tagged with: excel
type: Question
score: 3
has answer: http://stackoverflow.com/a/601810
has answer: http://stackoverflow.com/a/602089
has title: Import Data from MS Excel using Java Source Code
favorite count: 0
upvote count: 3
answer count: 5
has body: I want to Import data placed in MS Excel and print it using Java Application Program. I am newbie in Java. So Please guide, is it possible. If yes, how? Any website/tutorial will be of great help.. Thanks in advance..
has answer: http://stackoverflow.com/a/601800
downvote count: 0
type: UnansweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/16174760
has answer: http://stackoverflow.com/a/601837

http://stackoverflow.com/q/520615
type: Question
has title: Event handling with Jython & Swing
tagged with: jython
has body: I'm making a GUI by using Swing from Jython. Event handling seems to be particularly elegant from Jython, just set JButton("Push me", actionPerformed = nameOfFunctionToCall) However, trying same thing inside a class gets difficult. Naively trying JButton("Push me", actionPerformed = nameOfMethodToCall) or JButton("Push me", actionPerformed = nameOfMethodToCall(self)) from a GUI-construction method of the class doesn't work, because the first argument of a method to be called should be self, in order to access the data members of the class, and on the other hand, it's not possible to pass any arguments to the event handler through AWT event queue. The only option seems to be using lambda (as advised at http://www.javalobby.org/articles/jython/) which results in something like this: JButton("Push me", actionPerformed = lambda evt : ClassName.nameOfMethodToCall(self)) It works, but the elegance is gone. All this just because the method being called needs a self reference from somewhere. Is there any other way around this?
tagged with: user-interface
downvote count: 0
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/523456
upvote count: 8
tagged with: python
score: 8
type: AnsweredQuestion
tagged with: java
tagged with: swing
accepted answer: http://stackoverflow.com/a/523456

http://stackoverflow.com/a/483071
downvote count: 0
has body: First, configure your Gmail account to accept POP3 access. Then, simply access your mail account using Javamail !
answers question: http://stackoverflow.com/q/483048
type: Answer
upvote count: 1
score: 1

http://stackoverflow.com/comment/28070354
type: Comment
has text: In `if(v != 0)` the `!= 0` part does nothing but littering the source code.
comment on: http://stackoverflow.com/a/500495
score: 0
type: AnswerComment

http://stackoverflow.com/a/4103657
upvote count: 4
downvote count: 1
score: 3
has body: Don't make your interface generic. Make your methods, instead: public interface ISimpleService { public &lt;T&gt; T doSomething(T param); } Hope it helps.
answers question: http://stackoverflow.com/q/502994
type: Answer

http://stackoverflow.com/a/623970
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 22
accepted answer of: http://stackoverflow.com/q/623939
has body: Part of my current job is the care and feeding of a large java application that was designed to run with a large amount of memory (currently around 8 Gb), mostly due to ongoing calculations with lots of cached data. I did the initial deployment with the standard GC setup , mostly because there wasn't a simple way to simulate the production environment running at full tilt. In stages, over the next few months, I've customized the GC settings. Generally, the biggest available knob seems to be adjusting the frequency and magnitude of incremental gc - the biggest improvement has been in trading off large periodic gc for smaller and more frequent ones. But we've definitely been able to see performance improvements. I'm not going to post my specific settings because a) they're specific to our setup, and b) because I don't have them handy :). But in general, what I've found is there's been a lot of work done in tuning the default gc settings. Almost always the defaults work better than any tweaks I would make. At least for me, the situations where gc tuning was actually worthwhile were extreme enough that it was unreasonable to attempt to simulate them, so I had to do it experimentally and incrementally. Here's a good reference from a prev. stackoverflow discussion.
answers question: http://stackoverflow.com/q/623939
upvote count: 22

http://stackoverflow.com/comment/411880
comment on: http://stackoverflow.com/a/599181
score: 4
type: AnswerComment
has text: -1 for the use of +=, in this case it is a performance killer. Always use StringBuilder for repeated appending to a string.
type: Comment

http://stackoverflow.com/comment/195362
has text: Thanks Alex. I was able to build an acceptable solution (in terms of engineering work, anyway) using your suggestions. I'll post what I came up with when I'm not watching the kids. :)
comment on: http://stackoverflow.com/a/364593
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/25541957
has text: @willcodejavaforfood This is a million years later but if you care about whether an object was added or removed you can change up the id of the `PropertyChangeEvent`.
comment on: http://stackoverflow.com/a/559803
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/576736
type: Answer
has body: My person opinion , Go for QUARTZ with Spring. Its the perfect choice. Have been using it on production for 2+ years now. Why try and re-invent the wheel when some people are already doing it a the best. Not to mention the different modes of running it provide. I would suggest to atleast try it out.
answers question: http://stackoverflow.com/q/575803
score: 0

http://stackoverflow.com/comment/209664
has text: +1 you can't display a byte array as a string, but your method is the closest thing to what the question is looking for
comment on: http://stackoverflow.com/a/381934
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/386787
upvote count: 1
answers question: http://stackoverflow.com/q/386695
downvote count: 0
has body: At first, it's better to avoid multiple inheritance and use interfaces. And Java actually does not support multiple inheritance. But you can use mixins to fake the multiple inheritance. There are some manuals about this: Multiple Inheritance in Java The Java Mixin Pattern, or Faking Multiple Inheritance And if you want to make something composite, I advise to take a look at the Qi4j framework: Composite Oriented Programming with Qi4j
type: Answer
score: 1

http://stackoverflow.com/q/567987
has comment: http://stackoverflow.com/comment/383090
has answer: http://stackoverflow.com/a/568049
has answer: http://stackoverflow.com/a/568553
has answer: http://stackoverflow.com/a/568044
answer count: 10
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/379396
possible better answer: http://stackoverflow.com/a/568041
upvote count: 7
has answer: http://stackoverflow.com/a/568041
has answer: http://stackoverflow.com/a/568022
type: Question
score: 3
has answer: http://stackoverflow.com/a/568014
tagged with: java
has comment: http://stackoverflow.com/comment/379434
has answer: http://stackoverflow.com/a/568015
has comment: http://stackoverflow.com/comment/379452
has answer: http://stackoverflow.com/a/568039
has title: Is the Java API poorly designed and why?
downvote count: 4
tagged with: api
has answer: http://stackoverflow.com/a/568073
has answer: http://stackoverflow.com/a/568018
favorite count: 0
accepted answer: http://stackoverflow.com/a/568014
has body: I have heard this a lot, the the Java API is poorly designed. Do you agree and if so, how? I know there are major issues with the Calendar/Date apis. The collections api takes a lot of boilerplate code to use. The File/IO API can be complicated for some things. But, does this apply across the aboard? And to which versions of Java?
has comment: http://stackoverflow.com/comment/2775499

http://stackoverflow.com/comment/314440
type: Comment
comment on: http://stackoverflow.com/a/483407
has text: @Arkadiy, what are those Strings? Are they snippets of your (de)serialized xml or are they something completely different? Are they mostly the same bits and pieces or random?
score: 0
type: AnswerComment

http://stackoverflow.com/q/629778
has comment: http://stackoverflow.com/comment/442379
has answer: http://stackoverflow.com/a/629909
upvote count: 2
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/629819
has title: How do I pass formated (\n \t) text to a java command line
score: 2
has comment: http://stackoverflow.com/comment/442400
tagged with: java
has body: I need to pass a formatted string in a command line so that the input text is presented formatted in a JFrame: Hello The sun is shinning! How do I put a '\n' in a Windows batch file? java -cp . Test "Hello\nThe sun is shinning!" I cannot change the program, it is expecting a string as a command line parameter to be shown in a TextBox, and I want to pass multiple lines. Thanks
type: Question
downvote count: 0
tagged with: batch-file
answer count: 2
favorite count: 0

http://stackoverflow.com/comment/61183691
type: Comment
score: 11
has text: This answer is so bad that it's funny
comment on: http://stackoverflow.com/a/9650388
type: AnswerComment

http://stackoverflow.com/comment/16238009
type: Comment
score: 2
comment on: http://stackoverflow.com/a/527069
type: AnswerComment
has text: Links are broken (thanks, Oracle), here are the new ones: http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.8.9 and http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.8.7

http://stackoverflow.com/q/389680
downvote count: 0
tagged with: hudson
has answer: http://stackoverflow.com/a/1170815
favorite count: 0
has body: I am using hudson CI to manage a straight java web project, using ant to build. I would like to mandate that the unit test coverage never be worse than the previous build, thereby making sure any new code is always tested, or at least the coverage is continually improving. Is there a hudson plugin that works this way? Edit: I am currently using Emma, but would be willing to switch to another coverage app. Also, as a clarification, I've seen the thresholds in some Hudson plugins, but that's not exactly what I'm after. For example what I'd like is that if coverage for Build #12 was 46% overall, and someone checked in Build #13 with 45% coverage, the build would break. The reason I want to do this, is that I have a codebase with low test coverage. We don't have time to go back and retroactively write unit tests, but I'd like to make sure that the coverage keeps getting better. UPDATE: Dan pointed out an edge case with my plan that will definitely be a problem. I think I need to rethink whether this is even a good idea.
has title: Can my build stipulate that my code coverage never get worse?
score: 6
answer count: 4
has answer: http://stackoverflow.com/a/415767
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/389842
tagged with: code-coverage
has answer: http://stackoverflow.com/a/389696
tagged with: java
accepted answer: http://stackoverflow.com/a/389696
type: Question
tagged with: continuous-integration
upvote count: 6
has answer: http://stackoverflow.com/a/389842

http://stackoverflow.com/a/572946
score: 4
has body: As mentioned in this Sun article about thread, you can do whatever you want in the main thread, including building a GUI, even though it is risky. Swing methods are not thread-safe, but as long as no components (Swing or otherwise) have been realized (meaning that the component's paint() method has been or might be called), it was OK until 2004. Since 2004, as reminded in this SO question, it is mandatory to create the GUI in the EDT. Back to the question: Swing has not been implemented with the main thread solely related to GUI because that would force a pure multi-thread approach and: Component developers do not have to have an in-depth understanding of threads programming: Toolkits in which all components must fully support multithreaded access, can be difficult to extend, particularly for developers who are not expert at threads programming. Events are dispatched in a predictable order: The runnable objects enqueued by invokeLater() are dispatched from the same event queue as mouse and keyboard events, timer events, and paint requests. In toolkits where components support multithreaded access, component changes are interleaved with event processing at the whim of the thread scheduler. This makes comprehensive testing difficult or impossible. Less overhead: Toolkits that attempt to carefully lock critical sections can spend a substantial amount of time and space managing locks. Whenever the toolkit calls a method that might be implemented in client code (for example, any public or protected method in a public class), the toolkit must save its state and release all locks so that the client code can grab locks if necessary. When control returns from the method, the toolkit must regrab its locks and restore its state. All applications bear the cost of this, even though most applications do not require concurrent access to the GUI. So the main thread can be used for initialization (of data and GUI, provided they do not take too much time), while most post-initializat…
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/572921
answers question: http://stackoverflow.com/q/572921
type: Answer
downvote count: 1
has comment: http://stackoverflow.com/comment/385297
upvote count: 5

http://stackoverflow.com/a/600745
answers question: http://stackoverflow.com/q/600733
has comment: http://stackoverflow.com/comment/8255816
has comment: http://stackoverflow.com/comment/415752
upvote count: 37
downvote count: 1
has comment: http://stackoverflow.com/comment/20284212
score: 36
has comment: http://stackoverflow.com/comment/414195
type: Answer
has body: the non-regex way: String input = "FOO[BAR]", extracted; extracted = input.substring(input.indexOf("["),input.indexOf("]")); alternatively, for slightly better performance/memory usage (thanks Hosam): String input = "FOO[BAR]", extracted; extracted = input.substring(input.indexOf('['),input.lastIndexOf(']'));

http://stackoverflow.com/comment/436833
comment on: http://stackoverflow.com/a/623975
has text: I'm not sure that most people would see setting the Xmx parameter as "tuning" GC.
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/a/555699
type: AcceptedAnswer
upvote count: 12
type: Answer
has body: I have used Scala on our existing Java infrastructure to query and manipulate large xml documents. Was not possible using the standard Java xml libraries or not as easily. I was tempted to use it for portfolio performance calculations, but had already finished the Java version. A Scala version would have been easier to maintain as it is easier to translate the formulas directly into code. Another area where you can sneak in Scala is with multithreading. Have no real experience with this, but it seems to be easier in Scala. Point is, don't try to see it as a Java replacement for now, but use it where you can utilize it strenghts next to your existing Java code. I used Intellij with the Scala plugin as an IDE, but it is not there yet. It is do-able in combination with the maven plugin and the console. I'm also a Smalltalk programmer and love being able to use code blocks in Scala. Compared to Java there is less code, but still not as readible as Smalltalk code. BTW, the smalltalk community is growing again thanks to the Seaside framework, so you might want to return The things I learned or got a better understanding of: the use of constructors the immutable concept working with lists and recursion functional programming in general So yes, I think it is worth it.
accepted answer of: http://stackoverflow.com/q/554913
downvote count: 0
answers question: http://stackoverflow.com/q/554913
score: 12

http://stackoverflow.com/comment/45813072
type: AnswerComment
has text: Wow! Just wow! This is neat, of course, but... you know - the C programmer inside me screams in pain seeing that you allocate a full-blown HashMap and perform lookups inside it all of it JUST to essentially manage 4 constants: spades, hearts, diamonds and clubs! A C programmer would allocate 1 byte for each: 'const char CLUBS=0;' etc... Yes,a HashMap lookup is O(1), but the memory and CPU overhead of a HashMap, in this case make it many orders of magnitude slower and resource hungry than calling .values() directly! No wonder Java is such a memory hog if people write like this...
type: Comment
score: 16
comment on: http://stackoverflow.com/a/4637105

http://stackoverflow.com/q/481379
accepted answer: http://stackoverflow.com/a/481432
favorite count: 0
has answer: http://stackoverflow.com/a/481419
tagged with: linux
tagged with: windows
has answer: http://stackoverflow.com/a/481430
answer count: 4
has title: Java: Handle logoff or shutdown on Windows and Linux
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/481430
tagged with: swing
type: Question
score: 5
has body: Is there a way for a Java GUI application to respond to system shutdown or logoff events, other than to use JNI? (On Windows, the JNI would use WM_QUERYENDSESSION, on Linux?) The method should allow the program to prompt users to save, etc., and then continue the logoff process.
upvote count: 5
has answer: http://stackoverflow.com/a/481432
has answer: http://stackoverflow.com/a/481447
downvote count: 0

http://stackoverflow.com/a/442622
downvote count: 2
answers question: http://stackoverflow.com/q/442564
score: 0
upvote count: 2
type: Answer
has body: It depends on the task you want to do, but I wouldn't use it. Also, check if the thread-save-ness you want to accompish couldn't be done by synchronize(this) in the first place? There are also some nice locks in the API that might help you :)

http://stackoverflow.com/q/473282
has answer: http://stackoverflow.com/a/60292724
accepted answer: http://stackoverflow.com/a/473309
answer count: 18
has answer: http://stackoverflow.com/a/473332
possible better answer: http://stackoverflow.com/a/35522727
linked to: http://stackoverflow.com/q/1235179
score: 1242
has answer: http://stackoverflow.com/a/77590594
has answer: http://stackoverflow.com/a/18595614
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/69794558
has title: How can I pad an integer with zeros on the left?
tagged with: java
downvote count: 2
tagged with: formatting
has answer: http://stackoverflow.com/a/75929090
has answer: http://stackoverflow.com/a/47177309
upvote count: 1244
type: Question
has body: How do you left pad an int with zeros when converting to a String in java? I'm basically looking to pad out integers up to 9999 with leading zeros (e.g. 1 = 0001).
has answer: http://stackoverflow.com/a/51025832
has comment: http://stackoverflow.com/comment/63427592
has comment: http://stackoverflow.com/comment/40714989
has comment: http://stackoverflow.com/comment/58735089
has answer: http://stackoverflow.com/a/473309
has answer: http://stackoverflow.com/a/63427171
has answer: http://stackoverflow.com/a/18419116
has answer: http://stackoverflow.com/a/473305
has answer: http://stackoverflow.com/a/52792330
has answer: http://stackoverflow.com/a/43869856
tagged with: zero-pad
has answer: http://stackoverflow.com/a/9539012
has answer: http://stackoverflow.com/a/35522727
favorite count: 0
has answer: http://stackoverflow.com/a/24931253
has comment: http://stackoverflow.com/comment/51016067
has answer: http://stackoverflow.com/a/30011421

http://stackoverflow.com/a/460511
answers question: http://stackoverflow.com/q/460446
has body: All languages supporting polymorphism use vtables to resolve method calls to the correct function. So also Java and .NET. They both compile to some intermediate langauge (IL for .NET and byte code for java) but the vtable is not visible in this intermediate language. It is supported by the underlying engine (CLR for .NET)
downvote count: 0
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/q/499528
type: UnansweredQuestion
has body: Does anyone know what happened to android.provider.Telephony? It is not there anymore.
tagged with: android
has answer: http://stackoverflow.com/a/499598
upvote count: 6
has answer: http://stackoverflow.com/a/522628
score: 6
has title: What happened to android.provider.Telephony?
type: Question
has answer: http://stackoverflow.com/a/2963487
tagged with: message
tagged with: java
has answer: http://stackoverflow.com/a/499551
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/500118
answer count: 5

http://stackoverflow.com/q/477886
has answer: http://stackoverflow.com/a/477912
favorite count: 0
has answer: http://stackoverflow.com/a/73160167
has answer: http://stackoverflow.com/a/10655576
has answer: http://stackoverflow.com/a/31271103
accepted answer: http://stackoverflow.com/a/477951
tagged with: excel
type: AnsweredQuestion
tagged with: java
has body: I have this application I'm developing in JSP and I wish to export some data from the database in XLS (MS Excel format). Is it possible under tomcat to just write a file as if it was a normal Java application, and then generate a link to this file? Or do I need to use a specific API for it? Will I have permission problems when doing this?
type: Question
score: 5
upvote count: 5
tagged with: jsp
has answer: http://stackoverflow.com/a/477951
possible better answer: http://stackoverflow.com/a/2154226
tagged with: tomcat
has title: JSP generating Excel spreadsheet (XLS) to download
has answer: http://stackoverflow.com/a/2154226
tagged with: export
has answer: http://stackoverflow.com/a/477898
has comment: http://stackoverflow.com/comment/104084686
downvote count: 0
answer count: 7

http://stackoverflow.com/a/498758
upvote count: 5
downvote count: 0
answers question: http://stackoverflow.com/q/498747
has body: The line calculate(s_ccc, s_ccc); indicates you're not actually doing anything to t_ccc. However, should this line have read calculate(s_ccc, t_ccc); than the effect remains the same. This is due to the fact that you're assigning a new value to c here: c = b; When assigning a new value to a reference argument the reference is lost. This is the difference between altering a by reference variable and assigning a new value.
type: Answer
score: 5

http://stackoverflow.com/a/508845
answers question: http://stackoverflow.com/q/508723
score: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/323337
type: Answer
has body: Java is the wrong tool for this. Setting up the JVM involves a lot of stuff happening in the background before the first line of Java code can be executed, and there's really no way to get around it.
upvote count: 3
has comment: http://stackoverflow.com/comment/323157

http://stackoverflow.com/comment/334616
comment on: http://stackoverflow.com/a/521144
type: AnswerComment
score: 0
type: Comment
has text: "That" being what, exactly? The last bit? That's not related to how big an actual object is - just some other objects being created or freed in the background.

http://stackoverflow.com/comment/377495
score: 1
has text: As you say, I meant serialized (was clear on the concept but not the vocabulary). Any threading issues are going to be independent of logging -- if I want to make sure I'm logging the right values I'll make the appropriate copies of volatile data at the right time.
comment on: http://stackoverflow.com/a/566073
type: AnswerComment
type: Comment

http://stackoverflow.com/a/603307
type: Answer
answers question: http://stackoverflow.com/q/603247
upvote count: 6
score: 4
has body: If you're using ANT and you want maven style dependency management without maven, take a look at Ivy. It can download from maven repositories and can even read maven pom files.
downvote count: 2

http://stackoverflow.com/comment/8553821
comment on: http://stackoverflow.com/a/5439943
type: Comment
has text: Yes, you can use the same underlying file system operations from native code, though some directories may not have the necessary permission to allow an "other" userid to generate a listing.
score: 0
type: AnswerComment

http://stackoverflow.com/q/624207
downvote count: 0
tagged with: utf-8
tagged with: string
has answer: http://stackoverflow.com/a/1547512
answer count: 4
favorite count: 0
upvote count: 1
has title: Reading a UTF-8 String from a ByteBuffer where the length is an unsigned int
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/624210
has body: I am trying to read a UTF8 string via a java.nio.ByteBuffer. The size is an unsinged int, which, of course, Java doesn't have. I have read the value into a long so that I have the value. The next issue I have is that I cannot create an array of bytes with the long, and casting he long back to an int will cause it to be signed. I also tried using limit() on the buffer, but again it works with int not long. The specific thing I am doing is reading the UTF8 strings out of a class file, so the buffer has more in it that just the UTF8 string. Any ideas on how to read a UTF8 string that has a potential length of an unsigned int from a ByteBuffer. EDIT: Here is an example of the issue. SourceDebugExtension_attribute { u2 attribute_name_index; u4 attribute_length; u1 debug_extension[attribute_length]; } attribute_name_index The value of the attribute_name_index item must be a valid index into the constant_pool table. The constant_pool entry at that index must be a CONSTANT_Utf8_info structure representing the string "SourceDebugExtension". attribute_length The value of the attribute_length item indicates the length of the attribute, excluding the initial six bytes. The value of the attribute_length item is thus the number of bytes in the debug_extension[] item. debug_extension[] The debug_extension array holds a string, which must be in UTF-8 format. There is no terminating zero byte. The string in the debug_extension item will be interpreted as extended debugging information. The content of this string has no semantic effect on the Java Virtual Machine. So, from a technical point of view, it is possible to have a string in the class file that is the full u4 (unsigned, 4 bytes) in length. These won't be an issue if there is a limit to the size of a UTF8 string (I am no UTF8 expert so perhaps there is such a limit). I could just punt on it and go with the reality that there is not going to be a String that long...
score: 1
tagged with: java
type: Question
possible better answer: http://stackoverflow.com/a/624215
has answer: http://stackoverflow.com/a/624215
tagged with: bytebuffer
accepted answer: http://stackoverflow.com/a/624210
has answer: http://stackoverflow.com/a/624554

http://stackoverflow.com/comment/26074713
has text: The debugger might call ToString() for some objects but not all, as evinced by List<something> where the debugger output is much more useful that the output of ToString().
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/563699

http://stackoverflow.com/a/401545
type: Answer
has body: Why not store the documents etc. in a database, then have the web-app access the database and allow users to pull files that way? Does it have to be a mapped network drive? Otherwise if it's a matter of knowing what is there, you could always construct the jnlp file dynamically and pass file lists, etc. in as arguments (if they are server side). Guess we need to know a little more about what you are trying to accomplish.
answers question: http://stackoverflow.com/q/401513
upvote count: 1
downvote count: 1
score: 0
has comment: http://stackoverflow.com/comment/227416

http://stackoverflow.com/a/611573
downvote count: 0
has body: Are the lines below exactly from your web.xml? Tomcat finds the servlet mapping that maps /myservlet to the servlet named "MyServlet" but complains that it cannot find any servlet definition with that name. Case matters. What you provided looks correct, but double check your web.xml to make sure the case is correct. Double check the web.xml where Tomcat is using it, in the directory mywebapp/WEB-INF/web.xml MyServlet <-- Check this name MyServlet MyServlet <-- Compare against this name /myservlet If that's not it, let us know. But these names are case sensitive.
type: Answer
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/611465

http://stackoverflow.com/q/510506
tagged with: java
has title: Is there a good reference for using OLE Automation (from Java)?
possible better answer: http://stackoverflow.com/a/1974431
type: Question
upvote count: 2
answer count: 2
tagged with: automation
has answer: http://stackoverflow.com/a/510977
accepted answer: http://stackoverflow.com/a/510977
tagged with: ole
favorite count: 0
has answer: http://stackoverflow.com/a/1974431
downvote count: 0
has body: I am trying to communicate with Excel from a Java/SWT application. I have been able to open a worksheet, open a file and save it but that's about it. Can anyone point me to some documentation/examples for this? I especially need to know which commands are available. I did try to record macros to inspect. This was useful but did not give me everything I wanted. This is a sample of what I have been trying so far: private static OleAutomation openFile( OleAutomation automation, String fileName) { Variant workbooks = automation.getProperty(0x0000023c);// get User // Defined // Workbooks Variant[] arguments = new Variant[1]; arguments[0] = new Variant(fileName); System.out.println("workbooks::\t" + workbooks); IDispatch p1 = workbooks.getDispatch(); int[] rgdispid = workbooks.getAutomation().getIDsOfNames(new String[] { "Open" }); int dispIdMember = rgdispid[0]; Variant workbook = workbooks.getAutomation().invoke(dispIdMember, arguments); System.out.println("Opened the Work Book"); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } int id = workbook.getAutomation().getIDsOfNames(new String[] { "ActiveSheet" })[0]; System.out.println(id); Variant sheet = workbook.getAutomation().getProperty(id); OleAutomation sheetAutomation = sheet.getAutomation(); return (sheetAutomation); }
score: 2
type: AnsweredQuestion

http://stackoverflow.com/a/382106
has body: As with many, i am stuck to manage application written in Java 1.4 (migration to 1.5 is one the way in many cases). So even if Java 7 or 8 get new feature I will not be able to used them... Anyways syntactic sugar is good, it can help the writing, reading and analysis of code.
score: 0
type: Answer
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/381733

http://stackoverflow.com/a/444501
has comment: http://stackoverflow.com/comment/266152
downvote count: 0
answers question: http://stackoverflow.com/q/444426
has comment: http://stackoverflow.com/comment/266216
score: 1
has comment: http://stackoverflow.com/comment/266225
has comment: http://stackoverflow.com/comment/266135
type: Answer
has comment: http://stackoverflow.com/comment/266206
upvote count: 1
has comment: http://stackoverflow.com/comment/266090
has body: The problem with this solution is that you may be creating a "pick and choose" model which is a bit un-mavenesque. In the case of the profiles you're describing you're sort of in-between; if each profile produces a decent result by itself you may be ok. The moment you start requiring specific combinations of profiles I think you're heading for troubles. Individual developers will typically run into consistency issues because they forget which set of profiles should be used for a given scenario. Your mileage may vary, but we had real problems with this. Half your developers will forget the "correct" combinations after only a short time and end up wasting hours on a regular basis because they run the wrong combinations at the wrong time. The practical problem you'll have with this is that AFAIK there's no way to have a set of "meta" profiles that activate a set of sub-profiles. If there had been a nice way to create an umbrella profile this'd be a really neat feature. Your "fitnesse" and "sources" profiles should really be private, activated by one or more meta-profiles. (You can activate a default set in settings.xml for each developer)
has comment: http://stackoverflow.com/comment/266168

http://stackoverflow.com/q/556478
has comment: http://stackoverflow.com/comment/3085692
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/556531
has answer: http://stackoverflow.com/a/557457
tagged with: java
linked to: http://stackoverflow.com/q/221966
upvote count: 21
has answer: http://stackoverflow.com/a/556651
tagged with: swing
has title: Top tips for designing GUIs?
type: Question
has answer: http://stackoverflow.com/a/3018514
has answer: http://stackoverflow.com/a/556565
has answer: http://stackoverflow.com/a/556551
score: 21
has answer: http://stackoverflow.com/a/557325
possible better answer: http://stackoverflow.com/a/557457
has answer: http://stackoverflow.com/a/3018647
tagged with: user-interface
downvote count: 0
has answer: http://stackoverflow.com/a/557232
favorite count: 0
accepted answer: http://stackoverflow.com/a/556531
has answer: http://stackoverflow.com/a/3018622
answer count: 10
has body: A while back I read (before I lost it) a great book called GUI Bloopers which was full of examples of bad GUI design but also full of useful tidbits like Don't call something a Dialog one minute and a Popup the next. What top tips would you give for designing/documenting a GUI? It would be particularly useful to hear about widgets you designed to cram readable information into as little screen real-estate as possible. I'm going to roll this off with one of my own: avoid trees (e.g. Swing's JTree) unless you really can't avoid it, or have a unbounded hierarchy of stuff. I have found that users don't find them intuitive and they are hard to navigate and filter. PS. I think this question differs from this one as I'm asking for generalist tips
has comment: http://stackoverflow.com/comment/14998252

http://stackoverflow.com/q/482029
has answer: http://stackoverflow.com/a/534588
accepted answer: http://stackoverflow.com/a/496157
tagged with: listeners
tagged with: swing
has title: How can a JComponent notified about the closed event of it's parent J(Internal)Frame?
type: AnsweredQuestion
tagged with: components
has answer: http://stackoverflow.com/a/496157
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/298820
answer count: 2
has body: I want to write a component that monitors other activities, but it's listeners are to be removed when the component's window is closed. I don't want to write this removal code many times, but want the component to handle it itself. (How) can i do it? Thanks!
score: 0
possible better answer: http://stackoverflow.com/a/534588

http://stackoverflow.com/comment/73093267
comment on: http://stackoverflow.com/a/31147096
has text: It doesn't work at all for me. The first } closes the { before the @literal.
score: 1
type: AnswerComment
type: Comment

http://stackoverflow.com/q/369452
downvote count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/369645
tagged with: visitor-pattern
has body: I am being powerfully tempted to use an unchecked exception as a short-circuit control-flow construct in a Java program. I hope somebody here can advise me on a better, cleaner way to handle this problem. The idea is that I want to cut short the recursive exploration of sub-trees by a visitor without having to check a "stop" flag in every method call. Specifically, I'm building a control-flow graph using a visitor over the abstract syntax tree. A return statement in the AST should stop exploration of the sub-tree and send the visitor back to the nearest enclosing if/then or loop block. The Visitor superclass (from the XTC library) defines Object dispatch(Node n) which calls back via reflection methods of the form Object visitNodeSubtype(Node n) dispatch is not declared to throw any exceptions, so I declared a private class that extends RuntimeException private static class ReturnException extends RuntimeException { } Now, the visitor method for a return statement looks like Object visitReturnStatement(Node n) { // handle return value assignment... // add flow edge to exit node... throw new ReturnException(); } and every compound statement needs to handle the ReturnException Object visitIfElseStatement(Node n) { Node test = n.getChild(0); Node ifPart = n.getChild(1); Node elsePart = n.getChild(2); // add flow edges to if/else... try{ dispatch(ifPart); } catch( ReturnException e ) { } try{ dispatch(elsePart); } catch( ReturnException e ) { } } This all works fine, except: I may forget to catch a ReturnException somewhere and the compiler won't warn me. I feel dirty. Is there a better way to do this? Is there a Java pattern I am unaware of to implement this kind of non-local flow-of-control? [UPDATE] This specific example turns out to be somewhat invalid: the Visitor superclass catches and wraps exceptions (even RuntimeExceptions), so the exception throwing doesn't really help. I've implemented the suggestion to return an enum type from visitReturnStatement. Luckily, t…
type: Question
has answer: http://stackoverflow.com/a/369494
tagged with: java
score: 10
has answer: http://stackoverflow.com/a/370544
has answer: http://stackoverflow.com/a/369466
has comment: http://stackoverflow.com/comment/198405
has answer: http://stackoverflow.com/a/369557
has title: Java: using a RuntimeException to escape from a Visitor
has answer: http://stackoverflow.com/a/369860
favorite count: 0
tagged with: exception
upvote count: 10
answer count: 7
tagged with: callcc
has answer: http://stackoverflow.com/a/369511

http://stackoverflow.com/comment/254746
type: Comment
has text: Very good advice. I'm still stuck in the XML mode, unfortunately. Old habits die hard. Another typically good comment. I look forward to your posts.
comment on: http://stackoverflow.com/a/431352
score: 0
type: AnswerComment

http://stackoverflow.com/a/523548
downvote count: 2
has body: The short answer is that it depends. Unless you can make the question more specific, there is no way to give an answer. What do you want to simulate? For example, if you want to simulate adding two numbers, you can do it using something like: a = b + c; If you want to simulate the bouncing of a ball, you can do that using a little bit of math equations and the graphic libraries. If you want to simulate a web browser, you can do that too. So the exact answer depends on what simulation you want to do.
answers question: http://stackoverflow.com/q/523541
type: Answer
score: 1
upvote count: 3

http://stackoverflow.com/q/574746
type: AnsweredQuestion
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/386685
upvote count: 1
has title: Why does JDialog 'jump' on setLocationRelativeTo()?
type: Question
has answer: http://stackoverflow.com/a/581062
downvote count: 0
tagged with: jdialog
has comment: http://stackoverflow.com/comment/386749
answer count: 1
has comment: http://stackoverflow.com/comment/386856
has body: Have a class that extends JDialog. It's initialized entirely on EDT (just in case). Now, public PropsDialog (JFrame parentFrame) { super(parentFrame); // boring pack(); setLocationRelativeTo(getParent()); setVisible(true); } results in dialog appearing in the leftmost corner and then jumping to it's intended position. Am I doing smth wrong?
favorite count: 0
accepted answer: http://stackoverflow.com/a/581062
has comment: http://stackoverflow.com/comment/386585
tagged with: swing

http://stackoverflow.com/comment/389621
type: Comment
score: 0
has text: Yes, no commercial libs please.
type: QuestionComment
comment on: http://stackoverflow.com/q/577622

http://stackoverflow.com/q/599634
has answer: http://stackoverflow.com/a/12614297
has answer: http://stackoverflow.com/a/47771708
score: 43
has body: I would like to convert some HTML characters back to text using Java Standard Library. I was wondering whether any library would achieve my purpose? /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here // "Happy &amp; Sad" in HTML form. String s = "Happy &amp;amp; Sad"; System.out.println(s); try { // Change to "Happy &amp; Sad". DOESN'T WORK! s = java.net.URLDecoder.decode(s, "UTF-8"); System.out.println(s); } catch (UnsupportedEncodingException ex) { } }
upvote count: 43
has answer: http://stackoverflow.com/a/32784449
tagged with: html-entities
possible better answer: http://stackoverflow.com/a/12614297
downvote count: 0
has answer: http://stackoverflow.com/a/599696
favorite count: 0
tagged with: http://stackoverflow.com/tag/html
has title: Convert HTML Character Back to Text Using Java Standard Library
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/599671
tagged with: java
accepted answer: http://stackoverflow.com/a/599696
type: Question
has answer: http://stackoverflow.com/a/599645
has answer: http://stackoverflow.com/a/49702475
answer count: 8
has answer: http://stackoverflow.com/a/599659

http://stackoverflow.com/comment/400199
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/588242
score: 1
has text: I'm guessing the reference to JavaScript was just an example of what he wants to achieve.

http://stackoverflow.com/a/9726856
upvote count: 2
has body: For me just using the Integer.toString() method works for me just fine. You can convert it over if you just want to very if it is null. Example below: private void setCarColor(int redIn, int blueIn, int greenIn) { //Integer s = null; if (Integer.toString(redIn) == null || Integer.toString(blueIn) == null || Integer.toString(greenIn) == null )
answers question: http://stackoverflow.com/q/646012
type: Answer
score: 2
downvote count: 0

mru
tag name: mru
type: Tag
tags question: http://stackoverflow.com/q/583852

http://stackoverflow.com/a/607122
type: Answer
upvote count: 0
score: -2
answers question: http://stackoverflow.com/q/607031
downvote count: 2
has body: It's very difficult to decipher your question. But in general, if you want to know which button it was that caused an event, add a different ActionListener to each one (or its model). Keep the code as clean and simple as possible.

http://stackoverflow.com/comment/356470
type: AnswerComment
comment on: http://stackoverflow.com/a/544212
has text: +1. Your web server will just receive an X.509 cert in the request
type: Comment
score: 1

http://stackoverflow.com/q/436590
tagged with: jsf
upvote count: 1
type: AnsweredQuestion
has body: In JSF, is it possible to solve the following validation / updating scenario using the validation framework of JSF (aka validators, immediate, required, etc.)? +-- Form ----------------------------------------------------+ | | | Field A: |____________|v| | | Field B: |____________|v| | | Field C: |____________|v| Button: [Update C using A and B] | | Field D: |____________|v| Button: [Update D using B and C] | | | | More Fields: ... | | | | Button : [Submit All] | +------------------------------------------------------------+ Where all fields are drop downs and where pressing the [Update C] button would only cause A, B and C to validate but not the rest, pressing the [Update D] button would only cause fields B, C and D to validate and pressing [Submit All] button would cause all fields to validate.
has title: JSF Multiple Partial Validations Scenario
score: 1
tagged with: java
tagged with: forms
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/438641
tagged with: validation
downvote count: 0
favorite count: 0
possible better answer: http://stackoverflow.com/a/438993
tagged with: partial
has answer: http://stackoverflow.com/a/438993
accepted answer: http://stackoverflow.com/a/438641

http://stackoverflow.com/q/573918
accepted answer: http://stackoverflow.com/a/573978
upvote count: 1
tagged with: direction
has body: G'day all, After learning on here that the Java console doesn't support keyboard input a great deal, I switched to Swing and AWT. My problem now is how to detect when the keyboard direction keys (non-numeric keypad) are used. My code (below) does not do more than print a "small box" character when pressing the down, up, left, right keys. This small box character is no different from the character used by the CTRL and ALT keys, for example. Does anyone know what the identity of the keyboard direction keys actually is so that I can code for them in my application? import java.awt.*; import java.awt.event.*; import javax.swing.*; public class KeyChecker extends JFrame { JLabel keyLabel = new JLabel("Hit any key"); public KeyChecker() { super("Hit a Key"); setSize(300, 200); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout(FlowLayout.CENTER)); KeyMonitor monitor = new KeyMonitor(this); setFocusable(true); addKeyListener(monitor); add(keyLabel); setVisible(true); } public static void main(String[] arguments) { new KeyChecker(); } } class KeyMonitor extends KeyAdapter { KeyChecker display; KeyMonitor(KeyChecker display) { this.display = display; } public void keyPressed(KeyEvent event) { display.keyLabel.setText("" + event.getKeyChar()); display.repaint(); } }
tagged with: key
tagged with: keyboard
favorite count: 0
has answer: http://stackoverflow.com/a/573978
answer count: 1
tagged with: swing
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
has title: Detecting keyboard direction keys using keyPressed
type: Question

http://stackoverflow.com/comment/404613
type: Comment
has text: After much trying, I can't get the BigInteger version of my code to be less than three times slower than your code. This deserves an upvote.
comment on: http://stackoverflow.com/a/582487
type: AnswerComment
score: 0

http://stackoverflow.com/q/472176
has answer: http://stackoverflow.com/a/678648
has comment: http://stackoverflow.com/comment/32503243
has comment: http://stackoverflow.com/comment/58733267
has answer: http://stackoverflow.com/a/2701353
upvote count: 34
has comment: http://stackoverflow.com/comment/2644832
tagged with: java
score: 34
has title: Any good resource for java interview questions?
type: Question
tagged with: jakarta-ee
has answer: http://stackoverflow.com/a/472246
has answer: http://stackoverflow.com/a/472181
answer count: 6
has answer: http://stackoverflow.com/a/2350265
has body: Can somebody point me to a good interview question repository for java/j2ee programming and architect position?
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/67801407
has comment: http://stackoverflow.com/comment/63614476
has answer: http://stackoverflow.com/a/472296
type: UnansweredQuestion

http://stackoverflow.com/comment/365169
score: 0
has text: (d'oh - I meant non-final. Need my morning wakie drugs)
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/545797

http://stackoverflow.com/a/573583
upvote count: 6
has comment: http://stackoverflow.com/comment/385406
score: 6
has body: Well, I have to say, regardless of whether the C#, Scala, or Groovy fans would like to agree or not, I think some of the suggestions here are completely daft. 1) Anyone who makes the mistake of calling Thread.run instead of Thread.start should NOT be programming. Here the programmer is at fault not the framework or language. 2) Disallow overloading? Why, why on earth would you do this. Again this makes no sense, what problems does it cause? I find overloading very very useful in any number of scenarios. 3) What is the real difference between factory methods and constructors. This is what constructors are, they are factory methods that create instances of the object. If you want or prefer factory methods, then IMPLEMENT THEM...not hard 4) == invoking equals(), operator overloading is one of the worst ideas to ever come in to the domain of object orientation. Do you realise how complex C++ programs can become with an array of overloaded operators. Its not obvious, and requires time consuming analysis. 5) Java would completely die if deprecated methods were removed. Why not just ignore them? Every language is heading in this direction, no language is perfect and mistakes can only be deprecated if developers are to continue with it and upgrade. Although some of your comments make sense, I find that inexperience tends people twards principles and ideals and with experience you realize that pragmatism is what matters. Why is making Java perfect what matters, surly its what you can do with it. I see closures, reified generics, and properties as the only fundamental enhancements needed. Java is not a toy for recreation, its here and popular because businesses are build on it and rely on it.
has comment: http://stackoverflow.com/comment/385591
has comment: http://stackoverflow.com/comment/385559
answers question: http://stackoverflow.com/q/573543
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/385741

http://stackoverflow.com/comment/217754
type: Comment
has text: So does that mean that any existing Java Applications need to be specificly compliled for Dalvik for them to work (as long as the functionality that is in the initial java Application is part of the **most** in the above quote ;) )
comment on: http://stackoverflow.com/a/390488
type: AnswerComment
score: 0

http://stackoverflow.com/a/595592
answers question: http://stackoverflow.com/q/595554
score: 4
has comment: http://stackoverflow.com/comment/9471956
type: Answer
upvote count: 4
downvote count: 0
has comment: http://stackoverflow.com/comment/407521
has comment: http://stackoverflow.com/comment/407581
has body: It's certainly limiting what is possible, but it's not a total waste of time either. Since the type in question is final, it can't be mocked-up easily for isolated testing. However, instances of that type may still be highly configurable through their properties. Using Spring to inject an instance that is properly configured at runtime simplifies the containing class immensely. The class can focus on its responsibilities, relying on Spring to provide it with the collaborators that it needs. Interfaces are over used; this may be a response to that. I think that starting with final, concrete classes for many types, then using readily-available refactoring tools to extract interfaces later, when a specific need is identified, is a defensible position in many contexts.
has comment: http://stackoverflow.com/comment/9472542
has comment: http://stackoverflow.com/comment/9512275
has comment: http://stackoverflow.com/comment/9442473

http://stackoverflow.com/a/381790
accepted answer of: http://stackoverflow.com/q/381733
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/210762
has body: While I don't necessarily agree with Java's philosophy, I think that adding lots of syntactic sugar to Java would go against its philosophy. Java is supposed to be a very simple, easy to reason about language with few constructs, kind of a lowest common denominator lingua franca in the programming community. It was largely a reaction to the complexity of C++. There is supposed to be very little "magic" in it, beyond what is needed (garbage collection, mostly) to make it a memory-safe language. If you want more sugar, etc. in a reasonably high-performance, statically typed language, I would say that Java is just the wrong language for you. You're probably better off just using C#, or maybe D.
type: Answer
has comment: http://stackoverflow.com/comment/209702
score: 14
upvote count: 14
has comment: http://stackoverflow.com/comment/86326986
answers question: http://stackoverflow.com/q/381733

http://stackoverflow.com/q/407612
tagged with: java
has body: I have a Java application that I run from a console which in turn executes an another Java process. I want to get a thread/heap dump of that child process. On Unix, I could do a kill -3 &lt;pid&gt; but on Windows AFAIK the only way to get a thread dump is Ctrl-Break in the console. But that only gives me the dump of the parent process, not the child. Is there another way to get that heap dump?
linked to: http://stackoverflow.com/q/1197912
has answer: http://stackoverflow.com/a/28474185
has answer: http://stackoverflow.com/a/407625
has answer: http://stackoverflow.com/a/59575039
has answer: http://stackoverflow.com/a/38268609
has answer: http://stackoverflow.com/a/51664333
score: 279
type: Question
linked to: http://stackoverflow.com/q/52053455
upvote count: 279
has answer: http://stackoverflow.com/a/59298829
has answer: http://stackoverflow.com/a/56163317
tagged with: heap-dump
linked to: http://stackoverflow.com/q/36604102
has answer: http://stackoverflow.com/a/407792
has answer: http://stackoverflow.com/a/48923965
has answer: http://stackoverflow.com/a/407685
has answer: http://stackoverflow.com/a/3042463
linked to: http://stackoverflow.com/q/813086
downvote count: 0
has answer: http://stackoverflow.com/a/56362179
has answer: http://stackoverflow.com/a/18880485
tagged with: jvm
favorite count: 0
has answer: http://stackoverflow.com/a/1816177
has comment: http://stackoverflow.com/comment/80116520
has answer: http://stackoverflow.com/a/407635
answer count: 20
has answer: http://stackoverflow.com/a/54408355
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/19370350
has answer: http://stackoverflow.com/a/35284729
linked to: http://stackoverflow.com/q/23580934
has answer: http://stackoverflow.com/a/42984176
has title: How to get a thread and heap dump of a Java process on Windows that's not running in a console
tagged with: thread-dump
has answer: http://stackoverflow.com/a/8913240

http://stackoverflow.com/a/490431
downvote count: 0
upvote count: 11
has comment: http://stackoverflow.com/comment/39337787
has body: Why not simply: Object o = new Object(); Object[] array = { o }; // no method call required! What are you really trying to accomplish?
type: Answer
answers question: http://stackoverflow.com/q/490424
score: 11

http://stackoverflow.com/a/13993890
score: 0
type: Answer
has body: I personally like CXF because it's very easy to setup and it performs very well. I also, agree with "LiorH" and don't like Axis2. However, the only article I could find for you to do a comparison was this one. http://www.ibm.com/developerworks/java/library/j-jws14/index.html good luck
answers question: http://stackoverflow.com/q/428514

http://stackoverflow.com/comment/84385546
comment on: http://stackoverflow.com/a/18419116
score: 0
type: AnswerComment
type: Comment
has text: ... and System.out can be redirected.

http://stackoverflow.com/comment/427832
score: 0
type: Comment
type: QuestionComment
has text: I'd like to know too. We eventually gave up and just keep copies of libraries on a server...
comment on: http://stackoverflow.com/q/614892

http://stackoverflow.com/comment/67172361
score: 1
type: AnswerComment
has text: `Objects.toString()` just calls `toString()` on the collection. In your example, this works because presumably `toString()` on the array-backed collection happens to pretty-print nicely.
type: Comment
comment on: http://stackoverflow.com/a/34928115

http://stackoverflow.com/a/548101
score: 3
has body: a term used to describe an efficient method of transferring program control (branching) to another part of a program (or a different program that may have been dynamically loaded) using a table of branch instructions." One way to transfer program control is to call a function. One way to call the right function when you have several to choose from, is to key it off of the type of an object. That's called polymorphism. Java and other Object Oriented languages have polymorphism, implemented through inheritance (subclassing). Not sure how it's implemented in Java, but in C++ there's (generally? or always?) a pointer in each object that points to the v-table for it's class, which contains pointers to virtual functions. I seriously doubt the lack of a user-defined jump table is going to cripple the performance of your java application.
answers question: http://stackoverflow.com/q/548053
downvote count: 0
upvote count: 3
has comment: http://stackoverflow.com/comment/360185
type: Answer

http://stackoverflow.com/q/640208
has comment: http://stackoverflow.com/comment/453736
has body: I use Java for client-side development with Swing. I love Swing; I believe it is one of the better GUI frameworks there. What I miss, however, is the support for declarative validation. Like this snippet from XForms. Do you know any library which allows validating data entry in forms in a declarative way, not by writing ugly validation document listeners for every component there?
tagged with: swing
has comment: http://stackoverflow.com/comment/453706
has comment: http://stackoverflow.com/comment/457520
possible better answer: http://stackoverflow.com/a/3607197
accepted answer: http://stackoverflow.com/a/640400
type: AnsweredQuestion
score: 7
tagged with: java
tagged with: declarative
has answer: http://stackoverflow.com/a/640270
type: Question
has answer: http://stackoverflow.com/a/640400
answer count: 3
tagged with: validation
upvote count: 7
favorite count: 0
has title: Declarative validation of forms in Java/Swing
has comment: http://stackoverflow.com/comment/453766
has answer: http://stackoverflow.com/a/3607197
downvote count: 0

http://stackoverflow.com/comment/330951
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/516780
type: Comment
has text: It's a hint--a coding construct given additional meaning by consistent or standardized use under more constrained circumstances than are legal.

http://stackoverflow.com/a/20646571
upvote count: 1
answers question: http://stackoverflow.com/q/574240
score: 1
downvote count: 0
type: Answer
has body: From a Java specification summary: http://www.cs.cornell.edu/andru/javaspec/17.doc.html The synchronized statement (§14.17) computes a reference to an object; it then attempts to perform a lock action on that object and does not proceed further until the lock action has successfully completed. ... A synchronized method (§8.4.3.5) automatically performs a lock action when it is invoked; its body is not executed until the lock action has successfully completed. If the method is an instance method, it locks the lock associated with the instance for which it was invoked (that is, the object that will be known as this during execution of the body of the method). If the method is static, it locks the lock associated with the Class object that represents the class in which the method is defined. ... Based on these descriptions, I would say most previous answers are correct, and a synchronized method might be particularly useful for static methods, where you would otherwise have to figure out how to get the "Class object that represents the class in which the method was defined." Edit: I originally thought these were quotes of the actual Java spec. Clarified that this page is just a summary/explanation of the spec

http://stackoverflow.com/comment/125005153
comment on: http://stackoverflow.com/a/9392771
score: 1
type: AnswerComment
type: Comment
has text: OK great, but in Java? the original question has the #Java tag...

http://stackoverflow.com/comment/17857103
comment on: http://stackoverflow.com/a/614269
score: 0
type: AnswerComment
type: Comment
has text: @ThorbjørnRavnAndersen: If the attempt to load the document corrupted a data structure which is shared with other open documents, informing the user of the problem may be appropriate, but the problem should *not* be considered resolved. Unfortunately, both Java and .net assume that a `catch` block will resolve just about any exception unless the code manually rethrows it.

http://stackoverflow.com/q/613603
has title: Java Nimbus LAF with transparent text fields
has answer: http://stackoverflow.com/a/615748
possible better answer: http://stackoverflow.com/a/613616
answer count: 4
upvote count: 11
has comment: http://stackoverflow.com/comment/426614
tagged with: swing
score: 11
tagged with: nimbus
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/615748
tagged with: java
has answer: http://stackoverflow.com/a/618856
has body: I have an application that uses disabled JTextFields in several places which are intended to be transparent - allowing the background to show through instead of the text field's normal background. When running the new Nimbus LAF these fields are opaque (despite setting setOpaque(false)), and my UI is broken. It's as if the LAF is ignoring the opaque property. Setting a background color explicitly is both difficult in several places, and less than optimal due to background images actually doesn't work - it still paints it's LAF default background over the top, leaving a border-like appearance (the splash screen below has the background explicitly set to match the image). Any ideas on how I can get Nimbus to not paint the background for a JTextField? Note: I need a JTextField, rather than a JLabel, because I need the thread-safe setText(), and wrapping capability. Note: My fallback position is to continue using the system LAF, but Nimbus does look substantially better. See example images below. Conclusions The surprise at this behavior is due to a misinterpretation of what setOpaque() is meant to do - from the Nimbus bug report: This is a problem the the orginal design of Swing and how it has been confusing for years. The issue is setOpaque(false) has had a side effect in exiting LAFs which is that of hiding the background which is not really what it is ment for. It is ment to say that the component my have transparent parts and swing should paint the parent component behind it. It's unfortunate that the Nimbus components also appear not to honor setBackground(null) which would otherwise be the recommended way to stop the background painting. Setting a fully transparent background seems unintuitive to me. In my opinion, setOpaque()/isOpaque() is a faulty public API choice which should have been only: public boolean isFullyOpaque(); I say this, because isOpaque()==true is a contract with Swing that the component subclass will take responsibility for painting it's entir…
type: Question
downvote count: 0
has answer: http://stackoverflow.com/a/618802
has answer: http://stackoverflow.com/a/613616
favorite count: 0

http://stackoverflow.com/a/484551
type: Answer
answers question: http://stackoverflow.com/q/484172
accepted answer of: http://stackoverflow.com/q/484172
score: 20
upvote count: 21
type: AcceptedAnswer
downvote count: 1
has comment: http://stackoverflow.com/comment/5662639
has body: Going to get downvoted by the Java fanboys for this but as someone who writes both Java and C# I'd say that C# is as close to Java ++ as you are going to get. C to C++ was a paradigm shift, from procedural to Object oriented, the only reason they retain the name is to woo C programmers into thinking that it was the same language which led to a load of really bad C code masquerading as C++. Java is constantly expanding and Sun are quickly incorporating more and more features, so it could well be that Java 7 or 8 is your Java ++

http://stackoverflow.com/q/608704
tagged with: puzzle
downvote count: 1
has body: I have a class, which I have simplified to this: final class Thing { private final int value; public Thing(int value) { this.value = value; } public int getValue() { return value; } @Override public String toString() { return Integer.toString(value); } } I want to sort an array of this thing. So I have created a simple copmarator: private static final Comparator&lt;Thing&gt; reverse = new Comparator&lt;Thing&gt;() { public int compare(Thing a, Thing b) { return a.getValue() - b.getValue(); } }; I then use the two argument form of Arrays.sort. This works fine for my test cases, but sometimes it goes all wrong with the array ending up in a strange but repeatable order. How can this be?
favorite count: 0
accepted answer: http://stackoverflow.com/a/608720
has answer: http://stackoverflow.com/a/609643
upvote count: 18
has answer: http://stackoverflow.com/a/609515
possible better answer: http://stackoverflow.com/a/608715
has answer: http://stackoverflow.com/a/608720
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/608727
tagged with: java
has answer: http://stackoverflow.com/a/608718
score: 17
type: Question
has title: Why is my simple comparator broken?
tagged with: sorting
answer count: 6
has answer: http://stackoverflow.com/a/608715

http://stackoverflow.com/q/622517
has answer: http://stackoverflow.com/a/622575
upvote count: 1
has title: How to represent a 400x400 window as a map in a Java game?
favorite count: 0
possible better answer: http://stackoverflow.com/a/622556
has body: I'm building a pacman game. Basically, I want to have a map representation of this window consisting of blocks/tiles. Then as the pacman character/ghost moves i would change their position on the map to represent what's on the screen, and use that for collision detection etc. How can I build this map, especially since the screen is made of x,y coordinates, so how can I correctly represent them in tiles/on this map?
has answer: http://stackoverflow.com/a/622555
accepted answer: http://stackoverflow.com/a/622555
answer count: 4
type: AnsweredQuestion
tagged with: 2d
downvote count: 0
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/622546
tagged with: maps
type: Question
has answer: http://stackoverflow.com/a/622556

http://stackoverflow.com/comment/387638
has text: Hi. Yes I will implement the connection pool idea, certainly before I let anyone else use it. If you're interested I'm about to add edit about the ALIASes above.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/574850
type: Comment

http://stackoverflow.com/a/503944
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/503877
downvote count: 0
has body: It may be the case that the underlying OS doesn't provide timers with nanosecond precision. There is also an older post.

http://stackoverflow.com/a/36412358
answers question: http://stackoverflow.com/q/407255
downvote count: 0
type: Answer
has body: I tested for JS with Node 4.0.0 if anyone is interested. Declaring outside the loop resulted in a ~.5 ms performance improvement on average over 1000 trials with 100 million loop iterations per trial. So I'm gonna say go ahead and write it in the most readable / maintainable way which is B, imo. I would put my code in a fiddle, but I used the performance-now Node module. Here's the code: var now = require("../node_modules/performance-now") // declare vars inside loop function varInside(){ for(var i = 0; i &lt; 100000000; i++){ var temp = i; var temp2 = i + 1; var temp3 = i + 2; } } // declare vars outside loop function varOutside(){ var temp; var temp2; var temp3; for(var i = 0; i &lt; 100000000; i++){ temp = i temp2 = i + 1 temp3 = i + 2 } } // for computing average execution times var insideAvg = 0; var outsideAvg = 0; // run varInside a million times and average execution times for(var i = 0; i &lt; 1000; i++){ var start = now() varInside() var end = now() insideAvg = (insideAvg + (end-start)) / 2 } // run varOutside a million times and average execution times for(var i = 0; i &lt; 1000; i++){ var start = now() varOutside() var end = now() outsideAvg = (outsideAvg + (end-start)) / 2 } console.log('declared inside loop', insideAvg) console.log('declared outside loop', outsideAvg)
score: 1
upvote count: 1

http://stackoverflow.com/q/557844
possible better answer: http://stackoverflow.com/a/4937594
downvote count: 0
score: 75
favorite count: 0
tagged with: tail
answer count: 9
has body: I'm wondering what techniques and/or library to use to implement the functionality of the linux command "tail -f ". I'm essentially looking for a drop in add-on/replacement for java.io.FileReader. Client code could look something like this: TailFileReader lft = new TailFileReader("application.log"); BufferedReader br = new BufferedReader(lft); String line; try { while (true) { line= br.readLine(); // do something interesting with line } } catch (IOException e) { // barf } The missing piece is a reasonable implementation of TailFileReader. It should be able to read parts of the file that exist before the file is opened as well as the lines that are added.
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/558262
tagged with: java
tagged with: file
type: Question
accepted answer: http://stackoverflow.com/a/558262
has answer: http://stackoverflow.com/a/559146
tagged with: iostream
has answer: http://stackoverflow.com/a/4356328
has answer: http://stackoverflow.com/a/31202832
has answer: http://stackoverflow.com/a/558403
has answer: http://stackoverflow.com/a/4937594
has answer: http://stackoverflow.com/a/12420491
has answer: http://stackoverflow.com/a/40246029
has answer: http://stackoverflow.com/a/4339748
upvote count: 75
has title: Java IO implementation of unix/linux "tail -f"
tagged with: file-io

http://stackoverflow.com/comment/54494198
has text: What is this IAction class you are using? I cannot find what I should import to use it...
type: Comment
comment on: http://stackoverflow.com/a/427088
type: AnswerComment
score: 0

http://stackoverflow.com/q/398422
type: Question
answer count: 2
has title: Simple way to detect unused properties keys?
downvote count: 0
has answer: http://stackoverflow.com/a/1487272
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/51807581
tagged with: properties
has body: Given a set of properties files and list of files which may reference keys in those properties files, what's the easiest way to determine which keys are unused? Example: Given a project with files muppets.properties kermit=Kermit the Frog oscar=Oscar the Grouch smurfs.properties papa=Papa Smurf and /WEB-INF/pages/template.jsp Some jsp template displaying the key &lt;bean:write bundle='muppets' key='kermit'/&gt;. then running program with inputs "*.properties" and "/WEB-INF/**/*.jsp" should report Unused properties: muppets.properties oscar smurfs.properties papa What's the simplest way to do this? Are there any open-source Java libraries that make this easy? The idea is to embed the solution inside an in-house Maven reporting plugin that would run when building a web app. I'm aware that there will be false positives (key strings appearing in the files in a non-key context), but that's ok. Being able to find any unused keys would be helpful. Edit: I'm seeking a standalone code-base solution.
has answer: http://stackoverflow.com/a/398524
score: 3
upvote count: 3
tagged with: java

http://stackoverflow.com/a/466940
score: 0
has body: What asserts are you doing in your tests that the verify in @After is being reported? If there is an assertion failure (or the fail() method is called) then that will be reported, and the after method will not be reported. What does the test method look like?
answers question: http://stackoverflow.com/q/466548
type: Answer

http://stackoverflow.com/comment/65956082
comment on: http://stackoverflow.com/a/4208156
type: AnswerComment
type: Comment
has text: I try not to let "The database comes first.". An application contains the business rules for the features a client asks for and they almost never ask to create a database. That's a technical detail determined during implementation.
score: 2

http://stackoverflow.com/comment/27240700
score: 0
type: Comment
has text: @ThorbjørnRavnAndersen -- yep the situation has changed a bit over the last 5 years. Java on iSeries is more common and better supported. Java within CICS is now usable. And Legacy calling Java classes is now possible.
type: AnswerComment
comment on: http://stackoverflow.com/a/381263

http://stackoverflow.com/a/4013565
downvote count: 0
has comment: http://stackoverflow.com/comment/127378853
answers question: http://stackoverflow.com/q/499010
type: Answer
score: 41
upvote count: 41
has comment: http://stackoverflow.com/comment/9211403
has comment: http://stackoverflow.com/comment/53322946
has body: check this out: http://site.icu-project.org/ (icu4j) they have libraries for detecting charset from IOStream could be simple like this: BufferedInputStream bis = new BufferedInputStream(input); CharsetDetector cd = new CharsetDetector(); cd.setText(bis); CharsetMatch cm = cd.detect(); if (cm != null) { reader = cm.getReader(); charset = cm.getName(); }else { throw new UnsupportedCharsetException() }
has comment: http://stackoverflow.com/comment/9211285

http://stackoverflow.com/a/4796329
downvote count: 0
answers question: http://stackoverflow.com/q/568134
score: 6
has body: I worked with a project recently that insisted that all transactions were marked out at the application layer (the service classes), and that Data Access Objects must not be called directly. This was to ensure that the database wasn't ever written to without the associated application logic being invoked (usually, the database operation was paired up with a message sent to queue). An application of MANDATORY on every DAO EJB ensured that whilst they would run in a transaction, it was the job of a caller to start one. Since the DAOs were called by the service classes (which had the default of REQUIRED), this meant that they worked just fine but anybody accidentally calling them directly would be rewarded with an exception.
upvote count: 6
type: Answer

http://stackoverflow.com/a/1098590
answers question: http://stackoverflow.com/q/561188
score: 0
type: Answer
has body: Did you try to make multiple boxes ? I think you may see the doc of your MQ ? running multiple boxes may need some configuartion in your MQ but it will run ISA

http://stackoverflow.com/comment/265827
score: 0
type: Comment
comment on: http://stackoverflow.com/a/442872
has text: That's a lovely comprehensive answer indeed now.
type: AnswerComment

http://stackoverflow.com/a/11938641
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/527140
has body: An alternative to using createFormulaEvaluator is to use SetCellType(CellType.STRING) and then access StringCellValue. I ran into problems using a formula evaluator (using NPOI) when it contains the WORKDAY() function.
downvote count: 0
type: Answer

http://stackoverflow.com/q/512002
accepted answer: http://stackoverflow.com/a/518588
type: AnsweredQuestion
has title: To use the Gears WorkerPool in GWT do I have to write the same code in Java and Javascript?
tagged with: java
has answer: http://stackoverflow.com/a/518588
type: Question
tagged with: gwt
has body: In order to use the WorkerPool (Javascript Threads) class and functionality in GWT/Gears, do I need to write my code in both Java and Javascript? Upon inspection of WorkerPool - Getting Started and the sample WorkerPool application in the GWT-Gears-1.1 download package it seems that I need to. It seems that the Java code is used to demonstrate the synchronous nature of Javascript and the same algorithm in Javascript is used for the asynchronous calls. Am I missing something? Wasn't GWT created so that you don't have to write Javascript code? Why can't you write your WorkerThread code in Java and have the compiler compile it to Javascript? Here is the relevant Java code from that url: public void syncWorker(String message) { // Busy wait for 5 seconds long end = System.currentTimeMillis() + 5000; while (true) { int busyCounter = 1000; String busyVar; while (busyCounter-- &gt; 0) { busyVar = "garbage" + busyCounter; } long now = System.currentTimeMillis(); if (now &gt; end) { break; } } logMessage("Approved: " + message); } Here is the relevant Javascript code in worker.js (notice how it is the same algorithm written in Javascript): function doWork(message) { // Busy wait for 5 seconds var start = new Date(); while (true) { var busyCounter = 10000; var busyVar; while (busyCounter-- &gt; 0) { busyVar = "garbage" + busyCounter; } var now = new Date(); if (now.getTime() - start.getTime() &gt; 5000) { break; } } return "Approved: " + message; }; Here is the call in Java: wp = Factory.getInstance().createWorkerPool(); wp.setMessageHandler(GearsWorkerPoolTutorial.this); workerId = wp.createWorkerFromUrl("worker.js"); Can anyone with experience in GWT and Gears shed some light on this? Thanks! Edit: It seems according to this http://markmail.org/message/gxipzth2jheccpha#query:+page:1+mid:sabv4llpymbavt7t+state:results my suspicions are true. I'm not sure I understand why this limitation exists. I would love to read any insight on the matter. Edit 2: This also seems to confir…
tagged with: javascript
tagged with: google-gears
score: 0
answer count: 1

http://stackoverflow.com/a/362931
answers question: http://stackoverflow.com/q/362919
score: 1
upvote count: 1
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/362919
has body: You can open a new window with AppletContext.showDocument(). You'll need to have a page on the server with the HTML and all. You get the context from your applet, which inherits getAppletContext() from the base class. It'll end up looking something like this: AppletContext ctxt = getAppletContext(); ctxt.showDocument("http://www.example.com/child_applet.html", "_top"); If you just want an external window, you can create and show a frame. It'll be a child of the applet and subject to the same restrictions. Also, it'll disappear if the user navigates away from the applet page. JFrame frame = new JFrame(); // setup all the context... frame.show();
type: Answer

concurrency
tag name: concurrency
tags question: http://stackoverflow.com/q/639275
tags question: http://stackoverflow.com/q/510632
tags question: http://stackoverflow.com/q/575803
tags question: http://stackoverflow.com/q/517532
tags question: http://stackoverflow.com/q/574240
tags question: http://stackoverflow.com/q/561671
tags question: http://stackoverflow.com/q/616484
tags question: http://stackoverflow.com/q/601491
tags question: http://stackoverflow.com/q/603363
tags question: http://stackoverflow.com/q/454294
tags question: http://stackoverflow.com/q/617591
tags question: http://stackoverflow.com/q/480566
tags question: http://stackoverflow.com/q/609963
tags question: http://stackoverflow.com/q/362740
tags question: http://stackoverflow.com/q/578904
tags question: http://stackoverflow.com/q/368613
tags question: http://stackoverflow.com/q/484119
tags question: http://stackoverflow.com/q/636011
tags question: http://stackoverflow.com/q/464784
tags question: http://stackoverflow.com/q/519099
tags question: http://stackoverflow.com/q/440036
tags question: http://stackoverflow.com/q/625726
tags question: http://stackoverflow.com/q/574397
tags question: http://stackoverflow.com/q/564903
tags question: http://stackoverflow.com/q/435069
tags question: http://stackoverflow.com/q/421357
type: Tag
tags question: http://stackoverflow.com/q/536327
tags question: http://stackoverflow.com/q/451576
tags question: http://stackoverflow.com/q/646990
tags question: http://stackoverflow.com/q/461896

http://stackoverflow.com/a/629589
score: 8
downvote count: 0
upvote count: 8
has body: Just to elaborate on what duffymo said: Java is designed to be backward compatible. I.e. if you write something in 1.5 you can run it in 1.6. Of course there are limits to that (e.g. new reserved words like assert break it) but in general it works fine. If you go the other way, it's a bit more dangerous. You certainly won't need to rewrite all your code, but you might have used features only available since 1.6. Such features can be new classes or new methods of existing classes. Another thing is the binary code level. You can set your compiler running 1.6 to create code for 1.5 or even 1.4. But beware, that your 1.6 compiler most certainly compiles against a 1.6 rt.jar. That means you won't notice missing classes or methods until you actually run or compile your code with 1.5. Setting the compliance level only means that the 1.5 JRE will understand the code, not that all "default" classes are available. I don't have any experience with 1.6 specifics, but i think while 1.5 added a lot of new language features (that are not all compatible with 1.4), 1.6 was more of a maintenance release.
answers question: http://stackoverflow.com/q/629506
type: Answer

http://stackoverflow.com/comment/111535349
type: Comment
has text: If anyone needs it, if hexadecimal string is long enough to surpass the int, then you need a long type for that conversion.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/516610

http://stackoverflow.com/comment/68506915
score: 0
type: Comment
comment on: http://stackoverflow.com/a/10125367
has text: This is the only solution I could find that would handle all implementing classes of sub-interfaces as well. And it was easy to integrate and use.
type: AnswerComment

http://stackoverflow.com/comment/316086
score: 0
has text: Or return one==null ? (two==null ? 0 :-1) : two==null ? -1 : one.compareToIgnoreCase(two);
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/481836

http://stackoverflow.com/q/464149
tagged with: user-interface
downvote count: 0
accepted answer: http://stackoverflow.com/a/9337632
answer count: 4
has answer: http://stackoverflow.com/a/892019
favorite count: 0
has title: How to build a Google-chrome tabs and menubar interface in Java Swing?
tagged with: swing
score: 4
type: AnsweredQuestion
tagged with: java
tagged with: google-chrome
has answer: http://stackoverflow.com/a/464249
has answer: http://stackoverflow.com/a/9337632
type: Question
upvote count: 4
tagged with: open-source
possible better answer: http://stackoverflow.com/a/475672
has body: Does someone know an open source project or code snippets, which demonstrate how to create a google-chrome like interface with similar tabs and toolbar in Swing? I know, that I can use JTabbedPane, but I'm thinking of an interface which looks and feels very similar to the google chrome "tabbed browsing".
has answer: http://stackoverflow.com/a/475672

http://stackoverflow.com/a/366947
type: Answer
score: 0
has body: Your URL has localhost in it. Are you trying to connect to this server on the network? Your URL may be incorrect.
answers question: http://stackoverflow.com/q/366861

http://stackoverflow.com/a/54085333
score: 12
answers question: http://stackoverflow.com/q/577363
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/109065218
upvote count: 12
has comment: http://stackoverflow.com/comment/109086653
has body: The open-source IPAddress Java library will do this in a polymorphic manner for both IPv4 and IPv6 and handles subnets. Disclaimer: I am the project manager of that library. Example code: contains("10.10.20.0/30", "10.10.20.3"); contains("10.10.20.0/30", "10.10.20.5"); contains("1::/64", "1::1"); contains("1::/64", "2::1"); contains("1::3-4:5-6", "1::4:5"); contains("1-2::/64", "2::"); contains("bla", "foo"); static void contains(String network, String address) { IPAddressString one = new IPAddressString(network); IPAddressString two = new IPAddressString(address); System.out.println(one + " contains " + two + " " + one.contains(two)); } Output: 10.10.20.0/30 contains 10.10.20.3 true 10.10.20.0/30 contains 10.10.20.5 false 1::/64 contains 1::1 true 1::/64 contains 2::1 false 1::3-4:5-6 contains 1::4:5 true 1-2::/64 contains 2:: true bla contains foo false

http://stackoverflow.com/a/492821
has comment: http://stackoverflow.com/comment/49005369
has comment: http://stackoverflow.com/comment/311152
upvote count: 122
has comment: http://stackoverflow.com/comment/18536691
type: Answer
answers question: http://stackoverflow.com/q/492703
has comment: http://stackoverflow.com/comment/129905436
score: 121
has comment: http://stackoverflow.com/comment/3002222
downvote count: 1
has comment: http://stackoverflow.com/comment/18661598
has comment: http://stackoverflow.com/comment/18657312
has body: The difference is between the CLR (.Net) GC and the JVM GC rather than the languages themselves. Both are subject to change and the specification of their behaviour loose to allow this to be changed without it affecting the correctness of programs. There are some historical differences largely due to .Net being designed with lessons from the evolution of the java (and other gc based platforms). In the following do not assume that the .Net one was in some way superior because it included functionality from the beginning, it is simply the result of coming later. A notable publicly visible difference is that the MS GC exposes its generational nature (via the GC api) this is likely to remain true for some time since this is an obvious approach to take based on the behaviour that most programs exhibit: Most allocations are extremely short lived. Initial JVM's did not have generational garbage collectors though this feature was swiftly added. The first generational collectors implemented by Sun Oracle and others tended to be Mark and Sweep. It was realized that a mark-sweep-compact approach would lead to much better memory locality justifying the additional copying overhead. The CLR runtime debuted with this behaviour. A difference between Sun Oracle's and Microsoft's GC implementation 'ethos' is one of configurability. Sun 's provides a vast number of options (at the command line) to tweaks aspects of the GC or switch it between different modes. Many options are of the -X or -XX to indicate their lack of support across different versions or vendors. The CLR by contrast provides next to no configurability; your only real option is the use of the server or client collectors which optimise for throughput verses latency respectively. Active research in GC strategies is ongoing in both companies (and in open source implementations) current approaches being used in the most recent GC implementations are per thread eden areas (improving locality and allowing the eden collection…

http://stackoverflow.com/a/33446821
score: 3
type: Answer
upvote count: 3
has comment: http://stackoverflow.com/comment/54681837
has body: try creating both /*by default beanutils copyproperties looks for below method if you use either apache or spring flavour of beanutils. always prefer using apache 1.9.2 ( fixed many bugs) but bit slow compared with spring beanutils.*/ public Boolean getProperty() { return property; } //which is used by some frameworks public Boolean isProperty() { return property; }
downvote count: 0
answers question: http://stackoverflow.com/q/614734

http://stackoverflow.com/q/576918
favorite count: 0
has answer: http://stackoverflow.com/a/577106
has answer: http://stackoverflow.com/a/576946
possible better answer: http://stackoverflow.com/a/576927
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/576927
tagged with: reflection
has answer: http://stackoverflow.com/a/576945
has answer: http://stackoverflow.com/a/577007
tagged with: java
score: 23
tagged with: methods
downvote count: 1
upvote count: 24
type: Question
has title: How do I intercept a method invocation with standard java features (no AspectJ etc)?
accepted answer: http://stackoverflow.com/a/577106
has answer: http://stackoverflow.com/a/577014
answer count: 7
has answer: http://stackoverflow.com/a/12053269
has body: I want to intercept all method invocations to some class MyClass to be able to react on some setter-invocations. I tried to use dynamic proxies, but as far as I know, this only works for classes implementing some interface. But MyClass does not have such an interface. Is there any other way, besides implementing a wrapper class, that delegates all invocations to a member, which is an instance of the MyClass or besided using AOP?

http://stackoverflow.com/a/383554
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/383551
has comment: http://stackoverflow.com/comment/25320055
downvote count: 14
has comment: http://stackoverflow.com/comment/82242861
type: Answer
score: 41
has comment: http://stackoverflow.com/comment/211310
upvote count: 55
has body: It's virtual machine dependent.
has comment: http://stackoverflow.com/comment/242197
accepted answer of: http://stackoverflow.com/q/383551

http://stackoverflow.com/a/497595
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/497552
type: Answer
answers question: http://stackoverflow.com/q/497552
score: 4
has body: As far as I remember you cant be certain that the stateless bean is global enough for you to keep data in static fields. There exist several caching frameworks that would help you with this. Maybe memcache? EDIT: http://java.sun.com/blueprints/qanda/ejb_tier/restrictions.html#static_fields says: Nonfinal static class fields are disallowed in EJBs because such fields make an enterprise bean difficult or impossible to distribute
upvote count: 4

http://stackoverflow.com/comment/903636
type: Comment
score: 0
comment on: http://stackoverflow.com/a/455546
has text: I highly recommend that entry as well -- correlates well with my experiences.
type: AnswerComment

http://stackoverflow.com/q/642897
has answer: http://stackoverflow.com/a/644859
tagged with: element
has answer: http://stackoverflow.com/a/3675366
duplicate of: http://stackoverflow.com/q/112503
has body: Is there any fast (and nice looking) way to remove an element from an array in Java?
answer count: 15
favorite count: 0
has answer: http://stackoverflow.com/a/642914
has answer: http://stackoverflow.com/a/646321
has answer: http://stackoverflow.com/a/642923
has answer: http://stackoverflow.com/a/642909
score: 176
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/642904
has answer: http://stackoverflow.com/a/3476868
linked to: http://stackoverflow.com/q/112503
has title: Removing an element from an Array (Java)
tagged with: java
has comment: http://stackoverflow.com/comment/79694143
has answer: http://stackoverflow.com/a/642949
has answer: http://stackoverflow.com/a/643027
downvote count: 3
has answer: http://stackoverflow.com/a/644719
has answer: http://stackoverflow.com/a/642913
accepted answer: http://stackoverflow.com/a/644719
upvote count: 179
has answer: http://stackoverflow.com/a/13111620
type: Question
has answer: http://stackoverflow.com/a/642917
possible better answer: http://stackoverflow.com/a/644859
has answer: http://stackoverflow.com/a/644764
tagged with: arrays

http://stackoverflow.com/comment/384007
has text: Yeah, it has zip & tar.gz support as well; btw, if you want to see a horror movie, look the way 7z sdk is implemented :D
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/567559
type: Comment

http://stackoverflow.com/comment/430635
comment on: http://stackoverflow.com/a/424399
type: Comment
score: 3
type: AnswerComment
has text: The Apple Javascript API (JavascriptCore) is in the PrivateFrameworks folder, and thus cannot be used directly from the best of my knowledge.

http://stackoverflow.com/a/582702
has body: Never call setPreferredSize() - it should be a calculation. For example, your ButtonPanel is being set to a fixed preferred size. What if you add I18N support and the user is using a language with very long localizations? What if the user resizes the frame? Check out my article on layout managers for details on how you should really use them. It's from 1999 but still applies: http://java.sun.com/developer/onlineTraining/GUI/AWTLayoutMgr/ Enjoy!
score: 0
answers question: http://stackoverflow.com/q/571026
type: Answer

http://stackoverflow.com/a/518802
has comment: http://stackoverflow.com/comment/9497843
has comment: http://stackoverflow.com/comment/335642
type: Answer
downvote count: 0
score: 7
answers question: http://stackoverflow.com/q/517527
has body: Do you have the statement &lt;global-method-security secured-annotations="enabled" jsr250-annotations="enabled" /&gt; in the same configuration file as the one you defined the MyServiceManager bean? I had the same problem until I turned on debug for org.springframework, and noticed that spring security was only applied on the same file as the ones where global-method-security was defined in.
upvote count: 7

http://stackoverflow.com/a/559500
score: 6
upvote count: 6
answers question: http://stackoverflow.com/q/559433
has comment: http://stackoverflow.com/comment/373586
type: Answer
has body: We use a 64-bit JVM with heaps of around 40&nbsp;Gb. In our application, a lot of data is cached, resulting in a large "old" generation. The default garbage collection settings did not work well and needed some painful tuning in production. Lesson: make sure that you have adequate load-testing infrastructure before you scale up like this. That said, once we got the kinks worked out, GC performance has been great.
downvote count: 0

http://stackoverflow.com/q/528685
type: Question
has answer: http://stackoverflow.com/a/529055
has title: webservices and attribute types
possible better answer: http://stackoverflow.com/a/528801
accepted answer: http://stackoverflow.com/a/529055
score: 0
answer count: 2
has body: I'm currently working on a project which exposes some functions through webservices. Trouble is, some calls should return an array of "Attribute", which is a container class for a database cell. These attributes are, obviously, of different types (int, string, date, timestamp and so on). Nothing really hard, just basic types. By now, the webservice calls simply return an array of Attribute objects which holds the values in strings. Now I haven't coded the webservices, I just want to know if there are some known patterns for design such situations (in order to make advices to the guy which is actually the developer of those webservices).
tagged with: web-services
tagged with: design-patterns
type: AnsweredQuestion
tagged with: java
tagged with: apache-axis
has answer: http://stackoverflow.com/a/528801

http://stackoverflow.com/q/564320
answer count: 9
possible better answer: http://stackoverflow.com/a/564330
has answer: http://stackoverflow.com/a/79397280
has answer: http://stackoverflow.com/a/564330
has answer: http://stackoverflow.com/a/68477375
has answer: http://stackoverflow.com/a/78567255
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/564685
accepted answer: http://stackoverflow.com/a/564334
has answer: http://stackoverflow.com/a/564362
tagged with: java
score: 24
upvote count: 24
type: Question
tagged with: if-statement
has title: Can you store a variable inside a if-clause?
has body: I'm kinda waiting for a 'no' answer on this question. I was interested if you can save a variable at the same time when you checking it in an if-clause. Let's say I have this code. if(foo!=null){ if(foo.getBar()!=null){ Bar bar = foo.getBar(); System.out.println("Success: " + bar); } else { System.out.println("Failure."); } } else { System.out.println("Failure."); } I handling now to "failure" -states independently, even if the outcome is the same. I could get them together like this: if(foo!=null &amp;&amp; foo.getBar()!=null){ Bar bar = foo.getBar(); System.out.println("Success: " + bar); } else { System.out.println("Failure."); } Much neater code already. if foo is null it will stop there and won't try foo.getBar (in the if) so I won't get a NPE. The last thing i would like to enhance, and the main question: Do I really gave to call on foo.getBar() twice? It would be nice to get away from the second identical call if getBar() would be a very heavy operation. So I am wondering if there is somehow possible to do something similiar to this: if(foo!=null &amp;&amp; (Bar bar = foo.getBar())!=null){ Bar bar = foo.getBar(); System.out.println("Success: " + bar); } else { System.out.println("Failure."); } I would have to break it up to two different if's again if I would like to do Bar bar = foo.getBar(); if (bar!=null) ...
has answer: http://stackoverflow.com/a/565237
has answer: http://stackoverflow.com/a/564334
downvote count: 0
has answer: http://stackoverflow.com/a/49430680
tagged with: initialization
favorite count: 0

http://stackoverflow.com/comment/428420
type: AnswerComment
has text: he doesn't have problems with localhost, he has them with 10.0.0.1
comment on: http://stackoverflow.com/a/615400
type: Comment
score: 0

http://stackoverflow.com/comment/341200
type: AnswerComment
has text: (contd.) The question in any specific case is, does the change in markup require updating the translation.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/518140

http://stackoverflow.com/comment/244250
type: AnswerComment
has text: the problem with creating your own interfaces instead of using the standard java ones is that you cant take advantage of the many utility libraries that uses the java interfaces, unless you implemented them as well. IMHO, that is a price too high to pay for deep const-ness.
type: Comment
score: 0
comment on: http://stackoverflow.com/a/416661

http://stackoverflow.com/q/376338
upvote count: 22
linked to: http://stackoverflow.com/q/321864
linked to: http://stackoverflow.com/q/367633
has answer: http://stackoverflow.com/a/376432
has answer: http://stackoverflow.com/a/376365
has title: What are the common undefined behaviours that Java Programmers should know about
has answer: http://stackoverflow.com/a/378077
has body: The same as this question but for java Update Based on the comments and responses of a few people, Its clear that Java has very little undefined behaviour. So I'd like to ask as well what behaviour is not obvious. Please when answering make the distinction between the two :)
has answer: http://stackoverflow.com/a/378121
accepted answer: http://stackoverflow.com/a/376354
answer count: 10
tagged with: undefined
favorite count: 0
has answer: http://stackoverflow.com/a/376368
linked to: http://stackoverflow.com/q/2397984
has answer: http://stackoverflow.com/a/376419
has answer: http://stackoverflow.com/a/14058719
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/376379
score: 21
tagged with: java
has answer: http://stackoverflow.com/a/376379
downvote count: 1
has answer: http://stackoverflow.com/a/376354
has answer: http://stackoverflow.com/a/377997
type: Question

http://stackoverflow.com/comment/22441068
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/494480
has text: Version with LOG.infos replaced with System out calls and imports included here: https://gist.github.com/williamberg/5299998
score: 1

http://stackoverflow.com/a/531400
downvote count: 0
answers question: http://stackoverflow.com/q/528014
score: 3
has body: I think that this not a matter of which servlet container you use, but what you do with the response inside your servlet. If you set your character encoding by calling ServletResponse's setContentType (2.3) or setCharacterEncoding (2.4, 2.5) with parameter null or "" it should work (didn't try myself). But be sure to call the methods named above before calling getWriter, otherwise setting the encoding will have no effect!
upvote count: 3
has comment: http://stackoverflow.com/comment/344917
type: Answer
has comment: http://stackoverflow.com/comment/344959

http://stackoverflow.com/comment/7742173
has text: -1, incorrect: `null instanceof X` (where X is some class known at compile time) will always return `false`.
score: 4
type: Comment
comment on: http://stackoverflow.com/a/4409848
type: AnswerComment

layout
tags question: http://stackoverflow.com/q/549451
tag name: layout
tags question: http://stackoverflow.com/q/502763
tags question: http://stackoverflow.com/q/539567
tags question: http://stackoverflow.com/q/360877
type: Tag
tags question: http://stackoverflow.com/q/428256
tags question: http://stackoverflow.com/q/519918

http://stackoverflow.com/comment/51330948
type: Comment
has text: Why is reference to 700+ lines long source file above straight answer with almost 500 vole ups ?
type: AnswerComment
comment on: http://stackoverflow.com/a/28428698
score: 5

http://stackoverflow.com/comment/12089224
type: Comment
score: 2
comment on: http://stackoverflow.com/a/456176
type: AnswerComment
has text: If you like StringTemplate, you may like Google Soy Templates even better: https://developers.google.com/closure/templates/ Also, what drozzy said.

http://stackoverflow.com/q/359970
tagged with: ms-word
favorite count: 0
accepted answer: http://stackoverflow.com/a/476675
upvote count: 2
has body: On the web page, it looks like there is no current development in the old style .doc. Is it good enough to create complex documents? Can it read all .docs without crashing? What features do (not) work? I am not currently interested in the XML based formats, as I don't control the client side. The excel support seems to be much better.
tagged with: ms-office
score: 2
type: AnsweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/476675
possible better answer: http://stackoverflow.com/a/362470
has title: How good is Apache POI word support?
has answer: http://stackoverflow.com/a/368768
has answer: http://stackoverflow.com/a/362470
answer count: 3
tagged with: apache
downvote count: 0

http://stackoverflow.com/a/508363
score: 0
type: Answer
answers question: http://stackoverflow.com/q/507602
has comment: http://stackoverflow.com/comment/32353365
upvote count: 4
downvote count: 4
has body: I've done something a bit different. Not the best, but it works for me. Maybe it could be "genericized". private static final Object[][] ENTRIES = { {new Integer(1), "one"}, {new Integer(2), "two"}, }; private static final Map myMap = newMap(ENTRIES); private static Map newMap(Object[][] entries) { Map map = new HashMap(); for (int x = 0; x &lt; entries.length; x++) { Object[] entry = entries[x]; map.put(entry[0], entry[1]); } return map; }

http://stackoverflow.com/a/577386
type: Answer
accepted answer of: http://stackoverflow.com/q/577379
upvote count: 7
has body: From this thread: Class.getClassLoader() returns the ClassLoader that loaded the class it is invoked on. Thread.getContextClassLoader() returns the ClassLoader set as the context ClassLoader for the Thread it is invoked on, which can be different from the ClassLoader that loaded the Thread class itself if the Thread's setContextClassLoader(ClassLoader) method has been invoked. This can be used to allow the object starting a thread to specify a ClassLoader that objects running in the thread should use, but the cooperation of some of those objects is required for that to work. So if you are wondering why there are 3 API calls Thread&lt;instance&gt;.getContextClassLoader() Thread&lt;instance&gt;.getClassLoader() Class&lt;instance&gt;.getClassLoader() , you can find in this Find a way out of the ClassLoader maze an answer. Why do thread context classloaders exist in the first place? They were introduced in J2SE without much fanfare. A certain lack of proper guidance and documentation from Sun Microsystems likely explains why many developers find them confusing. In truth, context classloaders provide a back door around the classloading delegation scheme also introduced in J2SE. Normally, all classloaders in a JVM are organized in a hierarchy such that every classloader (except for the primordial classloader that bootstraps the entire JVM) has a single parent. [...] To make matters worse, certain application servers set context and current classloaders to different ClassLoader instances that have the same classpaths and yet are not related as a delegation parent and child.
score: 7
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/577379

http://stackoverflow.com/a/1998619
type: Answer
has comment: http://stackoverflow.com/comment/12599625
downvote count: 4
upvote count: 0
has body: If you need logging in your app then youve probably done smething really wrong. I would argue that reporting the occasional problem is ok, but having debug, info etc statements in lots of classes with logic is plain wrong. Any large application with logging statements in most of its logic filled classes is going to amount to information overload even if one picks just the right loggers on. Most of the time the information will be incomplete, noisy or the actual information you need is plain missing. Im basically saying that you should only need to write debug statements to inform the user about program reactions to external factors formating problem in a text based config file. Problems with opening or locating a required file.
has comment: http://stackoverflow.com/comment/15511357
has comment: http://stackoverflow.com/comment/15514395
answers question: http://stackoverflow.com/q/607863
score: -4

http://stackoverflow.com/comment/274994
comment on: http://stackoverflow.com/a/444924
has text: @SteveB: Read the question: " I know for a fact that none of the data members have changed, so the only barrier is the serialVersionUID check."
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/2107261
type: Answer
downvote count: 0
score: 1
has body: I would strongly consider also having a look at springs ReflectionUtils class. Very powerful reflection handling.
answers question: http://stackoverflow.com/q/364523
upvote count: 1

http://stackoverflow.com/comment/311625
has text: Is your DBDiagnostics class file in a .JAR, or is it just in the same directory you're trying to run from?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/495893
score: 0

http://stackoverflow.com/q/398953
has answer: http://stackoverflow.com/a/400918
has answer: http://stackoverflow.com/a/54354372
upvote count: 36
has title: What is the preferred Throwable to use in a private utility class constructor?
has answer: http://stackoverflow.com/a/398960
has answer: http://stackoverflow.com/a/398975
accepted answer: http://stackoverflow.com/a/398960
has answer: http://stackoverflow.com/a/399074
tagged with: coding-style
type: AnsweredQuestion
tagged with: throwable
downvote count: 0
has answer: http://stackoverflow.com/a/51349251
tagged with: java
has body: Effective Java (Second Edition), Item 4, discusses using private constructors to enforce noninstantiability. Here's the code sample from the book: public final class UtilityClass { private UtilityClass() { throw new AssertionError(); } } However, AssertionError doesn't seem like the right thing to throw. Nothing is being "asserted", which is how the API defines the use of AssertionError. Is there a different Throwable that's typically in this situation? Does one usually just throw a general Exception with a message? Or is it common to write a custom Exception for this? It's pretty trivial, but more than anything I guess I'm just curious about it from a style and standards perspective.
type: Question
answer count: 8
has answer: http://stackoverflow.com/a/398967
has answer: http://stackoverflow.com/a/399103
favorite count: 0
possible better answer: http://stackoverflow.com/a/400918
score: 36
linked to: http://stackoverflow.com/q/22053306
has comment: http://stackoverflow.com/comment/39034222

http://stackoverflow.com/a/1403331
answers question: http://stackoverflow.com/q/419524
type: Answer
has body: You really should check out the Orange data mining toolkit. It comes with a drag and drop gui as well as a Python API.
score: 0

http://stackoverflow.com/a/433982
has body: If you're writing a lot of data, then it sounds like you may be disk bound. Take a look at your disk io stats on the machine, and if that's actually the bottleneck, either find hardware with better io, or figure out how to do less writes.
type: Answer
downvote count: 0
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/433973

http://stackoverflow.com/comment/330238
type: AnswerComment
type: Comment
score: 0
comment on: http://stackoverflow.com/a/498775
has text: For bonus points: what is the value of i after executing "i = i++;"?

http://stackoverflow.com/q/465284
answer count: 3
upvote count: 1
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/467155
type: UnansweredQuestion
tagged with: sockets
has title: Are localhost sockets affected when public IP address changes
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/465303
has answer: http://stackoverflow.com/a/466259
type: Question
has comment: http://stackoverflow.com/comment/1049240
has body: I have implemented some remote method invocation using sockets opened on 127.0.0.1. During programs run, computers public IP address changes, because my program connects to net via GPRS modem from time to time. Can you tell me how does that affect my opened sockets? Java version is 1.3, windows platform. There are several network interfaces and their ip address changes over time (+VPN connection is established). But client and server are on the same machine, and use 127.0.0.1 to establish connection over sockets. Is there any way that this address changing over these network interfaces affects 127.0.0.1 communication.
has comment: http://stackoverflow.com/comment/283611

http://stackoverflow.com/a/534697
type: Answer
score: 8
downvote count: 0
has body: I was searching for another issue concerning JNA and structs, and Google redirected me here. I hope this helps. From JNA API To pass a structure by value, first define the structure, then define an empty class from that which implements Structure.ByValue. Use the ByValue class as the argument or return type. // Original C code typedef struct _Point { int x, y; } Point; Point translate(Point pt, int dx, int dy); // Equivalent JNA mapping class Point extends Structure { public static class ByValue extends Point implements Structure.ByValue { } public int x, y; } Point.ByValue translate(Point.ByValue pt, int x, int y); ... Point.ByValue pt = new Point.ByValue(); Point result = translate(pt, 100, 100);
upvote count: 8
answers question: http://stackoverflow.com/q/494325

http://stackoverflow.com/a/514323
has comment: http://stackoverflow.com/comment/329608
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/512266
has body: Another way to write this is public void setExpireTimeInDays(int expireTimeInDays) { expireTimeInMilliseconds = (long) expireTimeInDays * 24 * 60 * 60 * 1000; } or public void setExpireTimeInDays(int expireTimeInDays) { expireTimeInMilliseconds = expireTimeInDays * 24L * 60 * 60 * 1000; }
downvote count: 0

http://stackoverflow.com/a/26296972
score: 9
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/604424
has body: To add to the previous answers, and address some of the discussions around nulls and NPE I'm using Guava Optionals to handle absent/invalid cases. This works great for URI and parameter parsing. public enum E { A,B,C; public static Optional&lt;E&gt; fromString(String s) { try { return Optional.of(E.valueOf(s.toUpperCase())); } catch (IllegalArgumentException|NullPointerException e) { return Optional.absent(); } } } For those not aware, here's some more information on avoiding null with Optional.
upvote count: 9

http://stackoverflow.com/comment/295488
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/477438
has text: Thank you. Nice tools to be used next to the main ones. :)

http://stackoverflow.com/q/629804
tagged with: collections
has comment: http://stackoverflow.com/comment/442509
has answer: http://stackoverflow.com/a/631167
type: Question
has comment: http://stackoverflow.com/comment/71866930
possible better answer: http://stackoverflow.com/a/632525
has body: What is the most efficient Java Collections library? A few years ago, I did a lot of Java and had the impression back then that trove is the best (most efficient) Java Collections implementation. But when I read the answers to the question "Most useful free Java libraries?" I noticed that trove is hardly mentioned. So which Java Collections library is best now? UPDATE: To clarify, I mostly want to know what library to use when I have to store millions of entries in a hash table etc. (need a small runtime and memory footprint).
upvote count: 146
accepted answer: http://stackoverflow.com/a/629833
has comment: http://stackoverflow.com/comment/442574
has answer: http://stackoverflow.com/a/629852
has answer: http://stackoverflow.com/a/629928
has title: What is the most efficient Java Collections library?
has comment: http://stackoverflow.com/comment/11610421
has answer: http://stackoverflow.com/a/630034
has comment: http://stackoverflow.com/comment/34459684
has answer: http://stackoverflow.com/a/2569591
has answer: http://stackoverflow.com/a/630067
favorite count: 0
answer count: 12
has answer: http://stackoverflow.com/a/629833
downvote count: 8
has answer: http://stackoverflow.com/a/632525
has answer: http://stackoverflow.com/a/630864
has comment: http://stackoverflow.com/comment/38832174
has answer: http://stackoverflow.com/a/629867
type: AnsweredQuestion
score: 138
has answer: http://stackoverflow.com/a/9221261
tagged with: java
has answer: http://stackoverflow.com/a/636993

http://stackoverflow.com/comment/282319
type: AnswerComment
has text: Learning C is much easier than C++, you don't have inheritance, templates, references, everything is whot you see, but I can't argue with you because your only argument is that C is the bad way (which is subjective and is a personal opinion).
comment on: http://stackoverflow.com/a/463636
type: Comment
score: 0

http://stackoverflow.com/comment/440958
has text: It starts with a slash if you want it absolute within the classpath and doesn't start with a slash if you want it relative to the class.
comment on: http://stackoverflow.com/a/628294
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/559233
type: Answer
upvote count: 12
has body: This is kind of Flex/BlazeDS specific, but here's the solution I've come up with. Sorry if answering my own question is a faux pas. HttpServletRequest request = flex.messaging.FlexContext.getHttpRequest(); Cookie[] cookies = request.getCookies(); for (Cookie c:cookies) { log.debug(String.format("Cookie: %s, %s, domain: %s",c.getName(), c.getValue(),c.getDomain())); } It works, I get the cookies. My problem was looking to Spring - BlazeDS had it. Spring probably does too, but I still don't know how to get to it.
downvote count: 0
answers question: http://stackoverflow.com/q/559155
score: 12

itext
tags question: http://stackoverflow.com/q/491752
tags question: http://stackoverflow.com/q/626632
tag name: itext
tags question: http://stackoverflow.com/q/425590
tags question: http://stackoverflow.com/q/367965
tags question: http://stackoverflow.com/q/431966
type: Tag
tags question: http://stackoverflow.com/q/408042
tags question: http://stackoverflow.com/q/595684

http://stackoverflow.com/comment/289825
score: 0
type: Comment
comment on: http://stackoverflow.com/a/472138
type: AnswerComment
has text: As I said, syntactical sugar. I can't see any benefit or usefulness, but yes I am seeing coding nightmare, bad practices, and lot of refactoring.

http://stackoverflow.com/comment/23259378
type: AnswerComment
comment on: http://stackoverflow.com/a/534501
score: 8
has text: [This article](http://www.javapractices.com/topic/TopicAction.do?Id=205) explains quite nicely why it is better to use _package-by-feature_ instead of _package-by-layer_.
type: Comment

http://stackoverflow.com/comment/306485
type: Comment
has text: A Set might be better. For example, a red-black tree will have excellent search characteristics for finding whether a state has been visited, compared to an array list.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/489381

http://stackoverflow.com/comment/76638391
type: Comment
score: 1
comment on: http://stackoverflow.com/a/44811546
has text: The question was about creating an array of the type of the generic type parameter `T`, not an array of some parameterized type.
type: AnswerComment

http://stackoverflow.com/comment/394344
type: Comment
has text: it seems pretty clear from the error message that is the issue. I did not edit the code at all...this is straight from the book's code. I'll update the question with more details on the code.
comment on: http://stackoverflow.com/a/582458
score: 0
type: AnswerComment

http://stackoverflow.com/q/551838
downvote count: 0
has comment: http://stackoverflow.com/comment/363529
score: 1
favorite count: 0
has body: class HelloObject { void speak() { System.out.println("Hello (from object)!"); } } class HelloTester { public static void main(String[] args) { HelloObject object = new HelloObject(); object.speak(); } } When I change the "HelloTester" class name to something like "HelloTester2", the program suddenly works. The class file is called ClassesBegin.java. Why does the java program not work when I try to change the name of the class? EDIT: Sorry I should have clarified more. I changed the class name to HelloTestera and this is the error I get: Exception in thread "main" java.lang.NoClassDefFoundError: HelloTester But it works even when the file name has nothing to do with a class name. It works with HelloTester when the file name is ClassesBegin.java
answer count: 5
has answer: http://stackoverflow.com/a/551883
has comment: http://stackoverflow.com/comment/364243
has answer: http://stackoverflow.com/a/552288
has comment: http://stackoverflow.com/comment/363503
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/551861
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/551857
tagged with: java
has title: Error when I try to change the class name
tagged with: class
has answer: http://stackoverflow.com/a/551849

memory-management
tags question: http://stackoverflow.com/q/641462
tags question: http://stackoverflow.com/q/565871
tags question: http://stackoverflow.com/q/433406
tags question: http://stackoverflow.com/q/405364
tags question: http://stackoverflow.com/q/366658
tags question: http://stackoverflow.com/q/511013
tags question: http://stackoverflow.com/q/627784
type: Tag
tags question: http://stackoverflow.com/q/605592
tags question: http://stackoverflow.com/q/477881
tags question: http://stackoverflow.com/q/532521
tags question: http://stackoverflow.com/q/426005
tags question: http://stackoverflow.com/q/555580
tags question: http://stackoverflow.com/q/441400
tag name: memory-management

http://stackoverflow.com/a/30377830
score: 14
upvote count: 14
answers question: http://stackoverflow.com/q/531779
has body: Short answer s1 == "" // No! s1.equals("") // Ok s1.isEmpty() // Ok: fast (from Java 1.6) "".equals(s1) // Ok: null safe I would assure s1 is not null and use isEmpty(). Note: empty string "" is not a special String, but counts as any other "value". A little longer answer References to String objects depend on the way they are created: String objects created using the operator new always refer to separate objects, even if they store the same sequence of characters so: String s1 = new String(""); String s2 = new String(""); s1 == s2 // false String objects created using the operator = followed by a value enclosed whitin double quotes (= "value") are stored in a pool of String objects: before creating a new object in the pool, an object with the same value is searched in the pool and referenced if found. String s1 = ""; // "" added to the pool String s2 = ""; // found "" in the pool, s2 will reference the same object of s1 s1 == s2 // true The same is true for strings created enclosing a value whitin double quotes ("value"), so: String s1 = ""; s1 == ""; //true String equals method checks for both, that's why it is safe to write: s1.equals(""); This expression may throw a NullPointerException if s1 == null, so, if you don't check for null before, it is safer to write: "".equals(s1); Please read also How do I compare strings in Java? Hope it may help not so experienced users, who may find other answers a bit too complicated. :)
downvote count: 0
type: Answer

multithreading
tags question: http://stackoverflow.com/q/532360
tags question: http://stackoverflow.com/q/484182
tags question: http://stackoverflow.com/q/641514
type: Tag
tags question: http://stackoverflow.com/q/427306
tags question: http://stackoverflow.com/q/625241
tags question: http://stackoverflow.com/q/536327
tags question: http://stackoverflow.com/q/609826
tags question: http://stackoverflow.com/q/451576
tags question: http://stackoverflow.com/q/573194
tags question: http://stackoverflow.com/q/631645
tags question: http://stackoverflow.com/q/468266
tags question: http://stackoverflow.com/q/541487
tags question: http://stackoverflow.com/q/466599
tags question: http://stackoverflow.com/q/464214
tags question: http://stackoverflow.com/q/536073
tags question: http://stackoverflow.com/q/564589
tags question: http://stackoverflow.com/q/573826
tags question: http://stackoverflow.com/q/461896
tags question: http://stackoverflow.com/q/491323
tags question: http://stackoverflow.com/q/533783
tags question: http://stackoverflow.com/q/554339
tags question: http://stackoverflow.com/q/462697
tags question: http://stackoverflow.com/q/520860
tags question: http://stackoverflow.com/q/442564
tags question: http://stackoverflow.com/q/629315
tags question: http://stackoverflow.com/q/512595
tags question: http://stackoverflow.com/q/497063
tags question: http://stackoverflow.com/q/646700
tags question: http://stackoverflow.com/q/574240
tags question: http://stackoverflow.com/q/442589
tags question: http://stackoverflow.com/q/467224
tags question: http://stackoverflow.com/q/607112
tags question: http://stackoverflow.com/q/471311
tags question: http://stackoverflow.com/q/584234
tags question: http://stackoverflow.com/q/640464
tags question: http://stackoverflow.com/q/453776
tags question: http://stackoverflow.com/q/473111
tags question: http://stackoverflow.com/q/544341
tags question: http://stackoverflow.com/q/390242
tags question: http://stackoverflow.com/q/416183
tags question: http://stackoverflow.com/q/429089
tags question: http://stackoverflow.com/q/538872
tags question: http://stackoverflow.com/q/603363
tags question: http://stackoverflow.com/q/497176
tags question: http://stackoverflow.com/q/557298
tags question: http://stackoverflow.com/q/555977
tags question: http://stackoverflow.com/q/426758
tags question: http://stackoverflow.com/q/634102
tags question: http://stackoverflow.com/q/469089
tags question: http://stackoverflow.com/q/619675
tags question: http://stackoverflow.com/q/616487
tags question: http://stackoverflow.com/q/586000
tags question: http://stackoverflow.com/q/440036
tags question: http://stackoverflow.com/q/566582
tags question: http://stackoverflow.com/q/511857
tags question: http://stackoverflow.com/q/541194
tags question: http://stackoverflow.com/q/385195
tags question: http://stackoverflow.com/q/605284
tags question: http://stackoverflow.com/q/467324
tags question: http://stackoverflow.com/q/578904
tags question: http://stackoverflow.com/q/591627
tags question: http://stackoverflow.com/q/565893
tags question: http://stackoverflow.com/q/534919
tags question: http://stackoverflow.com/q/604667
tags question: http://stackoverflow.com/q/519099
tags question: http://stackoverflow.com/q/613724
tags question: http://stackoverflow.com/q/641906
tags question: http://stackoverflow.com/q/424516
tags question: http://stackoverflow.com/q/375129
tags question: http://stackoverflow.com/q/539076
tag name: multithreading
tags question: http://stackoverflow.com/q/365743
tags question: http://stackoverflow.com/q/646990
tags question: http://stackoverflow.com/q/510270
tags question: http://stackoverflow.com/q/583800

http://stackoverflow.com/a/437954
score: 0
accepted answer of: http://stackoverflow.com/q/434818
type: Answer
has body: I added the following jar's and the console now opens and I can see the problems. Hope this helps someone else. org.eclipse.update.configurator_3.2.201.R34x_v20080819.jar org.eclipse.equinox.app_1.1.0.v20080421-2006.jar org.eclipse.equinox.common_3.4.0.v20080421-2006.jar org.eclipse.equinox.launcher_1.0.101.R34x_v20080819.jar org.eclipse.equinox.preferences_3.2.201.R34x_v20080709.jar org.eclipse.equinox.registry_3.4.0.v20080516-0950.jar org.eclipse.osgi.services_3.1.200.v20071203.jar org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar org.eclipse.ui.workbench_3.4.1.M20080827-0800a.jar org.eclipse.ui_3.4.1.M20080910-0800.jar
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/434818

http://stackoverflow.com/a/559432
downvote count: 0
answers question: http://stackoverflow.com/q/545831
type: Answer
upvote count: 1
has body: Try specifying the build directory in your pom. 4.0.0 com.mycomp.build build-base 1.0-SNAPSHOT pom /path/to/jboss/server/default/deploy
score: 1

http://stackoverflow.com/a/2210992
has body: There's yet another resource at Codehaus for a very robust list of archetypes out there on the 'net. http://docs.codehaus.org/display/MAVENUSER/Archetypes+List
has comment: http://stackoverflow.com/comment/5699750
answers question: http://stackoverflow.com/q/635543
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/3966791

http://stackoverflow.com/comment/8653006
type: AnswerComment
type: Comment
has text: @Jeremy: it was interesting, but I am unable to understand how to translate the old `dev.eclipse.org/newslists` URL into a new `www.eclipse.org/forum` one...
comment on: http://stackoverflow.com/a/479078
score: 0

http://stackoverflow.com/a/448272
type: Answer
has comment: http://stackoverflow.com/comment/269339
downvote count: 1
upvote count: 40
has comment: http://stackoverflow.com/comment/269311
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/448258
score: 39
has body: (This answer applies to C# and Java. I believe C++ works differently on this matter.) Calling a virtual method in a constructor is indeed dangerous, but sometimes it can end up with the cleanest code. I would try to avoid it where possible, but without bending the design hugely. (For instance, the "initialize later" option prohibits immutability.) If you do use a virtual method in the constructor, document it very strongly. So long as everyone involved is aware of what it's doing, it shouldn't cause too many problems. I would try to limit the visibility though, as you've done in your first example. EDIT: One thing which is important here is that there's a difference between C# and Java in order of initialization. If you have a class such as: public class Child : Parent { private int foo = 10; protected override void ShowFoo() { Console.WriteLine(foo); } } where the Parent constructor calls ShowFoo, in C# it will display 10. The equivalent program in Java would display 0.
answers question: http://stackoverflow.com/q/448258

http://stackoverflow.com/q/588546
possible better answer: http://stackoverflow.com/a/588558
has answer: http://stackoverflow.com/a/588557
score: 29
has answer: http://stackoverflow.com/a/588558
type: Question
has answer: http://stackoverflow.com/a/590387
has answer: http://stackoverflow.com/a/588579
has answer: http://stackoverflow.com/a/589913
accepted answer: http://stackoverflow.com/a/588557
has body: After providing some answers here, and reading some comments, it would seem that, in practice IOException is never thrown on close for file I/O. Are there any cases in which calling close on a Stream/Reader/Writer actually throws an IOException? If an exception is actually thrown, how should it be dealt with?
downvote count: 0
has title: Does close ever throw an IOException?
favorite count: 0
linked to: http://stackoverflow.com/q/5649500
answer count: 5
has comment: http://stackoverflow.com/comment/93220674
upvote count: 29
type: AnsweredQuestion
tagged with: ioexception
tagged with: java

http://stackoverflow.com/a/522955
has body: This script seems to do the trick on all major browsers: http://www.pinlady.net/PluginDetect/JavaDetect.htm
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/522158
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/365922
has comment: http://stackoverflow.com/comment/337960

http://stackoverflow.com/a/610098
type: Answer
has body: I'll focus on using a template engine, because that is what I have most experience with. It depends on what you really want to do. Servlets in combination with Velocity (or FreeMarker for that matter) offer a very good seperation of logic and presentation. Templates are harder to test, because you would need to evaluate the template to be able to judge wheter the HTML (or whatever else the output format is) is correct. For JSP this can be done in your IDE of choice. The big advantage of templates is that you can store these completely outside of your application and even update them while your application is running. This is something that is a little harder to do with JSP, although hot deployment comes pretty close. Reusable components can be created by using the include functionality of the template engine.
upvote count: 3
downvote count: 0
score: 3
answers question: http://stackoverflow.com/q/610062

http://stackoverflow.com/q/381586
tagged with: java
has answer: http://stackoverflow.com/a/382375
tagged with: eclipse
tagged with: debugging
type: UnansweredQuestion
has body: I have a piece of Java code I can't edit which I want to debug. The issue is that one of my 10,000 records has a data error and is causing the application to crash. I can remote debug the live application and add watch which would pick up the id of the record as each is processed. The problem is when the "bad record" is processed and the method is exited the value held in the watch is lost so I don't know which record it was that causes the problem. Is there any way of storing/printing the value held in the watch Thanks
has title: outputting the value of a "Watch" in Eclipse to a log file
downvote count: 0
score: 1
favorite count: 0
type: Question
answer count: 2
upvote count: 1
tagged with: watch
has answer: http://stackoverflow.com/a/384095

http://stackoverflow.com/a/542387
downvote count: 0
upvote count: 2
type: Answer
has body: Swing is your best choice if you're stuck choosing between Swing and AWT. If you have the flexibility, I would at least consider SWT. It's faster, matches the platform look and feel, and seems to have fewer porting hurdles and regression problems from release to release. There is a small hurdle in setting up your first project (getting the right jars and such), but other than that, it's no more difficult to work in.
has comment: http://stackoverflow.com/comment/13522876
score: 2
answers question: http://stackoverflow.com/q/542234

http://stackoverflow.com/a/530576
answers question: http://stackoverflow.com/q/530441
upvote count: 1
score: 1
has body: Maybe I'm missing something here, but couldn't you just go without any regular expression and ignore anything for which this is true: string.contains("/ HTTP") Because a file path will never end with a slash.
downvote count: 0
type: Answer

http://stackoverflow.com/a/456167
has body: One general purpose way which works for many systems is simply to have a cron job which performs a periodic wget against your app.
type: Answer
has comment: http://stackoverflow.com/comment/275925
answers question: http://stackoverflow.com/q/456162
score: 2
upvote count: 3
downvote count: 1

http://stackoverflow.com/comment/276572
type: Comment
has text: If you use your iterator in a for-loop, the for-loop content would not be synchronized and your iterator would probably throw a concurrent modification exception if someone use put between 'next's. Hence, you need extra synchronization (there are other options as well of course).
comment on: http://stackoverflow.com/a/453698
score: 0
type: AnswerComment

http://stackoverflow.com/comment/52637377
has text: Note: In java, ints are 32 bits and longs are 64 bits (regardless of the processor architecture), the original question was related to java, maybe the tag got added later. I am not sure though, whether on a 64 bit processor the write will be atomic or not. It will depend on JVM to JVM.
type: AnswerComment
comment on: http://stackoverflow.com/a/517539
type: Comment
score: 3

http://stackoverflow.com/a/35452697
has comment: http://stackoverflow.com/comment/79711983
has comment: http://stackoverflow.com/comment/79719378
has comment: http://stackoverflow.com/comment/123510176
type: Answer
has comment: http://stackoverflow.com/comment/77514340
upvote count: 55
has comment: http://stackoverflow.com/comment/79730906
has comment: http://stackoverflow.com/comment/63620647
score: 54
answers question: http://stackoverflow.com/q/468789
has comment: http://stackoverflow.com/comment/87845634
has comment: http://stackoverflow.com/comment/62941153
has comment: http://stackoverflow.com/comment/62969386
has body: Path class introduced in Java 7 adds new alternatives, like the following: /** * * Checks if a string is a valid path. * Null safe. * * Calling examples: * isValidPath("c:/test"); //returns true * isValidPath("c:/te:t"); //returns false * isValidPath("c:/te?t"); //returns false * isValidPath("c/te*t"); //returns false * isValidPath("good.txt"); //returns true * isValidPath("not|good.txt"); //returns false * isValidPath("not:good.txt"); //returns false * */ public static boolean isValidPath(String path) { try { Paths.get(path); } catch (InvalidPathException | NullPointerException ex) { return false; } return true; } Edit: Note Ferrybig's comment : "The only disallowed character in a file name on Linux is the NUL character, this does work under Linux."
has comment: http://stackoverflow.com/comment/90855916
has comment: http://stackoverflow.com/comment/63608625
has comment: http://stackoverflow.com/comment/80243360
downvote count: 1
has comment: http://stackoverflow.com/comment/79730757
has comment: http://stackoverflow.com/comment/71024475
has comment: http://stackoverflow.com/comment/90854371
has comment: http://stackoverflow.com/comment/77527147
has comment: http://stackoverflow.com/comment/98546017
has comment: http://stackoverflow.com/comment/80243430

http://stackoverflow.com/q/636172
accepted answer: http://stackoverflow.com/a/737323
tagged with: servlets
tagged with: security
answer count: 3
has answer: http://stackoverflow.com/a/662917
downvote count: 0
has body: I need to interface an existing application with Acegi/Spring security. In order to get started I am looking for one simple piece of information: in this context, will HttpServletRequest.getUserPrincipal() called from my application properly return the username obtained through Spring (as opposed to using Spring-specific objects)? I have Googled conflicting information on this. I assume that if Acegi is implemented with filters, it is able to overload the Servlet API's getUserPrincipal(), right? Subsidiary question: if this is not the case by default, is there any way to turn it on? Thanks, -Erik
tagged with: spring-security
favorite count: 0
has title: Does Acegi/Spring security support getUserPrincipal()?
has answer: http://stackoverflow.com/a/638484
tagged with: spring
has answer: http://stackoverflow.com/a/737323
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/638484
tagged with: java
type: Question
score: 5
upvote count: 5

http://stackoverflow.com/comment/273978
has text: They may not be Java specific, but it's easy to forget those
type: Comment
score: 0
comment on: http://stackoverflow.com/a/453579
type: AnswerComment

http://stackoverflow.com/comment/58375157
has text: You can also use the @Resource annotation instead of Autowired. You don't need to require the autowiring explicitly then, and you're binding to Spring a little less.
type: Comment
score: 7
type: AnswerComment
comment on: http://stackoverflow.com/a/1795931

http://stackoverflow.com/a/2817176
downvote count: 0
has comment: http://stackoverflow.com/comment/132647339
has body: Let's say we need to use the class Classname that is contained in the jar file org.example.jar And your source is in the file mysource.java Like this: import org.example.Classname; public class mysource { public static void main(String[] argv) { ...... } } First, as you see, in your code you have to import the classes. To do that you need import org.example.Classname; Second, when you compile the source, you have to reference the jar file. Please note the difference in using : and ; while compiling If you are under a unix like operating system: javac -cp '.:org.example.jar' mysource.java If you are under windows: javac -cp .;org.example.jar mysource.java After this, you obtain the bytecode file mysource.class Now you can run this : If you are under a unix like operating system: java -cp '.:org.example.jar' mysource If you are under windows: java -cp .;org.example.jar mysource
type: Answer
answers question: http://stackoverflow.com/q/460364
has comment: http://stackoverflow.com/comment/36753391
has comment: http://stackoverflow.com/comment/13348309
score: 199
upvote count: 199
has comment: http://stackoverflow.com/comment/36753177
has comment: http://stackoverflow.com/comment/24118340
has comment: http://stackoverflow.com/comment/125801359

http://stackoverflow.com/a/44659512
downvote count: 0
score: 4
has body: You may use StickyMap and MapEntry from Cactoos: private static final Map&lt;String, String&gt; MAP = new StickyMap&lt;&gt;( new MapEntry&lt;&gt;("name", "Jeffrey"), new MapEntry&lt;&gt;("age", "35") );
answers question: http://stackoverflow.com/q/507602
type: Answer
upvote count: 4

http://stackoverflow.com/q/634962
has answer: http://stackoverflow.com/a/644600
has answer: http://stackoverflow.com/a/634993
downvote count: 0
has answer: http://stackoverflow.com/a/11345666
favorite count: 0
accepted answer: http://stackoverflow.com/a/634993
has title: Microsoft Team System and Java
possible better answer: http://stackoverflow.com/a/635806
answer count: 5
has answer: http://stackoverflow.com/a/635806
tagged with: tfs
type: AnsweredQuestion
score: 3
has body: We're starting a project written in Java in a company which works purely on MS technologies. Microsoft Team System is used as source control tool. A question is whether we should try to integrate Eclipse with MTS (which makes sense from the top level as there would be still a single repository for the company) or we should try to setup another source control tool - most likely Subversion (which makes sense from developers perspective)? Anyone tried to marry Team System with Java projects? Does it makes any sense?
has answer: http://stackoverflow.com/a/637228
upvote count: 3
tagged with: java
type: Question

http://stackoverflow.com/comment/364547
has text: we now get into the essence of programming, which is a clear cut definition of whats normally called "business rules". these rules can change at a moment's notice, with no warning. thus, what is the best way to cater for these rules? polymorphism is one, but it has limitations.
score: 0
comment on: http://stackoverflow.com/a/551014
type: Comment
type: AnswerComment

http://stackoverflow.com/a/561595
upvote count: 3
answers question: http://stackoverflow.com/q/561588
downvote count: 1
has body: Well, in C++ I believe they have different uses, depending on when you want the variable updated. Efficiency shouldn't determine when you use one over the other, but I would assume they would have the same efficiency either way.
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/372716

http://stackoverflow.com/a/593295
answers question: http://stackoverflow.com/q/590069
score: 0
has body: if an lru cache would work, consider just using http://java.sun.com/javase/6/docs/api/java/util/LinkedHashMap.html#LinkedHashMap(int,%20float,%20boolean), http://java.sun.com/javase/6/docs/api/java/util/LinkedHashMap.html#removeEldestEntry(java.util.Map.Entry)
type: Answer

http://stackoverflow.com/q/382474
has answer: http://stackoverflow.com/a/382940
has answer: http://stackoverflow.com/a/384642
type: AnsweredQuestion
score: 7
tagged with: java
upvote count: 7
type: Question
accepted answer: http://stackoverflow.com/a/384642
answer count: 3
downvote count: 0
possible better answer: http://stackoverflow.com/a/382842
has answer: http://stackoverflow.com/a/382842
favorite count: 0
has title: JDE for Emacs for JDK 6.10
has body: Is there a version of JDE for emacs that supports the JDK 6.10? I haven't been able to find any information on this. While it runs, every time I attempt to compile files the JDE says that it doesn't recognize my JDK version and reverts to assuming it is a Java5 version.
tagged with: emacs

http://stackoverflow.com/a/375927
score: 4
upvote count: 4
has body: As discussed in this RFE and its comments, you could call tempDir.delete() first. Or you could use System.getProperty("java.io.tmpdir") and create a directory there. Either way, you should remember to call tempDir.deleteOnExit(), or the file won't be deleted after you're done.
downvote count: 0
has comment: http://stackoverflow.com/comment/204085
type: Answer
has comment: http://stackoverflow.com/comment/3899833
answers question: http://stackoverflow.com/q/617414
has comment: http://stackoverflow.com/comment/206163

http://stackoverflow.com/comment/400400
score: 0
type: AnswerComment
has text: ... ignore in your test - never reference again. Are you having a problem with your real code? Does andReturn(null) cause problems? You're just trying to make the return value enough so that the code runs the way you desire it to.
type: Comment
comment on: http://stackoverflow.com/a/588295

http://stackoverflow.com/comment/9714906
score: 0
type: Comment
comment on: http://stackoverflow.com/a/640124
has text: This does not answer the question at all. You're autowiring the repository, not the domain objects.
type: AnswerComment

http://stackoverflow.com/comment/94505490
score: 0
type: Comment
comment on: http://stackoverflow.com/a/497918
type: AnswerComment
has text: this one works great! an example of Java-based config: `@Bean public PlaceholderBean myThirdPartyClassName() { return new PlaceholderBean(); }` and before building ApplicationContext, call `PlaceholderBean.beanNames.put("myThirdPartyClassName", myThirdPartyObject);`

file
type: Tag
tag name: file
tags question: http://stackoverflow.com/q/462696
tags question: http://stackoverflow.com/q/526037
tags question: http://stackoverflow.com/q/368658
tags question: http://stackoverflow.com/q/465107
tags question: http://stackoverflow.com/q/494869
tags question: http://stackoverflow.com/q/586830
tags question: http://stackoverflow.com/q/402683
tags question: http://stackoverflow.com/q/585452
tags question: http://stackoverflow.com/q/557844
tags question: http://stackoverflow.com/q/595631
tags question: http://stackoverflow.com/q/620993
tags question: http://stackoverflow.com/q/623977
tags question: http://stackoverflow.com/q/578305
tags question: http://stackoverflow.com/q/416285
tags question: http://stackoverflow.com/q/459622
tags question: http://stackoverflow.com/q/617414
tags question: http://stackoverflow.com/q/479762
tags question: http://stackoverflow.com/q/428073
tags question: http://stackoverflow.com/q/574675
tags question: http://stackoverflow.com/q/440430
tags question: http://stackoverflow.com/q/499010
tags question: http://stackoverflow.com/q/625420
tags question: http://stackoverflow.com/q/636046
tags question: http://stackoverflow.com/q/463972
tags question: http://stackoverflow.com/q/605696
tags question: http://stackoverflow.com/q/369023
tags question: http://stackoverflow.com/q/484182
tags question: http://stackoverflow.com/q/562160

http://stackoverflow.com/a/425275
has body: You should try adding the header lines I mentioned to the very top of the message and see how Outlook deals with it then. Add a To:, From:, Subject: and maybe even a Date: with real data in them, and Outlook is more likely to treat it as a message, rather that just a file.
downvote count: 0
accepted answer of: http://stackoverflow.com/q/421944
answers question: http://stackoverflow.com/q/421944
type: AcceptedAnswer
type: Answer
upvote count: 1
score: 1

http://stackoverflow.com/a/457353
has body: The argument is the return code which the java process will return (0 means "successful"). It can be used when a Java program is a part of a batch script, or by build tools such as Ant.
answers question: http://stackoverflow.com/q/457338
type: Answer
upvote count: 3
score: 3
downvote count: 0

http://stackoverflow.com/comment/42283564
type: AnswerComment
comment on: http://stackoverflow.com/a/559525
score: 0
type: Comment
has text: You can also download a longer English dictionary list of words for Aspell using this nice script: http://app.aspell.net/create to use it in Jazzy.

http://stackoverflow.com/comment/407247
type: Comment
has text: PrepareForTest is on the class. Not sure what the fork mode is as I'm running it from within Eclipse. Can I presume this startup time will increase the more PowerMock is being used then?
comment on: http://stackoverflow.com/a/595331
score: 0
type: AnswerComment

http://stackoverflow.com/comment/300044
type: QuestionComment
comment on: http://stackoverflow.com/q/370695
score: 0
has text: Could you expand a bit on your motives for this design? Why does matter that B extend A, in what kind of situations are all this stuff going to be used? Otherwise uzhin's approach seems to be pointing in a right direction.
type: Comment

http://stackoverflow.com/a/427540
score: 0
answers question: http://stackoverflow.com/q/427482
type: AcceptedAnswer
type: Answer
has comment: http://stackoverflow.com/comment/253214
has comment: http://stackoverflow.com/comment/257566
has body: Not sure about the issue. I can run your code successfully in my Tomcat. May be this problem is particular to Resin. Or, as said by Dave, may be a headless issue. Your best bet is to convert the image in some POJO and then spit that to the browser, or may be save it somewhere on the disk and then link it in your JSP. If problem persists, try running in headless mode, as Dave pointed out. Moreover, its important to understand that JSP is a view technology for the web, and must not do that kind of graphics manipulation.
accepted answer of: http://stackoverflow.com/q/427482
has comment: http://stackoverflow.com/comment/253232

http://stackoverflow.com/q/467224
favorite count: 0
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/467250
accepted answer: http://stackoverflow.com/a/468093
has answer: http://stackoverflow.com/a/467250
has answer: http://stackoverflow.com/a/467243
tagged with: java
has comment: http://stackoverflow.com/comment/285533
tagged with: multithreading
has comment: http://stackoverflow.com/comment/285844
score: 16
tagged with: naming
has answer: http://stackoverflow.com/a/760400
upvote count: 16
has body: I am working on a project that is slowly getting larger and larger and the number of active threads used by many different processes is increasing. Lately, I have been taking a closer look at the running threads in the debugger and I have noticed that a lot of my third party libraries have given very poor names to their threads - Timer-0, qtp0, etc. I want other devs unfamiliar with the poorly named threads to know instantly what is running. Rather than write patches for the libs we are using, does anyone know how to rename the running threads? Or if this is even a good idea? Any suggestions would be appreciated.
type: Question
has answer: http://stackoverflow.com/a/39717422
has answer: http://stackoverflow.com/a/478880
has answer: http://stackoverflow.com/a/467260
has answer: http://stackoverflow.com/a/468093
has title: Renaming Threads in Java
downvote count: 0
answer count: 7

http://stackoverflow.com/comment/284938
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/466808
has text: A friend of mine developed a tool to do just that for his final year project as part of his CS degree. There were a few bugs in it though. He called it SML (Swing markup language).
score: 0

http://stackoverflow.com/q/496928
has answer: http://stackoverflow.com/a/3657960
tagged with: java
has answer: http://stackoverflow.com/a/2472999
has answer: http://stackoverflow.com/a/4795955
has answer: http://stackoverflow.com/a/4409848
score: 512
type: Question
upvote count: 512
has body: Which of the following is better? a instanceof B or B.class.isAssignableFrom(a.getClass()) The only difference that I know of is, when 'a' is null, the first returns false, while the second throws an exception. Other than that, do they always give the same result?
has answer: http://stackoverflow.com/a/7070786
possible better answer: http://stackoverflow.com/a/496968
downvote count: 0
accepted answer: http://stackoverflow.com/a/497001
has answer: http://stackoverflow.com/a/496968
answer count: 16
has answer: http://stackoverflow.com/a/12106524
has answer: http://stackoverflow.com/a/8433889
linked to: http://stackoverflow.com/q/103564
has answer: http://stackoverflow.com/a/36086355
has answer: http://stackoverflow.com/a/18705541
has comment: http://stackoverflow.com/comment/123885505
has answer: http://stackoverflow.com/a/77641689
linked to: http://stackoverflow.com/q/12106799
favorite count: 0
has answer: http://stackoverflow.com/a/73546274
has answer: http://stackoverflow.com/a/3561415
tagged with: instanceof
has answer: http://stackoverflow.com/a/61193297
linked to: http://stackoverflow.com/q/14190189
linked to: http://stackoverflow.com/q/4973359
has answer: http://stackoverflow.com/a/45784735
has answer: http://stackoverflow.com/a/497001
type: AnsweredQuestion
has title: What is the difference between instanceof and Class.isAssignableFrom(...)?
tagged with: reflection
has comment: http://stackoverflow.com/comment/15537254

http://stackoverflow.com/a/2026856
has comment: http://stackoverflow.com/comment/8065719
upvote count: 28
answers question: http://stackoverflow.com/q/414583
has comment: http://stackoverflow.com/comment/5267198
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/414583
score: 28
type: Answer
downvote count: 0
has body: Spring Roo seems to be exactly what you're looking for: CRUD code generation, spits out pure Java code that can be made tun run entirely independant from the framework.
has comment: http://stackoverflow.com/comment/8065570

http://stackoverflow.com/a/411362
downvote count: 0
accepted answer of: http://stackoverflow.com/q/411331
has body: We actually have some notification code in our product that uses TLS to send mail if it is available. You will need to set the Java Mail properties. You only need the TLS one but you might need SSL if your SMTP server uses SSL. Properties props = new Properties(); props.put("mail.smtp.starttls.enable","true"); props.put("mail.smtp.auth", "true"); // If you need to authenticate // Use the following if you need SSL props.put("mail.smtp.socketFactory.port", d_port); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put("mail.smtp.socketFactory.fallback", "false"); You can then either pass this to a JavaMail Session or any other session instantiator like Session.getDefaultInstance(props).
answers question: http://stackoverflow.com/q/411331
type: Answer
upvote count: 80
has comment: http://stackoverflow.com/comment/236187
has comment: http://stackoverflow.com/comment/129939813
has comment: http://stackoverflow.com/comment/48053576
score: 80
type: AcceptedAnswer

http://stackoverflow.com/q/504559
has answer: http://stackoverflow.com/a/13918190
answer count: 5
type: UnansweredQuestion
tagged with: swing
has answer: http://stackoverflow.com/a/504813
upvote count: 5
tagged with: java
has comment: http://stackoverflow.com/comment/319894
has answer: http://stackoverflow.com/a/504680
type: Question
has answer: http://stackoverflow.com/a/504587
score: 5
has body: My boilerplate listener: class MyMouseMotionListener implements MouseMotionListener { public void mouseDragged(MouseEvent e) { System.out.println("Dragged..."); } public void mouseMoved(MouseEvent e) { System.out.println("Moved..."); }} Simple enough, but what do I add it to in order to listen to system-wide events? I've been researching are things like the GraphicsDevice and AccessibleContext subclasses -- they don't offer the addition of MouseMotionListeners directly but I was hoping they might give me some idea as to how I could implement this. Edit: This isn't at all event-based but I've found this: MouseInfo.getPointerInfo().getLocation() Does actually return the mouse position outside the context of my app, even when the app itself does not have focus. Is there any way to observe this and dispatch an event if its value has changed?
downvote count: 0
tagged with: awt
favorite count: 0
has title: Is it possible to have a MouseMotionListener listen to all system mouse motion events?
has answer: http://stackoverflow.com/a/11584602

http://stackoverflow.com/comment/10344442
type: AnswerComment
comment on: http://stackoverflow.com/a/473223
type: Comment
score: 0
has text: javax.mail.internet.MimeUtility included in appengine-api.jar

http://stackoverflow.com/a/368671
answers question: http://stackoverflow.com/q/368613
type: Answer
score: 2
upvote count: 2
has body: Can you just pass a reference to the existing ExecutorService to your worker objects? public class Task implements Runnable { private final ExecutorService threadPool; private final SubTask[] subtasks; public Task(ExecutorService threadPool) { this.threadPool = threadPool; this.subtasks = createSubtasksIGuess(); } public void run() { for(SubTask sub : subtasks) threadPool.submit(sub); } }
downvote count: 0

http://stackoverflow.com/a/481873
upvote count: 5
has comment: http://stackoverflow.com/comment/298664
has comment: http://stackoverflow.com/comment/300593
has comment: http://stackoverflow.com/comment/298687
score: 4
answers question: http://stackoverflow.com/q/481802
type: Answer
has comment: http://stackoverflow.com/comment/299264
has comment: http://stackoverflow.com/comment/298683
has comment: http://stackoverflow.com/comment/300950
has comment: http://stackoverflow.com/comment/298655
downvote count: 1
has body: I know I'll get downvoted for this, but I really think people are starting to overabuse the annotation mechanism in Java. All it was designed for was to be a mechanism for providing metainformation about classes and methods for the purpose of the compiler or of programming-support tools (e.g., testing infrastructure, model checkers, code generators, etc.) It was not meant for actual production-oriented code, macro metaprogramming, and all that. This is just as inelegant as using preprocessor macros in C instead of actual functions. If menus are first-class entities in your program, I really don't feel that you should be using the annotation mechanism for them. As for your specific questions, you can easily define a default value. However, you can't start doing things like nesting annotations to overcome the menu problem. It really wasn't designed for this.
has comment: http://stackoverflow.com/comment/298627

http://stackoverflow.com/a/397885
has comment: http://stackoverflow.com/comment/224065
type: Answer
score: 0
has comment: http://stackoverflow.com/comment/224057
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/397867
has comment: http://stackoverflow.com/comment/61183752
has body: You can use signed numbers provided the values don't overflow...for example long in java is a 64 bit signed integer. However the intent in this algorithm seems to be to use a 64 bit unsigned value, and if so I think you would be out of luck with the basic types. You could use the multiprecision integers provided in the java class libraries (BigInteger). Or you could implement your own 64 bit unsigned type as an Object containing two java longs to represent the least significant and most significant words (but you'd have to implement the basic arithmetic operations yourself in the class).
has comment: http://stackoverflow.com/comment/61183783

http://stackoverflow.com/q/567659
answer count: 16
has answer: http://stackoverflow.com/a/567708
has answer: http://stackoverflow.com/a/42320897
tagged with: groovy
score: 48
has answer: http://stackoverflow.com/a/4147545
has answer: http://stackoverflow.com/a/1776721
upvote count: 48
favorite count: 0
has answer: http://stackoverflow.com/a/2856787
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/1454955
has answer: http://stackoverflow.com/a/1776549
has answer: http://stackoverflow.com/a/567694
has answer: http://stackoverflow.com/a/57537910
has answer: http://stackoverflow.com/a/7125087
has answer: http://stackoverflow.com/a/7792903
has answer: http://stackoverflow.com/a/2757551
tagged with: java
tagged with: date
has answer: http://stackoverflow.com/a/4862435
type: Question
has answer: http://stackoverflow.com/a/567678
has answer: http://stackoverflow.com/a/55978244
has body: I have... Date start = new Date() ... ... ... Date stop = new Date() I'd like to get the years, months, days, hours, minutes and seconds ellapsed between these two dates. -- I'll refine the question. I just want to get the elapsed time, as an absolute measure, that is without taking into account leap years, the days of each month, etc. Thus I think it's impossible to get the years and months elapsed, all I can get is days, hours, minutes and seconds. More specifically I want to tell that a certain task lasted for e.g. 20 sec 13 min, 4 sec 2 h, 10 min, 2 sec 4 d, 4 h, 2 min, 2 sec So please forgive my lack of precision.
has answer: http://stackoverflow.com/a/4840582
linked to: http://stackoverflow.com/q/38922754
has title: Calculate elapsed time in Java / Groovy
downvote count: 0

http://stackoverflow.com/a/379406
has body: If your thinking about an online game like a RPG or card game I might be selfish and suggest you have a look at Project Darkstar and let us know how you got on. I've been trying to get started with it and cannot get it up running in my environment.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/379375

http://stackoverflow.com/q/527610
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/527891
has answer: http://stackoverflow.com/a/8838787
has answer: http://stackoverflow.com/a/65811590
upvote count: 38
tagged with: .net
tagged with: pfx
downvote count: 0
has title: How can I create a PFX file from a Java Keystore?
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/40030467
has body: I have a Java keystore (.jks file) holding a single certificate. How can I create a .pfx file from this keystore?
tagged with: java
tagged with: certificate
tagged with: jks
answer count: 4
score: 38

http://stackoverflow.com/comment/26576955
comment on: http://stackoverflow.com/a/500495
score: 0
type: Comment
has text: @mslot Would you consider exception-handling in Java a case of `instanceof` being flawed design? For example, since `FileNotFoundException` and `EOFException` is `IOException` could we use `if (exception instanceof EOFException)` in catch block and still not have design suffer?
type: AnswerComment

http://stackoverflow.com/comment/451632
has text: (cont) XML has the two latter options: you can specify encoding, or you are required to use UTF-8 (or UTF-16, but that's a whole 'nother mess)
score: 0
comment on: http://stackoverflow.com/a/638339
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/24441504
has text: Looks like it was moved to Github. Makes sense, given how sour Oracle got with the whole Jenkins/Hudson thing.
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/741318
type: Comment

http://stackoverflow.com/comment/130017710
score: 0
type: Comment
comment on: http://stackoverflow.com/a/574650
type: AnswerComment
has text: @Enerccio you are looking for native binary I guess (.exe) take a look at graalvm but you can also set your windows via ASSOC and FTYPE command to know JAR files you run it like normal executable, in Linux and BSD try shebang line, a search through google about thing I just said it will be helpful.

http://stackoverflow.com/comment/301071
comment on: http://stackoverflow.com/a/484255
type: AnswerComment
has text: @iny, I'd argue that most developers aren't writing concurrent code. Maybe it's running in a concurrent environment, but I think that it is a minority of developers who deal every day with multithreading (and this is probably a good thing)
type: Comment
score: 1

http://stackoverflow.com/comment/43120164
type: AnswerComment
comment on: http://stackoverflow.com/a/6914824
type: Comment
has text: `GroovyWrapper` uses `Ant` to build groovy scripts into a jar file.This build can also be done in `Gradle` way.See [this answer](http://stackoverflow.com/a/9749869/2011291) if someone likes it.
score: 1

http://stackoverflow.com/comment/7083587
comment on: http://stackoverflow.com/a/3838348
has text: I would replace last line with this: `String result = Hex.encodeHexString(resultByte);`
type: AnswerComment
score: 15
type: Comment

http://stackoverflow.com/a/1870722
type: Answer
upvote count: 5
downvote count: 0
has body: You probably have already found a good solution, but if not, I have recently done some work on a framework for producing 2D charts allowing for live updates at a rate of over 50 changes per second. The original intention was to mimic the appearance of a chart recorder in a scrolling region of a web page, but I believe the approach has wider application. A demo can be found at Chart Recorder Demo if anyone is interested. The appearance is defined by a template (www.journeylog.co.uk/chart/templates/chartRecorder.xml). One feature is the ability to specify drawing either on the server or in the browser using ExplorerCanvas. If anyone is interested I could start an open source project for it.
has comment: http://stackoverflow.com/comment/3248137
score: 5
answers question: http://stackoverflow.com/q/555804
has comment: http://stackoverflow.com/comment/1769893

http://stackoverflow.com/a/20301490
has body: If you want to specify relative path to the image. Let's say your project folder structure is as following: sample_project/images sample_project/images/loading.gif sample_project/src sampler_project/src/package_name Now the image tag would look like this: "&lt;img src='file:images/loading.gif' width='100' height='100'&gt;" Yaay!
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/573055
score: 1
upvote count: 1

http://stackoverflow.com/q/504332
tagged with: java
upvote count: 4
tagged with: mocking
downvote count: 0
has answer: http://stackoverflow.com/a/504580
score: 4
tagged with: jmockit
favorite count: 0
has answer: http://stackoverflow.com/a/29103928
has answer: http://stackoverflow.com/a/504890
has body: This question is self explanatory if you know how to use JMockit: How do I mock a method that has generics on it? I want to mock this method: public T save(T entity) but it always throws an exception like this: mockit.RealMethodNotFoundForMockException: Corresponding real methods not found for the following mocks: Object save(Object) at mockit.internal.RedefinitionEngine.modifyRealClass(RedefinitionEngine.java:130) at mockit.internal.RedefinitionEngine.modifyRealClass(RedefinitionEngine.java:88) at mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:72) at mockit.Mockit.setUpMocks(Mockit.java:197) at com.mytest.MyTest.setUp(AdminManagerImplTest.java:83)
has answer: http://stackoverflow.com/a/1637311
tagged with: generics
possible better answer: http://stackoverflow.com/a/29103928
answer count: 4
type: AnsweredQuestion
has title: How do I mock a method with generic objects in JMockit?
accepted answer: http://stackoverflow.com/a/504580
type: Question

http://stackoverflow.com/comment/65218636
has text: We could use modulus function instead of subtraction: `long days = TimeUnit.MILLISECONDS.toDays(millis);` `long hours = TimeUnit.MILLISECONDS.toHours(millis) % 24;` `long minutes = TimeUnit.MILLISECONDS.toMinutes(millis) % 60;` `long seconds = TimeUnit.MILLISECONDS.toSeconds(millis) % 60;` `long milliseconds = millis % 1000;` and also String.format method: `return String.format("%d Days %d Hours %d Minutes %d Seconds %d Milliseconds", days, hours, minutes, seconds, milliseconds);`
score: 12
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/7663966

http://stackoverflow.com/a/484579
answers question: http://stackoverflow.com/q/484355
score: 5
upvote count: 5
downvote count: 0
type: Answer
has body: From my own experience (which includes mixing Java and Perl in a single system), I'd suggest the following: 1) "Java is slower" is not necessarily true, but also isn't relevant (even if true) unless the additional run time interferes with some time-critical workflow. 2) Long-term maintainability is a legitimate issue. Having e.g. a single DAO layer that doesn't have to be maintained in two languages can pay back in the long haul. How much of your Java code and current scriptage would have to be modified (twice) to cover a refactoring in the database? 3) If you really have a preference for lighter-weight notation, but your manager wants Java, could you compromise on Java libraries (from previous point) combined with one of the interoperable scripting-like languages that runs on the JVM and could share use of the standard libs you write for e.g. database access? I'm thinking of something in the JRuby-Groovy-Scala-Jython spectrum.

http://stackoverflow.com/comment/14486413
comment on: http://stackoverflow.com/a/582014
type: AnswerComment
has text: On the other hand, if you are on a child thread and you allow an Error to go uncaught, it will (may) get silently ignored ... and that's WORSE than catching and logging the Error.
score: 0
type: Comment

http://stackoverflow.com/a/429378
upvote count: 5
has body: Reputation is everything here, especially for a startup. As a startup, you don't have a long history of reliability/security/... - so all depends on users to give you the 'benefit of the doubt' when they start using your app. If your server gets hacked and your users notice that, your reputation is gone. Once it's gone, it doesn't matter whether your app and your features are the 'next new thing' or not. It doesn't matter whether the security breach was minor or not - people won't trust your app/company anymore. So, I would consider security to be the top priority.
downvote count: 0
answers question: http://stackoverflow.com/q/429352
type: Answer
score: 5

http://stackoverflow.com/q/586284
has answer: http://stackoverflow.com/a/55801082
has comment: http://stackoverflow.com/comment/398075
possible better answer: http://stackoverflow.com/a/588853
score: 22
answer count: 13
has answer: http://stackoverflow.com/a/586314
has answer: http://stackoverflow.com/a/588853
has comment: http://stackoverflow.com/comment/400337
has answer: http://stackoverflow.com/a/28793422
downvote count: 0
has comment: http://stackoverflow.com/comment/398068
favorite count: 0
has comment: http://stackoverflow.com/comment/402975
has answer: http://stackoverflow.com/a/586307
linked to: http://stackoverflow.com/q/605226
has title: Finding prime numbers with the Sieve of Eratosthenes (Originally: Is there a better way to prepare this array?)
has answer: http://stackoverflow.com/a/586302
tagged with: primes
has answer: http://stackoverflow.com/a/45695242
has comment: http://stackoverflow.com/comment/21580291
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/586348
has answer: http://stackoverflow.com/a/586377
has answer: http://stackoverflow.com/a/586310
tagged with: java
has answer: http://stackoverflow.com/a/20730190
tagged with: sieve-of-eratosthenes
accepted answer: http://stackoverflow.com/a/586302
type: Question
upvote count: 22
has comment: http://stackoverflow.com/comment/2165138
has answer: http://stackoverflow.com/a/586317
has comment: http://stackoverflow.com/comment/21579267
has answer: http://stackoverflow.com/a/48961670
has body: Note: Version 2, below, uses the Sieve of Eratosthenes. There are several answers that helped with what I originally asked. I have chosen the Sieve of Eratosthenes method, implemented it, and changed the question title and tags appropriately. Thanks to everyone who helped! Introduction I wrote this fancy little method that generates an array of int containing the prime numbers less than the specified upper bound. It works very well, but I have a concern. The Method private static int [] generatePrimes(int max) { int [] temp = new int [max]; temp [0] = 2; int index = 1; int prime = 1; boolean isPrime = false; while((prime += 2) &lt;= max) { isPrime = true; for(int i = 0; i &lt; index; i++) { if(prime % temp [i] == 0) { isPrime = false; break; } } if(isPrime) { temp [index++] = prime; } } int [] primes = new int [index]; while(--index &gt;= 0) { primes [index] = temp [index]; } return primes; } My Concern My concern is that I am creating an array that is far too large for the final number of elements the method will return. The trouble is that I don't know of a good way to correctly guess the number of prime numbers less than a specified number. Focus This is how the program uses the arrays. This is what I want to improve upon. I create a temporary array that is large enough to hold every number less than the limit. I generate the prime numbers, while keeping count of how many I have generated. I make a new array that is the right dimension to hold just the prime numbers. I copy each prime number from the huge array to the array of the correct dimension. I return the array of the correct dimension that holds just the prime numbers I generated. Questions Can I copy the whole chunk (at once) of temp[] that has nonzero elements to primes[] without having to iterate through both arrays and copy the elements one by one? Are there any data structures that behave like an array of primitives that can grow as elements are added, rather than requiring a dimension upon instantia…
tagged with: arrays

http://stackoverflow.com/comment/376444
score: 0
has text: Sorry I never said there was anything wrong with the question in fact I re-tagged it to Java. So more relevant people would look at it.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/565115

http://stackoverflow.com/comment/331267
type: Comment
score: 7
comment on: http://stackoverflow.com/a/517769
type: AnswerComment
has text: Yes, that's the problem. That seems so broken to me... or at least, counter-intuitive.

http://stackoverflow.com/comment/242244
has text: Thanks! Should've thought of downloading the source code myself :)
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/417739
type: Comment

http://stackoverflow.com/comment/335044
has text: You think Java runs on more platforms than C?
comment on: http://stackoverflow.com/a/521431
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/594617
type: Answer
answers question: http://stackoverflow.com/q/594604
score: 1
downvote count: 1
has body: The new keyword always makes a new string. More detail here.
upvote count: 2

http://stackoverflow.com/a/361791
has body: I read a really great post about efficiently and effectively executing physics calculations loop: Fix Your Timestep! When a game is running that is usually the main application that the user cares about so tight looping is not that big of a deal. What you really should do though schedule your updates. You should know how long -- at your target framerate -- that your frame has to execute. You should measure the time that your frame took and only sleep for the time that your frame took minus that known frame time. That way your system will lock into a frame rate and not vary with the amount of time that your frame takes to render. Another thing is that I don't believe that Thread.sleep has a very good resolution, well over 5 milliseconds, you may want to look for a more accurate timer available for Java.
upvote count: 9
has comment: http://stackoverflow.com/comment/194814
score: 9
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/192231
type: Answer
answers question: http://stackoverflow.com/q/361756
accepted answer of: http://stackoverflow.com/q/361756

http://stackoverflow.com/comment/98267781
type: Comment
comment on: http://stackoverflow.com/a/564167
has text: @schoenk - `Runtime.getRuntime().exec("chmod g+w directory);` ?
type: AnswerComment
score: 0

http://stackoverflow.com/a/554355
score: 1
has body: This does some of what you want (converts the System.properties to a ResourceBundle). Better error handling is left up to you :-) public static ResourceBundle createBundle() { final ResourceBundle bundle; final Properties properties; final CharArrayWriter charWriter; final PrintWriter printWriter; final CharArrayReader charReader; charWriter = new CharArrayWriter(); printWriter = new PrintWriter(charWriter); properties = System.getProperties(); properties.list(printWriter); charReader = new CharArrayReader(charWriter.toCharArray()); try { bundle = new PropertyResourceBundle(charReader); return (bundle); } catch(final IOException ex) { // cannot happen ex.printStackTrace(); } throw new Error(); }
upvote count: 1
type: AcceptedAnswer
type: Answer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/554120
has comment: http://stackoverflow.com/comment/11358974
answers question: http://stackoverflow.com/q/554120

http://stackoverflow.com/q/458820
possible better answer: http://stackoverflow.com/a/29600883
type: Question
has answer: http://stackoverflow.com/a/29600883
has answer: http://stackoverflow.com/a/51509822
accepted answer: http://stackoverflow.com/a/1012279
tagged with: intellij-idea
downvote count: 0
score: 10
has answer: http://stackoverflow.com/a/24145898
has answer: http://stackoverflow.com/a/459144
has title: Can IntelliJ create hyperlinks to the source code from log4j output?
linked to: http://stackoverflow.com/q/9937485
tagged with: log4j
favorite count: 0
has body: In the IntelliJ console, stack traces automatically contain hyperlinks that bring you to the relevant source files. The links appear at the end of each line in the format (Log4jLoggerTest.java:25). I can configure log4j to output text in a similar format. log4j.appender.Console.layout.ConversionPattern=%d{ABSOLUTE} (%F:%L) - %m%n In eclipse, the console automatically turned text like this into links. In IntelliJ, the stack traces are links but my own output in the same form remains un-linked. Is there any way to get IntelliJ to do the same?
answer count: 5
has answer: http://stackoverflow.com/a/1012279
type: AnsweredQuestion
tagged with: java
upvote count: 10
tagged with: eclipse

http://stackoverflow.com/comment/128276906
has text: I'm getting a link error when I try to use the JAR in my project. Is there a configuration I've missed to use the fat JAR? https://stackoverflow.com/questions/72593905/how-to-run-jblas-java-linear-algebra-without-native-libraries
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2173579
type: AnswerComment

http://stackoverflow.com/q/521110
upvote count: 33
favorite count: 0
has answer: http://stackoverflow.com/a/525463
has answer: http://stackoverflow.com/a/525938
answer count: 33
has answer: http://stackoverflow.com/a/525496
has body: More of a wiki list/collection, I'm looking for a list of good Java desktop apps. I've added a couple below to get started. Please list the framework/widget toolkit being used if it's know as well.
has comment: http://stackoverflow.com/comment/8197235
has answer: http://stackoverflow.com/a/522863
has answer: http://stackoverflow.com/a/522084
has title: Examples of good Java desktop applications
has answer: http://stackoverflow.com/a/2692261
has answer: http://stackoverflow.com/a/521116
possible better answer: http://stackoverflow.com/a/521191
has answer: http://stackoverflow.com/a/527949
has answer: http://stackoverflow.com/a/7250892
score: 31
has answer: http://stackoverflow.com/a/2692156
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/1150008
has answer: http://stackoverflow.com/a/2692296
tagged with: java
has answer: http://stackoverflow.com/a/2691979
has answer: http://stackoverflow.com/a/521125
has answer: http://stackoverflow.com/a/525479
has comment: http://stackoverflow.com/comment/100727306
has answer: http://stackoverflow.com/a/530326
has answer: http://stackoverflow.com/a/521666
has answer: http://stackoverflow.com/a/521123
type: Question
accepted answer: http://stackoverflow.com/a/525469
has answer: http://stackoverflow.com/a/4674963
has answer: http://stackoverflow.com/a/1309178
has answer: http://stackoverflow.com/a/521150
has answer: http://stackoverflow.com/a/2691866
has answer: http://stackoverflow.com/a/521164
tagged with: desktop-application
has answer: http://stackoverflow.com/a/525466
has answer: http://stackoverflow.com/a/521191
has answer: http://stackoverflow.com/a/521154
has answer: http://stackoverflow.com/a/1309186
has answer: http://stackoverflow.com/a/525469
has answer: http://stackoverflow.com/a/521141
downvote count: 2
has answer: http://stackoverflow.com/a/521115
has answer: http://stackoverflow.com/a/521590
has answer: http://stackoverflow.com/a/521114
has answer: http://stackoverflow.com/a/521174
has answer: http://stackoverflow.com/a/4552649
has comment: http://stackoverflow.com/comment/338731

http://stackoverflow.com/comment/477149
has text: Jon - just pinging you to let you know that there's a 100 point bounty on this question - if you have more time to spend giving a more complete answer (and the points are worth it) - I'd certainly welcome that :). Thanks!
comment on: http://stackoverflow.com/a/553898
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/62499689
downvote count: 0
has body: Java 10 introduced List#copyOf which returns unmodifiable List while preserving the order: List&lt;Integer&gt; list = List.copyOf(coll);
type: Answer
upvote count: 19
score: 19
answers question: http://stackoverflow.com/q/580160

http://stackoverflow.com/q/601957
has answer: http://stackoverflow.com/a/602058
type: Question
tagged with: streaming
upvote count: 1
tagged with: http://stackoverflow.com/tag/jpeg
has body: I am building a server sided html rendering browser that renders html and sends jpegs to the mobile client. I need to figure out how to build a server that grabs jpegs and streams them in a session to a client that i am going to write in j2me
tagged with: java
tagged with: rtp
answer count: 3
has answer: http://stackoverflow.com/a/602092
has answer: http://stackoverflow.com/a/869350
has title: How to create a stream of jpegs(live) in c++ or c# or java? RTSP?
downvote count: 0
type: UnansweredQuestion
score: 1
tagged with: java-me
favorite count: 0

http://stackoverflow.com/comment/271589
has text: Lots of things Hibernate is, but lightweight is not one of them. And as far as out of the box persistence goes, you need to create a database schema before even starting.
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/450891
type: Comment

http://stackoverflow.com/comment/491268
has text: You just stole my words. Incredible answer.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/669512
score: 1

http://stackoverflow.com/q/610628
has answer: http://stackoverflow.com/a/610700
has answer: http://stackoverflow.com/a/610702
tagged with: java
has title: Best way to check whether a certain exception type was the cause (of a cause, etc ...) in a nested exception?
tagged with: nested-exceptions
has answer: http://stackoverflow.com/a/24872376
score: 45
downvote count: 0
upvote count: 45
has answer: http://stackoverflow.com/a/610681
has answer: http://stackoverflow.com/a/69176942
favorite count: 0
accepted answer: http://stackoverflow.com/a/610700
answer count: 9
tagged with: exception
has answer: http://stackoverflow.com/a/610831
possible better answer: http://stackoverflow.com/a/29252884
tagged with: spring
has answer: http://stackoverflow.com/a/45176471
has answer: http://stackoverflow.com/a/29252884
type: AnsweredQuestion
has body: I am writing some JUnit tests that verify that an exception of type MyCustomException is thrown. However, this exception is wrapped in other exceptions a number of times, e.g. in an InvocationTargetException, which in turn is wrapped in a RuntimeException. What's the best way to determine whether MyCustomException somehow caused the exception that I actually catch? I would like to do something like this (see underlined): try { doSomethingPotentiallyExceptional(); fail("Expected an exception."); } catch (RuntimeException e) { if (!e.wasCausedBy(MyCustomException.class) fail("Expected a different kind of exception."); } I would like to avoid calling getCause() a few "layers" deep, and similar ugly work-arounds. Is there a nicer way? Apparently, Spring has NestedRuntimeException.contains(Class), which does what I want - but I'm not using Spring.
has answer: http://stackoverflow.com/a/64673592
type: Question

http://stackoverflow.com/a/610050
type: Answer
answers question: http://stackoverflow.com/q/609265
score: 0
has body: If this is for security reasons, then this is not possible. Anything the browsers sends to you, can also be send by the user. But unclear is what you mean by send by the user.

http://stackoverflow.com/a/557405
downvote count: 0
has body: I see four possible methods. Use your own Thread subclass with an overridden run() method. Add a finally block for thread termination. Use a Runnable with similar decoration, perhaps as a wrapper around the supplied Runnable. A variant of this is to subclass Thread in order to apply this wrapper at construction time. Create a 2nd thread to join() on the real thread and thus detect its termination. Use instrumentation to rewrite the Thread.run() method as above.
upvote count: 3
has comment: http://stackoverflow.com/comment/368703
type: Answer
score: 3
answers question: http://stackoverflow.com/q/557298

http://stackoverflow.com/a/18785300
has comment: http://stackoverflow.com/comment/53253016
upvote count: 35
has comment: http://stackoverflow.com/comment/73061231
downvote count: 0
has comment: http://stackoverflow.com/comment/53268580
type: Answer
answers question: http://stackoverflow.com/q/464784
has comment: http://stackoverflow.com/comment/53280929
score: 35
has comment: http://stackoverflow.com/comment/53203313
has body: This is an old question, but here's both a solution to the problem, and some background information. As others have pointed out, a classic readers-writer lock (like the JDK ReentrantReadWriteLock) inherently does not support upgrading a read lock to a write lock, because doing so is susceptible to deadlock. If you need to safely acquire a write lock without first releasing a read lock, there is a however a better alternative: take a look at a read-write-update lock instead. I've written a ReentrantReadWrite_Update_Lock, and released it as open source under an Apache 2.0 license here. I also posted details of the approach to the JSR166 concurrency-interest mailing list, and the approach survived some back and forth scrutiny by members on that list. The approach is pretty simple, and as I mentioned on concurrency-interest, the idea is not entirely new as it was discussed on the Linux kernel mailing list at least as far back as the year 2000. Also the .Net platform's ReaderWriterLockSlim supports lock upgrade also. So effectively this concept had simply not been implemented on Java (AFAICT) until now. The idea is to provide an update lock in addition to the read lock and the write lock. An update lock is an intermediate type of lock between a read lock and a write lock. Like the write lock, only one thread can acquire an update lock at a time. But like a read lock, it allows read access to the thread which holds it, and concurrently to other threads which hold regular read locks. The key feature is that the update lock can be upgraded from its read-only status, to a write lock, and this is not susceptible to deadlock because only one thread can hold an update lock and be in a position to upgrade at a time. This supports lock upgrade, and furthermore it is more efficient than a conventional readers-writer lock in applications with read-before-write access patterns, because it blocks reading threads for shorter periods of time. Example usage is provided on the site. The …

http://stackoverflow.com/a/431352
downvote count: 0
has comment: http://stackoverflow.com/comment/254788
has comment: http://stackoverflow.com/comment/254799
accepted answer of: http://stackoverflow.com/q/431107
upvote count: 19
answers question: http://stackoverflow.com/q/431107
has comment: http://stackoverflow.com/comment/255741
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/254906
type: Answer
has comment: http://stackoverflow.com/comment/254746
has body: If you're still reasonably early in the project I'd advice you strongly to look at annotation-driven configuration. After converting to annotations we only have 1 xml file with definitions and it's really quite small, and this is a large project. Annotation driven configuration puts focus on your implementation instead of the xml. It also more or less removes the fairly redundant abstraction layer which is the spring "bean name". It turns out the bean name exists mostly because of xml (The bean name still exists in annotation config but is irrelevant in most cases). After doing this switch on a large project everyone's 100% in agreement that it's a lot better and we also have fairly decent evidence that it's a more productive environment. I'd really recommend anyone who's using spring to switch to annotations. It's possible to mix them as well. If you need transitional advice I suppose it's easy to ask on SO ;)
score: 19

http://stackoverflow.com/comment/383644
type: Comment
score: 1
has text: It's not answerable. Needs are "in the eye of the beholder," and even then, they change over time. Given the squabbling between OSGi and JSR-294 camps, it's an emotionally charge, controversial issue for many.
type: QuestionComment
comment on: http://stackoverflow.com/q/571616

http://stackoverflow.com/a/534823
upvote count: 2
has body: This question is about daemonizing an arbitrary program (not java-specific) so some of the answers may apply to your case:
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/534648
score: 2

http://stackoverflow.com/comment/2014750
score: 0
type: AnswerComment
has text: He's using JSP's. The `fmt:formatDate` as mentioned by Vincent Ramdhanie is the **only right way**. It's by the way already backed by `SimpleDateFormat` and automagically already takes locale into account. Reread his answer for the sake that.
comment on: http://stackoverflow.com/a/2083215
type: Comment

http://stackoverflow.com/comment/125399426
type: Comment
comment on: http://stackoverflow.com/a/25601484
has text: +1 for actually including the import lines. Anyone asking this question might not know which bits import from where.
score: 0
type: AnswerComment

http://stackoverflow.com/a/3120297
has comment: http://stackoverflow.com/comment/5684687
has comment: http://stackoverflow.com/comment/21141094
answers question: http://stackoverflow.com/q/371538
has comment: http://stackoverflow.com/comment/6276533
has comment: http://stackoverflow.com/comment/102650202
has comment: http://stackoverflow.com/comment/5706950
score: 112
downvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/21135436
has comment: http://stackoverflow.com/comment/6276303
has body: Thought I'd just add my $0.02 here about my ORMLite package. It is a lightweight replacement to Hibernate and uses native Android OS database calls to support SQLite on Android. It also supports many other database types using JDBC on other architectures. We have an Android mailing list for ORMLite questions.
upvote count: 113

http://stackoverflow.com/a/1141037
downvote count: 0
score: 2
upvote count: 2
has body: There are a few JavaFX apps from the JavaFX Coding Challenge; my personal favorite is Music Explorer FX. The new version of Indaba Music's software was written in JavaFX; the old version was in Flash.
type: Answer
answers question: http://stackoverflow.com/q/471966

http://stackoverflow.com/comment/7923727
score: 0
has text: Yes, that's right Dave. Tycho is indeed a maven plugin. I wanted to be sure to mention it, because is quite new.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/6664138

http://stackoverflow.com/comment/264590
has text: Do I understand you correctly when you say it depends on your experience?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/442597
type: Comment

http://stackoverflow.com/a/442603
has comment: http://stackoverflow.com/comment/264481
has body: The best idiom for threadsafe initialization code (imho) is the lazy inner class. The classic version is class Outer { class Inner { private final static SomeInterface SINGLETON; static { // create the SINGLETON } } public SomeInterface getMyObject() { return Inner.SINGLETON; } } because it's threadsafe, lazy-loading and (imho) elegant. Now you want testability and replaceability. It's hard to advise without knowing what exactly it is but the most obvious solution would be to use dependency injection, particularly if you're using Spring and have an application context anyway. That way your "singleton"'s behaviour is represented by an interface and you simply inject one of those into your relevant classes (or a factory to produce one) and then you can of course replace it with whatever you like for testing purposes.
downvote count: 0
answers question: http://stackoverflow.com/q/442589
has comment: http://stackoverflow.com/comment/264698
has comment: http://stackoverflow.com/comment/6033412
type: Answer
upvote count: 6
has comment: http://stackoverflow.com/comment/264707
score: 6

http://stackoverflow.com/q/482955
favorite count: 0
has answer: http://stackoverflow.com/a/482975
has answer: http://stackoverflow.com/a/482977
has answer: http://stackoverflow.com/a/482979
answer count: 5
has answer: http://stackoverflow.com/a/483312
upvote count: 13
tagged with: c++
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/300005
score: 12
tagged with: java
has title: Why was constness removed from Java and C#?
tagged with: language-features
has answer: http://stackoverflow.com/a/483013
accepted answer: http://stackoverflow.com/a/482977
downvote count: 1
type: Question
tagged with: c#
tagged with: programming-languages
has comment: http://stackoverflow.com/comment/300106
has body: I know this has been discussed many times, but I am not sure I really understand why Java and C# designers chose to omit this feature from these languages. I am not interested in how I can make workarounds (using interfaces, cloning, or any other alternative), but rather in the rationale behind the decision. From a language design perspective, why has this feature been declined? P.S: I'm using words such as "omitted", which some people may find inadequate, as C# was designed in an additive (rather than subtractive) approach. However, I am using such words because the feature existed in C++ before these languages were designed, so it is omitted in the sense of being removed from a programmer's toolbox.
possible better answer: http://stackoverflow.com/a/482975

http://stackoverflow.com/comment/201401
type: QuestionComment
comment on: http://stackoverflow.com/q/372639
has text: It works, just can be a hassle, especially for a new programmer.
score: 0
type: Comment

http://stackoverflow.com/a/426251
upvote count: 1
accepted answer of: http://stackoverflow.com/q/415863
answers question: http://stackoverflow.com/q/415863
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: Not sure how you are generating your PDFs, but if possible, skip the disk IO all together, stash the PDF content in a byte[] and flush it out to the user in a servlet setting the mime type to application/pdf* that responds to a URL which is specified by a link in your client or dynamically set in a &lt;div&gt; by javascript. You're probably taking the memory hit anyways, and in addition to skipping the IO, you don't have to worry about deleting the tmp files when you're done with the preview. *****I think this is right. Need to look it up.
score: 1

http://stackoverflow.com/q/482589
tagged with: filepath
score: 8
has body: My problem is :: From a string like "/usr/folder1/folder2/filename.ext" I have to extract out file name only for display (filename.ext only). My question would be how should I do it? Splitting on "/" and taking the last element is one way but doesn't smell nice to me. I have to create a hyperlink which uses URI of the file as the destination. That will be something similar to file://domain.com/usr/folder1/folder2/filename.ext I looked at URI and URL interfaces in java.net but could not find anything useful there. Also, in some cases, my file path can have COMMA, SPACE etc (Windows folders). So, keep that in mind when giving any ideas.
has title: How to extract the file name from a file URI and create a link for the same?
has answer: http://stackoverflow.com/a/482626
tagged with: java
type: Question
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/23294834
accepted answer: http://stackoverflow.com/a/482626
possible better answer: http://stackoverflow.com/a/22404180
answer count: 3
has answer: http://stackoverflow.com/a/22404180
downvote count: 0
favorite count: 0
linked to: http://stackoverflow.com/q/9832712
upvote count: 8
has answer: http://stackoverflow.com/a/482601

http://stackoverflow.com/a/65123060
answers question: http://stackoverflow.com/q/547219
downvote count: 0
has body: I had the same problem with a really old local router and was not able to open its WebGUI because of self-signed certificates. The solution was to install an old Firefox Portable version. I tested the following versions: Firefox 33.1.1 (worked) Firefox 45.0.2 (worked) Firefox 56.0.2 (failed) This is strange because it should be only a problem since version 59, but as long it works, it's ok for me.
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/a/845187
score: 3
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/495217
upvote count: 3
has body: It appears from one of your comments that you wish to dynamically create the JPanels when the buttons are clicked. If this is the case then CardLayout is not ideal. It is relatively easy to achieve the same effect yourself. The code will look something like this: public void actionPerformed(ActionEvent event) { Container contentPane = frame.getContentPane(); contentPane.removeAll(); contentPane.add(new YourPanel()); contentPane.invalidate(); contentPane.repaint(); } That assumes that the changing panel is the only component in the frame. If it is not then add a JPanel with a BorderLayout to the content pane in Matisse and then add the new panels to that rather than the content pane.

http://stackoverflow.com/comment/371066
comment on: http://stackoverflow.com/q/558839
type: QuestionComment
type: Comment
has text: See http://stackoverflow.com/questions/559779/should-java-treat-arrays-as-objects for how I would suggest asking questions in future. It's hard enough reading some of them without having to wade through pages of waffle or web links, no offence intended.
score: 0

http://stackoverflow.com/q/511552
has answer: http://stackoverflow.com/a/511692
has comment: http://stackoverflow.com/comment/333123
answer count: 5
accepted answer: http://stackoverflow.com/a/511679
possible better answer: http://stackoverflow.com/a/511692
has body: I'm trying to do some Socket programming in Java, and I'm using the BufferedStreamReader.read(char[]) method. the java doc states: Reads characters into an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached. Only it's not blocking on input. can somone point out the problem with the following code? Even with the line that writes to the output stream the line that prints "RCVD:" is printing but without any data after the RCVD. public class Main { /** * @param args the command line arguments */ private static Socket tcpSocket; public static void main(String args[]) { try { tcpSocket = new Socket("localhost", 8080); } catch (UnknownHostException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } new Thread(new Runnable() { public void run() { try { System.out.println("Starting listening"); char[] dataBytes = new char[9]; BufferedReader netStream = new BufferedReader(new InputStreamReader(tcpSocket.getInputStream())); while (true) { netStream.read(dataBytes); System.out.println("RCVD: " + String.copyValueOf(dataBytes)); } } catch (UnknownHostException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } }).start(); new Thread(new Runnable(){ public void run() { System.out.println("Starting Writer"); PrintWriter out = null; try { out = new PrintWriter(tcpSocket.getOutputStream(), true); for (int i = 0 ; i &lt; 10 ; i++) { // out.println("000000000"); } } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } }).start(); } } ADDITIONAL INFO I've tried changing the port number and the application crashes, maybe I'm connecting to something else running on the machine. Also I am reciveing a steady stream of bytes all of which are spa…
has comment: http://stackoverflow.com/comment/333126
has answer: http://stackoverflow.com/a/511725
tagged with: sockets
upvote count: 1
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/511704
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/325457
has answer: http://stackoverflow.com/a/511679
type: Question
has title: Reading from a socket not waiting for input?
downvote count: 0
has answer: http://stackoverflow.com/a/519826
favorite count: 0

http://stackoverflow.com/comment/23148919
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/390449
has text: I've answered in basically the same question here: http://stackoverflow.com/questions/3966411/java-object-memory-usage/3966510#3966510
score: 0

http://stackoverflow.com/comment/45449740
comment on: http://stackoverflow.com/q/435740
has text: [Spring Shell](https://github.com/spring-projects/spring-shell) looks pretty good.
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/439176
has text: javashlook is correct, the @Transactional annotations belong on the implementation, not the interface.
comment on: http://stackoverflow.com/a/624504
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/654252
type: Answer
has body: Ha! Thanks to this post I've found another way to do this: public static class Extensions { public static string JoinWith(this IEnumerable&lt;string&gt; strings, string separator) { return String.Join(separator, strings.ToArray()); } } Of course this is in C# now and Java won't (yet) support the extension method, but you ought to be able to adapt it as needed &mdash; the main thing is the use of String.Join anyway, and I'm sure java has some analog for that. Also note that this means doing an extra iteration of the strings, because you must first create the array and then iterate over that to build your string. Also, you will create the array, where with some other methods you might be able to get by with an IEnumerable that only holds one string in memory at a time. But I really like the extra clarity. Of course, given the Extension method capability you could just abstract any of the other code into an extension method as well.
answers question: http://stackoverflow.com/q/448320
score: 0

http://stackoverflow.com/comment/266057
has text: The reason I want you to post the answer is that I can't "accept" my own answer. Please post a new answer and I'll "accept it".
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/444335

http://stackoverflow.com/comment/426896
type: Comment
has text: imagine you declare an instance variable like "@readonly property int foo; (property would be new keyword). That would have the compiler spit out a getMethod (no set) and since it has the property keyword it would turn all .foo into a call to .getFoo().
comment on: http://stackoverflow.com/a/604237
score: 0
type: AnswerComment

http://stackoverflow.com/q/629798
answer count: 6
has body: Random.nextGaussian() is supposed to give random no.s with mean 0 and std deviation 1. Many no.s it generated are outside range of [-1,+1]. how can i set so that it gives normally distributed random no.s only in the range -1 to 1.
possible better answer: http://stackoverflow.com/a/629816
favorite count: 0
accepted answer: http://stackoverflow.com/a/629820
has answer: http://stackoverflow.com/a/629823
has answer: http://stackoverflow.com/a/28140767
has answer: http://stackoverflow.com/a/629850
type: AnsweredQuestion
upvote count: 7
has title: problem with Random.nextGaussian()
type: Question
has answer: http://stackoverflow.com/a/629814
has answer: http://stackoverflow.com/a/629820
score: 7
tagged with: java
has answer: http://stackoverflow.com/a/629816
tagged with: random
downvote count: 0

http://stackoverflow.com/a/479851
upvote count: 1
downvote count: 0
has body: Apache Wicket is a possible java based web framework you might consider. The default would be the java servlet and jsp frameworks.
type: Answer
score: 1
answers question: http://stackoverflow.com/q/479836

http://stackoverflow.com/a/406062
type: Answer
answers question: http://stackoverflow.com/q/403902
upvote count: 1
score: 1
downvote count: 0
has body: I have a solution that works as needed for this particular situation. I've used the Ant replace task in conjunction with a "saved" version of the constant class: &lt;target name="one" description="constant substitution #1"&gt; &lt;delete file="./tme3/MyConst.java" /&gt; &lt;copy file="./save/MyConst.java" tofile="./tme3/MyConst.java" /&gt; &lt;replace file="./tme3/MyConst.java" token="@BRANDING@" value="ONE_BRAND"/&gt; &lt;replace file="./tme3/MyConst.java" token="@STYLESHEET@" value="../stylesheet/onebrand.css"/&gt; &lt;replace file="./tme3/MyConst.java" token="@FAVICON@" value="../images/onebrand.ico"/&gt; &lt;replace file="./tme3/MyConst.java" token="@SHOW_LANGUAGES@" value="false"/&gt; &lt;/target&gt; I just make copies of this block and change the substitutions for the cases I need - in my particular case there are 3 sets now, but more expected. Thanks one and all for the great replies.

http://stackoverflow.com/a/620202
has body: You can use par including modules (or even as an executable) if you don't have perl installed on the target platform: http://metacpan.org/pod/PAR
score: 1
upvote count: 2
downvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/619822

http://stackoverflow.com/a/42862452
downvote count: 0
has body: Let's consider this lines of code (Java): System.out.println("H"+"A"); //HA System.out.println('H'+'a'); //169 First line is concatenation of H and A that will result in HA (String literal) Second we are adding the values of two char that according to the ASCII Table H=72 and a=97 that means that we are adding 72+97 it's like ('H'+'a'). Let's consider another case where we would have: System.out.println("A"+'N');//AN In this case we are dealing with concatenation of String A and char N that will result in AN.
type: Answer
answers question: http://stackoverflow.com/q/439485
score: 23
upvote count: 23

http://stackoverflow.com/comment/453285
type: AnswerComment
has text: My solution will find where java.exe resides on *your* path, if at all.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/639293

http://stackoverflow.com/a/461964
downvote count: 0
has body: The dumbest mistake I frequently make is forgetting to synchronize before calling notify() or wait() on an object.
upvote count: 8
type: Answer
score: 8
answers question: http://stackoverflow.com/q/461896
has comment: http://stackoverflow.com/comment/297678
has comment: http://stackoverflow.com/comment/298642

http://stackoverflow.com/q/445990
upvote count: 18
has answer: http://stackoverflow.com/a/446005
has body: This questions is prompted by strange HashMap.put() behaviour I think I understand why Map&lt;K,V&gt;.put takes a K but Map&lt;K,V&gt;.get takes an Object, it seems not doing so will break too much existing code. Now we get into a very error-prone scenario: java.util.HashMap&lt;Long, String&gt; m = new java.util.HashMap&lt;Long, String&gt;(); m.put(5L,"Five"); // compiler barfs on m.put(5, "Five") m.contains(5); // no complains from compiler, but returns false Couldn't this have been solved by returning true if the Long value was withing int range and the values are equal?
has answer: http://stackoverflow.com/a/9504183
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/444638
has answer: http://stackoverflow.com/a/446853
downvote count: 0
tagged with: java
possible better answer: http://stackoverflow.com/a/446911
has title: Why is Long.valueOf(0).equals(Integer.valueOf(0)) false?
type: Question
has answer: http://stackoverflow.com/a/446911
score: 18
has answer: http://stackoverflow.com/a/449539
has answer: http://stackoverflow.com/a/446899
answer count: 7
favorite count: 0
tagged with: equals
has answer: http://stackoverflow.com/a/446012
accepted answer: http://stackoverflow.com/a/446012

http://stackoverflow.com/a/958138
answers question: http://stackoverflow.com/q/554913
has body: I basically hit everyone on the head with Scala code in our last project, as I got sick of debugging the same problems caused by a lack of understanding of Hibernate + JBoss. (It's amazing, really. The developers who wrote the original system are still there and still get lost in Hibernate details.) What we had -> a wacky system built mostly with a bunch of stateless EJB beans wired together with some hibernate code tossed together with some SQL. (We're an ASP, basically. The production cluster is fairly small -> only around 100 machines.) What I did -> put together various REST-based services, where we redefined the RPC between some of the servers. This is making everything very easy to code, plus, implementing a public API into what was a system where no attention was paid to dependencies. So far, we've started to deploy code in and out of JBoss instances with no real problems. The first time you try to use a Scala object in Java, you'll probably wrinkle your nose. But otherwise, nobody really noticed. So far, it's been about 5 months since we really started. We've done a couple of major revisions, and subsequently are behind, but the system is far, far better tested than in the past. So, while we've had some bad ideas sneak in there while we were really learning the system, we've now been able to remove them all, and, get very close to production deployment. All in all, I'd say the typical dude needs 2-3 months to stop coding like a Java programmer, and get "familiar" with most of the standard libraries. Writing JDBC code instead of an ORM system basically has thrown out almost all of our performance problems. The speed has been actually significantly better, but that was mostly because I was able to do everything I wanted with less real application code. Tools I'm using: Restlet : Very happy with this framework. Our restlet layer is outrageously trivial code. JDBC -> note: we've tweaked what was basically there in the wiki XML (and soon, JSON) buildr, maven on a…
downvote count: 0
has comment: http://stackoverflow.com/comment/801866
type: Answer
score: 6
upvote count: 6

http://stackoverflow.com/comment/84380217
has text: @user257319 doesn't seems to me as "the new best practice java introduces", at least there is no reference, this is let say official practice...
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/551709
type: Comment

http://stackoverflow.com/q/377361
has comment: http://stackoverflow.com/comment/207559
has answer: http://stackoverflow.com/a/377402
has answer: http://stackoverflow.com/a/12120219
has body: 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2 power of 1000 (2^1000)? Can anyone provide the solution or algorithm for this problem in java?
has comment: http://stackoverflow.com/comment/205255
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/205236
has answer: http://stackoverflow.com/a/377412
has answer: http://stackoverflow.com/a/377401
has comment: http://stackoverflow.com/comment/61040977
has comment: http://stackoverflow.com/comment/205383
has answer: http://stackoverflow.com/a/409068
linked to: http://stackoverflow.com/q/265258
has answer: http://stackoverflow.com/a/2417393
downvote count: 23
has comment: http://stackoverflow.com/comment/205226
has comment: http://stackoverflow.com/comment/205200
has comment: http://stackoverflow.com/comment/205250
tagged with: algorithm
has comment: http://stackoverflow.com/comment/205376
tagged with: java
has answer: http://stackoverflow.com/a/377532
has comment: http://stackoverflow.com/comment/205245
score: -8
has answer: http://stackoverflow.com/a/377384
type: Question
has title: Sum of the digits of the number 2^1000
has answer: http://stackoverflow.com/a/377586
upvote count: 15
has answer: http://stackoverflow.com/a/7817454
has comment: http://stackoverflow.com/comment/9464260
has comment: http://stackoverflow.com/comment/205205
has answer: http://stackoverflow.com/a/11598303
has comment: http://stackoverflow.com/comment/2399151
answer count: 11
favorite count: 0
has comment: http://stackoverflow.com/comment/61040935

http://stackoverflow.com/comment/52387374
comment on: http://stackoverflow.com/a/577701
type: AnswerComment
score: 0
type: Comment
has text: help please http://stackoverflow.com/questions/32252715/java-the-following-listed-types-were-not-enhanced-at-build-time-or-at-class-load

jpa
tags question: http://stackoverflow.com/q/474159
tags question: http://stackoverflow.com/q/458048
tags question: http://stackoverflow.com/q/643700
tags question: http://stackoverflow.com/q/448181
tags question: http://stackoverflow.com/q/388206
tags question: http://stackoverflow.com/q/408051
tags question: http://stackoverflow.com/q/374886
tags question: http://stackoverflow.com/q/586185
tags question: http://stackoverflow.com/q/639908
tags question: http://stackoverflow.com/q/585454
tags question: http://stackoverflow.com/q/463349
tags question: http://stackoverflow.com/q/467375
tags question: http://stackoverflow.com/q/462898
tags question: http://stackoverflow.com/q/413131
tags question: http://stackoverflow.com/q/530215
tags question: http://stackoverflow.com/q/444932
tags question: http://stackoverflow.com/q/534652
tags question: http://stackoverflow.com/q/508019
tags question: http://stackoverflow.com/q/594597
tags question: http://stackoverflow.com/q/643055
type: Tag
tags question: http://stackoverflow.com/q/430899
tags question: http://stackoverflow.com/q/586077
tags question: http://stackoverflow.com/q/452627
tags question: http://stackoverflow.com/q/416208
tags question: http://stackoverflow.com/q/442488
tags question: http://stackoverflow.com/q/644577
tags question: http://stackoverflow.com/q/471799
tags question: http://stackoverflow.com/q/385532
tags question: http://stackoverflow.com/q/584742
tags question: http://stackoverflow.com/q/527945
tags question: http://stackoverflow.com/q/586592
tags question: http://stackoverflow.com/q/452669
tags question: http://stackoverflow.com/q/452630
tags question: http://stackoverflow.com/q/578433
tags question: http://stackoverflow.com/q/498676
tag name: jpa
tags question: http://stackoverflow.com/q/576659
tags question: http://stackoverflow.com/q/418197
tags question: http://stackoverflow.com/q/452631
tags question: http://stackoverflow.com/q/480324
tags question: http://stackoverflow.com/q/552968
tags question: http://stackoverflow.com/q/427447
tags question: http://stackoverflow.com/q/467282

http://stackoverflow.com/q/575038
has title: Java applet double buffer trouble (and loop trouble)
score: 0
downvote count: 1
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/575434
tagged with: java
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/575434
upvote count: 1
has body: For some reason when I try to double buffer my Java applet it shows up a white square even though I'm not telling it to. Also if I try to put a loop in start() I get only a white screen even if repaint() is at the end. /** * @(#)vo4k.java * * vo4k Applet application * * @author William Starkovich * @version 1.00 2009/2/21 */ import java.awt.*; import java.applet.*; import java.awt.event.*; import java.awt.image.*; public class vo4k extends Applet implements KeyListener { obj p1, e1; boolean[] keys; boolean end = false; Graphics g2d; Dimension size; Image buf; public void init() { keys = new boolean[256]; for(int i = 0; i &lt; 256; i++) keys[i] = false; addKeyListener(this); p1 = new obj(); p1.x = 0; size = getSize(); buf = createImage(size.width,size.height); g2d = buf.getGraphics(); } public void keyTyped(KeyEvent e) {} public void keyPressed(KeyEvent e) {keys[e.getKeyCode()] = true;} public void keyReleased(KeyEvent e) {keys[e.getKeyCode()] = false;} public void controls() { if(keys[KeyEvent.VK_SPACE]) end = true; if(keys[KeyEvent.VK_W]) p1.x += 10; } public void start() { // while(!end) // { // } } public void paint(Graphics g) { controls(); //g2d = (Graphics2D) g; g2d.setColor(Color.RED); g2d.fillRect(0,0,size.width,size.height); g2d.setColor(Color.BLUE); g2d.drawString("Welcome 2 Java!!", (int) 50, 60 ); //g2d.drawString("Welcome to Java!!", (int) p1.x, 60 ); g.drawImage(buf, 0, 0, this); repaint(); } } class obj { double x,y,l,a,s; }
answer count: 1
tagged with: applet

http://stackoverflow.com/a/411477
type: Answer
score: 41
downvote count: 0
accepted answer of: http://stackoverflow.com/q/411447
has comment: http://stackoverflow.com/comment/236339
answers question: http://stackoverflow.com/q/411447
has comment: http://stackoverflow.com/comment/238464
has body: A very good follow up question. I consider null a truly special value, and if a method may return null it must clearly document in the Javadoc when it does (@return some value ..., or null if ...). When coding I'm defensive, and assume a method may return null unless I'm convinced it can't (e.g., because the Javadoc said so.) People realized that this is an issue, and a proposed solution is to use annotations to state the intention in a way it can be checked automatically. See JSR 305: Annotations for Software Defect Detection, JSR 308: Annotations on Java Types and JetBrain's Nullable How-To. Your example might look like this, and refused by the IDE, the compiler or other code analysis tools. @NotNull public Object methodWhichCannotReturnNull(int i) throws Exception { return null; // this would lead to a compiler error! }
has comment: http://stackoverflow.com/comment/237604
has comment: http://stackoverflow.com/comment/101175163
upvote count: 41
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/239273

http://stackoverflow.com/a/376102
type: Answer
answers question: http://stackoverflow.com/q/376093
has comment: http://stackoverflow.com/comment/55959463
has comment: http://stackoverflow.com/comment/204074
has body: I'm not 100% sure, but don't you need to annotate the get method and not the private variable?
upvote count: 2
score: 0
downvote count: 2

http://stackoverflow.com/comment/83437560
comment on: http://stackoverflow.com/a/47771708
score: 1
type: AnswerComment
has text: I prefer this solution. When possible I suggest using Apache libs. (my opinion)
type: Comment

http://stackoverflow.com/a/1610914
downvote count: 0
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/397488
has comment: http://stackoverflow.com/comment/42857506
has body: You could take a look at BlueJ which is an interactive Java development environment meant for teaching OOP rather than as full IDE like Eclipse or NetBeans. It's kind of fun to have a play with anyway. You can see it in action on YouTube in a series of Java tutorials.

http://stackoverflow.com/a/37977373
upvote count: 10
type: Answer
downvote count: 0
has body: Using Transformer Factory:- public static String printSoapMessage(final SOAPMessage soapMessage) throws TransformerFactoryConfigurationError, TransformerConfigurationException, SOAPException, TransformerException { final TransformerFactory transformerFactory = TransformerFactory.newInstance(); final Transformer transformer = transformerFactory.newTransformer(); // Format it transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); final Source soapContent = soapMessage.getSOAPPart().getContent(); final ByteArrayOutputStream streamOut = new ByteArrayOutputStream(); final StreamResult result = new StreamResult(streamOut); transformer.transform(soapContent, result); return streamOut.toString(); }
score: 10
answers question: http://stackoverflow.com/q/522395

http://stackoverflow.com/q/499070
has answer: http://stackoverflow.com/a/499111
downvote count: 0
has answer: http://stackoverflow.com/a/499229
favorite count: 0
answer count: 5
type: AnsweredQuestion
score: 3
has answer: http://stackoverflow.com/a/681468
upvote count: 3
accepted answer: http://stackoverflow.com/a/499229
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/499266
tagged with: network-programming
has title: Java NIO: Sending large messages quickly leads to truncated packets and data loss
has answer: http://stackoverflow.com/a/499110
tagged with: nio
has body: I've got this nasty problem where sending multiple, large messages in quick succession from a Java (NIO) server (running Linux) to a client will lead to truncated packets. The messages have to be large and sent very rapidly for the problem to occur. Here's basically what my code is doing (not actual code, but more-or-less what's happening): //-- setup stuff: -- Charset charset = Charset.forName("UTF-8"); CharsetEncoder encoder = charset.newEncoder(); String msg = "A very long message (let's say 20KB)..."; //-- inside loop to handle incoming connections: -- ServerSocketChannel ssc = (ServerSocketChannel)key.channel(); SocketChannel sc = ssc.accept(); sc.configureBlocking(false); sc.socket().setTcpNoDelay(true); sc.socket().setSendBufferSize(1024*1024); //-- later, actual sending of messages: -- for (int n=0; n&lt;20; n++){ ByteBuffer bb = encoder.encode(CharBuffer.wrap(msg+'\0')); sc.write(bb); bb.rewind(); } So, if the packets are long enough and sent as quickly as possible (i.e. in a loop like this with no delay), then on the other end it often comes out something like this: [COMPLETE PACKET 1] [COMPLETE PACKET 2] [COMPLETE PACKET 3] [START OF PACKET 4][SOME OR ALL OF PACKET 5] There is data loss, and the packets start to run together, such that the start of packet 5 (in this example) arrives in the same message as the start of packet 4. It's not just truncating, its running the messages together. I imagine that this is related to the TCP buffer or "window size", or that the server here is just providing data faster than the OS, or network adapter, or something, can handle it. But how do I check for, and prevent it from happening? If I reduce the length of message per use of sc.write(), but then increase the repetitions, I'll still run into the same problem. It seems to simply be an issue with the amount of data in a short amount of time. I don't see that sc.write() is throwing any exceptions either (I know that in my example above I'm not checking, but have in my …
possible better answer: http://stackoverflow.com/a/499111

http://stackoverflow.com/a/598007
score: 2
has body: I think the stacktrace presented above is concealing the real problem here. Below is the code in the method run within org.eclipse.jface.dialogs.ProgressMonitorDialog (with a comment added by me): public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { setCancelable(cancelable); try { aboutToRun(); // Let the progress monitor know if they need to update in UI Thread progressMonitor.forked = fork; ModalContext.run(runnable, fork, getProgressMonitor(), getShell() .getDisplay()); } finally { finishedRun(); // this is line 498 } } The second-from-bottom line in Jared's stacktrace is line 498 of this class, which is the call to finishedRun() within the finally block. I suspect that the real cause is an exception being thrown in the try block. Since the code in the finally block also throws an exception, the original exception is lost.
downvote count: 0
answers question: http://stackoverflow.com/q/596999
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/596999
upvote count: 2
type: Answer

http://stackoverflow.com/a/16564417
has comment: http://stackoverflow.com/comment/29715903
score: -1
downvote count: 1
type: Answer
has body: There are two ways in which Strings can be created in Java. Following are the examples for both the ways: 1) Declare a variable of type String(a class in Java) and assign it to a value which should be put between double quotes. This will create a string in the string pool area of memory. eg: String str = "JAVA"; 2)Use the constructor of String class and pass a string(within double quotes) as an argument. eg: String s = new String("JAVA"); This will create a new string JAVA in the main memory and also in the string pool if this string is not already present in string pool.
upvote count: 0
answers question: http://stackoverflow.com/q/390703

http://stackoverflow.com/a/463479
has comment: http://stackoverflow.com/comment/282727
accepted answer of: http://stackoverflow.com/q/463460
score: 6
answers question: http://stackoverflow.com/q/463460
downvote count: 0
type: AcceptedAnswer
upvote count: 6
has body: The appendReplacement method in Matcher looks like it might be useful, although I can't vouch for its speed. Here's the sample code from the Javadoc: Pattern p = Pattern.compile("cat"); Matcher m = p.matcher("one cat two cats in the yard"); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, "dog"); } m.appendTail(sb); System.out.println(sb.toString()); EDIT: If this is as complicated as it gets, you could probably implement your own state machine fairly easily. You'd pretty much be doing what appendReplacement is already doing, although a specialized implementation might be faster.
type: Answer

http://stackoverflow.com/a/516756
score: 7
answers question: http://stackoverflow.com/q/516565
upvote count: 7
has body: Try using JSON (JavaScript Object Notation) it'd be quite simple to encode the array and decode it on JavaScript. You could use for instance the org.json.JSONArray class for this purpose. Here is a useful article on this subject: Converting a Java List to a JSON array Example with Spring MVC In your Java controller: @GetMapping("/some-path") public ModelAndView viewUser(ViewUserRequest viewUserRequest) { List<String> columns = List.of("One", "Two", "Three"); ModelAndView modelAndView = new ModelAndView("your-jsp-page"); modelAndView.addObject("columns", new JSONArray(columns)); return modelAndView; } In your JSP file: Home
downvote count: 0
has comment: http://stackoverflow.com/comment/119851912
type: Answer

http://stackoverflow.com/a/583913
has comment: http://stackoverflow.com/comment/44549141
score: 24
has comment: http://stackoverflow.com/comment/58001432
accepted answer of: http://stackoverflow.com/q/583852
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/395938
has body: Java Collections provide LinkedHashMap out of the box, which is well-suited to building caches. You probably don't have this in Java ME, but you can grab the source code here: http://kickjava.com/src/java/util/LinkedHashMap.java.htm If you can't just copy-paste it, looking at it should get you started implementing one for inclusion in your mobile app. The basic idea is just to include a linked list through the map elements. If you keep this updated whenever someone does put or get, you can efficiently track access order and use order. The docs contain instructions for building an MRU Cache by overriding the removeEldestEntry(Map.Entry) method. All you really have to do is make a class that extends LinkedHashMap and override the method like so: private static final int MAX_ENTRIES = 100; protected boolean removeEldestEntry(Map.Entry eldest) { return size() &gt; MAX_ENTRIES; } There's also a constructor that lets you specify whether you want the class to store things in order by insertion or by use, so you've got a little flexibility for your eviction policy, too: public LinkedHashMap(int initialCapacity, float loadFactor, boolean accessOrder) Pass true for use-order and false for insertion order.
type: Answer
upvote count: 24
downvote count: 0
has comment: http://stackoverflow.com/comment/69007256
has comment: http://stackoverflow.com/comment/396558
answers question: http://stackoverflow.com/q/583852

oracle-database
tags question: http://stackoverflow.com/q/643280
tags question: http://stackoverflow.com/q/456532
tag name: oracle-database
tags question: http://stackoverflow.com/q/377745
tags question: http://stackoverflow.com/q/620041
tags question: http://stackoverflow.com/q/445455
tags question: http://stackoverflow.com/q/379594
tags question: http://stackoverflow.com/q/597022
tags question: http://stackoverflow.com/q/471475
type: Tag
tags question: http://stackoverflow.com/q/515278
tags question: http://stackoverflow.com/q/529573
tags question: http://stackoverflow.com/q/520869
tags question: http://stackoverflow.com/q/370818
tags question: http://stackoverflow.com/q/521278
tags question: http://stackoverflow.com/q/520041
tags question: http://stackoverflow.com/q/383783
tags question: http://stackoverflow.com/q/583141
tags question: http://stackoverflow.com/q/457933
tags question: http://stackoverflow.com/q/529471
tags question: http://stackoverflow.com/q/503003
tags question: http://stackoverflow.com/q/433689
tags question: http://stackoverflow.com/q/415779
tags question: http://stackoverflow.com/q/365168
tags question: http://stackoverflow.com/q/427447
tags question: http://stackoverflow.com/q/639757
tags question: http://stackoverflow.com/q/495376

http://stackoverflow.com/a/593538
upvote count: 4
has body: There is also an example on how you can call Clojure code from JRuby.
downvote count: 0
answers question: http://stackoverflow.com/q/591459
type: Answer
score: 4

http://stackoverflow.com/a/378647
upvote count: 1
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/376346
has body: If you are counting the size of the Collatz sequence for numbers upto 1,000,000 you should re-consider using Integer type. I suggest using BigInteger or possible a long. This should alleviate the problems encountered, but be warned you may still run out of heap-space depending on your JVM.

http://stackoverflow.com/a/2210504
has body: Unless you implement g() as follows: g() { synchronized(getClass()) { ... } } I find this pattern useful also when I want to implement mutual exclusion between different instances of the object (which is needed when accesing an external resource, for example).
type: Answer
upvote count: 16
has comment: http://stackoverflow.com/comment/4661798
downvote count: 1
answers question: http://stackoverflow.com/q/437620
score: 15

http://stackoverflow.com/a/2798109
upvote count: 4
downvote count: 0
has body: Check out JSpell by Page Scholar, http://www.jspell.com.
score: 4
answers question: http://stackoverflow.com/q/559510
type: Answer

http://stackoverflow.com/q/397488
has answer: http://stackoverflow.com/a/697736
has answer: http://stackoverflow.com/a/397739
has answer: http://stackoverflow.com/a/46219791
has answer: http://stackoverflow.com/a/3673179
has answer: http://stackoverflow.com/a/20122821
has answer: http://stackoverflow.com/a/35231735
has answer: http://stackoverflow.com/a/12790112
has answer: http://stackoverflow.com/a/397505
favorite count: 0
has answer: http://stackoverflow.com/a/19713943
has answer: http://stackoverflow.com/a/2637925
has answer: http://stackoverflow.com/a/397514
has answer: http://stackoverflow.com/a/30070787
has answer: http://stackoverflow.com/a/5837037
downvote count: 2
has comment: http://stackoverflow.com/comment/49815760
has answer: http://stackoverflow.com/a/12789297
has comment: http://stackoverflow.com/comment/17291105
accepted answer: http://stackoverflow.com/a/397505
tagged with: read-eval-print-loop
has answer: http://stackoverflow.com/a/397490
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/1610914
has answer: http://stackoverflow.com/a/7318347
has answer: http://stackoverflow.com/a/9510182
tagged with: java
has answer: http://stackoverflow.com/a/65445603
has answer: http://stackoverflow.com/a/397613
has answer: http://stackoverflow.com/a/16597636
type: Question
score: 92
has answer: http://stackoverflow.com/a/1278987
has title: Is there something like python's interactive REPL mode, but for Java?
has answer: http://stackoverflow.com/a/38913829
has answer: http://stackoverflow.com/a/15962251
has answer: http://stackoverflow.com/a/2639774
upvote count: 94
has answer: http://stackoverflow.com/a/397519
has body: Is there something like python's interactive REPL mode, but for Java? So that I can, for example, type InetAddress.getAllByName( localHostName ) in a window, and immediately get results, without all this public static void nightmare() thing?
has answer: http://stackoverflow.com/a/38118773
has answer: http://stackoverflow.com/a/2636083
answer count: 29
has answer: http://stackoverflow.com/a/397496
possible better answer: http://stackoverflow.com/a/1278987
linked to: http://stackoverflow.com/q/26549307

http://stackoverflow.com/q/477267
answer count: 1
downvote count: 0
favorite count: 0
has body: Currently I'm using a session-per-request approach to manage Hibernate sessions in a Java web application. I heard the term session-per-conversation thrown around and was wondering what situations it suits and what benefits it can bring over session-per-request?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/477639
tagged with: java
tagged with: hibernate
tagged with: web-applications
type: Question
has title: What are the benefits of session-per-conversation?
tagged with: session
upvote count: 5
accepted answer: http://stackoverflow.com/a/477639
score: 5

http://stackoverflow.com/a/5837037
downvote count: 0
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/397488
has body: DrJava is an educational IDE that includes an REPL pane. There is an Eclipse plugin as well, but it hasn't worked for me. I think it just hasn't been updated in a while. So what I generally do is keep a DrJava window open for the "what happens if I do this" questions. EclipseShell might be good too, but I haven't used it yet.

http://stackoverflow.com/a/15208183
type: Answer
upvote count: 3
score: 3
answers question: http://stackoverflow.com/q/602397
has body: Maybe this is not exactly what author asked for (to externalize to non-java file), but this is how I solved it: 1.) in my application context xml file I added mappingResources to sessionFactory META-INF/Country.hbm.xml <util:list> com.example.Country </util:list> and in that Country.hbm.xml I have <?xml version="1.0" encoding="UTF-8"?> select c from Country c where c.code = :code select c from Country c where c.name = :name I used that just to define named queries, the rest of entity configuration is in annotations. Maybe that helps someone.
downvote count: 0

http://stackoverflow.com/a/397910
type: Answer
has comment: http://stackoverflow.com/comment/38005131
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/396391
has body: The fact about Many to Many is that it needs a little more configuration, because its imperative that Hibernate generates a relation table. Try this: @Entity @Table(name="users") public class User { @Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name="userid") protected Long id = null; @ManyToMany @JoinTable(name = "user_friends", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "friend_id")) protected List friends = null; @ManyToMany(mappedBy = "friends") protected List befriended = null; } Hope it works =) EDIT: Also, be very careful with fetch types... you can enter an user fetching out-of-control loop and get all the DB.
accepted answer of: http://stackoverflow.com/q/396391
downvote count: 0
type: AcceptedAnswer

http://stackoverflow.com/q/507602
linked to: http://stackoverflow.com/q/6802483
has title: How can I initialise a static Map?
tagged with: dictionary
has answer: http://stackoverflow.com/a/13943037
has answer: http://stackoverflow.com/a/40855194
answer count: 43
has answer: http://stackoverflow.com/a/52266947
linked to: http://stackoverflow.com/q/1372113
has answer: http://stackoverflow.com/a/21083994
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/28202853
has answer: http://stackoverflow.com/a/4420400
tagged with: java
has answer: http://stackoverflow.com/a/35662460
has answer: http://stackoverflow.com/a/30345279
has answer: http://stackoverflow.com/a/44659512
has answer: http://stackoverflow.com/a/507686
tagged with: collections
has answer: http://stackoverflow.com/a/31860743
downvote count: 1
has answer: http://stackoverflow.com/a/37384773
type: Question
has comment: http://stackoverflow.com/comment/75947669
possible better answer: http://stackoverflow.com/a/7258027
upvote count: 1254
has answer: http://stackoverflow.com/a/30630355
has answer: http://stackoverflow.com/a/56749997
has answer: http://stackoverflow.com/a/35066601
has answer: http://stackoverflow.com/a/7258027
has answer: http://stackoverflow.com/a/36531434
accepted answer: http://stackoverflow.com/a/507658
has answer: http://stackoverflow.com/a/508988
has answer: http://stackoverflow.com/a/18890130
has answer: http://stackoverflow.com/a/507621
has answer: http://stackoverflow.com/a/34508760
has answer: http://stackoverflow.com/a/46937591
has comment: http://stackoverflow.com/comment/138376887
has body: How would you initialise a static Map in Java? Method one: static initialiser Method two: instance initialiser (anonymous subclass) or some other method? What are the pros and cons of each? Here is an example illustrating the two methods: import java.util.HashMap; import java.util.Map; public class Test { private static final Map&lt;Integer, String&gt; myMap = new HashMap&lt;&gt;(); static { myMap.put(1, "one"); myMap.put(2, "two"); } private static final Map&lt;Integer, String&gt; myMap2 = new HashMap&lt;&gt;(){ { put(1, "one"); put(2, "two"); } }; }
has answer: http://stackoverflow.com/a/2964275
has comment: http://stackoverflow.com/comment/94831143
has answer: http://stackoverflow.com/a/64913102
has answer: http://stackoverflow.com/a/507800
has answer: http://stackoverflow.com/a/23214686
has answer: http://stackoverflow.com/a/508363
linked to: http://stackoverflow.com/q/1958636
has answer: http://stackoverflow.com/a/33816920
has answer: http://stackoverflow.com/a/507850
has answer: http://stackoverflow.com/a/43711510
has answer: http://stackoverflow.com/a/1134205
has answer: http://stackoverflow.com/a/32454155
has answer: http://stackoverflow.com/a/25829097
tagged with: initialization
has comment: http://stackoverflow.com/comment/62279931
favorite count: 0
has answer: http://stackoverflow.com/a/509016
linked to: http://stackoverflow.com/q/924285
has answer: http://stackoverflow.com/a/23102809
has answer: http://stackoverflow.com/a/44130916
has answer: http://stackoverflow.com/a/18007334
has answer: http://stackoverflow.com/a/507626
tagged with: idioms
has answer: http://stackoverflow.com/a/40878647
has answer: http://stackoverflow.com/a/39510693
has answer: http://stackoverflow.com/a/12136950
score: 1253
has answer: http://stackoverflow.com/a/47492794
linked to: http://stackoverflow.com/q/3013538
has answer: http://stackoverflow.com/a/507658

http://stackoverflow.com/comment/15324912
score: 1
type: AnswerComment
type: Comment
has text: If you need to look for a lot of columns, you can always have this return a `Set<String>` populated by the `getColumnName(i)` method calls. In this way, you can refer to `set.contains(myCol)` instead of iterating over it everything.
comment on: http://stackoverflow.com/a/462570

http://stackoverflow.com/q/566186
tagged with: swing
upvote count: 8
has answer: http://stackoverflow.com/a/566730
has title: JTable with a complex editor
type: Question
tagged with: java
has body: I have many custom editors for a JTable and it's an understatement to say that the usability, particularly in regard to editing with the keyboard, is lacking. The main reason for this is that my editors are always created with a similar (though often more complex) situation to this: @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { JPanel container = new JPanel(); container.setLayout(new BorderLayout()); container.add(field, BorderLayout.CENTER); field.setText((String) value); container.add(new JButton("..."), BorderLayout.EAST); return container; } I.E a panel with more than one component inside. The actual text editor is a descendant of the component being returned as the editor. So, rendering issues aside, from what I can tell, the JTable is focusing the component that is returned by the getTableCellEditorComponent method so when you press a key with a cell highlighted it passes focus and the key press to the panel, thinking that's the editor. Is there anyway I can inform JTable that the "real" editor is the JTextfield? Adding a hacky requestFocusInWindow on the correct component is insufficient as the key press won't get passed on.
has answer: http://stackoverflow.com/a/13406258
tagged with: jtable
tagged with: user-interface
has answer: http://stackoverflow.com/a/568666
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/612241
answer count: 4
score: 8
tagged with: editor
downvote count: 0

http://stackoverflow.com/a/577880
score: 6
has comment: http://stackoverflow.com/comment/452052
upvote count: 6
accepted answer of: http://stackoverflow.com/q/577868
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/577868
has body: Since SVN doesn't know about programming languages it would be very dangerous if it would try to deduce semantic meaning from change sets. Therefore it can only do relatively simple merges (i.e. if a file changed in two completely different areas). The common solution is to use small commits. Don't keep big changes piling up. Commit often. Update often.
type: Answer
downvote count: 0

http://stackoverflow.com/comment/386626
has text: synchronize on a method may not necessarily work, although it might make you think that it does.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/574806
type: Comment

http://stackoverflow.com/comment/106121164
has text: Can you add 4. option of modifying environment of *running* child process? I assume it is same as 1.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/580097

http://stackoverflow.com/comment/8859928
type: AnswerComment
has text: I guess that if an exception is thrown in the finally block, the rest of the block is not executed.
type: Comment
comment on: http://stackoverflow.com/a/464102
score: 2

http://stackoverflow.com/q/456935
has body: In java a class can implement Iterable which lets you use the foreach() statement and the iteration syntatic sugar: for(T t:ts) ... However, this does not allow you to throw exceptions on the construction for an Iterator. If you were iterating off a network, file, database etc it would be nice to be able to throw exceptions. Obvious candidates are java.io.InputStream, Reader and the java.nio.Channel code, but none of this can use Generics like the Iterable interface can. Is there a common idiom or Java API for this situation? Clarification: This is asking if there is a pattern or alternative interface for iterating for objects off a non-memory source. As responders have said, just throwing RuntimeExceptions to get around the problem is not recommended or what I was looking for. Edit 2: Thanks to answers so far. The consensus seems to be "you can't". So can I extend the question to "What do you do in this situation, when this situation would be useful?" Just write your own interface?
upvote count: 5
has title: In Java how would you write the equivalent of Iterable which could throw exceptions?
has answer: http://stackoverflow.com/a/456954
has answer: http://stackoverflow.com/a/457223
has answer: http://stackoverflow.com/a/457084
possible better answer: http://stackoverflow.com/a/456997
has answer: http://stackoverflow.com/a/456997
downvote count: 0
favorite count: 0
tagged with: exception
answer count: 5
has answer: http://stackoverflow.com/a/457149
accepted answer: http://stackoverflow.com/a/457084
type: AnsweredQuestion
tagged with: java
type: Question
score: 5

http://stackoverflow.com/comment/69285715
score: 0
comment on: http://stackoverflow.com/a/494200
type: Comment
has text: It's not working when testDate is today's current date.. How to handle this scenario in above suggested solution.
type: AnswerComment

http://stackoverflow.com/q/532521
has answer: http://stackoverflow.com/a/801353
has title: Which data structure uses more memory?
tagged with: data-structures
has answer: http://stackoverflow.com/a/533738
score: 0
has answer: http://stackoverflow.com/a/532575
has answer: http://stackoverflow.com/a/532556
upvote count: 1
downvote count: 1
favorite count: 0
tagged with: memory-management
answer count: 9
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/532558
has answer: http://stackoverflow.com/a/532583
has answer: http://stackoverflow.com/a/532632
has comment: http://stackoverflow.com/comment/345504
has answer: http://stackoverflow.com/a/532569
has answer: http://stackoverflow.com/a/532899
tagged with: java
type: Question
has body: Which type of data structure uses more memory? Hashtable Hashmap ArrayList Could you please give me a brief explanation which one is less prone to memory leakage?

http://stackoverflow.com/comment/49108965
has text: I'm confused... I couldn't get it to work until I used 3 `\ ` in `replaceAll()` for `String before = " this \nhere ";`
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/542258

jogl
tag name: jogl
tags question: http://stackoverflow.com/q/617429
tags question: http://stackoverflow.com/q/623923
tags question: http://stackoverflow.com/q/428225
tags question: http://stackoverflow.com/q/615899
type: Tag
tags question: http://stackoverflow.com/q/625302
tags question: http://stackoverflow.com/q/623805
tags question: http://stackoverflow.com/q/414915
tags question: http://stackoverflow.com/q/602614
tags question: http://stackoverflow.com/q/465994

http://stackoverflow.com/a/646275
has comment: http://stackoverflow.com/comment/1188821
has comment: http://stackoverflow.com/comment/461754
score: 6
has body: If you have the possibility (may be difficult in web applications), it would be better to store passwords in character arrays than to store them in strings. If you finished storing the password you can overwrite it in memory by using Array.fill() and make the reference available for the garbage collector by discarding it: Arrays.fill(password, ' '); password = null; I just noticed that nulling the password would be a bit paranoid but you can do if it reassures you :)
accepted answer of: http://stackoverflow.com/q/646224
has comment: http://stackoverflow.com/comment/1089772
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/646224
type: Answer
upvote count: 6
has comment: http://stackoverflow.com/comment/60961620

http://stackoverflow.com/a/1014283
score: 0
type: Answer
has body: JavaMail will read the whole stream, possibly buffering it. I agree with @skaffman, however my perspective is that it's just heavily optimized without comments as to why, and that makes it hard to use. The MimeMessage.parse(InputStream) method is what you're dealing with. It does read the whole stream, without closing it, unless you're using a SharedInputStream. It will leave the InputStream positioned at the end, as you are seeing. The MimeMessage doesn't do much to interpret the data in the stream, therefore I think you're "missing something bigger" to use your words. Why do you expect it to interpret the data? Can you just send the multipart messages that you're using to create your streams?
answers question: http://stackoverflow.com/q/599188

http://stackoverflow.com/a/568452
upvote count: 9
score: 9
has body: You want to use Apple's eio.FileManager extension: static public String documentsDirectory() throws java.io.FileNotFoundException { // From CarbonCore/Folders.h final String kDocumentsDirectory = "docs"; return com.apple.eio.FileManager.findFolder( com.apple.eio.FileManager.kUserDomain, com.apple.eio.FileManager.OSTypeToInt(kDocumentsDirectory) ); } Documentation
downvote count: 0
has comment: http://stackoverflow.com/comment/15977706
type: Answer
has comment: http://stackoverflow.com/comment/3881110
answers question: http://stackoverflow.com/q/567874

http://stackoverflow.com/a/434526
answers question: http://stackoverflow.com/q/431654
has body: Others have already commetned about JPanel and using a TitledBorder, that's fine. However, when playing with Swing LayoutManagers, you may find it annoying that components in different JPanels cannot align correctly (each panel has its own LayoutManager). For this reason, it is a good practice (check "JGoodies" on the web for more details) in Swing GUIs to NOT use TitledBorders but rather separate groups of components in a JPanel by a JLabel followed by a horizontal JSeparator. Ref. "First Aid for Swing"
has comment: http://stackoverflow.com/comment/67891073
downvote count: 0
score: 8
upvote count: 8
type: Answer
has comment: http://stackoverflow.com/comment/40447383

http://stackoverflow.com/a/480362
has comment: http://stackoverflow.com/comment/101805994
has body: There are a lot of similarities between both implementations (and in my opinion: yes, they're both "virtual machines"). For one thing, they're both stack-based VM's, with no notion of "registers" like we're used to seeing in a modern CPU like the x86 or PowerPC. The evaluation of all expressions ((1 + 1) / 2) is performed by pushing operands onto the "stack" and then popping those operands off the stack whenever an instruction (add, divide, etc) needs to consume those operands. Each instruction pushes its results back onto the stack. It's a convenient way to implement a virtual machine, because pretty much every CPU in the world has a stack, but the number of registers is often different (and some registers are special-purpose, and each instruction expects its operands in different registers, etc). So, if you're going to model an abstract machine, a purely stack-based model is a pretty good way to go. Of course, real machines don't operate that way. So the JIT compiler is responsible for performing "enregistration" of bytecode operations, essentially scheduling the actual CPU registers to contain operands and results whenever possible. So, I think that's one of the biggest commonalities between the CLR and the JVM. As for differences... One interesting difference between the two implementations is that the CLR includes instructions for creating generic types, and then for applying parametric specializations to those types. So, at runtime, the CLR considers a List&lt;int&gt; to be a completely different type from a List&lt;String&gt;. Under the covers, it uses the same MSIL for all reference-type specializations (so a List&lt;String&gt; uses the same implementation as a List&lt;Object&gt;, with different type-casts at the API boundaries), but each value-type uses its own unique implementation (List&lt;int&gt; generates completely different code from List&lt;double&gt;). In Java, generic types are a purely a compiler trick. The JVM has no notion of which classes have …
has comment: http://stackoverflow.com/comment/99925414
has comment: http://stackoverflow.com/comment/21381474
answers question: http://stackoverflow.com/q/453610
has comment: http://stackoverflow.com/comment/14636290
upvote count: 295
has comment: http://stackoverflow.com/comment/89722496
has comment: http://stackoverflow.com/comment/321603
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/101804859
has comment: http://stackoverflow.com/comment/58219622
has comment: http://stackoverflow.com/comment/101895447
accepted answer of: http://stackoverflow.com/q/453610
has comment: http://stackoverflow.com/comment/101805178
type: Answer
has comment: http://stackoverflow.com/comment/7072474
score: 292
downvote count: 3
has comment: http://stackoverflow.com/comment/79072778

http://stackoverflow.com/comment/1042995
type: AnswerComment
has text: As long as you are within the object cache, the cost autoboxing and unboxing is notional. Auto-boxing is never necessary however.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/517769

http://stackoverflow.com/q/450486
type: UnansweredQuestion
has title: Template engine for image generation
downvote count: 0
score: 7
tagged with: java
has answer: http://stackoverflow.com/a/450517
has answer: http://stackoverflow.com/a/47750488
type: Question
has body: Does anyone know of any templating engines for generating images, preferably Java-based? What I have in mind is something like StringTemplate where a you have a set of parameterized templates that render to an image (or SVG, etc) rather than text. It needs to be more general purpose than "insert text here to generate a sign". Primitives would be various shapes, other images, text, etc. I realize I can build this pretty easily myself with a text template engine that generates SVG, but I'm looking for something that works "out of the box". Thanks! To elaborate a bit, here's some totally made up syntax for what I'm looking for. Image I want to generate an icon with some status overlays (like icons in Eclipse): iconTemplate(base, status, svn) { image($base), // the base icon // create a 2x2 grid for status overlays gridlayout(2, 2) { // conditionally add overlays in corners based on parameters if($status == "error") { image("error.png") { layoutInfo : cell(1, 0) } } if($svn == "changed") { image("changed.png") { layoutInfo : cell(1, 1) } } } } Note this syntax is completed made up and obviously sucks, but maybe it gets the idea across :)
tagged with: image
answer count: 3
upvote count: 7
has answer: http://stackoverflow.com/a/450964
tagged with: template-engine
favorite count: 0

http://stackoverflow.com/q/595222
has answer: http://stackoverflow.com/a/595363
tagged with: java
type: Question
type: AnsweredQuestion
has title: Java JDBC driver and TYPE_FORWARD_ONLY
has answer: http://stackoverflow.com/a/595353
score: 0
possible better answer: http://stackoverflow.com/a/595362
has answer: http://stackoverflow.com/a/595362
has body: How I could determine if JDBC driver is TYPE_FORWARD_ONLY? In my program the user configures connection parameters to database and he could use any JDBC driver in the class path. I want to know if the driver is TYPE_FORWARD_ONLY before executing any statements. Is this possible?
accepted answer: http://stackoverflow.com/a/595363
has answer: http://stackoverflow.com/a/595334
tagged with: jdbc
answer count: 4

http://stackoverflow.com/comment/205398
has text: I thought Java died a long time ago? :P
score: 1
comment on: http://stackoverflow.com/q/377593
type: Comment
type: QuestionComment

http://stackoverflow.com/q/456926
tagged with: c++
has body: Please tell me C++/Java code which utilize memory more than 70% . For Example we have 3 Virtual machine and in memory resources we want to test the memory utilization as per memory resources allocated by user.
downvote count: 0
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/456948
type: Question
has title: Code to utilize memory more than 70%
tagged with: http://stackoverflow.com/tag/c
answer count: 3
upvote count: 1
has answer: http://stackoverflow.com/a/456943
favorite count: 0
type: UnansweredQuestion
tagged with: python
has answer: http://stackoverflow.com/a/460265

http://stackoverflow.com/a/564915
has body: Use the constructor where you don't need to specify these values, then reasonable defaults are chosen.
upvote count: 7
has comment: http://stackoverflow.com/comment/376213
score: 7
downvote count: 0
answers question: http://stackoverflow.com/q/564899
type: Answer
has comment: http://stackoverflow.com/comment/137143080

http://stackoverflow.com/q/601143
favorite count: 0
tagged with: http://stackoverflow.com/tag/xml
has answer: http://stackoverflow.com/a/1702110
has answer: http://stackoverflow.com/a/17613289
has comment: http://stackoverflow.com/comment/65264183
has answer: http://stackoverflow.com/a/3280116
has body: I have Java classes with the following structure (the class names do not imply anything, I was just making them up). package test; import java.util.ArrayList; import java.util.List; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlValue; @XmlRootElement public class Test { @XmlAccessorType(XmlAccessType.FIELD) static class Machine { @XmlElementWrapper(name="servers") @XmlElement(name="server") List servers = new ArrayList (); } @XmlAccessorType(XmlAccessType.FIELD) static class Server { Threshold t = new Threshold(); } @XmlAccessorType(XmlAccessType.FIELD) static class Threshold { RateThreshold load = new RateThreshold(); } @XmlAccessorType(XmlAccessType.FIELD) static class RateThreshold { @XmlAccessorType(XmlAccessType.FIELD) static class Rate { int count; Period period = new Period(); } @XmlAccessorType(XmlAccessType.FIELD) private static class Period { @XmlAttribute private String type = "second"; @XmlValue private float period; } Rate min = new Rate(); Rate max = new Rate(); } @XmlElementWrapper(name="machines") @XmlElement(name="machine") List machines = new ArrayList (); public static void main(String[] args) { Machine m = new Machine(); Server s = new Server(); s.t.load.max.count = 10; s.t.load.min.count = 1; m.servers.add(s); Test t = new Test(); t.machines.add(m); JAXBContext jaxbContext; Marshaller marshaller; try { jaxbContext = JAXBContext.newInstance(Test.class); marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(t, System.out); } catch (JAXBException e) { e.printStackTrace(); } } } The problem I am h…
type: AnsweredQuestion
tagged with: java
tagged with: jaxb
type: Question
score: 12
possible better answer: http://stackoverflow.com/a/17613289
has title: JAXB XML output format questions
upvote count: 12
downvote count: 0
answer count: 3
has comment: http://stackoverflow.com/comment/65291715
accepted answer: http://stackoverflow.com/a/3280116

http://stackoverflow.com/a/529610
upvote count: 1
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/529573
accepted answer of: http://stackoverflow.com/q/529573
type: Answer
has comment: http://stackoverflow.com/comment/346764
score: 1
has body: If you use Oracle ADF 11i Faces, you have over 100 Components out of the box (According to the Oracle site even over a 150 Ajax-enabled JSF components). Try using these first (could be better than custom components).

http://stackoverflow.com/a/455750
downvote count: 3
upvote count: 10
type: Answer
has body: Maybe this would work: Remove the double backslashes from the parameter of the split method: split = docStr.split("\n");
has comment: http://stackoverflow.com/comment/275699
answers question: http://stackoverflow.com/q/454908
has comment: http://stackoverflow.com/comment/127962364
score: 7
has comment: http://stackoverflow.com/comment/10361192

http://stackoverflow.com/a/533397
type: Answer
score: 6
upvote count: 6
has comment: http://stackoverflow.com/comment/346861
has comment: http://stackoverflow.com/comment/346629
has body: There are usually both levels of division present. From the top, there are deployment units. These are named 'logically' (in your terms, think Eclipse features). Inside deployment unit, you have functional division of packages (think Eclipse plugins). For example, feature is com.feature, and it consists of com.feature.client, com.feature.core and com.feature.ui plugins. Inside plugins, I have very little division to other packages, although that's not unusual too. Update: Btw, there is great talk by Juergen Hoeller about code organization at InfoQ: http://www.infoq.com/presentations/code-organization-large-projects. Juergen is one of architects of Spring, and knows a lot about this stuff.
downvote count: 0
answers question: http://stackoverflow.com/q/533102

http://stackoverflow.com/a/480611
has comment: http://stackoverflow.com/comment/297460
type: Answer
has comment: http://stackoverflow.com/comment/312045
has comment: http://stackoverflow.com/comment/301042
has comment: http://stackoverflow.com/comment/313893
has comment: http://stackoverflow.com/comment/297674
has comment: http://stackoverflow.com/comment/297476
accepted answer of: http://stackoverflow.com/q/480566
has comment: http://stackoverflow.com/comment/297325
has comment: http://stackoverflow.com/comment/297450
answers question: http://stackoverflow.com/q/480566
has comment: http://stackoverflow.com/comment/298018
has comment: http://stackoverflow.com/comment/297420
has comment: http://stackoverflow.com/comment/312056
has comment: http://stackoverflow.com/comment/299172
has comment: http://stackoverflow.com/comment/297449
has comment: http://stackoverflow.com/comment/311283
has comment: http://stackoverflow.com/comment/312069
has comment: http://stackoverflow.com/comment/297343
has comment: http://stackoverflow.com/comment/297903
has body: Yes, because GC can only collect objects not reachable by any thread, and Thread must hold a reference to it's runnable (or it would not be able to invoke it). So, clearly, your Runnable object is reachable while your thread is running. Regardless of the semantics required for execution, your object will not be GC'd until it is no longer reachable by this new thread or any other; that will be at least long enough to invoke your Runnable's run(), and for the entire life of the thread if that thread is able to reach the Runnable instance, so your construct is guaranteed to be safe by the JVM specification. EDIT: Because Darron is beating this to death, and some seem convinced by his argument I'm going to expand upon my explanation, based on his. Assume for the moment that it was not legal for anyone except Thread itself to call Thread.run(), In that case it would be legal for the default implementation of Thread.run() to look like: void run() { Runnable tmp = this.myRunnable; // Assume JIT make this a register variable. this.myRunnable = null; // Release for GC. if(tmp != null) { tmp.run(); // If the code inside tmp.run() overwrites the register, GC can occur. } } I contend that in this case tmp is still a reference to the runnable reachable by the thread executing within Thread.run() and therefore is not eligible for GC. What if (for some inexplicable reason) the code looked like: void run() { Runnable tmp = this.myRunnable; // Assume JIT make this a register variable. this.myRunnable = null; // Release for GC. if(tmp != null) { tmp.run(); // If the code inside tmp.run() overwrites the register, GC can occur. System.out.println("Executed runnable: "+tmp.hashCode()); } } Clearly, the instance referred to by tmp cannot be GC'd while tmp.run() is executing. I think Darron mistakingly believes that reachable means only those references which can be found by chasing instance references starting with all Thread instances as roots, rather than being defined as a reference w…
has comment: http://stackoverflow.com/comment/313814
has comment: http://stackoverflow.com/comment/311902
score: 12
has comment: http://stackoverflow.com/comment/297540
has comment: http://stackoverflow.com/comment/312753
downvote count: 2
has comment: http://stackoverflow.com/comment/300196
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/9404513
upvote count: 14
has comment: http://stackoverflow.com/comment/313810
has comment: http://stackoverflow.com/comment/313875

http://stackoverflow.com/q/529432
linked to: http://stackoverflow.com/q/4753251
has title: Java: Format number in millions
tagged with: numericupdown
score: 14
has answer: http://stackoverflow.com/a/529488
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/57721847
has body: Is there a way to use DecimalFormat (or some other standard formatter) to format numbers like this: 1,000,000 =&gt; 1.00M 1,234,567 =&gt; 1.23M 1,234,567,890 =&gt; 1234.57M Basically dividing some number by 1 million, keeping 2 decimal places, and slapping an 'M' on the end. I've thought about creating a new subclass of NumberFormat but it looks trickier than I imagined. I'm writing an API that has a format method that looks like this: public String format(double value, Unit unit); // Unit is an enum Internally, I'm mapping Unit objects to NumberFormatters. The implementation is something like this: public String format(double value, Unit unit) { NumberFormatter formatter = formatters.get(unit); return formatter.format(value); } Note that because of this, I can't expect the client to divide by 1 million, and I can't just use String.format() without wrapping it in a NumberFormatter.
tagged with: java
tagged with: formatting
tagged with: numeric
has comment: http://stackoverflow.com/comment/49591555
type: Question
answer count: 8
has comment: http://stackoverflow.com/comment/342405
has answer: http://stackoverflow.com/a/55224088
has answer: http://stackoverflow.com/a/530366
favorite count: 0
upvote count: 14
has comment: http://stackoverflow.com/comment/342433
has answer: http://stackoverflow.com/a/529453
has answer: http://stackoverflow.com/a/529501
accepted answer: http://stackoverflow.com/a/529488
has answer: http://stackoverflow.com/a/64688890
possible better answer: http://stackoverflow.com/a/530366
has answer: http://stackoverflow.com/a/529476

http://stackoverflow.com/a/647314
score: 39
has comment: http://stackoverflow.com/comment/117570830
downvote count: 0
has comment: http://stackoverflow.com/comment/75005503
upvote count: 39
type: Answer
answers question: http://stackoverflow.com/q/647116
has comment: http://stackoverflow.com/comment/8536972
has body: If you happen to have both a bash shell and jad: JAR=(your jar file name) unzip -d $JAR.tmp $JAR pushd $JAR.tmp for f in `find . -name '*.class'`; do jad -d $(dirname $f) -s java -lnc $f done popd I might be a tiny, tiny bit off with that, but it should work more or less as advertised. You should end up with $JAR.tmp containing your decompiled files.

http://stackoverflow.com/a/481908
downvote count: 0
accepted answer of: http://stackoverflow.com/q/481802
upvote count: 2
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/298660
type: Answer
has body: The way I've seen multiple annotations attached is to use a container annotation, and then specify the items as an array. @Retention(RetentionPolicy.RUNTIME) public @interface Menu { String name(); String[] children(); } @Retention(RetentionPolicy.RUNTIME) public @interface MenuBar { Menu[] value(); } @Retention(RetentionPolicy.RUNTIME) public @interface MenuItem { String value(); } @MenuBar( { @Menu(name="File", children= {"Save","Load","Print","Preview","Quit"}), @Menu(name="Print", children= {"Preview","Print"}), @Menu(name="Edit", children= {"Copy","Paste"}) } ) public class TestMenu { @MenuItem ("Save") public void save() { System.out.println("saved"); } @MenuItem ("Load") public void load() { System.out.println("loaded"); } }
score: 2
answers question: http://stackoverflow.com/q/481802

http://stackoverflow.com/a/56604090
type: Answer
answers question: http://stackoverflow.com/q/610333
has body: How about replacing multiple ‘+’ with an undefined amount of repeats? Example: test+test+test+1234 (+) or [+] seem to pick on a single literal character but on repeats.
score: 0

http://stackoverflow.com/q/443846
has title: Cons for defining logger non-static
has answer: http://stackoverflow.com/a/443891
has body: Comments for this answer How do you reduce Java logging boilerplate code? strongly suggest not to use loggers as instance member variables. I can think of two negative side-effects: 1) superclass logs with the subclass's logger 2) object cannot be serialized (unless marked transient) But if serializing is not necessary and logging with subclass name is not a problem, is there anything else why it should be avoided? I think it reduces boilerplate code and avoids copy-paste errors while copying logger variable definition from one class to another. Even Spring framework (which I believe has very good coding standards) uses this method.
has answer: http://stackoverflow.com/a/443908
has answer: http://stackoverflow.com/a/443906
favorite count: 0
type: UnansweredQuestion
upvote count: 10
has answer: http://stackoverflow.com/a/443926
has answer: http://stackoverflow.com/a/5977374
has answer: http://stackoverflow.com/a/15130749
downvote count: 0
tagged with: logging
type: Question
tagged with: java
score: 10
answer count: 6

http://stackoverflow.com/a/446682
type: Answer
has comment: http://stackoverflow.com/comment/78775676
downvote count: 0
upvote count: 39
has comment: http://stackoverflow.com/comment/268375
has body: As far as I am concerned, I prefer to externalize the error messages in a properties files. This will be really helpful in case of internationalization of your application (one properties file per language). It is also easier to modify an error message, and it won't need any re-compilation of the Java sources. On my projects, generally I have an interface that contains errors codes (String or integer, it doesn't care much), which contains the key in the properties files for this error: public interface ErrorCodes { String DATABASE_ERROR = "DATABASE_ERROR"; String DUPLICATE_USER = "DUPLICATE_USER"; ... } in the properties file: DATABASE_ERROR=An error occurred in the database. DUPLICATE_USER=The user already exists. ... Another problem with your solution is the maintenability: you have only 2 errors, and already 12 lines of code. So imagine your Enumeration file when you will have hundreds of errors to manage!
score: 39
answers question: http://stackoverflow.com/q/446663

http://stackoverflow.com/a/54648481
upvote count: 6
has comment: http://stackoverflow.com/comment/139750756
type: Answer
score: 6
has comment: http://stackoverflow.com/comment/139751954
answers question: http://stackoverflow.com/q/412380
downvote count: 0
has body: Late to the party perhaps, but I wanted to share my take on this. I prefer not to pull in entire libraries for something like this. Instead, I'm using a Builder pattern and allow conveniently chained append(more) calls. It even allows mixing File and String, and can easily be extended to support Path as well. Furthermore, it automatically handles the different path separators correctly on both Linux, Macintosh, etc. public class Files { public static class PathBuilder { private File file; private PathBuilder ( File root ) { file = root; } private PathBuilder ( String root ) { file = new File(root); } public PathBuilder append ( File more ) { file = new File(file, more.getPath()) ); return this; } public PathBuilder append ( String more ) { file = new File(file, more); return this; } public File buildFile () { return file; } } public static PathBuilder buildPath ( File root ) { return new PathBuilder(root); } public static PathBuilder buildPath ( String root ) { return new PathBuilder(root); } } Example of usage: File root = File.listRoots()[0]; String hello = "hello"; String world = "world"; String filename = "warez.lha"; File file = Files.buildPath(root).append(hello).append(world) .append(filename).buildFile(); String absolute = file.getAbsolutePath(); The resulting absolute will contain something like: /hello/world/warez.lha or maybe even: A:\hello\world\warez.lha

http://stackoverflow.com/q/489993
has answer: http://stackoverflow.com/a/490019
type: Question
accepted answer: http://stackoverflow.com/a/490019
tagged with: java
tagged with: eclipse
score: 0
has answer: http://stackoverflow.com/a/490046
answer count: 3
possible better answer: http://stackoverflow.com/a/490776
has body: For example, let's say I want to find all instances of using the == operator with any string object, so that I can replace it with .equals() instead. How can I do such a search? Otherwise I'd have to pick through all my code line-by-line... Thanks :)
has title: Search for usage of a class object with a given operator? [Eclipse]
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/490776

http://stackoverflow.com/a/601326
type: Answer
has comment: http://stackoverflow.com/comment/413692
downvote count: 0
has body: can't you add exit to your batch file to exit it's own command prompt. Uisng taskill seems overkill for just closing one command prompt, don't you think? PS: I've never worked on batch files just the command prompt so I'm assuming it accepts the same commands.
score: 3
answers question: http://stackoverflow.com/q/601315
upvote count: 3
has comment: http://stackoverflow.com/comment/413642

http://stackoverflow.com/q/447739
upvote count: 57
duplicate of: http://stackoverflow.com/q/410437
has answer: http://stackoverflow.com/a/447923
has answer: http://stackoverflow.com/a/447764
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/447792
tagged with: java
possible better answer: http://stackoverflow.com/a/448318
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/448318
has answer: http://stackoverflow.com/a/447831
has title: Java Performance Testing
tagged with: performance
has answer: http://stackoverflow.com/a/447779
has comment: http://stackoverflow.com/comment/268833
has comment: http://stackoverflow.com/comment/268903
has body: I want to do some timing tests on a Java application. This is what I am currently doing: long startTime = System.currentTimeMillis(); doSomething(); long finishTime = System.currentTimeMillis(); System.out.println("That took: " + (finishTime - startTime) + " ms"); Is there anything "wrong" with performance testing like this? What is a better way? Duplicate: Is stopwatch benchmarking acceptable?
accepted answer: http://stackoverflow.com/a/447792
has answer: http://stackoverflow.com/a/447747
tagged with: performance-testing
has answer: http://stackoverflow.com/a/475642
has comment: http://stackoverflow.com/comment/268839
score: 56
favorite count: 0
has answer: http://stackoverflow.com/a/447753
answer count: 9

http://stackoverflow.com/q/509950
has comment: http://stackoverflow.com/comment/12760995
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/510047
tagged with: transactions
tagged with: java
tagged with: hibernate
upvote count: 1
has body: Is there a way to reduce unnecessary/empty fields in SQL inserts and SQL updates? For example, I have a single hibernate entity class mapped to a table that has 10 columns. The populating of data is actually done in two phases. When the user submit a request, I will insert the request information into the table with the hibernate entity, but populating only 7 fields. After some processing (wait for other users interaction for example), I will populate the remaining 3 fields (with the id given from the previous insert). If I stick with a single entity class, for the second update, the steps I do is as follows: 1) Load the entity identified by id 2) Save the entity, which generates sql that seems to be sending all the fields over. Alternatively, I created two entity class, and point to the same table and save them seperately. Does anyone have a better suggestion? Kent Edit: What I really like to achieve is something to the following effect: insert t(id,field1,field2) (?,?,?) update t set field3=? field4=? where id=? The best I could achieve now with dynamicUpdate=true is insert t(id,field1,field2) (?,?,?) select field1,field2,field3,field4 from t where id=? update t set field3=? field4=? where id=? Is there a way to eliminate that select statement? The original persisted object is not stored anywhere in memory after the insert. An additional note. The entity class is annotated with Hibernate validation. I am currently trying out to achieve the above desired effect, so I commented them out. But when I turn them back on, I get validation errors due to @NotNull and @NotEmpty.
type: Question
has title: Optimize Hibernate entities saving?
answer count: 1
downvote count: 0
score: 1

http://stackoverflow.com/comment/312991
score: 0
comment on: http://stackoverflow.com/a/497089
type: AnswerComment
type: Comment
has text: +1 for being the only remotely sensible answer (that actually read the question) so far.

http://stackoverflow.com/q/574594
tagged with: maven-2
favorite count: 0
has answer: http://stackoverflow.com/a/62575445
answer count: 33
linked to: http://stackoverflow.com/q/12611213
linked to: http://stackoverflow.com/q/2596655
has answer: http://stackoverflow.com/a/28952832
has comment: http://stackoverflow.com/comment/44923586
linked to: http://stackoverflow.com/q/25915793
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2387907
tagged with: build
has answer: http://stackoverflow.com/a/18986754
has answer: http://stackoverflow.com/a/26308794
has answer: http://stackoverflow.com/a/1399739
has answer: http://stackoverflow.com/a/54934796
has answer: http://stackoverflow.com/a/1559850
has title: How can I create an executable/runnable JAR with dependencies using Maven?
tagged with: java
upvote count: 2937
score: 2931
has answer: http://stackoverflow.com/a/7052423
has answer: http://stackoverflow.com/a/3706174
has answer: http://stackoverflow.com/a/35609830
has answer: http://stackoverflow.com/a/30486689
type: Question
has answer: http://stackoverflow.com/a/33914333
has answer: http://stackoverflow.com/a/8279014
has answer: http://stackoverflow.com/a/33880083
has answer: http://stackoverflow.com/a/5289121
has comment: http://stackoverflow.com/comment/11501234
has answer: http://stackoverflow.com/a/39268946
has answer: http://stackoverflow.com/a/44684869
has answer: http://stackoverflow.com/a/36998853
has answer: http://stackoverflow.com/a/589111
has answer: http://stackoverflow.com/a/46944196
has answer: http://stackoverflow.com/a/16742511
has answer: http://stackoverflow.com/a/28490744
has comment: http://stackoverflow.com/comment/131771944
tagged with: executable-jar
linked to: http://stackoverflow.com/q/41794914
has answer: http://stackoverflow.com/a/72985769
has answer: http://stackoverflow.com/a/39781522
has answer: http://stackoverflow.com/a/634989
downvote count: 6
linked to: http://stackoverflow.com/q/31736038
has answer: http://stackoverflow.com/a/574650
has answer: http://stackoverflow.com/a/3770791
accepted answer: http://stackoverflow.com/a/574650
has body: I want to package my project in a single executable JAR for distribution. How can I make a Maven project package all dependency JARs into my output JAR?
has comment: http://stackoverflow.com/comment/79263695
has answer: http://stackoverflow.com/a/9692010
linked to: http://stackoverflow.com/q/8310539
has comment: http://stackoverflow.com/comment/73301277
possible better answer: http://stackoverflow.com/a/4323501
has answer: http://stackoverflow.com/a/1970326
linked to: http://stackoverflow.com/q/35217128
tagged with: build-automation
has answer: http://stackoverflow.com/a/4323501
has answer: http://stackoverflow.com/a/23986765
has answer: http://stackoverflow.com/a/70713637

http://stackoverflow.com/a/369416
upvote count: 2
has body: http://weblogs.asp.net/stefansedich/archive/2008/10/03/paging-with-nhibernate-using-a-custom-extension-method-to-make-it-easier.aspx In that post I spotted a CriteriaTransformer.clone method. That should copy the criteria object. You can also set the projection on your getlist method. Woops I didn't notice you were referring to java hibernate. Anyway, this http://forum.hibernate.org/viewtopic.php?t=939039 forum post should be able to answer your question.
answers question: http://stackoverflow.com/q/368966
downvote count: 0
type: Answer
score: 2

http://stackoverflow.com/a/473146
upvote count: 4
answers question: http://stackoverflow.com/q/473111
downvote count: 0
type: Answer
has body: Take a look at java.util.concurrent.atomic - there may be some good things in there you can use.
score: 4

http://stackoverflow.com/q/394616
linked to: http://stackoverflow.com/q/4881136
tagged with: java
has answer: http://stackoverflow.com/a/26803522
has answer: http://stackoverflow.com/a/67478471
has title: Running JAR file on Windows
score: 307
type: Question
has answer: http://stackoverflow.com/a/27390927
has body: I have a JAR file named helloworld.jar. In order to run it, I'm executing the following command in a command-line window: java -jar helloworld.jar This works fine, but how do I execute it with double-click instead? Do I need to install any software?
has answer: http://stackoverflow.com/a/26432758
has answer: http://stackoverflow.com/a/19593238
has answer: http://stackoverflow.com/a/47800168
tagged with: jar
has answer: http://stackoverflow.com/a/52412281
has answer: http://stackoverflow.com/a/18467548
has answer: http://stackoverflow.com/a/395470
has answer: http://stackoverflow.com/a/394620
upvote count: 307
has comment: http://stackoverflow.com/comment/37989905
has answer: http://stackoverflow.com/a/30115096
has answer: http://stackoverflow.com/a/18198189
answer count: 26
tagged with: executable-jar
has answer: http://stackoverflow.com/a/13181501
has answer: http://stackoverflow.com/a/53321138
favorite count: 0
has answer: http://stackoverflow.com/a/7470683
has answer: http://stackoverflow.com/a/56003292
has answer: http://stackoverflow.com/a/56409204
has answer: http://stackoverflow.com/a/1459206
has answer: http://stackoverflow.com/a/41423675
has answer: http://stackoverflow.com/a/47631159
has answer: http://stackoverflow.com/a/2022161
has answer: http://stackoverflow.com/a/2879843
linked to: http://stackoverflow.com/q/354664
has answer: http://stackoverflow.com/a/2022372
has answer: http://stackoverflow.com/a/394628
accepted answer: http://stackoverflow.com/a/394628
has answer: http://stackoverflow.com/a/8902372
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2022161
has answer: http://stackoverflow.com/a/79143602
downvote count: 0

http://stackoverflow.com/a/535455
type: Answer
has comment: http://stackoverflow.com/comment/349594
has comment: http://stackoverflow.com/comment/348248
has comment: http://stackoverflow.com/comment/349368
score: 3
has comment: http://stackoverflow.com/comment/349521
downvote count: 0
has comment: http://stackoverflow.com/comment/348180
has comment: http://stackoverflow.com/comment/349661
has comment: http://stackoverflow.com/comment/348342
has body: Here is a pure XML representation that can be processed very efficiently as is, without the need to be converted into any other internal data structure: &lt;table&gt; &lt;record Customer="UTI" Txn-Group="CORP" Txn-Type="ONEOFF" Sender="ABC1" Priority="LOW" Target="TRG1"/&gt; &lt;record Customer="UTI" Txn-Group="Gov" Txn-Type="ONEOFF" Sender="ABC2" Priority="LOW" Target="TRG2"/&gt; &lt;/table&gt; There is an extremely efficient way to query data in this format using the &lt;xsl:key&gt; instruction and the XSLT key() function: This transformation: &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output omit-xml-declaration="yes"/&gt; &lt;xsl:key name="kRec" match="record" use="concat(@Customer,'+',@Sender)"/&gt; &lt;xsl:template match="/"&gt; &lt;xsl:copy-of select="key('kRec', 'UTI+ABC2')"/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; when applied on the above XML document produces the desired result: &lt;record Customer="UTI" Txn-Group="Gov" Txn-Type="ONEOFF" Sender="ABC2" Priority="LOW" Target="TRG2"/&gt; Do note the following: There can be multiple &lt;xsl:key&gt;s defined that identify a record using different combinations of values to be concatenated together (whatever will be considered "keys" and/or "primary keys"). If an &lt;xsl:key&gt; is defined to use the concatenation of "primary keys" then a unique record (or no record) will be found when the key() function is evaluated. If an &lt;xsl:key&gt; is defined to use the concatenation of "non-primary keys", then more than one record may be found when the key() function is evaluated. The &lt;xsl:key&gt; instruction is the equivalent of defining an index in a database. This makes using the key() function extremely efficient. In many cases it is not necessary to convert the above XML form to an intermediary data structure, due neither to reasons of understandability nor of efficiency.
answers question: http://stackoverflow.com/q/534807
upvote count: 3
has comment: http://stackoverflow.com/comment/349553

http://stackoverflow.com/a/48241654
has comment: http://stackoverflow.com/comment/90752649
has body: In 2018 no one should use the Calendar class anymore. It it long outmoded, and java.time the modern Java date and time API is so much nicer to work with. Instead use, depending on you exact requirements, a ZonedDateTime or perhaps an OffsetDateTime or LocalDateTime. In either case, set the time of day this way: dateTime = dateTime.with(LocalTime.of(hour, minute)); Link: Oracle Tutorial Date Time
has comment: http://stackoverflow.com/comment/90752426
has comment: http://stackoverflow.com/comment/90751162
type: Answer
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/90751064
upvote count: 2
answers question: http://stackoverflow.com/q/460293

http://stackoverflow.com/a/571013
downvote count: 0
accepted answer of: http://stackoverflow.com/q/570785
type: Answer
answers question: http://stackoverflow.com/q/570785
has body: You have an awful lot of extra code there. public class SelectionFrame extends JFrame { Font name; Font title; public SelectionFrame() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setJMenuBar(createMenuBar()); } public JMenuBar createMenuBar() { JMenuBar menuBar; JMenu m_file; JMenuItem mi_save; JMenuItem mi_load; JMenu m_edit; JMenuItem mi_tileHeight; JMenuItem mi_tileWidth; menuBar = new JMenuBar(); m_file = new JMenu("File"); m_edit = new JMenu("Edit"); mi_save = new JMenuItem("Save file", KeyEvent.VK_S); mi_load = new JMenuItem("Load file", KeyEvent.VK_L); mi_tileHeight = new JMenuItem("Set tile height", KeyEvent.VK_H); mi_tileWidth = new JMenuItem("Set tile width", KeyEvent.VK_W); menuBar.add(m_file); m_file.add(mi_save); m_file.add(mi_load); menuBar.add(m_edit); m_edit.add(mi_tileHeight); m_edit.add(mi_tileWidth); return menuBar; } public void main( String args[] ) { SelectionFrame sel = new SelectionFrame(); sel.setLocationRelativeTo(null); sel.setSize(400 + (sel.getInsets().left + &gt; sel.getInsets().right), 400 + (sel.getInsets().top + sel.getInsets().bottom)); sel.setTitle("Tiles/Meta"); sel.setResizable(false); sel.setFocusable(true); sel.getContentPane().add( new JLabel( "Content", SwingConstants.CENTER), BorderLayout.CENTER ); sel.setLocation(sel.getX() - (sel.getWidth() / 2), sel.getY() - &gt; (sel.getHeight() / 2)); sel.setVisible(true); } } That shows up with a menu bar and everything. if you add your content to the CENTER of the content pane (by default a border layout), the center automatically fills the whole content area, you don't have to resize anything. This shows up as a window with a menu bar and everything works fine. What platform are you doing this on? I'm on Vista, i get what i expect to see.
score: 5
type: AcceptedAnswer
upvote count: 5

http://stackoverflow.com/comment/207668
type: QuestionComment
has text: @RB: Yup! Of course mx and ms only control *heap* size; there's thread stacks, executable space, class heap, perm gen, and things. But these are typically less than heap use and they are typically stable once the program gets going.
comment on: http://stackoverflow.com/q/366658
score: 0
type: Comment

http://stackoverflow.com/a/430761
upvote count: 13
has comment: http://stackoverflow.com/comment/105268880
has comment: http://stackoverflow.com/comment/11171281
answers question: http://stackoverflow.com/q/430755
has comment: http://stackoverflow.com/comment/856625
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/430755
type: Answer
has comment: http://stackoverflow.com/comment/855370
has body: When I had similar problems after checking the jars it turned out that some 3rd party jar was signed by someone else. You should create a separate jnlp file for the jars signed by the other certificate and read this jnlp from your jnlp file: &lt;resources&gt; ... &lt;extension name="other" href="other.jnlp"/&gt; &lt;/resources&gt; Here or here you can find an example.
score: 13

http://stackoverflow.com/a/516358
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/516263
has body: Multithreading needs synchronisation. Are you using a synced stream (or syncing the access to the stream yourself)? Update: The code sample given may very well be called from multiple threads. If multiple threads access the same stream, errors like the ones you are experiencing may very well occur. I suggest having a look at http://java.sun.com/docs/books/tutorial/essential/concurrency/sync.html. By marking a method/class synchronized, the runtime will make sure that this method/class will be active in no more than 1 thread at the same time. This is actually a vast and difficult topic, so take some time to learn the basics and make sure you understand the basic problem. :)
accepted answer of: http://stackoverflow.com/q/516263
has comment: http://stackoverflow.com/comment/331306
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/329972

http://stackoverflow.com/q/600604
has title: Java appears hung
tagged with: java-service-wrapper
tagged with: java
type: Question
tagged with: debugging
has body: I've been using the Java Service wrapper in a custom application for quite a while and it's been working fine. Since updating our application to a new version in the last few days the JVM started hanging and then wrapper prints this in the log: JVM appears hung: Timed out waiting for signal from JVM. It then automatically terminates the JVM and starts the app again. This happens after about 10 hours of running, which just makes it harder to debug. Of course I am going to look through the changes that we've made, but no major changes were made that I would suspect is causing this type of problem. Where can I look to try and figure out what is happening? Debug messages from the application don't indicate anything interesting. If the JVM just crashes it will usually create a dump, which can help in debugging it, but it's hanging, so it's not creating a dump. If I make it not restart the service automatically is there anything I can do to get some useful information out of the JVM before restarting it? It seems to me that the JVM shouldn't hang from typical programming errors. What have you run into before that can cause the JVM to hang?
has answer: http://stackoverflow.com/a/626351
downvote count: 0
has answer: http://stackoverflow.com/a/600853
has answer: http://stackoverflow.com/a/600626
has answer: http://stackoverflow.com/a/600623
possible better answer: http://stackoverflow.com/a/600626
answer count: 4
accepted answer: http://stackoverflow.com/a/626351
score: 8
favorite count: 0
upvote count: 8
tagged with: freeze
type: AnsweredQuestion

http://stackoverflow.com/comment/397734
has text: Both my copies of the book are packed away in boxes somewhere, so I have no idea.
type: AnswerComment
type: Comment
score: 0
comment on: http://stackoverflow.com/a/581542

http://stackoverflow.com/comment/397803
score: 0
type: AnswerComment
type: Comment
has text: I hope people haven't been using Observer/Observable. That may be wishful thinking. They should have a big @deprecated on them.
comment on: http://stackoverflow.com/a/584266

http://stackoverflow.com/a/12446260
type: Answer
has body: The best solution , is to use Derby, because it keep being a multi platform app developed via Java.
score: 0
answers question: http://stackoverflow.com/q/574984

http://stackoverflow.com/comment/45322557
score: 0
comment on: http://stackoverflow.com/a/371043
type: AnswerComment
has text: this looks almost identical to the one I just wrote for myself :)
type: Comment

http://stackoverflow.com/a/404742
answers question: http://stackoverflow.com/q/404733
score: 21
upvote count: 21
type: Answer
has body: Yes, you can simply use Character.UnicodeBlock.of(char)
downvote count: 0

http://stackoverflow.com/a/33149434
type: Answer
downvote count: 5
answers question: http://stackoverflow.com/q/624581
score: -2
has body: This is the best method: public static boolean isValidEmail(String enteredEmail){ String EMAIL_REGIX = "^[\\\\w!#$%&amp;’*+/=?`{|}~^-]+(?:\\\\.[\\\\w!#$%&amp;’*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\\\\.)+[a-zA-Z]{2,6}$"; Pattern pattern = Pattern.compile(EMAIL_REGIX); Matcher matcher = pattern.matcher(enteredEmail); return ((!enteredEmail.isEmpty()) &amp;&amp; (enteredEmail!=null) &amp;&amp; (matcher.matches())); } Sources:- http://howtodoinjava.com/2014/11/11/java-regex-validate-email-address/ http://www.rfc-editor.org/rfc/rfc5322.txt
upvote count: 3

http://stackoverflow.com/a/376778
has body: Check out Blaze DS. It's pretty simple to set this up so that you can invoke methods on your Java classes from Flex. http://opensource.adobe.com/wiki/display/blazeds/BlazeDS/ Basically you register a RemoteObject that references the URL of your Flash Remoting endpoint and specifies the destination (usually the class name). Consult the WebOrb docs on how to do that. Once that's done, you can just invoke the RemoteObject like so: var token : AsyncToken = emailService.sendEmail(subject, body); token.addResponder(responderImpl); You create an implementation of the IResponder interface and register it against the "AsyncToken" which is returned from remoting calls in Flex. All calls to the server in Flex are asynchronous which is why you register a responder which then has either the result or fault method invoked.
downvote count: 0
answers question: http://stackoverflow.com/q/376714
upvote count: 3
type: Answer
score: 3

http://stackoverflow.com/comment/75245364
comment on: http://stackoverflow.com/a/397613
score: 0
type: AnswerComment
type: Comment
has text: @hshib: No. The last commit on github is from 2013.

http://stackoverflow.com/a/585346
type: Answer
has body: If you only use static methods then you are programming in a procedural, non-object-oriented style. However, the only context I can think of where this would be OK is during the first programming lessons before object orientation is introduced.
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/585031
score: 0

http://stackoverflow.com/q/415779
score: 0
tagged with: java
tagged with: database
type: UnansweredQuestion
type: Question
tagged with: oracle-database
has title: SQL query statement to retrieve records having CLOB data from the oracle database
tagged with: jdbc
has body: I tried this code and the value of comments from final table having a clob datatype is null or sometimes displays few words. What should I add so that I retrieve the whole data from comments and displays to the textarea? Thanks:-) <%@ page import="java.sql.*" %> <% Class.forName("oracle.jdbc.driver.OracleDriver"); %> <TITLE>SHIFT REPORT <% Connection connection=DriverManager.getConnection ("jdbc:oracle:thin:@oradev2.j.com:1521:RPDB","shiftrpt", // "shiftrpt" ); Statement statement = connection.createStatement() ; ResultSet resultset = statement.executeQuery("select * from final") ; %> RECORD NUMBER TESTER NUMBER DATE TIME SYSTEM TYPE PACKAGE CATEGORY COMMENTS VALIDATED BY <% while(resultset.next()){ %> <%= resultset.getLong(1) %> <%= resultset.getString(2) %> <%= resultset.getDate(3) %> <%= resultset.getString(4) %> <%= resultset.getString(5) %> <%= resultset.getString(6) %> <%= resultset.getString(7) %> <%= resultset.getString(8) %> <%= resultset.getString(9) %> <% } %>
has answer: http://stackoverflow.com/a/415800
answer count: 1

http://stackoverflow.com/a/584833
answers question: http://stackoverflow.com/q/584742
has comment: http://stackoverflow.com/comment/396828
has body: Just a guess here, but you might try query.cacheQueryResults(); after you create it but before you getResultList. -- MarkusQ
score: 0
has comment: http://stackoverflow.com/comment/4351359
type: Answer

hudson
type: Tag
tags question: http://stackoverflow.com/q/502776
tags question: http://stackoverflow.com/q/604385
tags question: http://stackoverflow.com/q/389680
tag name: hudson
tags question: http://stackoverflow.com/q/635154
tags question: http://stackoverflow.com/q/461581
tags question: http://stackoverflow.com/q/470141

http://stackoverflow.com/a/2605884
answers question: http://stackoverflow.com/q/634564
upvote count: 33
accepted answer of: http://stackoverflow.com/q/634564
has body: Use Named Pipes to Communicate Between Java and .Net Processes Relevant part in the link try { // Connect to the pipe RandomAccessFile pipe = new RandomAccessFile("\\\\.\\pipe\\testpipe", "rw"); String echoText = "Hello word\n"; // write to pipe pipe.write ( echoText.getBytes() ); // read response String echoResponse = pipe.readLine(); System.out.println("Response: " + echoResponse ); pipe.close(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }
has comment: http://stackoverflow.com/comment/62892123
downvote count: 4
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/124736189
type: Answer
has comment: http://stackoverflow.com/comment/62894301
has comment: http://stackoverflow.com/comment/65140943
score: 29

http://stackoverflow.com/a/581893
has comment: http://stackoverflow.com/comment/394869
has body: Usually Errors are problems you cannot possibly recover from, like OutOfMemoryError. There's nothing to do by catching them, so you should usually let them escape, and bring down the virtual machine.
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/581878
has comment: http://stackoverflow.com/comment/393822
upvote count: 6
has comment: http://stackoverflow.com/comment/393829
score: 6
has comment: http://stackoverflow.com/comment/395287
has comment: http://stackoverflow.com/comment/393984
has comment: http://stackoverflow.com/comment/139771211

http://stackoverflow.com/q/370978
accepted answer: http://stackoverflow.com/a/371087
has answer: http://stackoverflow.com/a/371759
type: AnsweredQuestion
has body: I have an application that uses a cron like job to update a set of data. The update process happens once a minute and doesn't last long. A servlet exposes this data set to the users. My problem is that during the update process, the servlet requests should block and wait for the process to complete. In bottom line I have these two functions: private void updateData() { } public List getData() { } The first function runs once a minute. The second one can be called any number of times simultaneously. When updateData runs, all calls of getData must wait for it to complete. One getData call shouldn't block subsequent calls of the same function. The updateData function has higher priority than the getData, i.e. when updateData is to run, it has to wait for all calls of getData to complete, but new calls shouldn't be allowed to start. What synchronization mechanism should I use for a case like this? I am using a Java server, but I would be interested to know what solutions exist for other platforms as well.
tagged with: java
possible better answer: http://stackoverflow.com/a/371046
type: Question
has answer: http://stackoverflow.com/a/371046
has answer: http://stackoverflow.com/a/371087
score: 0
has answer: http://stackoverflow.com/a/370995
answer count: 4
tagged with: synchronization
has title: How to synchronize requests for data with data update process?
has comment: http://stackoverflow.com/comment/200503

http://stackoverflow.com/q/570929
type: AnsweredQuestion
type: Question
has answer: http://stackoverflow.com/a/571042
tagged with: java
has body: In .net you have the ability to Response.End() in any context you want. Is there similar functionality in Java/JSP? Thanks, Sam
score: 4
upvote count: 4
has answer: http://stackoverflow.com/a/571222
possible better answer: http://stackoverflow.com/a/571042
answer count: 2
downvote count: 0
tagged with: jsp
favorite count: 0
has title: Response.End() in Java/JSP
accepted answer: http://stackoverflow.com/a/571222

http://stackoverflow.com/comment/371630
type: AnswerComment
has text: As far as I know, LinearLayout does not do any wrapping. WRAP_CONTENT on both axes would make the LinearLayout-widget one line high and extend way off the screen. And from what I understand, the setSingleLine on the text-widget only affects the size and shape of that widget, not its parents layout.
type: Comment
score: 0
comment on: http://stackoverflow.com/a/558825

variables
tag name: variables
tags question: http://stackoverflow.com/q/610976
tags question: http://stackoverflow.com/q/415924
tags question: http://stackoverflow.com/q/575336
type: Tag
tags question: http://stackoverflow.com/q/415687
tags question: http://stackoverflow.com/q/473685
tags question: http://stackoverflow.com/q/545391
tags question: http://stackoverflow.com/q/407255

http://stackoverflow.com/q/513600
tagged with: performance
has comment: http://stackoverflow.com/comment/327345
linked to: http://stackoverflow.com/q/6785
tagged with: java
upvote count: 248
has title: Should I use Java's String.format() if performance is important?
has answer: http://stackoverflow.com/a/513616
has answer: http://stackoverflow.com/a/513705
has answer: http://stackoverflow.com/a/6522436
has comment: http://stackoverflow.com/comment/3991193
has comment: http://stackoverflow.com/comment/1111634
tagged with: micro-optimization
score: 248
has body: We have to build Strings all the time for log output and so on. Over the JDK versions we have learned when to use StringBuffer (many appends, thread safe) and StringBuilder (many appends, non-thread-safe). What's the advice on using String.format()? Is it efficient, or are we forced to stick with concatenation for one-liners where performance is important? e.g. ugly old style, String s = "What do you get if you multiply " + varSix + " by " + varNine + "?"; vs. tidy new style (String.format, which is possibly slower), String s = String.format("What do you get if you multiply %d by %d?", varSix, varNine); Note: my specific use case is the hundreds of 'one-liner' log strings throughout my code. They don't involve a loop, so StringBuilder is too heavyweight. I'm interested in String.format() specifically.
downvote count: 0
tagged with: string
has answer: http://stackoverflow.com/a/7129469
answer count: 13
has answer: http://stackoverflow.com/a/513637
favorite count: 0
has answer: http://stackoverflow.com/a/30383354
has answer: http://stackoverflow.com/a/513625
linked to: http://stackoverflow.com/q/1532461
has comment: http://stackoverflow.com/comment/132066369
accepted answer: http://stackoverflow.com/a/513705
linked to: http://stackoverflow.com/q/504103
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/1281651
has answer: http://stackoverflow.com/a/24418487
tagged with: string-formatting
has answer: http://stackoverflow.com/a/513964
has comment: http://stackoverflow.com/comment/3928819
has answer: http://stackoverflow.com/a/31061425
has answer: http://stackoverflow.com/a/513787
type: Question
has comment: http://stackoverflow.com/comment/3932266
possible better answer: http://stackoverflow.com/a/1281651
has answer: http://stackoverflow.com/a/40979631
has comment: http://stackoverflow.com/comment/29065631

http://stackoverflow.com/q/519725
possible better answer: http://stackoverflow.com/a/520979
answer count: 3
downvote count: 0
has answer: http://stackoverflow.com/a/520979
favorite count: 0
tagged with: mvp
has answer: http://stackoverflow.com/a/545637
accepted answer: http://stackoverflow.com/a/545637
tagged with: design-patterns
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/534355
score: 3
has title: Applying the MVP pattern to JDialogs
upvote count: 3
tagged with: java
tagged with: swing
has body: I'm writing a Swing application, and further to my previous question, have settled on using the Model-View-Presenter pattern to separate the user interface from the business logic. When my application starts up, it executes the following code: Model model = new BasicModel(); Presenter presenter = new Presenter(model); View view = new SwingView(presenter); presenter.setView(view); presenter.init(); which creates the user interface. Events are generated by the View, and delegated to the Presenter. The Presenter then manipulates the Model and updates the View accordingly. In order to handle some events, I need to obtain further information from the user. In the case of these events, I believe it is appropriate for the Swing view to spawn a new JDialog window. One line of thinking makes me feel this might be appropriate code in the orignal Presenter: public void handlePreferences() { Preferences prefs = view.getPreferences(); model.setPreferences(prefs); } That is, the contents of each JDialog should represent a distinct object that should be retrieved from the View and updated in the Model. However, this leaves the question: do I create a new Model to represent the Preferences object and a new Presenter for event handling in that JDialog? It seems to me that creating a new Presenter and Model internal to the original View forces me to do a lot of work that would be harder to port if I wanted to change the UI to use JSF, for example. Please feel free to add comments for clarification.
type: Question

http://stackoverflow.com/a/624750
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/437594
downvote count: 0
answers question: http://stackoverflow.com/q/624741
has body: Here is how you get file size, but how do you get bitrate and track length? import java.io.*; import java.net.*; public class FileSizeFromURL { public static final void main(String[] args) { URL url; URLConnection conn; int size; if(args.length != 1) { System.out.println("Usage: FileSizeFromURL "); return; } try { url = new URL(args[0]); conn = url.openConnection(); size = conn.getContentLength(); if(size &lt; 0) System.out.println("Could not determine file size."); else System.out.println(args[0] + "\nSize: " + size); conn.getInputStream().close(); } catch(Exception e) { e.printStackTrace(); } } }
has comment: http://stackoverflow.com/comment/437743
type: Answer

http://stackoverflow.com/comment/376712
type: Comment
comment on: http://stackoverflow.com/a/565445
type: AnswerComment
has text: Can you use this on a JTextArea? (The example you gave using a editor pane)
score: 0

http://stackoverflow.com/comment/458244
comment on: http://stackoverflow.com/a/639829
score: 0
type: AnswerComment
has text: There were 2 things here : adding a SqlOutParamater as **first** parameter and using the good Type. I don't know why I wrote Types.VARCHAR... I'll fix the answer.
type: Comment

http://stackoverflow.com/a/634345
downvote count: 0
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/631695
type: Answer
has body: Ok I am an idiot. My problem is I glanced over the stack trace but didn't really read it. Here is the full stack traces (or one of them, 3 slightly different versions show up in my logs). org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111) at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150) at com.generic.orm.generated.SearchRule$$EnhancerByCGLIB$$de674d10.toString(&lt;generated&gt;) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuffer.append(StringBuffer.java:219) at org.apache.commons.lang.builder.ToStringStyle.appendDetail(ToStringStyle.java:578) at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.java:542) at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:428) at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java:840) at org.apache.commons.lang.builder.ReflectionToStringBuilder.appendFieldsIn(ReflectionToStringBuilder.java:606) at org.apache.commons.lang.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:759) at org.apache.commons.lang.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:287) at org.apache.commons.lang.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:121) at com.generic.orm.generated.Report.toString(Report.java:141) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:115) at java.util.AbstractCollection.toString(AbstractCollection.java:422) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:115) at java.util.AbstractMap.toString(AbstractMap.java:490) at org.netbeans.modules.web.monitor.server.MonitorFilter.recordRequestAttributes(Moni…

http://stackoverflow.com/q/646189
tagged with: java
score: 13
type: Question
has body: What is the reason for encountering this Exception: org.apache.commons.fileupload.FileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly
tagged with: apache-commons
favorite count: 0
has answer: http://stackoverflow.com/a/646230
answer count: 3
has answer: http://stackoverflow.com/a/646296
has answer: http://stackoverflow.com/a/40673209
downvote count: 0
tagged with: file-upload
type: UnansweredQuestion
upvote count: 13
has comment: http://stackoverflow.com/comment/69955491
has title: Why did I get "FileUploadException: Stream ended unexpectedly" with Apache Commons FileUpload?

http://stackoverflow.com/a/413763
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/238494
answers question: http://stackoverflow.com/q/413713
has comment: http://stackoverflow.com/comment/238507
has body: I think you answered most of your own questions. Source control: pick SVN - easy installation, great integration with Eclipse (subclipse). Use Ant to build your project and deploy it (SCP/SFTP task) Keep all your settings (Eclipse project settings, build xmls, etc.) in SVN. Use Bugzilla to keep track of your bugs/issues/requests/ideas.
upvote count: 2
type: Answer

http://stackoverflow.com/comment/294220
has text: Yep, that's because the getter only gets a label that was previously set (I think the doco specifically mentions that).
comment on: http://stackoverflow.com/a/476756
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/518527
has answer: http://stackoverflow.com/a/2422165
upvote count: 5
tagged with: mdx
type: AnsweredQuestion
has title: Best Way to Access MS Analysis Services Cube from Java
has answer: http://stackoverflow.com/a/987403
downvote count: 0
favorite count: 0
has body: I want to issue MDX against a MSAS cube from a Java client. What connectivity approaches have proven to be reliable for this?
type: Question
answer count: 2
score: 5
accepted answer: http://stackoverflow.com/a/987403
possible better answer: http://stackoverflow.com/a/2422165
tagged with: java

http://stackoverflow.com/q/481808
type: UnansweredQuestion
has title: How can I provide a custom log4j.xml for different ant tasks?
score: 6
upvote count: 6
answer count: 4
tagged with: java
has answer: http://stackoverflow.com/a/1257048
has answer: http://stackoverflow.com/a/481841
type: Question
tagged with: taskdef
tagged with: ant
has answer: http://stackoverflow.com/a/481850
downvote count: 0
has body: I have a build file that as part of the build process relies on several taskdefs. These taskdef items (for example, webdoclet and jasper2) use log4j as a logger. Ideally, I'd like to be able to provide a different log4j configuration file for each, but minimally, I'd like to be able to specify which log4j configuration file is used. What I did that used to work was to put at the front of the classpath the directory containing the log4j.xml that I wanted the taskdef to use. For example: &lt;target name="define.jasper2"> &lt;path id="jspc.classpath"> &lt;!-- Put this FIRST so Jasper will find the log4j.xml in the Build directory --> &lt;pathelement location="Build"/> &lt;fileset dir="${tomcat.libs}"> .... &lt;/fileset> &lt;pathelement location="${log4j.jar}"/> .... &lt;/path> &lt;taskdef name="jasper2" classname="org.apache.jasper.JspC" classpathref="jspc.classpath"/> &lt;/target> I've verified that, in fact, the "Build" directory is at the front of the classpath and that a log4j.xml exists in that directory. However, when I run ant in verbose mode with log4j in debug, I see that log4j is choosing the log4j.xml that is in the current working directory, which is not the one I want. Log4j appears to not be using the classpath to resolve the default log4j.xml. I'm using log4j 1.2.8 (embedded within a larger framework, so I cannot upgrade it) and some of these taskdefs appear to rely on commons-logging 1.0.3. The build process uses Sun Java 5. If I set ANT_OPTS=-Dlog4j.configuration=Build/log4j.xml before running ant, the taskdefs correctly load the desired log4j.xml. Putting the "Build" directory at the front of the classpath for the taskdefs used to work. I don't know what changed. How can I restore the behavior where I can control -- within the build.xml -- which log4j configuration file is used for a given task? Is there a way other than setting ANT_OPTS and other than rearranging files to move the application's log4j.xml out of the current working directory to get lo…
has answer: http://stackoverflow.com/a/497298
tagged with: log4j
favorite count: 0

http://stackoverflow.com/q/628570
answer count: 9
accepted answer: http://stackoverflow.com/a/629884
possible better answer: http://stackoverflow.com/a/628585
has answer: http://stackoverflow.com/a/1148704
type: AnsweredQuestion
tagged with: performance
has answer: http://stackoverflow.com/a/5272498
tagged with: jsf
tagged with: java
has answer: http://stackoverflow.com/a/732556
has answer: http://stackoverflow.com/a/635119
type: Question
has answer: http://stackoverflow.com/a/37669304
tagged with: websphere
upvote count: 12
has body: Running into an issue where JSF is filling up our sessions. We had a system crash the other day. Sent the Heap to IBM for review and found that we had some sessions as large as 50M. They found JSF components in the session and some very large. So, is there any tuning that can be done? Configuration items to look at? Or other direction. Our system is build using JSF and Spring for the presentation layer, the back end is EJB, Spring and Hibernate all running on WebSphere 6.1.
has answer: http://stackoverflow.com/a/629884
has answer: http://stackoverflow.com/a/915342
has answer: http://stackoverflow.com/a/633538
score: 12
has title: JSF Tuning
has answer: http://stackoverflow.com/a/628585
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/45034721
score: -1
answers question: http://stackoverflow.com/q/605891
downvote count: 1
type: Answer
upvote count: 0
has body: public static void main(String[] args) { String str = "helloword"; char[] arr; List&lt;Character&gt; l = new ArrayList&lt;Character&gt;(); for (int i = 0; i &lt; str.length(); i++) { arr = str.toCharArray(); l.add(arr[i]); } Collections.sort(l); str = l.toString(); System.out.println(str); str = str.replaceAll("\\[", "").replaceAll("\\]", "") .replaceAll("[,]", ""); System.out.println(str); }

http://stackoverflow.com/a/767719
score: 1
upvote count: 1
has body: Tomcat 5.5 does not support Servlet API 2.5 which is used by JSTL 1.2. Upgrade to Tomcat 6.0 or downgrade the Servlet / JSP / JSTL versions. see http://tomcat.apache.org/whichversion.html
downvote count: 0
answers question: http://stackoverflow.com/q/542383
type: Answer

http://stackoverflow.com/a/498017
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/497025
has body: I would use two data structures --- a queue (e.g. ArrayDeque) for storing objects whose subobjects are to be visited, and a set (e.g. HashSet) for storing all visited objects without duplication. Set visited = new HashSet(); // all visited objects Queue next = new ArrayDeque(); // objects whose subobjects are to be visited // NOTE: At all times, the objects in "next" are contained in "visited" // add the first object visited.add(obj); Object nextObject = obj; while (nextObject != null) { // do stuff to nextObject for (Object o : nextObject.subobjects) { boolean fresh = visited.add(o); if (fresh) { next.add(o); } } nextObject = next.poll(); // removes the next object to visit, null if empty } // Now, "visited" contains all the visited objects NOTES: ArrayDeque is a space-efficient queue. It is implemented as a cyclic array, which means you use less space than a List that keeps growing when you add elements. "boolean fresh = visited.add(o)" combines "boolean fresh = !visited.contains(o)" and "if (fresh) visited.add(o)".
score: 5
accepted answer of: http://stackoverflow.com/q/497025
type: AcceptedAnswer
upvote count: 5

http://stackoverflow.com/comment/672571
comment on: http://stackoverflow.com/a/554599
score: 4
type: AnswerComment
has text: Sun's RMI tutorials explicitly tell you not to do this. It can cause problems.
type: Comment

http://stackoverflow.com/comment/224935
type: Comment
comment on: http://stackoverflow.com/a/399103
score: 3
has text: Hehe, declare it "throws Throwable", and throw an AssertionError anyway. :-)
type: AnswerComment

http://stackoverflow.com/a/463856
has comment: http://stackoverflow.com/comment/24116480
upvote count: 12
downvote count: 0
has comment: http://stackoverflow.com/comment/24158879
type: Answer
has body: Actually to get the drive name (ex. Local Disk) you need to use getSystemTypeDescription. getSystemDisplayName returns the volume name. import java.io.File; import java.util.Arrays; import java.util.List; import javax.swing.filechooser.FileSystemView; public class Test2 { public static void main(String args[]){ List &lt;File&gt;files = Arrays.asList(File.listRoots()); for (File f : files) { String s1 = FileSystemView.getFileSystemView().getSystemDisplayName (f); String s2 = FileSystemView.getFileSystemView().getSystemTypeDescription(f); System.out.println("getSystemDisplayName : " + s1); System.out.println("getSystemTypeDescription : " + s2); } /* output (French WinXP) getSystemDisplayName : getSystemTypeDescription : Disquette 3½ pouces getSystemDisplayName : REGA1 (C:) getSystemTypeDescription : Disque local getSystemDisplayName : getSystemTypeDescription : Lecteur CD getSystemDisplayName : My Book (F:) getSystemTypeDescription : Disque local */ } }
score: 12
has comment: http://stackoverflow.com/comment/24097980
has comment: http://stackoverflow.com/comment/26760622
answers question: http://stackoverflow.com/q/462110

http://stackoverflow.com/a/621033
has comment: http://stackoverflow.com/comment/434432
type: Answer
has body: I think it is off because you are translating about the wrong point. the size of the object depends on what container you have this in, so while your preferred size might be what you want, your actual size isn't? if you have this label in the CENTER of a BorderLayout, the size is always the full size of the container (minus north+south height, minus east+west width) so don't you have to translate about the actual size, not preferred size?
answers question: http://stackoverflow.com/q/620929
score: 0

http://stackoverflow.com/comment/441580
has text: Thanx sir, for the answer.. I have used LinkedHashMap class, and looks quite satisfied.. If it has any drawback over LinkedList, then plz comment..
score: 0
comment on: http://stackoverflow.com/a/628892
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/9531770
type: Comment
comment on: http://stackoverflow.com/a/445970
type: AnswerComment
score: 0
has text: Naked Objects is now open source on .net, see http://nakedobjects.codeplex.com/license

http://stackoverflow.com/a/9081954
type: Answer
answers question: http://stackoverflow.com/q/515428
score: 3
upvote count: 3
has body: If using maven, why wouldn't you ? :) Just use the maven-shade-plugin, works like a charm ! ... org.apache.maven.plugins maven-shade-plugin 1.5 package shade com.YOUR_COMPANY.YOUR_MAIN_CLASS ...
downvote count: 0

http://stackoverflow.com/q/500484
has body: I'm working on a Java 2D rendering program (running on 1.6.0_11), which uses external images for its UI rendering. These large images contain several UI graphics parts at the same time, which I extract now with the BufferedImage.getSubimage(). Assuming an average desktop system (with our without enabling DirectX/OpenGL acceleration), my questions are: The getSubimage() is a memory efficient call, as it shares the underlying image data, but does this affect the rendering speed of these sub images with the Graphics2D.drawImage()? If the images use 8 bit per pixel color palette mode, what would be the gain/loss of using RGBA mode (e.g. 4x memory) or relying on the palette color model (e.g conversion time)?
has comment: http://stackoverflow.com/comment/620284
accepted answer: http://stackoverflow.com/a/517339
type: AnsweredQuestion
tagged with: 2d
upvote count: 3
tagged with: java
tagged with: swing
has title: BufferedImage's getSubimage performance
type: Question
has answer: http://stackoverflow.com/a/517339
score: 3
answer count: 1
downvote count: 0
favorite count: 0

http://stackoverflow.com/q/555580
has answer: http://stackoverflow.com/a/556855
has answer: http://stackoverflow.com/a/1870224
type: Question
answer count: 8
downvote count: 0
has answer: http://stackoverflow.com/a/7433227
has answer: http://stackoverflow.com/a/560948
favorite count: 0
tagged with: memory-management
has answer: http://stackoverflow.com/a/555591
type: UnansweredQuestion
score: 6
tagged with: garbage-collection
has answer: http://stackoverflow.com/a/559119
has title: Finding Memory Usage in Java
upvote count: 6
tagged with: java
has answer: http://stackoverflow.com/a/555989
has answer: http://stackoverflow.com/a/555790
has body: Following is the scenario i need to solve. I have struck with two solutions. I need to maintain a cache of data fetched from database to be shown on a Swing GUI. Whenever my JVM memory exceeds 70% of its allocated memory, i need to warn user regarding excessive usage. And once JVM memory usage exceeds 80%, then i have to halt all the database querying and clean up the existing cache fetched as part of the user operations and notifying the user. During cleanup process, i will manually handle deleting some data based up on some rules and instructs JVM for a GC. Whenever GC occurs, if memory cleans up and reaches 60% of the allocated memory, I need to restart all the Database handling and giving back control to the user. For checking JVM memory statistics i found following two solutions. Could not able to decide which is best way and why. Runtime.freeMemory() - Thread created to run every 10 seconds and check for the free memory and if memory exceeds the limits mentioned, necessary popups will intimate user and will call the methods to halt the operations and freeing up the memory. MemoryPoolMXBean.getUsage() - Java 5 has introduced JMX to get the snapshot of the memory at runtime. In, JMX i cannot use Threshold notification since it will only notify when memory reaches/exceeds the given threshhold. Only way to use is Polling in MemoryMXBean and check the memory statistics over a period. In case of using polling, it seems for me both the implementations are going to be same. Please suggest the advantages of the methods and if there are any other alternatives/any corrections to the methods using.
tagged with: memory

http://stackoverflow.com/comment/338799
comment on: http://stackoverflow.com/a/525556
has text: Yes, it took a while to do the research w.r.t. initialization.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/14789119
score: 1
downvote count: 1
answers question: http://stackoverflow.com/q/529904
upvote count: 2
type: Answer
has body: If all you want is insert sql for oracle I would stick to a simple JDBC library. All you need is a Connection and maybe some ConnectionPool (maybe c3po). Hibernate and the like are too big/too complicated and IMO inferior. Hibernate incorporates JDBC under the hood but in every measurable way is inferior -- harder to use, not faster, and the queries you have to write or not any easier. It is also a testament to their inferiority because HQL also provides a bypass route so you can enter JDBC queries directly. They provide this (I suspect) because for any complex query you simply can't construct it well in HQL.

http://stackoverflow.com/q/421337
answer count: 2
has answer: http://stackoverflow.com/a/421364
downvote count: 0
tagged with: panel
favorite count: 0
type: UnansweredQuestion
has title: Java- How can you set a pane's background with an image?
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/423589
tagged with: jpanel
upvote count: 1
tagged with: background
type: Question
has body: I'm wondering if there is any way to set a JPanel's background to an image instead of just a colour. Thanks and I'm working on dr. java

http://stackoverflow.com/q/618616
type: Question
tagged with: weblogic
tagged with: jar
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/618877
has answer: http://stackoverflow.com/a/618691
has answer: http://stackoverflow.com/a/619342
answer count: 4
has title: Which Weblogic 10.3 JAR contains weblogic.rmi.RemoteException
possible better answer: http://stackoverflow.com/a/618845
has body: I am trying to track down the Weblogic 10.3 JAR that contains weblogic.rmi.RemoteException in order to solve a build path issue. Thanks in advance.
has answer: http://stackoverflow.com/a/618845
upvote count: 1
type: AnsweredQuestion
tagged with: rmi
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/618877

http://stackoverflow.com/q/521407
upvote count: 5
tagged with: java
type: Question
tagged with: c#
score: 5
downvote count: 0
has answer: http://stackoverflow.com/a/521440
accepted answer: http://stackoverflow.com/a/521533
has body: object is to class as enum is to ...? I'm using C# but I'd like the answer for Java as well, if there is one. Thank you, as always.
favorite count: 0
has answer: http://stackoverflow.com/a/522298
answer count: 5
has answer: http://stackoverflow.com/a/521533
possible better answer: http://stackoverflow.com/a/521440
has comment: http://stackoverflow.com/comment/335205
has title: object is to class as enum is to ...?
has answer: http://stackoverflow.com/a/521409
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/521585
tagged with: enums

http://stackoverflow.com/q/468059
has comment: http://stackoverflow.com/comment/286033
tagged with: awt
has title: Canvas isn't resizing with window in Java?
has comment: http://stackoverflow.com/comment/286005
has comment: http://stackoverflow.com/comment/288905
has body: I have a jFrame with a Canvas on it. When I run my program in Windows XP/Vista and resize the window the canvas resizes proportionately along with the window. However, in Ubuntu linux, when I compile the same java application and resize my window, the Canvas stays the same size. What do I need to do to make my Canvas resize with my window in both Windows and Linux? What is the deal with the discrepancy? Main.java public class Main { public static void main(String[] args) { JFrame frame = new JFrame("BallBounce"); frame.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(),BoxLayout.Y_AXIS)); BallCanvas ballCanvas = new BallCanvas(); frame.getContentPane().add(ballCanvas); frame.getContentPane().add(controlPanel); frame.pack(); frame.setVisible(true); } } BallCanvas.java public class BallCavnas extends Canvas { public BallCanvas() { setPreferredSize(new Dimension(640, 400)); setIgnoreRepaint(true); ... various gui controls are wired up here } ... rest of canvas code } Edit: My source code is zipped up here incase someone wants to take a look: http://www.filedropper.com/ballbounce I've done the suggestions made by Dave Ray, and it still isn't resizing the Canvas? Remember, it resizes for me fine when I compile this java program and run it in windows. Only in linux does it does this to me. I'm also running Java 6 Sun 1.6.0.10 JVM, if it matters. alt text http://img158.imageshack.us/img158/7642/screenshotww0.png Perhaps my canvas is resizing by my BufferStrategy/Graphics aren't resizing ? Edit 2: From the screenshot, it is definitely set to CENTER: frame.getContentPane().add(ballCanvas, BorderLayout.CENTER); frame.getContentPane().add(controlPanel, BorderLayout.SOUTH); Resolved Apparently the "Canvas" was getting resized but I was doing something weird with it's buffer strategy that wasn't allowing IT to be resized. I fixed it. Thanks everyone!
downvote count: 0
has comment: http://stackoverflow.com/comment/286046
favorite count: 0
has answer: http://stackoverflow.com/a/468141
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/289507
answer count: 4
has comment: http://stackoverflow.com/comment/286004
score: 3
has answer: http://stackoverflow.com/a/468150
upvote count: 3
tagged with: java
tagged with: swing
has answer: http://stackoverflow.com/a/8662859
has comment: http://stackoverflow.com/comment/10679988
type: Question
has answer: http://stackoverflow.com/a/468065
has comment: http://stackoverflow.com/comment/286048

http://stackoverflow.com/a/551567
upvote count: 8
accepted answer of: http://stackoverflow.com/q/551500
answers question: http://stackoverflow.com/q/551500
has comment: http://stackoverflow.com/comment/363305
type: AcceptedAnswer
downvote count: 0
has body: I've been doing academic research for the past 10 years on different issues that have to do with API usability in Java. I can tell you that the statement about having one way to do things in Java is fairly incorrect. There are often many ways to do the same thing in Java. And unfortunately, they are often not consistent or documented. One problem with bloating the interface of a class with convenience methods is that you are making it more difficult to understand the class and how to use it. The more choices you have, things become more complex. In an analysis of some open-source libraries, I've found instances of redundant functionality, added by different individuals using different terms. Clearly a bad idea. A greater problem is that the information carried by a name is no longer meaningful. For example, things like putLayer vs. setLayer in swing, where one just updates the layer and the other also refreshes (guess which one?) are a problem. Similarly, getComponentAt and findComponentAt. In other ways, the more ways to do something, the more you obfuscate everything else and reduce the "entropy" of your existing functionality. Here is a good example. Suppose you want in Java to replace a substring inside a string with another string. You can use String.replace(CharSequence, CharSequence) which works perfectly as you'd expect, literal for literal. Now suppose you wanted to do a regular expression replacement. You could use Java's Matcher and do a regular expression based replacement, and any maintainer would understand what you did. However, you could just write String.replaceAll(String, String), which calls the Matcher version. However, many of your maintainers might not be familiar with this, and not realize the consequences, including the fact that the replacement string cannot contains "$"s. So, the replacement of "USD" with "$" signs would work well with replace(), but would cause crazy things with replaceAll(). Perhaps the greatest problem, however, is that …
score: 8
type: Answer

http://stackoverflow.com/comment/88792964
type: Comment
has text: The number `min + 1` will be twice as likely than the other number to be the result of `getRandomNumberBetween`!
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/11923174

http://stackoverflow.com/comment/3899703
score: 0
type: Comment
comment on: http://stackoverflow.com/a/617438
has text: Nice touch of just reusing the guaranteed temporary name.
type: AnswerComment

http://stackoverflow.com/q/572001
tagged with: keyboard
favorite count: 0
has body: G'day all, I have a console project where it is intended the user presses the keyboard direction keys (non-numeric keypad) to move an avatar. I am having difficulty coding to check for the press of these keys. In Pascal it was easy enough to use "readkey" and code, for example, for #80 for the down keypress. However, I am stumped how to implement the same functionality in Java, though I think I understand the use of System.in and BufferedInputStream. Could anyone help me out? Your thoughts or hints are much appreciated.
has answer: http://stackoverflow.com/a/572011
answer count: 4
upvote count: 13
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/572011
score: 13
has answer: http://stackoverflow.com/a/51489353
type: Question
has answer: http://stackoverflow.com/a/572024
has answer: http://stackoverflow.com/a/573524
tagged with: java
possible better answer: http://stackoverflow.com/a/573524
tagged with: direction
downvote count: 0
has title: Detecting and acting on keyboard direction keys in Java
tagged with: key

http://stackoverflow.com/comment/423862
comment on: http://stackoverflow.com/a/611178
has text: +1 - you can set a watch on a variable in Eclipse and NetBeans deguggers as well.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/13477227
has comment: http://stackoverflow.com/comment/103912003
has body: Google Guava 14 includes a new class ClassPath with three methods to scan for top level classes: getTopLevelClasses() getTopLevelClasses(String packageName) getTopLevelClassesRecursive(String packageName) See the ClassPath javadocs for more info.
answers question: http://stackoverflow.com/q/520328
has comment: http://stackoverflow.com/comment/26983598
upvote count: 148
has comment: http://stackoverflow.com/comment/107532622
has comment: http://stackoverflow.com/comment/44126044
has comment: http://stackoverflow.com/comment/124975016
downvote count: 1
has comment: http://stackoverflow.com/comment/65386699
score: 147
type: Answer
has comment: http://stackoverflow.com/comment/65385284

http://stackoverflow.com/a/568630
downvote count: 0
answers question: http://stackoverflow.com/q/568616
has body: You need to use an InputStream. Readers are for character data. Look into wrapping your input stream with a DataInputStream, like: stream=new DataInputStream(new BufferedInputStream(new FileInputStream(...))); The data input stream will give you many useful methods to read various types of data, and of course, the base InputStream methods for reading bytes. (This is actually exactly what a HTTP server must do to read a request with content.) The readUTF doesn't read a line, it reads a string that was written in (modified) UTF8 format - refer to the JavaDoc.
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/comment/269220
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/448168
has text: Iterating through the entrySet is more efficient than going through the keySet, even though I need to output the names of the keys as well?

http://stackoverflow.com/a/575783
upvote count: 40
score: 40
accepted answer of: http://stackoverflow.com/q/575706
answers question: http://stackoverflow.com/q/575706
has body: The setBackground method is/was only for use with the clearRect method. Fill the rectangle with the background colour before painting: int width = 200; int height = 400; BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_BINARY); Graphics g = image.createGraphics(); g.setColor(Color.WHITE); g.fillRect(0, 0, width, height); g.setColor(Color.BLACK); //ready for drawing
type: AcceptedAnswer
downvote count: 0
type: Answer

http://stackoverflow.com/q/376101
linked to: http://stackoverflow.com/q/10324996
favorite count: 0
tagged with: proxy
has answer: http://stackoverflow.com/a/7085409
accepted answer: http://stackoverflow.com/a/381698
tagged with: jvm
has title: Setting JVM/JRE to use Windows Proxy Automatically
has answer: http://stackoverflow.com/a/34204974
has answer: http://stackoverflow.com/a/381698
upvote count: 40
has answer: http://stackoverflow.com/a/53109730
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/4377179
tagged with: java
has answer: http://stackoverflow.com/a/3830563
answer count: 6
score: 40
type: Question
possible better answer: http://stackoverflow.com/a/34204974
has body: I did see the question about setting the proxy for the JVM but what I want to ask is how one can utilize the proxy that is already configured (on Windows). Here is a demonstration of my issue: Go to your Control Panel->Java and set a proxy address. Run the following simple applet code (I'm using the Eclipse IDE): import java.awt.Graphics; import javax.swing.JApplet; import java.util.*; public class Stacklet extends JApplet { private String message; public void init(){ Properties props = System.getProperties(); message = props.getProperty("http.proxyHost", "NONE"); message = (message.length() == 0)? "NONE": message; } public void paint(Graphics g) { g.drawString(message, 20, 20); } } The Applet displays "NONE" without regard to the settings you've placed in the Java Control Panel. What would be best would be if the Windows proxy settings (usually set in Internet Explorer) were what I could determine but doing an extra configuration step in the Java Control Panel would still be an acceptable solution. Thanks!
downvote count: 0

http://stackoverflow.com/a/15009179
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/495741
score: 9
upvote count: 9
has body: For Scala 2.10: // Feature warning if you don't enable implicit conversions... import scala.language.implicitConversions import scala.collection.convert.WrapAsScala.enumerationAsScalaIterator

http://stackoverflow.com/a/571870
upvote count: 2
answers question: http://stackoverflow.com/q/492754
has body: I was able to get Eclipse 3.5M5 to run with JDK 1.6.0 as its base VM with a slightly modified path from above: ./eclipse -vm /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0 Better, I was able to put it in the eclipse.ini file in /Applications/eclipse3.5/Eclipse.app/Contents/MacOS, so long as it went above the '-vmargs'. For example: -startup ../../../plugins/org.eclipse.equinox.launcher_1.0.200.v20090128-1500.jar --launcher.library ../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.0.0.v20081125-1800 -vm /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0 -showsplash org.eclipse.platform -vmargs ...
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/comment/354284
comment on: http://stackoverflow.com/a/541538
score: 0
type: AnswerComment
type: Comment
has text: Then you're trading the overhead of IO operations for the overhead of encoding / decoding the data. It would take some experimentation to see if this was viable.

http://stackoverflow.com/q/366202
favorite count: 0
has answer: http://stackoverflow.com/a/39452156
tagged with: regex
has answer: http://stackoverflow.com/a/74514305
has answer: http://stackoverflow.com/a/366216
has answer: http://stackoverflow.com/a/23879905
has title: Regex for splitting a string using space when not surrounded by single or double quotes
linked to: http://stackoverflow.com/q/64904
upvote count: 135
downvote count: 0
has body: I'm new to regular expressions and would appreciate your help. I'm trying to put together an expression that will split the example string using all spaces that are not surrounded by single or double quotes. My last attempt looks like this: (?!") and isn't quite working. It's splitting on the space before the quote. Example input: This is a string that "will be" highlighted when your 'regular expression' matches something. Desired output: This is a string that will be highlighted when your regular expression matches something. Note that "will be" and 'regular expression' retain the space between the words.
has answer: http://stackoverflow.com/a/57151834
linked to: http://stackoverflow.com/q/54866
linked to: http://stackoverflow.com/q/23589174
possible better answer: http://stackoverflow.com/a/366229
has answer: http://stackoverflow.com/a/366222
has answer: http://stackoverflow.com/a/366532
has comment: http://stackoverflow.com/comment/195778
accepted answer: http://stackoverflow.com/a/366532
linked to: http://stackoverflow.com/q/61104216
has answer: http://stackoverflow.com/a/15350753
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/366227
tagged with: java
has answer: http://stackoverflow.com/a/15011583
has answer: http://stackoverflow.com/a/20539344
has answer: http://stackoverflow.com/a/47454129
type: Question
tagged with: split
score: 135
has answer: http://stackoverflow.com/a/366239
has answer: http://stackoverflow.com/a/3714474
has answer: http://stackoverflow.com/a/366229
has comment: http://stackoverflow.com/comment/195773
answer count: 16
has answer: http://stackoverflow.com/a/61120643
linked to: http://stackoverflow.com/q/5695240

http://stackoverflow.com/comment/391500
comment on: http://stackoverflow.com/a/579545
score: 0
type: AnswerComment
has text: @Eye of Hell: I expanded my answer to answer your question.
type: Comment

http://stackoverflow.com/a/419887
has comment: http://stackoverflow.com/comment/244402
answers question: http://stackoverflow.com/q/419858
type: Answer
has body: int[][] copy = new int[nums.length][]; for (int i = 0; i &lt; nums.length; i++) { copy[i] = new int[nums[i].length]; for (int j = 0; j &lt; nums[i].length; j++) { copy[i][j] = nums[i][j]; } } You can replace the second loop with System.arraycopy() or Arrays.copyOf().
upvote count: 13
score: 13
downvote count: 0

http://stackoverflow.com/comment/401607
type: AnswerComment
type: Comment
has text: but I believe I'll rather look for som tool that can scan source code during nightly builds and reports issues such as this.
comment on: http://stackoverflow.com/a/586252
score: 0

http://stackoverflow.com/comment/425322
score: 0
type: Comment
comment on: http://stackoverflow.com/a/610610
has text: When you're writing the compiler, you're bound by the language. However, I'd say that when designing the language you should recognise that it's a mistake to allow it. Anything reached via an expression should depend on the value of that expression in some way.
type: AnswerComment

http://stackoverflow.com/a/589211
score: 4
type: Answer
has body: A Module in ruby is a bit of scope/namespace that can be added to other things. They are used for two distinct but related purposes: bundling up a bunch of related things (constants, classes, etc.) that belong together and then adding them into some other scope (like multiple inheritance). For example, there are modules called things like Comparable and Enumerable and so forth that encapsulate the functionality you'd expect something to have if these adjectives applied. By providing a basic definition (a method that compares two instances for Comparable and an iterator for Enumerable) you can import the module and find yourself with the full interface. On the other hand there are modules like Net that you would seldom include in a class but which provide a bundle of functionality such as Net::HTTP, Net::FTP, Net::SMTP, and so on. In the middle there are things like Math and Process which might be used one way or the other. -- MarkusQ
upvote count: 4
answers question: http://stackoverflow.com/q/575920
downvote count: 0

http://stackoverflow.com/a/609303
score: 4
upvote count: 4
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/609293
has body: With option 1, the caller has the option of selecting exactly which exception to catch, and to ignore all others. With option 2, the caller has to remember to re-throw any exceptions not explicitly caught. Additionally, there's better self-documentation with option 1, as the method signature needs to specify exactly which exceptions are thrown, rather than a single over-riding exception. If there's a need to have an all-encompassing AppException, the other exception types can always inherit from it.

http://stackoverflow.com/a/408239
type: Answer
answers question: http://stackoverflow.com/q/408110
upvote count: 20
has body: If it wasn't checked in as a Java Project, you can add the java nature as shown here.
accepted answer of: http://stackoverflow.com/q/408110
score: 20
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/506939
downvote count: 0
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/506960
upvote count: 3
tagged with: java
answer count: 7
tagged with: bytecode
has answer: http://stackoverflow.com/a/506994
has answer: http://stackoverflow.com/a/506947
has body: How can I retrieve the bytecode and make a hash to see if someone has manipulated my bytecode in-memory or on file? EDIT: Does signing the binaries protect the code from being modified and executed? As much as I want to protect my users from making sure they are running my software. I would also like to protect the program (server) from being used by a hacked client. How do I detect from the server side if someone tampered with my client?
has title: Retrieve bytecode from in-memory to prevent hacking
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/507119
tagged with: security
has answer: http://stackoverflow.com/a/507057
has answer: http://stackoverflow.com/a/506943
score: 3
has answer: http://stackoverflow.com/a/2563074

http://stackoverflow.com/a/3100673
upvote count: 1
answers question: http://stackoverflow.com/q/645847
downvote count: 0
has body: This article expands on the AntBuilder example. http://preferisco.blogspot.com/2010/06/using-goovy-antbuilder-to-zip-unzip.html However, as a matter of principal - is there a way to find out all of the properties, closures, maps etc that can be used when researching a new facet in groovy/java? There seem to be loads of really useful things, but how to unlock their hidden treasures? The NetBeans/Eclipse code-complete features now seem hopelessly limited in the new language richness that we have here.
type: Answer
score: 1

http://stackoverflow.com/comment/62880282
type: Comment
comment on: http://stackoverflow.com/a/388476
score: 2
has text: `StringUtils`/`Strings` is still the better choice IMO when the size of the pad is a runtime variable.
type: AnswerComment

http://stackoverflow.com/a/571045
has body: JSplitPane pays attention to the minimum size, not the preferred size. Try simply changing setPreferredSize to setMinumumSize.
type: Answer
answers question: http://stackoverflow.com/q/571026
score: 0

http://stackoverflow.com/a/416987
has comment: http://stackoverflow.com/comment/241267
answers question: http://stackoverflow.com/q/416970
upvote count: 1
has body: From Java Persistence with Hibernate: A java.util.Map can be mapped with &lt;map&gt;, preserving key and value pairs. Use a java.util.HashMap to initialize a property. A java.util.SortedMap can be mapped with &lt;map&gt; element, and the sort attribute can be set to either a comparator or natural ordering for in-memory sorting. Initialize the collection with a java.util.TreeMap instance.
downvote count: 0
type: Answer
score: 1

http://stackoverflow.com/comment/446585
has text: Sensible whitespace == nice. Unnecessary braces == suck.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/633505
type: Comment

http://stackoverflow.com/comment/419346
score: 0
type: AnswerComment
type: Comment
has text: @zaczap: And you somehow missed where he doesn't understand how objects work?
comment on: http://stackoverflow.com/a/607056

http://stackoverflow.com/a/553923
upvote count: 1
has body: Only thing I can think of falls under unsafe hack (use reflection and alter the owner, but that could possibly change under different version of the JVM (even from the same vensor on the same platform)). Perhaps a better question for you to ask is "this is what I am trying to do... do I really need to change the owner of the dialog or is there a better way"? I am trying to think of reasons to want to change the owner and I cannot come up with any...
answers question: http://stackoverflow.com/q/553759
downvote count: 0
type: Answer
score: 1

http://stackoverflow.com/comment/906684
comment on: http://stackoverflow.com/a/421338
type: Comment
has text: Just a side note, but on a 1.5 JVM Thread.currentThread().getStackTrace() seems to be a lot slower than creating a new Exception() (approximately 3 times slower). But as already noted, you shouldn't be using code like this in a performance-critical area anyway. ;) A 1.6 JVM only seems to be ~10% slower and, as Software Monkey said, it expresses the intent better than the "new Exception" way.
score: 3
type: AnswerComment

http://stackoverflow.com/q/564392
has title: Converting an array of objects to an array of their primitive types
upvote count: 88
type: Question
has answer: http://stackoverflow.com/a/564475
has answer: http://stackoverflow.com/a/2179757
has answer: http://stackoverflow.com/a/68382672
score: 88
tagged with: java
possible better answer: http://stackoverflow.com/a/564475
has answer: http://stackoverflow.com/a/18794385
has answer: http://stackoverflow.com/a/24720136
has answer: http://stackoverflow.com/a/564427
has answer: http://stackoverflow.com/a/75669622
has answer: http://stackoverflow.com/a/564407
tagged with: arrays
downvote count: 0
favorite count: 0
tagged with: primitive-types
answer count: 10
has answer: http://stackoverflow.com/a/564418
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/564407
has body: If you have an array of Java objects which have a primitive type (for example Byte, Integer, Char, etc). Is there a neat way I can convert it into an array of the primitive type? In particular can this be done without having to create a new array and loop through the contents. So for example, given Integer[] array what is the neatest way to convert this into int[] intArray Unfortunately, this is something we have to do quite frequently when interfacing between Hibernate and some third party libraries over which we have no control. It seems this would be a quite common operation so I would be surprised if there's no shortcut. Thanks for your help!
has answer: http://stackoverflow.com/a/71975381

http://stackoverflow.com/a/591110
has body: Some level of abnormal termination is unavoidable. How would you catch the event of the power cable being pulled on the server?
answers question: http://stackoverflow.com/q/590899
upvote count: 1
score: 1
downvote count: 0
type: Answer

http://stackoverflow.com/a/522318
answers question: http://stackoverflow.com/q/522244
upvote count: 1
has body: If I read your question correctly, you're tracking both click and mousedrag events. Can you track the coordinates upon mousedown, followed by a short computation in mousedrag to see if the mouse has moved your desired minimum numbers of pixels? Of course, you then also want to cancel/reset on mouseup or when the mouse is dragged outside the bounds of your JComponent. Caveat: I haven't done this myself, but I think it's where I'd start if it were me.
downvote count: 0
type: Answer
score: 1

http://stackoverflow.com/a/53817587
type: Answer
score: 2
has body: You should choose access via fields over access via properties. With fields you can limit the data sent and received. With via properties you can send more data as a host, and set G denominations (which factory set most of the properties in total).
answers question: http://stackoverflow.com/q/594597
downvote count: 0
upvote count: 2

http://stackoverflow.com/q/402459
has answer: http://stackoverflow.com/a/402466
answer count: 2
downvote count: 1
favorite count: 0
has body: I'd like to know about basic classes for playing video from webcam I'd also like to play with video buffers pixels where can i find a Java JMF tutorial that will help me achieve that?
upvote count: 4
has title: where can i find Java JMF tutorial
type: AnsweredQuestion
tagged with: video
tagged with: jmf
score: 3
tagged with: webcam
tagged with: java
accepted answer: http://stackoverflow.com/a/402466
has answer: http://stackoverflow.com/a/3908978
type: Question
possible better answer: http://stackoverflow.com/a/3908978

http://stackoverflow.com/a/462570
upvote count: 10
type: Answer
has comment: http://stackoverflow.com/comment/281064
has comment: http://stackoverflow.com/comment/15324912
has body: There's not a simpler way with the general JDBC API (at least not that I know of, or can find...I've got exactly the same code in my home-grown toolset.) Your code isn't complete: ResultSetMetaData meta = crs.getMetaData(); int numCol = meta.getColumnCount(); for (int i = 1; i < numCol + 1; i++) { if (meta.getColumnName(i).equals("name")) { return true; } } return false; That being said, if you use proprietary, database-specific API's and/or SQL queries, I'm sure you can find more elegant ways of doing the same thing. Bbut you'd have to write custom code for each database you need to deal with. I'd stick with the JDBC APIs, if I were you. Is there something about your proposed solution that makes you think it's incorrect? It seems simple enough to me.
downvote count: 0
answers question: http://stackoverflow.com/q/462534
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/462534
score: 10

http://stackoverflow.com/a/26630228
has body: java.lang.Enum defines several useful methods, which is available to all enumeration types in Java: You can use the name() method to get the name of any Enum constants. The string literal used to write enum constants is their name. Similarly, the values() method can be used to get an array of all Enum constants from an Enum type. And for the asked question, you can use the valueOf() method to convert any String to an Enum constant in Java, as shown below. public class EnumDemo06 { public static void main(String args[]) { Gender fromString = Gender.valueOf("MALE"); System.out.println("Gender.MALE.name() : " + fromString.name()); } private enum Gender { MALE, FEMALE; } } Output: Gender.MALE.name() : MALE In this code snippet, the valueOf() method returns an Enum constant, Gender.MALE, and calling name on that returns "MALE".
answers question: http://stackoverflow.com/q/604424
score: 6
downvote count: 0
type: Answer
upvote count: 6

http://stackoverflow.com/comment/387212
has text: I store a *lot* of objects in a BerkeleyDB. Those objects contain a Map and reading/writing this map to an array of bytes may be an imortant factor.
type: AnswerComment
type: Comment
score: 1
comment on: http://stackoverflow.com/a/575348

http://stackoverflow.com/comment/413322
has text: ... it might be that the string argument isn't what you think. But the code you exhibited isn't correct in any case (no catch). Try the change I suggested and see what you find out. Oh, and what's the JVM version, the OS, and the hardware architecture?
comment on: http://stackoverflow.com/a/600944
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/619077
has comment: http://stackoverflow.com/comment/431961
has body: Take a look at the JXTaskPane from Swingx project. It already does what you need.
answers question: http://stackoverflow.com/q/619055
downvote count: 0
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/a/604308
downvote count: 0
type: Answer
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/416599
has body: To use BSF you need bsf.jar and the library for your scripting language of choice on the classpath. To execute Javascript, no additional libraries are required. To open an interactive Javascript console try: java org.mozilla.javascript.tools.shell.Main
answers question: http://stackoverflow.com/q/603346

http://stackoverflow.com/comment/23151099
has text: The resource.close() might throw and exception as well - i.e. when the buffer flush fails. This exception should never be consumed. However, if closing the stream as a result of previously raised exception, the resource should be quietly closed ignoring the exception and preserving the root cause.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/8895537

http://stackoverflow.com/q/638491
possible better answer: http://stackoverflow.com/a/639502
has answer: http://stackoverflow.com/a/638562
tagged with: translation
answer count: 4
has body: I'm looking for ways/tools/projects to translate Java bytecode into other programming languages or, failing that, at least into a structured representation (like XML). Ideally open source, naturally. I've looked at ASM, the "bytecode manipulation and analysis framework". It doesn't support translation to other representations, but looks like a good foundation for such a project. Sadly, none of the projects listed on their users page comes close.
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/639502
downvote count: 0
tagged with: java
upvote count: 8
type: Question
tagged with: bytecode
has answer: http://stackoverflow.com/a/638771
tagged with: decompiling
accepted answer: http://stackoverflow.com/a/638771
has answer: http://stackoverflow.com/a/638531
favorite count: 0
score: 8
has title: Translating Java bytecode into other representations and programming languages

http://stackoverflow.com/a/31332810
has body: I solved my problem. We can just send the header to application/json and pass the body as a json object. That simply solves the issue.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/480153

httpsession
tags question: http://stackoverflow.com/q/634929
tag name: httpsession
type: Tag

http://stackoverflow.com/q/574569
score: 0
has answer: http://stackoverflow.com/a/574575
has title: Object construction from serialization - which is preferred?
tagged with: parsing
has answer: http://stackoverflow.com/a/574589
possible better answer: http://stackoverflow.com/a/575549
has answer: http://stackoverflow.com/a/575674
has answer: http://stackoverflow.com/a/575549
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/574575
has answer: http://stackoverflow.com/a/575654
tagged with: java
has answer: http://stackoverflow.com/a/574577
has body: Lets say you have a class SomeClass which has its own implementation of toString(), and also has the ability to parse a new instance of itself by reading that same string. Which of these methods do you prefer, or find better to use? You can either define it as another constructor: public SomeClass(String serializedString); or you can define it as a static method, which in turn creates a new instance (by one of the other constructors, does some with it, and returns the new instance: public static SomeClass toObject(String serializedString); Does it even matter? (my hunch is there is no case this matters, but I am trying to make sure)
type: Question
tagged with: oop
answer count: 6

http://stackoverflow.com/a/369645
type: Answer
has body: Do you have to use Visitor from XTC? It's a pretty trivial interface, and you could implement your own which can throw checked ReturnException, which you would not forget to catch where needed.
score: 0
answers question: http://stackoverflow.com/q/369452

http://stackoverflow.com/a/444150
has comment: http://stackoverflow.com/comment/265990
downvote count: 3
type: Answer
has body: I think that the URI class is the one that you are looking for.
has comment: http://stackoverflow.com/comment/265943
has comment: http://stackoverflow.com/comment/265842
has comment: http://stackoverflow.com/comment/265663
has comment: http://stackoverflow.com/comment/265823
answers question: http://stackoverflow.com/q/444112
upvote count: 1
score: -2
has comment: http://stackoverflow.com/comment/265815

http://stackoverflow.com/a/615491
upvote count: 1
type: Answer
downvote count: 0
score: 1
has body: I recommend to call log API (log4j) via slf4j. Even if you use log4j, web container or depending modules may use different log API such as Java.util.logging or Jakarta commons logging. Slf4j provides bridge modules that redirect them to slf4j API. As a result, all log messages are written by log4j in that case.
answers question: http://stackoverflow.com/q/614666

http://stackoverflow.com/q/433358
downvote count: 0
favorite count: 0
has title: How to get a more compact automatic indentation in Eclipse (for Java)?
upvote count: 2
has body: What is the code formating option to indent as: Log.w(TAG, String.format( "Upgrading database from version %s to %s which will destroy all old data", oldVersion, newVersion)); instead of as: Log .w( TAG, String .format( "Upgrading database from version %s to %s which will destroy all old data", oldVersion, newVersion));
type: UnansweredQuestion
type: Question
has answer: http://stackoverflow.com/a/433380
tagged with: java
tagged with: eclipse
has answer: http://stackoverflow.com/a/998510
answer count: 2
score: 2

http://stackoverflow.com/a/569454
type: Answer
has body: Building on McDowell's answer, this seems to be of interest, it explains how to do a colorspace conversion.
upvote count: 3
answers question: http://stackoverflow.com/q/568994
score: 3
downvote count: 0

http://stackoverflow.com/comment/13848968
score: 1
has text: as a generic alternative you can use the javax annotation: @javax.persistence.OrderBy(value = "fieldName")
comment on: http://stackoverflow.com/a/408522
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/449142
type: Comment
has text: @rajKumar: With "ab" "c", the compiler does the concatenation for you.
comment on: http://stackoverflow.com/q/635807
score: 0
type: QuestionComment

http://stackoverflow.com/comment/194394
comment on: http://stackoverflow.com/a/364464
type: AnswerComment
has text: Why? What's wrong with checking for equality between unrelated types? It's a question with a perfectly fine and well-defined answer.
score: 0
type: Comment

http://stackoverflow.com/comment/268068
type: Comment
has text: Gave that a go, but no joy either.. will grab bat files and try that now.
comment on: http://stackoverflow.com/a/446452
score: 0
type: AnswerComment

http://stackoverflow.com/a/470636
answers question: http://stackoverflow.com/q/470592
has comment: http://stackoverflow.com/comment/288169
score: 0
has body: A jar file is just a normal zip file. If you want to add files to it, just use a tool such as winzip.
type: Answer

http://stackoverflow.com/a/1260517
downvote count: 0
answers question: http://stackoverflow.com/q/399546
type: Answer
has body: synthetic classes / methods / fields: These things are important for the VM. Have a look at following code snippet: class MyOuter { private MyInner inner; void createInner() { // The Compiler has to create a synthetic method // to construct a new MyInner because the constructor // is private. // --&gt; synthetic "constructor" method inner = new MyInner(); // The Compiler has to create a synthetic method // to doSomething on MyInner object because this // method is private. // --&gt; synthetic "doSomething" method inner.doSomething(); } private class MyInner { // the inner class holds a syntetic ref_pointer to // the outer "parent" class // --&gt; synthetic field private MyInner() { } private void doSomething() { } } }
score: 15
upvote count: 15

http://stackoverflow.com/q/504904
tagged with: oop
has answer: http://stackoverflow.com/a/506728
has comment: http://stackoverflow.com/comment/324779
has comment: http://stackoverflow.com/comment/37932826
has answer: http://stackoverflow.com/a/504921
tagged with: java
has answer: http://stackoverflow.com/a/35806153
tagged with: language-features
linked to: http://stackoverflow.com/q/18777989
has answer: http://stackoverflow.com/a/505018
type: Question
has answer: http://stackoverflow.com/a/504953
has answer: http://stackoverflow.com/a/504935
has comment: http://stackoverflow.com/comment/319659
linked to: http://stackoverflow.com/q/1913098
has answer: http://stackoverflow.com/a/50983439
has answer: http://stackoverflow.com/a/17220366
has answer: http://stackoverflow.com/a/504942
has answer: http://stackoverflow.com/a/505104
has answer: http://stackoverflow.com/a/504932
has comment: http://stackoverflow.com/comment/63324956
accepted answer: http://stackoverflow.com/a/504932
has answer: http://stackoverflow.com/a/505148
has answer: http://stackoverflow.com/a/504944
linked to: http://stackoverflow.com/q/379282
upvote count: 159
downvote count: 0
has answer: http://stackoverflow.com/a/505138
answer count: 17
favorite count: 0
has comment: http://stackoverflow.com/comment/51235459
has body: So lets say I have this interface: public interface IBox { public void setSize(int size); public int getSize(); public int getArea(); //...and so on } And I have a class that implements it: public class Rectangle implements IBox { private int size; //Methods here } If I wanted to use the interface IBox, i can't actually create an instance of it, in the way: public static void main(String args[]) { Ibox myBox=new Ibox(); } right? So I'd actually have to do this: public static void main(String args[]) { Rectangle myBox=new Rectangle(); } If that's true, then the only purpose of interfaces is to make sure that the class which implements an interface has got the correct methods in it as described by an interface? Or is there any other use of interfaces?
has answer: http://stackoverflow.com/a/504937
score: 159
tagged with: interface
linked to: http://stackoverflow.com/q/20463
has comment: http://stackoverflow.com/comment/319691
has answer: http://stackoverflow.com/a/511689
has answer: http://stackoverflow.com/a/43972738
has title: Is there more to an interface than having the correct methods
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/505148

http://stackoverflow.com/comment/386856
type: Comment
comment on: http://stackoverflow.com/q/574746
type: QuestionComment
has text: Really appreciate your effort. Thanks. Unfortunately, that doesn't change a thing. I think I'll end up checking on different JDKs under Win, Linux & Mac to see if the behavior is the same.
score: 0

http://stackoverflow.com/a/46648616
has body: I once used a kind of conversation scope to store some objects in the session scope, in order to keep them when re-entering the same page, but limited to a single page to avoid to leave useless objects in the session. The implementation just stored the page URL and cleaned the conversation scope on each page change.
answers question: http://stackoverflow.com/q/450557
score: 0
type: Answer

http://stackoverflow.com/a/10696096
downvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/506105
has comment: http://stackoverflow.com/comment/13885261
score: 0
has body: static String removeOccurences(String a, String b) { StringBuilder s2 = new StringBuilder(a); for(int i=0;i&lt;b.length();i++){ char ch = b.charAt(i); System.out.println(ch+" first index"+a.indexOf(ch)); int lastind = a.lastIndexOf(ch); for(int k=new String(s2).indexOf(ch);k &gt; 0;k=new String(s2).indexOf(ch)){ if(s2.charAt(k) == ch){ s2.deleteCharAt(k); System.out.println("val of s2 : "+s2.toString()); } } } System.out.println(s1.toString()); return (s1.toString()); }
upvote count: 1

http://stackoverflow.com/a/403959
has body: Put your values into a properties file, say "myapp.properties" and then load them into your constants from the classpath at startup (see below for how this fits into the build process): public class Constants { private static final Properties props = new Properties(); public static final String MY_CONSTANT; static { InputStream input = Constants.class.getResourceAsStream("/myapp.properties"); if(input != null) { try { properties.load(input); } catch(IOException e) { // TODO log error } } // Initialize constants (dont' forget defaults) MY_CONSTANT = properties.getProperty("constant", "default"); // .. other constants ... } } Now, have a separate properties file for each branding. Pass its name to ANT via -D or build.properties and copy the file to your build directory right before you jar (or war) it up. Obviously, the code above will work, but there are many ways you can clean it up and make it bullet proof.
has comment: http://stackoverflow.com/comment/234538
upvote count: 9
has comment: http://stackoverflow.com/comment/234589
answers question: http://stackoverflow.com/q/403902
type: Answer
downvote count: 0
score: 9

http://stackoverflow.com/a/518140
has comment: http://stackoverflow.com/comment/341191
type: Answer
has comment: http://stackoverflow.com/comment/335201
answers question: http://stackoverflow.com/q/516453
has body: As others have said, please never split the strings into segments. You will cause translators grief as they have to coerce their language syntax to the ad-hoc rules you inadvertently create. Often it will not be possible to provide a grammatically correct translation, especially if you reuse certain segments in different contexts. Do not remove the markup, either. Please do not assume professional translators work in Notepad :) Computer-aided translation (CAT) tools, such as the Trados suite, know about markup perfectly well. If the tagging is HTML, rather than some custom XML format, no special preparation is required. Trados will protect the tags from accidental modification, while still allowing changes where necessary. Note that certain elements of tags often need to be localized, e.g. alt text or some query strings, so just stripping all the markup won't do. Best of all, unless you're working on a zero-budget personal project, consider contacting a localization vendor. Localization is a service just like web design. A competent vendor will help you pick the optimal solution/format for your project and guide you through the preparation of the source material and incorporating the localized result. And of course they and their translators will have all the necessary tools. (Full disclosure: I am a translator / localization specialist. And don't split up strings :)
score: 7
upvote count: 7
has comment: http://stackoverflow.com/comment/341200
has comment: http://stackoverflow.com/comment/341183
downvote count: 0

http://stackoverflow.com/a/494201
has body: An easy way is to convert the dates into milliseconds after January 1, 1970 (use Date.getTime()) and then compare these values.
score: 4
type: Answer
upvote count: 4
answers question: http://stackoverflow.com/q/494180
downvote count: 0

http://stackoverflow.com/a/436758
has body: You are hiding the inherited variables with ones defined in the subclass. public class Bar extends Foo { public Bar() { dee = "DEE"; dum = "DUM"; } } should work better.
score: 9
answers question: http://stackoverflow.com/q/436742
upvote count: 9
type: Answer
downvote count: 0

http://stackoverflow.com/a/616880
has body: You cannot control the opened windows from Java. But I suggest two solutions for you: First: Runtime.exec("cmd /c start /MIN ...") The /MIN parameter will prevent windows from appearing. Second: put all the applications you must call inside the same batch file and call it once. :-)
type: Answer
score: 1
accepted answer of: http://stackoverflow.com/q/616700
upvote count: 2
answers question: http://stackoverflow.com/q/616700
downvote count: 1
has comment: http://stackoverflow.com/comment/431876
has comment: http://stackoverflow.com/comment/443883
type: AcceptedAnswer

http://stackoverflow.com/comment/341487
type: AnswerComment
type: Comment
has text: I imagine that it's just for clarity in this simple example.
comment on: http://stackoverflow.com/a/528464
score: 0

http://stackoverflow.com/comment/71928484
comment on: http://stackoverflow.com/a/37389179
type: AnswerComment
score: 0
type: Comment
has text: @JakeWilson801 It worked in scrolling container for me. But now there is [FlexboxLayoutManager in RecyclerView](https://android-developers.googleblog.com/2017/02/build-flexible-layouts-with.html), so maybe it solve your issue.

http://stackoverflow.com/comment/324386
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/483443
has text: Hi Markus, But wouldn't all this view management be in context of a web app? I am developing a desktop application and want to manage the same there.

http://stackoverflow.com/a/634599
has body: Under Linux you could use Runtime.exec() to execute “uptime” and evaluate the output. I don’t there’s a better way under Linux, and I don’t think there’s an equally “convenient” way under Windows.
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/634580
upvote count: 1
type: Answer

http://stackoverflow.com/a/547900
score: 3
answers question: http://stackoverflow.com/q/533102
has body: I personally prefer grouping classes logically then within that include a subpackage for each functional participation. Goals of packaging Packages are after all about grouping things together - the idea being related classes live close to each other. If they live in the same package they can take advantage of package private to limit visibility. The problem is lumping all your view and persitance stuff into one package can lead to a lot of classes being mixed up into a single package. The next sensible thing to do is thus create view, persistance, util sub packages and refactor classes accordingly. Underfortunately protected and package private scoping does not support the concept of the current package and sub package as this would aide in enforcing such visibility rules. I see now value in separation via functionality becase what value is there to group all the view related stuff. Things in this naming strategy become disconnected with some classes in the view whilst others are in persistance and so on. An example of my logical packaging structure For purposes of illustration lets name two modules - ill use the name module as a concept that groups classes under a particular branch of a pacckage tree. apple.model apple.store banana.model banana.store Advantages A client using the Banana.store.BananaStore is only exposed to the functionality we wish to make available. The hibernate version is an implementation detail which they do not need to be aware nor should they see these classes as they add clutter to storage operations. Other Logical v Functional advantages The further up towards the root the broader the scope becomes and things belonging to one package start to exhibit more and more dependencies on things belonging to toher modules. If one were to examine for example the "banana" module most of the dependencies would be limited to within that module. In fact most helpers under "banana" would not be referenced at all outside this package scope. Why functiona…
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/378776
upvote count: 3
has comment: http://stackoverflow.com/comment/359915

http://stackoverflow.com/comment/55619010
type: AnswerComment
has text: You dind't explain anything, you just posted some code. Not even commented code. A piece of code isn't an explanation, or a 'semantic'.
type: Comment
score: 1
comment on: http://stackoverflow.com/a/462414

http://stackoverflow.com/a/406886
answers question: http://stackoverflow.com/q/406247
has body: You'll get a nasty runtime error if you have classes in the same package and some are in a signed JAR while others are not.
downvote count: 0
type: Answer
score: 3
upvote count: 3

http://stackoverflow.com/a/501189
type: Answer
has body: Spring has three features that are equally important: dependency injection aspect oriented programming library of framework classes to help with persistence, remoting, web mvc, etc. I'll agree that it's hard to see an advantage to dependency injection when you compare that to a single call to new. In that case, the latter will certainly look simpler, because it's a single line of code. Spring's configuration will always increase the lines of code, so it's not a winning argument. It starts looking a lot better when you can take a cross-cutting concern like transactions out of your classes and use aspects to set them up in a declarative way. The comparison to a single "new" call isn't what Spring was created for. Perhaps the best outcome from using Spring is the way its recommended idiom uses interfaces, layering, and good principles like DRY. It's really just the distillation of object-oriented best practices that Rod Johnson used in his consulting gigs. He found that the code he built up over time helped him make a buck delivering better software for his clients. He summarized his experience in "Expert 1:1 J2EE" and ended up open sourcing the code as Spring. I'd say buy into the framework to the degree that you think his experience can help you write better code, too. I don't think you can get the full value of Spring until you combine all three of those features.
score: 13
upvote count: 13
answers question: http://stackoverflow.com/q/500637
downvote count: 0

http://stackoverflow.com/a/556570
downvote count: 0
answers question: http://stackoverflow.com/q/556526
type: Answer
upvote count: 1
score: 1
has body: I'm confused to the way it's supposed to work. And i don't think it's possible. Here's why: If you want to use the class code in the rest of your application, you need an interface (or heavy use of reflection) and that would mean, you know the column types beforehand - defeating the purpose of a generated class. A generated class might clash during runtime with another one. If you create a new class for each SQL call, you will have either different classes for the same purpose. And these would probably not even pass a regular call to "equals". You have to look up classes from previously executed statements. And you loose flexibility and/or fill your heap with classes.

http://stackoverflow.com/comment/80681728
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/558021
type: Comment
has text: @subes I'm having the same issue with `WindRiver Workbenck` on `Ubuntu 14.06` that is. I have installed above suggested packages but it still doesn't work for me... do you have any further clues? I read you recompiled the C++ compiler, is this what I have to do, too? My currentr gcc version is `5.4.0`

http://stackoverflow.com/a/472296
has body: JCEA question may be useful: http://www.coderanch.com/t/152957/Architect-Certification-SCEA/certification/java-application-client http://www.leocrawford.org.uk/work/jcea/part1/ http://www.sweber.be/SCEA/
score: 0
type: Answer
answers question: http://stackoverflow.com/q/472176

http://stackoverflow.com/a/35104301
has body: Or, although not a direct answer to your question, but it might be an answer to your problem (i.e. remove the effort of doing boilerplate code while being super fast) if you use Eclipse, the following steps will auto generate the hashCode and equals for you: Source > Generate hashCode and equals... and then select the fields, it's super effective! :D Cheers and I hope it helps whoever comes here with the purpose of cutting some time writing boilerplate. PS: I'm sure other popular IDEs must have similar features.
type: Answer
has comment: http://stackoverflow.com/comment/97513768
upvote count: 1
answers question: http://stackoverflow.com/q/472626
downvote count: 1
score: 0
has comment: http://stackoverflow.com/comment/100147714

http://stackoverflow.com/comment/425050
comment on: http://stackoverflow.com/q/610732
score: 0
type: Comment
has text: Changed the title since Click Upvote seems to be more looking for info about build automation in general, and not Ant in particular.
type: QuestionComment

http://stackoverflow.com/a/642319
has body: Even with perfect software, hardware will prevent you doing this. Hardware threads typically don't have fair performance. Over a short period, you are lucky if threads run within +-10% performance. The are, of course, outliers. Some chipsets will run some cores in powersaving mode and others not. I believe one of the Blue Gene research machines had software controlled scheduling of hardware threads instead of locks.
answers question: http://stackoverflow.com/q/641906
downvote count: 0
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/comment/84501335
score: 2
type: AnswerComment
has text: @LinkTheProgrammer it certainly *can* be a bad thing
comment on: http://stackoverflow.com/a/517996
type: Comment

http://stackoverflow.com/a/19956227
answers question: http://stackoverflow.com/q/625433
has body: Joda-Time Using Joda-Time: DateTime startTime = new DateTime(); // do something DateTime endTime = new DateTime(); Duration duration = new Duration(startTime, endTime); Period period = duration.toPeriod().normalizedStandard(PeriodType.time()); System.out.println(PeriodFormat.getDefault().print(period));
type: Answer
score: 9
upvote count: 9
downvote count: 0
has comment: http://stackoverflow.com/comment/59608828

http://stackoverflow.com/comment/7361091
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/584245
score: 0
has text: I agree with Paul. Seam definitely adds something new to the IOC world; I found "bijection" to be quite an interesting feature.

http://stackoverflow.com/comment/198032
has text: As I said, the JVM *is* pretty reluctant in deallocating memory - though I observed it starting at block 40, so it might depend on other factors as well, possibly the total system memory.
comment on: http://stackoverflow.com/a/366776
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/366830
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/555091
type: Comment
has text: Sorry, I forgot to mention that the application runs fine standalone, ie. not within a container.

http://stackoverflow.com/q/375831
has title: Java interface inheritance and implementation
has comment: http://stackoverflow.com/comment/203854
has answer: http://stackoverflow.com/a/375837
tagged with: inheritance
answer count: 1
downvote count: 0
favorite count: 0
duplicate of: http://stackoverflow.com/q/362770
accepted answer: http://stackoverflow.com/a/375837
tagged with: interface
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java
has body: I saw in the apache camel source code that public class DefaultCamelContext extends ServiceSupport implements CamelContext, Service My question is why this definition since public interface CamelContext extends Service and also public abstract class ServiceSupport implements Service Shouldn't it be just public class DefaultCamelContext extends ServiceSupport implements CamelContext ? Is the explicit 'implements Service' needed and I am missing something? Generally is there any case where this might be needed?
type: Question

http://stackoverflow.com/q/452669
downvote count: 0
tagged with: java
tagged with: hibernate
accepted answer: http://stackoverflow.com/a/452692
has answer: http://stackoverflow.com/a/14102951
tagged with: annotations
score: 17
has body: I've been using Hibernate for a few years but have only used it with annotations, and by setting the connection parameters in my code. Am I "missing something" by not using the XML files? Are there important capabilities available only in XML? Are there situations or patterns where it makes sense to use the XML?
has answer: http://stackoverflow.com/a/452683
type: Question
has answer: http://stackoverflow.com/a/452676
has answer: http://stackoverflow.com/a/2402292
has answer: http://stackoverflow.com/a/452692
tagged with: jpa
upvote count: 17
has answer: http://stackoverflow.com/a/453385
possible better answer: http://stackoverflow.com/a/452683
favorite count: 0
has answer: http://stackoverflow.com/a/5225422
answer count: 9
has title: Is there a good reason to configure hibernate with XML rather than via annotations?
has answer: http://stackoverflow.com/a/453330
tagged with: http://stackoverflow.com/tag/xml
has answer: http://stackoverflow.com/a/452706
type: AnsweredQuestion

http://stackoverflow.com/q/614812
type: AnsweredQuestion
has title: How to find creator of JmSession closed by CachedConnectionManager in JBoss
tagged with: java
has body: I am getting the following error in my logs on JBoss 5.0.1 with JBPM. I can't for the life of me work out where this session is getting opened and not closed (wherever we use JMS we cleanup the collection inside a finally block). 2009-03-05 13:11:12,595 INFO [org.jboss.resource.connectionmanager.CachedConnectionManager] (WorkerThread#1[127.0.0.1:51191]) Closing a connection for you. Please close them yourself: org.jboss.resource.adapter.jms.JmsSession@11ed463 Can anyone offer any pointers as to how I should go about finding where the JmsSession was created so that I can see what went wrong? Thanks in advance Rich
has answer: http://stackoverflow.com/a/614851
type: Question
tagged with: jakarta-ee
accepted answer: http://stackoverflow.com/a/614851
tagged with: jboss
score: 0
tagged with: jbpm
answer count: 1

http://stackoverflow.com/a/72414026
type: Answer
answers question: http://stackoverflow.com/q/388461
has body: For what it's worth, I was looking for something that would pad around and then I decided to code it myself. It's fairly clean and you can easily derive padLeft and padRight from this /** * Pads around a string, both left and right using pad as the template, aligning to the right or left as indicated. * @param a the string to pad on both left and right * @param pad the template to pad with, it can be of any size * @param width the fixed width to output * @param alignRight if true, when the input string is of odd length, adds an extra pad char to the left, so values are right aligned * otherwise add an extra pad char to the right. When the input is of even length no extra chars will be inserted * @return the input param a padded around. */ public static String padAround(String a, String pad, int width, boolean alignRight) { if (pad.length() == 0) throw new IllegalArgumentException("Pad cannot be an empty string!"); int delta = width - a.length(); if (delta < 1) return a; int half = delta / 2; int remainder = delta % 2; String padding = pad.repeat(((half+remainder)/pad.length()+1)); // repeating the padding to occupy all possible space StringBuilder sb = new StringBuilder(width); // sb.append( padding.substring(0,half + (alignRight ? 0 : remainder))); sb.append(padding, 0, half + (alignRight ? 0 : remainder)); sb.append(a); // sb.append( padding.substring(0,half + (alignRight ? remainder : 0))); sb.append(padding, 0, half + (alignRight ? remainder : 0)); return sb.toString(); } While it should be fairly fast it could prolly benefit from using a few finals here and there.
score: 0

http://stackoverflow.com/comment/38571841
type: Comment
has text: How did you know to search for the -Xrs option?
comment on: http://stackoverflow.com/a/559720
score: 1
type: AnswerComment

http://stackoverflow.com/a/642564
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/642532
type: Answer
downvote count: 2
has comment: http://stackoverflow.com/comment/455938
has comment: http://stackoverflow.com/comment/493770
has body: Create a static method in your class which will return an array of declared methods and do the correct handling of exceptions. private static Method[] declaredMethods(Class&lt;T&gt; clazz, String methodName) { Method[] result = new Method[1]; try{ result[0] = clazz.getDeclaredMethod(methodName); } catch (NoSuchMethodException nsme) { // respond to the error } catch (SecurityException se) { // Respond to the error } return result; } Method[] actions = declaredMethods("count");
has comment: http://stackoverflow.com/comment/455951
accepted answer of: http://stackoverflow.com/q/642532
upvote count: 0
score: -2

http://stackoverflow.com/comment/280013
comment on: http://stackoverflow.com/a/461225
has text: Updated the question again. I am determining the length of the file from same process with which I am doing seek(). As I updated just now other process appends the things and closes it. as close uses flush() yesh flush is happening.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/564865
comment on: http://stackoverflow.com/q/500637
has text: This is pretty similar to http://stackoverflow.com/questions/131975.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/499010
has answer: http://stackoverflow.com/a/500394
tagged with: java
has answer: http://stackoverflow.com/a/499032
tagged with: stream
tagged with: file
tagged with: character-encoding
linked to: http://stackoverflow.com/q/498636
has answer: http://stackoverflow.com/a/15821629
type: Question
has answer: http://stackoverflow.com/a/2019203
has answer: http://stackoverflow.com/a/27213396
tagged with: encoding
possible better answer: http://stackoverflow.com/a/499033
has answer: http://stackoverflow.com/a/32373318
has comment: http://stackoverflow.com/comment/114522928
has answer: http://stackoverflow.com/a/499033
answer count: 16
has body: With reference to the following thread: Java App : Unable to read iso-8859-1 encoded file correctly What is the best way to programatically determine the correct charset encoding of an inputstream/file ? I have tried using the following: File in = new File(args[0]); InputStreamReader r = new InputStreamReader(new FileInputStream(in)); System.out.println(r.getEncoding()); But on a file which I know to be encoded with ISO8859_1 the above code yields ASCII, which is not correct, and does not allow me to correctly render the content of the file back to the console.
linked to: http://stackoverflow.com/q/457655
has answer: http://stackoverflow.com/a/37196594
has comment: http://stackoverflow.com/comment/40860354
has answer: http://stackoverflow.com/a/909352
has answer: http://stackoverflow.com/a/4735911
has answer: http://stackoverflow.com/a/66574641
downvote count: 0
has answer: http://stackoverflow.com/a/30168441
favorite count: 0
score: 163
has answer: http://stackoverflow.com/a/4013565
has answer: http://stackoverflow.com/a/499037
upvote count: 163
has answer: http://stackoverflow.com/a/2265688
has title: Java : How to determine the correct charset encoding of a stream
has comment: http://stackoverflow.com/comment/10548873
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/51573443
accepted answer: http://stackoverflow.com/a/4735911

http://stackoverflow.com/comment/318700
type: AnswerComment
score: 0
has text: The thing about the "huge overhead" of Vector is nonsense; in fact, if you actually need the basic synchronization it provides, it is faster than using Collections.unmodifiableList().
type: Comment
comment on: http://stackoverflow.com/a/502429

http://stackoverflow.com/a/369867
has body: You should implement Comparable &lt;Person&gt;. Assuming all fields will not be null (for simplicity sake), that age is an int, and compare ranking is first, last, age, the compareTo method is quite simple: public int compareTo(Person other) { int i = firstName.compareTo(other.firstName); if (i != 0) return i; i = lastName.compareTo(other.lastName); if (i != 0) return i; return Integer.compare(age, other.age); }
has comment: http://stackoverflow.com/comment/19116320
has comment: http://stackoverflow.com/comment/37152007
has comment: http://stackoverflow.com/comment/40807848
has comment: http://stackoverflow.com/comment/40815359
upvote count: 185
downvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/369512
score: 183
has comment: http://stackoverflow.com/comment/35448596

http://stackoverflow.com/tag/csv
type: Tag
tag name: csv
tags question: http://stackoverflow.com/q/383260
tags question: http://stackoverflow.com/q/644539
tags question: http://stackoverflow.com/q/506317
tags question: http://stackoverflow.com/q/409173
tags question: http://stackoverflow.com/q/515631

spring-ide
tags question: http://stackoverflow.com/q/425794
tag name: spring-ide
type: Tag

http://stackoverflow.com/a/2423088
type: Answer
has body: You can use JEdit's textarea with built-in completion &amp; syntax highlighting framework. A more heavyweight solution (that is good on the long term) is use NetBeans Platform.
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/485530
downvote count: 0

http://stackoverflow.com/comment/30950203
comment on: http://stackoverflow.com/a/10026065
type: AnswerComment
type: Comment
has text: Also, in my mind *Apache Commons* should not be the accepted answer in 2013. (Even if some subprojects are better maintained than others.) [Guava can be used to achieve the same thing](http://stackoverflow.com/a/500643/56285); see `nullsFirst()` / `nullsLast()`.
score: 3

http://stackoverflow.com/comment/431625
has text: Don't get me wrong on this, I sure don't mind different concepts in languages, I carefully chose Java for this project and I'm happy with my choice. I was mainly wondering whether this is the language or some misunderstanding on my side.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/618394
type: Comment

http://stackoverflow.com/a/596885
has comment: http://stackoverflow.com/comment/32359648
score: 29
has body: This is something of a religious debate. Both approaches have their problems. Use instanceof and you can never add significant members to subclasses. Use getClass and you violate the Liskov substitution principle. Bloch has another relevant piece of advice in Effective Java Second Edition: Item 17: Design and document for inheritance or prohibit it
upvote count: 30
has comment: http://stackoverflow.com/comment/44506853
downvote count: 1
has comment: http://stackoverflow.com/comment/46413831
has comment: http://stackoverflow.com/comment/32375483
has comment: http://stackoverflow.com/comment/47463225
type: Answer
has comment: http://stackoverflow.com/comment/35336057
answers question: http://stackoverflow.com/q/596462
has comment: http://stackoverflow.com/comment/44507232

http://stackoverflow.com/q/366897
type: AnsweredQuestion
tagged with: java
has body: I've got a big file on which I'm opening a FileInputStream. This file contains some files each having an offset from the beginning and a size. Furthermore, I've got a parser that should evaluate such a contained file. File file = ...; // the big file long offset = 1734; // a contained file's offset long size = 256; // a contained file's size FileInputStream fis = new FileInputStream(file ); fis.skip(offset); parse(fis, size); public void parse(InputStream is, long size) { // parse stream data and insure we don't read more than size bytes is.close(); } I feel like this is no good practice. Is there a better way to do this, maybe using buffering? Furthermore, I feel like the skip() method slows the reading process a lot.
tagged with: inputstream
type: Question
has answer: http://stackoverflow.com/a/367018
score: 9
has answer: http://stackoverflow.com/a/366903
possible better answer: http://stackoverflow.com/a/366914
downvote count: 0
accepted answer: http://stackoverflow.com/a/366905
has answer: http://stackoverflow.com/a/366904
favorite count: 0
upvote count: 9
has answer: http://stackoverflow.com/a/366905
answer count: 5
has answer: http://stackoverflow.com/a/366914
has title: Good design: How to pass InputStreams as argument?

http://stackoverflow.com/q/443010
has answer: http://stackoverflow.com/a/4078274
has answer: http://stackoverflow.com/a/443034
has comment: http://stackoverflow.com/comment/264750
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/108993067
has body: I needed to convert a Java 1.5se app to C# 2.0. Does anyone know of a tool (preferably free/open source) to do this?
has comment: http://stackoverflow.com/comment/117600512
possible better answer: http://stackoverflow.com/a/443024
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/443024
has comment: http://stackoverflow.com/comment/4339580
has answer: http://stackoverflow.com/a/443041
tagged with: c#
upvote count: 46
linked to: http://stackoverflow.com/q/3070261
has answer: http://stackoverflow.com/a/9054680
accepted answer: http://stackoverflow.com/a/443034
has answer: http://stackoverflow.com/a/448269
tagged with: java
linked to: http://stackoverflow.com/q/4457962
has answer: http://stackoverflow.com/a/20597841
linked to: http://stackoverflow.com/q/78811
has answer: http://stackoverflow.com/a/19170704
score: 45
has title: Where can I find a Java to C# converter?
has answer: http://stackoverflow.com/a/4077993
favorite count: 0
linked to: http://stackoverflow.com/q/896867
answer count: 9

http://stackoverflow.com/a/506244
upvote count: 2
has body: You might want to check out Prevayler
score: 2
answers question: http://stackoverflow.com/q/506220
downvote count: 0
type: Answer

http://stackoverflow.com/a/33361413
has comment: http://stackoverflow.com/comment/77664538
upvote count: 2
answers question: http://stackoverflow.com/q/526037
type: Answer
score: 1
has comment: http://stackoverflow.com/comment/95092817
downvote count: 1
has body: This will work in windows Runtime.getRuntime().exec( "CMD /C START filename.ext " );
has comment: http://stackoverflow.com/comment/95091919

http://stackoverflow.com/a/61383032
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/537174
score: 22
has body: I got here from String Manipulation insert a character every 4th character and was looking for a solution on Android with Kotlin. Just adding a way to do that with Kotlin (you got to love the simplicity of it) val original = "123498761234" val dashed = original.chunked(4).joinToString("-") // 1234-9876-1234
upvote count: 22

http://stackoverflow.com/q/624929
type: AnsweredQuestion
score: 3
downvote count: 0
tagged with: java
has title: .NET equivalent of java.util.Arrays.toString(...) methods in Java
type: Question
has answer: http://stackoverflow.com/a/624932
accepted answer: http://stackoverflow.com/a/624932
tagged with: arrays
has answer: http://stackoverflow.com/a/624935
tagged with: .net
tagged with: comparison
upvote count: 3
answer count: 3
has answer: http://stackoverflow.com/a/78447833
favorite count: 0
has body: In Java, the java.util.Arrays class have several static toString(...) methods that take an array and return its string representation (i.e. the string representation of the contents of the array separated by commas and the whole representation enclosed in square brackets -- e.g. "[1, 2, 3]"). Is there an equivalent method/functionality in .NET? I am looking a for method that does this without resorting to manually constructing a loop/method to iterate through the array.
possible better answer: http://stackoverflow.com/a/624935

http://stackoverflow.com/a/413078
has comment: http://stackoverflow.com/comment/243809
downvote count: 0
has comment: http://stackoverflow.com/comment/237876
accepted answer of: http://stackoverflow.com/q/413053
score: 1
answers question: http://stackoverflow.com/q/413053
upvote count: 1
type: AcceptedAnswer
has body: AFAIK, JEditorPane is a very primitive HTML component: it is confused by CSS and knows nothing about JS. I doubt you will find a "small + free" class doing better, HTML parsing and displaying isn't a simple business, even less today. Perhaps it is better to let the big names in the business to take care of this task, ie. using Internet Explorer or Mozilla components (depending on what is available, etc.): JDIC: Embedding a Web browser in Java.
has comment: http://stackoverflow.com/comment/248569
has comment: http://stackoverflow.com/comment/237967
type: Answer

http://stackoverflow.com/q/548861
type: AnsweredQuestion
tagged with: open-source
has answer: http://stackoverflow.com/a/553434
has answer: http://stackoverflow.com/a/6989312
score: 7
tagged with: java
possible better answer: http://stackoverflow.com/a/3284807
has answer: http://stackoverflow.com/a/3284807
has body: I'd like to have a ActiveRecord implementation in Java and before crafting my own, I'd like to know if there is an open source implementation of it. I am aware of other successful java OR maping tools like Hibernate, Castor, etc... and that is not what i want, i want a ActiveRecord like in RoR: RoR ActiveRecord .NET Castle ActiveRecord Anyone?
accepted answer: http://stackoverflow.com/a/553434
has title: Is there an implementation of the ActiveRecord pattern in Java like the one from Ruby?
type: Question
has answer: http://stackoverflow.com/a/548873
has answer: http://stackoverflow.com/a/8269603
has answer: http://stackoverflow.com/a/549951
has answer: http://stackoverflow.com/a/3553608
answer count: 7
tagged with: activerecord
favorite count: 0
upvote count: 8
downvote count: 1

http://stackoverflow.com/q/416708
has comment: http://stackoverflow.com/comment/241288
tagged with: struts
has comment: http://stackoverflow.com/comment/241040
has body: I am interested in building a vehicle tracking system using GPRS. However, I have some questions for anyone who has done this before: Is GPRS the best technology to use? Any problems people are aware of? I am planning on using Java/Java EE - is there any better technologies? If someone has built this before - do you have some examples of what to see for system requirements? What are some good web resources you've found working on this? Is there a step-by-step guide anywhere to getting started?
upvote count: 4
score: 0
downvote count: 4
answer count: 3
favorite count: 0
has answer: http://stackoverflow.com/a/416774
has answer: http://stackoverflow.com/a/24610383
has comment: http://stackoverflow.com/comment/241222
type: UnansweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/416818
type: Question
tagged with: jakarta-ee
has title: Vehicle Tracking System[java/Java EE]

http://stackoverflow.com/q/559141
answer count: 1
tagged with: el
type: UnansweredQuestion
upvote count: 1
score: 1
has title: Problem with JSP EL evaluation
tagged with: java
type: Question
has body: Why doesn't the following work: &lt;c:set var="formId" value="#${otherFormId}"/&gt; where &lt;c:set var="formId" value="# ${otherFormId}"/&gt; notice the space ^ works fine (though is invalid for my purposes). Im trying to prepend ${otherFormId} with a # symbol (i.e. creating jquery id selector). The first form ends up with #${otherFormId} literally in the output. How can I get the outcome I am after?
downvote count: 0
tagged with: jsp
favorite count: 0
has answer: http://stackoverflow.com/a/559224

http://stackoverflow.com/a/632233
upvote count: 10
has comment: http://stackoverflow.com/comment/445296
downvote count: 0
answers question: http://stackoverflow.com/q/632204
type: Answer
score: 10
has body: import java.util.regex.PatternSyntaxException; // (:?\d+) \* x\^(:?\d+) // // Options: ^ and $ match at line breaks // // Match the regular expression below and capture its match into backreference number 1 «(:?\d+)» // Match the character “:” literally «:?» // Between zero and one times, as many times as possible, giving back as needed (greedy) «?» // Match a single digit 0..9 «\d+» // Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+» // Match the character “ ” literally « » // Match the character “*” literally «\*» // Match the characters “ x” literally « x» // Match the character “^” literally «\^» // Match the regular expression below and capture its match into backreference number 2 «(:?\d+)» // Match the character “:” literally «:?» // Between zero and one times, as many times as possible, giving back as needed (greedy) «?» // Match a single digit 0..9 «\d+» // Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+» try { String resultString = subjectString.replaceAll("(?m)(:?\\d+) \\* x\\^(:?\\d+)", "$1x$2"); } catch (PatternSyntaxException ex) { // Syntax error in the regular expression } catch (IllegalArgumentException ex) { // Syntax error in the replacement text (unescaped $ signs?) } catch (IndexOutOfBoundsException ex) { // Non-existent backreference used the replacement text }
has comment: http://stackoverflow.com/comment/445268
has comment: http://stackoverflow.com/comment/445269

http://stackoverflow.com/comment/3775657
score: 12
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/421696
has text: @BalusC: Not true, the BigInteger.toString method will return the full number in the base specified. 0x0606 will be printed as 606, just trailing zeros are omitted,

http://stackoverflow.com/comment/385034
type: QuestionComment
has text: I know, and it may not be there in the code. However, since there are lot of files and legacy (which almost always means bad), I don't want to take risk.
comment on: http://stackoverflow.com/q/572134
score: 0
type: Comment

http://stackoverflow.com/comment/74112757
score: 0
type: Comment
has text: If your username/password contain special characters, I believe you would need to urlencode those. Then, in the snippet of code above, you would pass `url.getUserInfo()` thorugh `URLDecoder.decode()` first (@Peter Rader).
type: AnswerComment
comment on: http://stackoverflow.com/a/13122190

http://stackoverflow.com/comment/308104
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/491268
has text: i was just about to post an example of range + select
score: 0

http://stackoverflow.com/a/524477
answers question: http://stackoverflow.com/q/492248
has body: Mostly its a lack of demand. You only really need 64-bit version if you intend to run more than 1200 MB of memory for a web start client. Otherwise it doesn't make much difference. Do you know of any examples of a web start application which uses this much memory?
downvote count: 0
has comment: http://stackoverflow.com/comment/338404
type: Answer
upvote count: 1
score: 1

http://stackoverflow.com/a/588731
score: 0
answers question: http://stackoverflow.com/q/552968
type: Answer
upvote count: 1
downvote count: 1
has body: Are you using Spring? If so you can use @Configurable and have that aspect inject your dependencies for you.

http://stackoverflow.com/comment/210011
comment on: http://stackoverflow.com/a/382381
type: Comment
has text: Then take it out of java and put it into one SP. That's not decomposing it, it's moving it from an inappropriate place to an appropriate place, as is, It won't fix what's broken, but may change the code standards rules. (It should be moved in any case.)
score: 0
type: AnswerComment

http://stackoverflow.com/comment/7427550
score: 2
comment on: http://stackoverflow.com/a/585643
type: AnswerComment
has text: In response to Zombies comment, did anyone ever find out if the connection reset means the server has closed the connection?
type: Comment

http://stackoverflow.com/a/616696
type: Answer
has comment: http://stackoverflow.com/comment/430630
answers question: http://stackoverflow.com/q/616601
score: 4
has body: In some ways, this depends on your client design. Do you have the opportunity, in your web design, for a single client to have multiple outstanding simultaneous requests using the same HTTP session? This seems difficult to do unless you tie a single HTTP session to multiple sockets. (aka, AJAX) Short of doing this, a given client's HTTP access will be single-threaded as far as the server is concerned, which means a single session is effectively Thread safe. Synchronization of your session objects will make the application safer against future changes that make your web application capable of having multiple simultaneous requests, so it's not a bad idea. In modern Java implementations, synchronization does not have the large cost that was previously associated with it, especially when the synchronization is usually uncontended. If your application uses AJAX, which implies that you expect multiple in-flight simultaneous requests to your web server, then synchronization is a must.
downvote count: 1
upvote count: 5

http://stackoverflow.com/a/554287
downvote count: 0
score: 7
upvote count: 7
answers question: http://stackoverflow.com/q/554266
type: Answer
has body: Don't use readLine(); transfer the contents one character at a time using the read() method. If you use it on a BufferedReader, this will have the same performance, although unlike your code above it will not "normalize" Windows-style CR/LF line breaks.

http://stackoverflow.com/q/382361
tagged with: sql
has answer: http://stackoverflow.com/a/382369
has answer: http://stackoverflow.com/a/382968
has answer: http://stackoverflow.com/a/382380
has answer: http://stackoverflow.com/a/382415
favorite count: 0
has answer: http://stackoverflow.com/a/3283435
answer count: 12
has answer: http://stackoverflow.com/a/403983
score: 6
upvote count: 7
possible better answer: http://stackoverflow.com/a/382389
has answer: http://stackoverflow.com/a/382389
tagged with: coding-style
type: AnsweredQuestion
has body: I am working on a project currently where there are SQL strings in the code that are around 3000 lines. The project is a java project, but this question could probably apply for any language. Anyway, this is the first time I have ever seen something this bad. The code base is legacy, so we can suddenly migrate to Hibernate or something like that. How do you handle very large SQL strings like that? I know its bad, but I don't know exactly what is the best thing to suggest for a solution.
accepted answer: http://stackoverflow.com/a/382369
has title: How to handle HUGE SQL strings in the source code
tagged with: java
has answer: http://stackoverflow.com/a/382376
downvote count: 1
has answer: http://stackoverflow.com/a/382365
type: Question
has answer: http://stackoverflow.com/a/382979
has answer: http://stackoverflow.com/a/382381
has answer: http://stackoverflow.com/a/382442

http://stackoverflow.com/comment/673536
type: Comment
has text: @Dave: I have to agree with Dan. Embedded systems capable of running managed runtimes are vastly outnumbered by those that can't. I think the number of embedded systems programmable with C++ will increase, although I also think C will remain the dominant embedded systems language because of the simplicity of C-based toolchains (C++ tools still need to be ported, and most embedded vendors don't write their own toolchains).
comment on: http://stackoverflow.com/a/537643
type: AnswerComment
score: 0

http://stackoverflow.com/comment/397843
score: 0
type: Comment
comment on: http://stackoverflow.com/a/586064
has text: No need to be a properties file - any kind of text file you can parse easily will do.
type: AnswerComment

http://stackoverflow.com/comment/1089003
type: AnswerComment
comment on: http://stackoverflow.com/a/518951
type: Comment
has text: Off the top of my head I don't know what Java does it if tries to increase its heap size and can't get all it asks for in one contiguous block. Do you know that it fails, or are you just guessing? But more important, the question is irrelevant in this context. If he's building an array of 120,000 words, then he needs 120,000 * the pointer size, which I think is 8, or about 1 MB. I wouldn't think that getting 1 MB of memory on a modern computer is an extravagant request. The strings themselves are all separate allocations, each relatively small.
score: 0

http://stackoverflow.com/comment/371303
type: Comment
has text: I disagree with the HashMap part. I know Sun's position, but... get for example must call obj.equals(key), which could be linear in the size of the objects contained. Consider that you typically have to read the fields for this comparison. The exceptions would be integers or strings (interned)???
comment on: http://stackoverflow.com/a/559856
score: 0
type: AnswerComment

http://stackoverflow.com/comment/269323
has text: @Blue - way more efficient BECAUSE you're using both key and value.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/448168

http://stackoverflow.com/q/519850
downvote count: 0
answer count: 7
has answer: http://stackoverflow.com/a/522284
favorite count: 0
has comment: http://stackoverflow.com/comment/8535109
has answer: http://stackoverflow.com/a/519878
has answer: http://stackoverflow.com/a/519936
has title: Network Programming: to maintain sockets or not?
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/519935
tagged with: java
has answer: http://stackoverflow.com/a/520024
score: 9
type: Question
has answer: http://stackoverflow.com/a/48197072
tagged with: network-programming
upvote count: 9
has answer: http://stackoverflow.com/a/519935
has body: I'm currently translating an API from C# to Java which has a network component. The C# version seems to keep the input and output streams and the socket open for the duration of its classes being used. Is this correct? Bearing in mind that the application is sending commands and receiving events based on user input, is it more sensible to open a new socket stream for each "message"? I'm maintaining a ServerSocket for listening to the server throwing events but I'm not so sure that maintaining a Socket and output stream for outbound comms is such a good idea. I'm not really used to Socket programming. As with many developers I usually work at the application layer when I need to do networking and not at the socket layer, and it's been 5 or 6 years since I did this stuff at university. Cheers for the help. I guess this is more asking for advice than for a definitive answer.
has answer: http://stackoverflow.com/a/520792
possible better answer: http://stackoverflow.com/a/519936

http://stackoverflow.com/comment/11997012
type: AnswerComment
comment on: http://stackoverflow.com/a/535026
score: 1
type: Comment
has text: This works a treat ...IDK Y this hasn't been checked as Answer :)

http://stackoverflow.com/q/442564
has answer: http://stackoverflow.com/a/17672039
has answer: http://stackoverflow.com/a/442597
type: Question
has answer: http://stackoverflow.com/a/54876721
linked to: http://stackoverflow.com/q/416183
has comment: http://stackoverflow.com/comment/3198471
possible better answer: http://stackoverflow.com/a/442570
has answer: http://stackoverflow.com/a/442580
linked to: http://stackoverflow.com/q/309631
downvote count: 0
score: 411
has answer: http://stackoverflow.com/a/442638
has answer: http://stackoverflow.com/a/57069640
has answer: http://stackoverflow.com/a/20090123
answer count: 23
has answer: http://stackoverflow.com/a/442783
has comment: http://stackoverflow.com/comment/264477
tagged with: synchronization
tagged with: synchronized
favorite count: 0
has answer: http://stackoverflow.com/a/3237204
has body: Whenever a question pops up on SO about Java synchronization, some people are very eager to point out that synchronized(this) should be avoided. Instead, they claim, a lock on a private reference is to be preferred. Some of the given reasons are: some evil code may steal your lock (very popular this one, also has an "accidentally" variant) all synchronized methods within the same class use the exact same lock, which reduces throughput you are (unnecessarily) exposing too much information Other people, including me, argue that synchronized(this) is an idiom that is used a lot (also in Java libraries), is safe and well understood. It should not be avoided because you have a bug and you don't have a clue of what is going on in your multithreaded program. In other words: if it is applicable, then use it. I am interested in seeing some real-world examples (no foobar stuff) where avoiding a lock on this is preferable when synchronized(this) would also do the job. Therefore: should you always avoid synchronized(this) and replace it with a lock on a private reference? Some further info (updated as answers are given): we are talking about instance synchronization both implicit (synchronized methods) and explicit form of synchronized(this) are considered if you quote Bloch or other authorities on the subject, don't leave out the parts you don't like (e.g. Effective Java, item on Thread Safety: Typically it is the lock on the instance itself, but there are exceptions.) if you need granularity in your locking other than synchronized(this) provides, then synchronized(this) is not applicable so that's not the issue
has answer: http://stackoverflow.com/a/443160
has answer: http://stackoverflow.com/a/442622
has comment: http://stackoverflow.com/comment/264387
has answer: http://stackoverflow.com/a/442601
accepted answer: http://stackoverflow.com/a/442601
has answer: http://stackoverflow.com/a/442571
has answer: http://stackoverflow.com/a/39438754
has answer: http://stackoverflow.com/a/53359380
linked to: http://stackoverflow.com/q/439302
has answer: http://stackoverflow.com/a/14973568
has answer: http://stackoverflow.com/a/442570
has answer: http://stackoverflow.com/a/53041597
has comment: http://stackoverflow.com/comment/94142605
has answer: http://stackoverflow.com/a/26731309
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/443260
has answer: http://stackoverflow.com/a/67877778
has title: Avoid synchronized(this) in Java?
tagged with: java
has answer: http://stackoverflow.com/a/77185409
tagged with: multithreading
has answer: http://stackoverflow.com/a/442771
upvote count: 411

http://stackoverflow.com/a/407361
has comment: http://stackoverflow.com/comment/232267
has comment: http://stackoverflow.com/comment/236626
answers question: http://stackoverflow.com/q/407343
upvote count: 7
downvote count: 1
has body: Swing applications are used in most cases where a Java app runs on the desktop. Sometimes you don't even know - for example, LimeWire is a Java Swing application. When learning Swing, you'll find that you will come to know those parts of AWT that are still important, such as Event, LayoutManager, Graphics, Font, Color, etc.
type: Answer
has comment: http://stackoverflow.com/comment/7916220
score: 6
has comment: http://stackoverflow.com/comment/232240
has comment: http://stackoverflow.com/comment/2860898

http://stackoverflow.com/a/424009
score: 14
answers question: http://stackoverflow.com/q/423994
downvote count: 1
upvote count: 15
has comment: http://stackoverflow.com/comment/47221964
has comment: http://stackoverflow.com/comment/136683549
type: Answer
has body: Most often this issue comes up for "class", in this case it is customary to write "clazz".

http://stackoverflow.com/comment/232416
comment on: http://stackoverflow.com/a/407305
score: 12
type: AnswerComment
type: Comment
has text: Yes, it's unpleasant to figure this out in practice.

http://stackoverflow.com/q/464825
has answer: http://stackoverflow.com/a/466082
tagged with: java
has answer: http://stackoverflow.com/a/35851419
score: 23
tagged with: http://stackoverflow.com/tag/jpeg
downvote count: 1
upvote count: 24
has body: I'd like to convert gif images to jpeg using Java. It works great for most images, but I have a simple transparent gif image: Input gif image http://img292.imageshack.us/img292/2103/indexedtestal7.gif [In case the image is missing: it's a blue circle with transparent pixels around it] When I convert this image using the following code: File file = new File("indexed_test.gif"); BufferedImage image = ImageIO.read(file); File f = new File("indexed_test.jpg"); ImageIO.write(image, "jpg", f); This code works without throwing an Exception, but results an invalid jpeg image: [In case the image is missing: IE cannot show the jpeg, Firefox shows the image with invalid colors.] I'm using Java 1.5. I also tried converting the sample gif to png with gimp and using the png as an input for the Java code. The result is the same. Is it a bug in the JDK? How can I convert images correctly preferably without 3rd party libraries? UPDATE: Answers indicate that jpeg conversion cannot handle transparency correctly (I still think that this is a bug) and suggest a workaround for replacing transparent pixels with predefined color. Both of the suggested methods are quite complex, so I've implemented a simpler one (will post as an answer). I accept the first published answer with this workaround (by Markus). I don't know which implementation is the better. I go for the simplest one still I found a gif where it's not working.
type: Question
has title: Converting transparent gif / png to jpeg using java
tagged with: http://stackoverflow.com/tag/gif
has answer: http://stackoverflow.com/a/1545417
tagged with: java-io
has answer: http://stackoverflow.com/a/4602892
has answer: http://stackoverflow.com/a/468491
answer count: 7
favorite count: 0
tagged with: transparency
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/859025
has answer: http://stackoverflow.com/a/464832

http://stackoverflow.com/a/612113
has comment: http://stackoverflow.com/comment/424867
downvote count: 0
has body: The class containing main() is just an ordinary class. In your case, you'd have to make myData public and possibly static (or, of course, add an accessor). Just like you'd do with any other class. You could also pass an Entry object to the other class, like this: public static void main(String[] args) { Entry entry = new Entry(); SomeOtherClass myClass=new SomeOtherClass(entry); // continue as before }
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/612095

http://stackoverflow.com/a/432009
has body: You should use: myClass test = new myClass( Double.class, 15 ); You were missing the .class part.
upvote count: 1
has comment: http://stackoverflow.com/comment/255384
type: Answer
answers question: http://stackoverflow.com/q/432006
downvote count: 0
score: 1

http://stackoverflow.com/comment/494887
score: 0
type: Comment
comment on: http://stackoverflow.com/a/587934
has text: What about using the Spring JmsTemplate stuff? You don't need the rest of Spring to use it, and it's pretty darn good as a generic JMS wrapper layer.
type: AnswerComment

http://stackoverflow.com/a/362006
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/39838251
has comment: http://stackoverflow.com/comment/5940176
score: 369
has comment: http://stackoverflow.com/comment/84912488
downvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/79696302
has body: Unfortunately, the file.encoding property has to be specified as the JVM starts up; by the time your main method is entered, the character encoding used by String.getBytes() and the default constructors of InputStreamReader and OutputStreamWriter has been permanently cached. As another user points out, in a special case like this, the environment variable JAVA_TOOL_OPTIONS can be used to specify this property, but it's normally done like this: java -Dfile.encoding=UTF-8 … com.x.Main Charset.defaultCharset() will reflect changes to the file.encoding property, but most of the code in the core Java libraries that need to determine the default character encoding do not use this mechanism. When you are encoding or decoding, you can query the file.encoding property or Charset.defaultCharset() to find the current default encoding, and use the appropriate method or constructor overload to specify it.
upvote count: 370
accepted answer of: http://stackoverflow.com/q/361975
answers question: http://stackoverflow.com/q/361975

http://stackoverflow.com/a/501618
type: Answer
has body: Session.instance().invalidate();
downvote count: 0
answers question: http://stackoverflow.com/q/501511
score: 1
upvote count: 1

http://stackoverflow.com/comment/39030738
score: 5
type: AnswerComment
comment on: http://stackoverflow.com/a/490225
type: Comment
has text: Doesn't discuss the use of <?>

http://stackoverflow.com/a/606722
answers question: http://stackoverflow.com/q/606074
type: Answer
upvote count: 4
downvote count: 0
score: 4
has body: Here it is. I found this in the JModem source. If you look at where it writes the data out, you can see its doing an SOH, blocknum, ~blocknum, data, and checksum. It uses a sector size of 128. Those together make up the standard XModem protocol. Its simple enough to do XModem1K, YModem, and ZModem from here, too. /** * a tiny version of Ward Christensen's MODEM program for UNIX. * Written ~ 1980 by Andrew Scott Beals. Last revised 1982. * A.D. 2000 - dragged from the archives for use in Java Cookbook. * * @author C version by Andrew Scott Beals, sjobrg.andy%mit-oz@mit-mc.arpa. * @author Java version by Ian F. Darwin, ian@darwinsys.com * $Id: TModem.java,v 1.8 2000/03/02 03:40:50 ian Exp $ */ class TModem { protected final byte CPMEOF = 26; /* control/z */ protected final int MAXERRORS = 10; /* max times to retry one block */ protected final int SECSIZE = 128; /* cpm sector, transmission block */ protected final int SENTIMOUT = 30; /* timeout time in send */ protected final int SLEEP = 30; /* timeout time in recv */ /* Protocol characters used */ protected final byte SOH = 1; /* Start Of Header */ protected final byte EOT = 4; /* End Of Transmission */ protected final byte ACK = 6; /* ACKnowlege */ protected final byte NAK = 0x15; /* Negative AcKnowlege */ protected InputStream inStream; protected OutputStream outStream; protected PrintWriter errStream; /** Construct a TModem */ public TModem(InputStream is, OutputStream os, PrintWriter errs) { inStream = is; outStream = os; errStream = errs; } /** Construct a TModem with default files (stdin and stdout). */ public TModem() { inStream = System.in; outStream = System.out; errStream = new PrintWriter(System.err); } /** A main program, for direct invocation. */ public static void main(String[] argv) throws IOException, InterruptedException { /* argc must == 2, i.e., `java TModem -s filename' */ if (argv.length != 2) usage(); if (argv[0].charAt(0) != '-') usage(); TModem tm = new TModem(); tm.setStandalone(true); boolean…

http://stackoverflow.com/a/2350265
has body: http://www.glassdoor.com/ has lot of good java questions and puzzles.
score: 2
answers question: http://stackoverflow.com/q/472176
upvote count: 2
downvote count: 0
type: Answer

http://stackoverflow.com/a/647117
score: 0
type: Answer
answers question: http://stackoverflow.com/q/646990
has body: The repaint method registers the need to paint the component but it doesn't actually paint it, however Java will repaint the object the next chance it gets. If you are trying to make something like an animation then there is no purpose to wait for repaint to complete. Instead I recommend you use a timer. Now you have 2 options for timers. If you are updating something where the timing doesn't have to be exact then often javax.swing.Timer is what you are looking for. You use it like this: //imports (before class definition) import javax.swing.Timer; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; //put this code where you want to start doing calculations int delay = 1000; //milliseconds ActionListener taskPerformer = new ActionListener() { public void actionPerformed(ActionEvent evt) { //update your calculations model.calculate(); //tell Java to call paint at the next chance it gets viewer.repaint(); } }; new Timer(delay, taskPerformer).start(); In the above code the model is the object you want to perform the calculations on and the viewer is the object that paints based on the model. The swing timer is not very exact in its timing which is fine for lots of things but sometimes you need code to be scheduled more exactly. In that case you may want to use the java.util.Timer class. You use it like this: //imports (before class definition) import java.util.Timer; import java.util.TimerTask; //inner class that does the calculations public class CalculateTask extends TimerTask { public void run() { model.calculate(); view.repaint(); } } //put this code where you want to start doing calculations int delay = 0;//time before running CalculateTask.run() int repeat = 1000; //time between each subsequent rums of CalculateTask.run() boolean isDaemon = true;//allow java to shutdown without stopping timer Timer timer = new Timer(isDaemon); timer.scheduleAtFixedRate(new CalculateTask(), delay, repeat);

http://stackoverflow.com/q/631598
has title: How to use JUnit to test asynchronous processes
favorite count: 0
score: 280
has answer: http://stackoverflow.com/a/631754
has answer: http://stackoverflow.com/a/60858020
upvote count: 280
tagged with: junit
has answer: http://stackoverflow.com/a/46890812
answer count: 18
tagged with: asynchronous
has answer: http://stackoverflow.com/a/34026037
linked to: http://stackoverflow.com/q/11007551
has answer: http://stackoverflow.com/a/23809378
has answer: http://stackoverflow.com/a/21099588
has answer: http://stackoverflow.com/a/13379486
has answer: http://stackoverflow.com/a/76021715
has answer: http://stackoverflow.com/a/41372052
has answer: http://stackoverflow.com/a/64460897
accepted answer: http://stackoverflow.com/a/631754
tagged with: unit-testing
has comment: http://stackoverflow.com/comment/80517607
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/631606
has answer: http://stackoverflow.com/a/43444508
has answer: http://stackoverflow.com/a/42588241
has answer: http://stackoverflow.com/a/3303638
has comment: http://stackoverflow.com/comment/101229009
tagged with: java
has comment: http://stackoverflow.com/comment/20756757
has body: How do you test methods that fire asynchronous processes with JUnit? I don't know how to make my test wait for the process to end (it is not exactly a unit test, it is more like an integration test as it involves several classes and not just one).
has answer: http://stackoverflow.com/a/1829949
type: Question
has answer: http://stackoverflow.com/a/39201557
has answer: http://stackoverflow.com/a/63728861
has answer: http://stackoverflow.com/a/47669002
has comment: http://stackoverflow.com/comment/40085017
downvote count: 0
possible better answer: http://stackoverflow.com/a/1829949

http://stackoverflow.com/comment/15172523
type: AnswerComment
has text: What if the value itself was Generic? For instance, instead of storing `String`s and `int`s you need to store `PrettyPrinter<T>` where `T` is the type token used as the key in the map?
type: Comment
score: 34
comment on: http://stackoverflow.com/a/416611

http://stackoverflow.com/a/427811
has body: Private methods should be exercised through the public interface of a class. If you have multiple implementations of the same interface, I'd write test classes for each implementation.
type: Answer
score: 4
answers question: http://stackoverflow.com/q/427755
upvote count: 4
downvote count: 0

http://stackoverflow.com/q/525408
favorite count: 0
tagged with: spring
has answer: http://stackoverflow.com/a/526813
upvote count: 3
type: UnansweredQuestion
tagged with: java
type: Question
score: 3
has body: I have a spring web application which has been working fine on tomcat 5.5. I've attempted to deploy the same web app to a tomcat 6 container and come up against some issues. The main two problems I've had are relating to configuring the container for jstl and getting the spring security login to work properly. I believe I've solved the jstl configuration issue by including the jstl-1.2.jar lib from here in the $CATALINA_HOME/lib directory (although it really does appear to be strange that it is so difficult to find out how to get this working). The main problem now is that when I attempt to log in using form based authentication, I get an HTTP 404 error when the login form is submitted to "j_spring_security_check". I have set up the filter in the web.xml file as per the spring security documentation but it appears that tomcat isn't invoking this as expected. I hope someone can share their experience here as I'm certainly missing something fundamental in my configuration. Thanks. Update: While trouble-shooting based on responses here, one of the things I ended up doing was downloading a fresh copy of tomcat 6.0.18 and ensured that I had the jstl-1.2.jar file in the WEB-INF/lib dir. Funnily enough, now the app seems to be working fine. I'm a little stumped but I'll now try to track down the difference in the two tomcat installs that was causing the error and post a further update here. Thanks for the responses to this guys.
has answer: http://stackoverflow.com/a/525423
answer count: 3
downvote count: 0
has answer: http://stackoverflow.com/a/525628
has title: Problem migrating Spring Web App from tomcat 5.5 to tomcat 6.0
tagged with: tomcat
tagged with: spring-security

http://stackoverflow.com/comment/522363
comment on: http://stackoverflow.com/a/396501
type: Comment
has text: I believe it does .doc but not .docx
score: 0
type: AnswerComment

http://stackoverflow.com/comment/381901
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/570244
has text: Yeah. I've done it. The amount of time/memory required is relatively high, but I also recall that you can alter Javadoc output settings (not display all uses of all classes, for example) to optimize for that.

http://stackoverflow.com/a/469898
has comment: http://stackoverflow.com/comment/290048
has comment: http://stackoverflow.com/comment/50498596
upvote count: 4
answers question: http://stackoverflow.com/q/469884
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/469884
has comment: http://stackoverflow.com/comment/291005
has body: You can use the Timer class. Specifically, scheduleAtFixedRate(TimerTask task, Date firstTime, long period). Where you can set a task to start at 10am on a particular day and repeat every 24 hours.
type: Answer
downvote count: 1
score: 3

http://stackoverflow.com/a/669574
score: 2
upvote count: 2
downvote count: 0
has body: Maybe I'm paranoid, but I suggest going with well-known providers of AMI images. To me, it's worth putting in the effort of installing the software you need on a trustworthy system. I'm not saying there are trojan horses and server-side-spyware all over the place, but think about it: why do you have to install from media after a break-in? Because even if things seem fine, you can never be sure if you can trust your system. Like The Oracle says, "know thyself." These days, I have been enjoying the Ubuntu 8.10 server image (just search for AMIs with the string "canonical"). If you add the universe repo then there is a Sun Java5 package as well as Apache httpd of course. I'm not sure about JBoss, sorry.
answers question: http://stackoverflow.com/q/605408
type: Answer

http://stackoverflow.com/a/25269748
has body: if adding a parameter with the class of the enum it's possible. an example that converts an enumset to a byte: public static &lt;T extends Enum&lt;T&gt;, U extends Enum&lt;?&gt;&gt; byte toByte(EnumSet&lt;T&gt; set, Class&lt;U&gt; type) { byte b = 0; if(type.getEnumConstants().length &gt; 8) { throw new RuntimeException("enum set doesn't fit in one byte"); } for(Enum&lt;?&gt; e: type.getEnumConstants()) { if(set.contains(e)) { b |= 1 &lt;&lt; e.ordinal(); } } return b; } public static &lt;E extends Enum&lt;E&gt;&gt; EnumSet&lt;E&gt; toSet(byte b, Class&lt;E&gt; type) { E[] enums = type.getEnumConstants(); EnumSet&lt;E&gt; enumSet = EnumSet.noneOf(type); for(int bit = 0; bit &lt; 8; bit++) { if((b &amp; 1 &lt;&lt; bit) &gt; 0) { enumSet.add(enums[bit]); } } return enumSet; }
upvote count: 3
type: Answer
score: 3
downvote count: 0
answers question: http://stackoverflow.com/q/363569

http://stackoverflow.com/a/62714247
downvote count: 0
has body: You can use getSimpleName(). Let's say we have a object: Dog d = new Dog(), The we can use below statement to get the class name: Dog. E.g.: d.getClass().getSimpleName(); // return String 'Dog'. PS: d.getClass() will give you the full name of your object.
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/541749

http://stackoverflow.com/a/426456
downvote count: 2
has comment: http://stackoverflow.com/comment/21773873
type: Answer
upvote count: 34
has body: I'm only mildly familiar with Flex, but have worked with GWT for many years. We had to make a very similar decision some years ago (Flash vs GWT), but for different reasons. In the end we saw the many advantages of GWT over Flash (Many of which apply to Flex): Not all our customers have flash, penetration numbers from Adobe are useless, you need your own (which we have) to see what your customers actually have. In corporate and education markets the penetration is actually far lower than the high 90s that Adobe quotes. GWT is truly cross-browser and platform compatible (Linux, Mac, Windows, Android, iPhone, etc, etc) whereas flash will never be. You may not care about that, but we did. Flex is proprietry Adobe Technology, whereas GWT is fully open source and customisable GWT integrates with the DOM, and everything else on your page far easier than flash and Flex do. GWT is coded in Java, and we all know Java extremely well To Address your specific points: * futureproof Nothing is truly future proof, but I feel that both GWT and Flex would be fairly future proof. Maybe GWT a tiny bit more so because it's open source. * works on all major browsers GWT works in Firefox(and all gecko browser), Safari (and all Webkit browsers), IE and Opera. Flex works in all browsers, but only if Flash is supported, so I would say GWT comes out on top there. * fast &amp; responsive user experience On platforms where it's supported, Flex is going to kill GWT dead for user experience. You just can't compete with flash when it comes to smoothness and slickness. * code should be unit testable Both are easily unit testable * code must be maintainable When coded well both are maintainable * speed &amp; ease of development As long as your familiar with them, I'd say it's much of a muchness. * supports vector graphics of some sort (SVG a plus) I can't speak for Flex, but GWT supports vector graphics via SVG, through third-party libraries.
has comment: http://stackoverflow.com/comment/3603003
has comment: http://stackoverflow.com/comment/3513141
has comment: http://stackoverflow.com/comment/3613609
has comment: http://stackoverflow.com/comment/4919553
score: 32
has comment: http://stackoverflow.com/comment/549614
has comment: http://stackoverflow.com/comment/9807420
answers question: http://stackoverflow.com/q/424895

http://stackoverflow.com/comment/416781
type: AnswerComment
type: Comment
has text: Thanks. I had tried that earlier but it seemed like the FileOutputStream was auto-creating the file. Turns out I had a "helper" method used in the test that auto-created the file.
comment on: http://stackoverflow.com/a/604523
score: 0

http://stackoverflow.com/a/561928
upvote count: 2
downvote count: 0
answers question: http://stackoverflow.com/q/559696
type: Answer
has body: Well, there's the Beans Binding project, for starters. There's an example on java.net. If you use NetBeans, there's support built in.
score: 2

http://stackoverflow.com/q/378297
tagged with: osgi
tagged with: jdbc
has answer: http://stackoverflow.com/a/379076
has body: I am developing an Eclipse plug-in that fits a client-server model. Its a commercial project so we cannot re-distribute the JDBC drivers for the various databases we support with the plug-in. So I developed a preference page to allow the user locate the jars and have a simple discovery mechanism that iterates through the classes in the jar files, loading each one to verify that it implements the java.sql.Driver interface. This all works great. But the catch is that I am using Hibernate. And Hibernate uses Class.forName() to instantiate the JDBC driver. If I try to use the following I get ClassNotFoundException. public Object execute(final IRepositoryCallback callback) { final DatabaseDriverClassLoader loader = new DatabaseDriverClassLoader( Activator.getDefault().getDatabaseDriverRegistry()); final ClassLoader oldLoader = Thread.currentThread() .getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(loader); try { final SessionFactory sessionFactory = this.configuration .buildSessionFactory(); if (sessionFactory != null) { final Session session = sessionFactory .openSession(); if (session != null) { // CHECKSTYLE:OFF try // CHECKSTYLE:ON { return callback.doExecute(session); } finally { session.close(); } } } connection.close(); } finally { } } // CHECKSTYLE:OFF catch (Exception e) // CHECKSTYLE:ON { RepositoryTemplate.LOG.error(e.getMessage(), e); } finally { Thread.currentThread().setContextClassLoader(oldLoader); } return null; } And if I try creating the driver myself as follows I get a SecurityException. public Object execute(final IRepositoryCallback callback) { final DatabaseDriverClassLoader loader = new DatabaseDriverClassLoader( Activator.getDefault().getDatabaseDriverRegistry()); final ClassLoader oldLoader = Thread.currentThread() .getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(loader); final Class driverClass = loader.loadClass(this.connectionDriverClassName); final Driver driver = (Driver)driverClass.ne…
upvote count: 2
type: UnansweredQuestion
score: 2
tagged with: java
tagged with: hibernate
type: Question
downvote count: 0
answer count: 1
has title: How do I dynamically replace the class loader for an Eclipse plug-in?
tagged with: eclipse-plugin
favorite count: 0

http://stackoverflow.com/comment/91015084
score: 1
comment on: http://stackoverflow.com/a/46962220
type: AnswerComment
has text: This should be the answer, simple and concise, no need to install external libraries.
type: Comment

http://stackoverflow.com/comment/406370
score: 0
type: Comment
comment on: http://stackoverflow.com/a/594621
type: AnswerComment
has text: String s1 = "BloodParrot is the man"; String s2 = "BloodParrot is the man"; s1 == s2 => true It seems that s1 and s2 are the SAME strings.

http://stackoverflow.com/a/376354
upvote count: 17
has comment: http://stackoverflow.com/comment/204248
has body: Anything to do with threads... :) Also: Overriding methods and expecting them to be used in the same way between versions Assumptions about underlying platform (file separator, for instance) Details of garbage collection/finalisation Some details about class initialisation Whether Integer.valueOf (and the like) return the same objects Performance, latency and memory usage
score: 15
answers question: http://stackoverflow.com/q/376338
has comment: http://stackoverflow.com/comment/46604566
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/204284
downvote count: 2
type: Answer
accepted answer of: http://stackoverflow.com/q/376338
has comment: http://stackoverflow.com/comment/46598648
has comment: http://stackoverflow.com/comment/17797254

http://stackoverflow.com/a/473128
has body: Setting a 32-bit (at least in .NET) is atomic, but it does you no good. You have to read it to know if it's locked, so you might read it, and after the read, someone else reads it before you can set it, so two threads end up inside the "protected" code. THis is exactly what actual synchronization objects (like the .NET Monitor class) are for. You could use an Interlocked to check and increment the lock variable as well. See also: Is accessing a variable in C# an atomic operation?
upvote count: 1
answers question: http://stackoverflow.com/q/473111
downvote count: 0
score: 1
type: Answer

http://stackoverflow.com/a/462347
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/5217092
score: 6
has body: As other answers point out, there are many and good reasons why this class was made generic. However there are plenty of times that you don't have any way of knowing the generic type to use with Class&lt;T&gt;. In these cases, you can simply ignore the yellow eclipse warnings or you can use Class&lt;?&gt; ... That's how I do it ;)
upvote count: 6
answers question: http://stackoverflow.com/q/462297

http://stackoverflow.com/q/624458
has comment: http://stackoverflow.com/comment/7193443
has comment: http://stackoverflow.com/comment/7183163
has answer: http://stackoverflow.com/a/6204945
has title: Extending ByteBuffer class
has comment: http://stackoverflow.com/comment/7194659
answer count: 7
has answer: http://stackoverflow.com/a/6157164
upvote count: 19
has comment: http://stackoverflow.com/comment/7218339
has body: Is there any way to create class that extends ByteBuffer class? Some abstract methods from ByteBuffer are package private, and if I create package java.nio, security exception is thrown. I would want to do that for performance reasons - getInt for example has about 10 method invocations, as well as quite a few if's. Even if all checks are left, and only method calls are inlined and big/small endian checks are removed, tests that I've created show that it can be about 4 times faster.
has comment: http://stackoverflow.com/comment/7184837
tagged with: java
has answer: http://stackoverflow.com/a/6196981
has comment: http://stackoverflow.com/comment/7143326
tagged with: nio
has comment: http://stackoverflow.com/comment/7185041
has answer: http://stackoverflow.com/a/6167913
has answer: http://stackoverflow.com/a/624506
downvote count: 0
has answer: http://stackoverflow.com/a/6167177
has comment: http://stackoverflow.com/comment/7143118
has comment: http://stackoverflow.com/comment/438543
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/7218482
linked to: http://stackoverflow.com/q/462094
tagged with: bytebuffer
favorite count: 0
has comment: http://stackoverflow.com/comment/7194711
score: 19
type: Question
has answer: http://stackoverflow.com/a/624508
has comment: http://stackoverflow.com/comment/7225334
has comment: http://stackoverflow.com/comment/7225233
has comment: http://stackoverflow.com/comment/7226575
has comment: http://stackoverflow.com/comment/7226773
has comment: http://stackoverflow.com/comment/7143103
has comment: http://stackoverflow.com/comment/7193914
linked to: http://stackoverflow.com/q/4682659

http://stackoverflow.com/a/486507
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/486494
has comment: http://stackoverflow.com/comment/302972
answers question: http://stackoverflow.com/q/486494
type: Answer
upvote count: 6
has comment: http://stackoverflow.com/comment/303028
score: 6
has comment: http://stackoverflow.com/comment/302997
has body: Is the shared resource protected by a username and password? And if so, is your application engine running as that user? If your application engine is running as a Windows Service, the Windows service cannot be running as the "Local System Account". This account cannot access the network. You must configure your service to run as a user that has the rights to access the shared drive.

http://stackoverflow.com/comment/386701
type: Comment
has text: It is incorrect that only one instance of a servlet is instantiated by the container. The specification does not demand it even if most containers implement it as such. More heavy weight containers allocate a number of threads to an instance and instantiate more if there are more requests.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/574806

http://stackoverflow.com/comment/67483043
has text: It is worth pointing out that the substring method was changed from Java 7 +. It now should return a new String representation containing only the substringed characters. That means that there is no need to return a call String::new
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/513637
type: Comment

http://stackoverflow.com/q/616601
linked to: http://stackoverflow.com/q/1820629
type: Question
tagged with: session
has body: Also, does the object that is being set have to be thread safe in order to guarantee that we know what the state of the object stored in session is known. Also, I was reading on the web that some suggest using: synchronized(session) { session.setAttribute("abc", "abc"); } Is this a valid suggestion?
tagged with: synchronized
has answer: http://stackoverflow.com/a/616730
downvote count: 0
favorite count: 0
answer count: 5
type: UnansweredQuestion
upvote count: 56
has answer: http://stackoverflow.com/a/616696
has title: Is HttpSession thread safe, are set/get Attribute thread safe operations?
has answer: http://stackoverflow.com/a/616723
has answer: http://stackoverflow.com/a/616697
score: 56
has answer: http://stackoverflow.com/a/616679
tagged with: java
tagged with: thread-safety

http://stackoverflow.com/a/574356
answers question: http://stackoverflow.com/q/574351
upvote count: 5
downvote count: 0
has body: You have to add the -classpath option to the java command also. Not only to the compiler. like: javac -classpath .;lib\myjar.jar MyClass.java and then java -classpath .;lib\myjar.jar MyClass Otherwise the interpreter ( java ) won't know where to find the classes needed.
score: 5
type: Answer

http://stackoverflow.com/a/535619
type: Answer
answers question: http://stackoverflow.com/q/531096
has comment: http://stackoverflow.com/comment/352463
score: 9
has comment: http://stackoverflow.com/comment/351829
upvote count: 9
downvote count: 0
has body: Have a look at AppFuse It has lot of starter web-app material. You also have something with Struts2-Spring-Hibernate.

http://stackoverflow.com/a/577628
has body: You can deploy clover build (along with the coverage.db files generated during the instrumentation) to your servers, add a bunch of clover-specific java options to set it up and then collect the results, merge them using the clover merge tools and generate the reports. See Clover Wiki for detailed instructions. Please note that by default, clover dumps the coverage data upon process termination - you might want to do some research on how to make it happen periodically. Look into -flushpolicy and -flushinterval options.
upvote count: 1
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/565317
score: 1

http://stackoverflow.com/comment/225167
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/399394
has text: Good point. Something isn't quite right if you need to do all that concatenation.

http://stackoverflow.com/comment/407505
comment on: http://stackoverflow.com/a/595427
type: AnswerComment
has text: The intended benefit of the toArray was that once the local copy of the array is created, if the original collection is modified during either the check or subsequent call to addAll there would not be an issue.
type: Comment
score: 0

http://stackoverflow.com/a/520177
has body: Maybe you can check the version of your compilator with : JVM version is ${ant.java.version} Target compilation is ${ant.build.javac.target} And you can add <property name="ant.build.javac.target" value="1.5" /> to force the compiler to use Java 5 compliance... This property is the default target from ant 1.7, for ant 1.6 I think you must add target="${ant.build.javac.target}" to your javac target.
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/520168
upvote count: 1
type: Answer

http://stackoverflow.com/a/46092572
downvote count: 2
has body: Here it goes another test. The results shows that ThreadLocal is a bit slower than a regular field, but in the same order. Aprox 12% slower public class Test { private static final int N = 100000000; private static int fieldExecTime = 0; private static int threadLocalExecTime = 0; public static void main(String[] args) throws InterruptedException { int execs = 10; for (int i = 0; i &lt; execs; i++) { new FieldExample().run(i); new ThreadLocaldExample().run(i); } System.out.println("Field avg:"+(fieldExecTime / execs)); System.out.println("ThreadLocal avg:"+(threadLocalExecTime / execs)); } private static class FieldExample { private Map&lt;String,String&gt; map = new HashMap&lt;String, String&gt;(); public void run(int z) { System.out.println(z+"-Running field sample"); long start = System.currentTimeMillis(); for (int i = 0; i &lt; N; i++){ String s = Integer.toString(i); map.put(s,"a"); map.remove(s); } long end = System.currentTimeMillis(); long t = (end - start); fieldExecTime += t; System.out.println(z+"-End field sample:"+t); } } private static class ThreadLocaldExample{ private ThreadLocal&lt;Map&lt;String,String&gt;&gt; myThreadLocal = new ThreadLocal&lt;Map&lt;String,String&gt;&gt;() { @Override protected Map&lt;String, String&gt; initialValue() { return new HashMap&lt;String, String&gt;(); } }; public void run(int z) { System.out.println(z+"-Running thread local sample"); long start = System.currentTimeMillis(); for (int i = 0; i &lt; N; i++){ String s = Integer.toString(i); myThreadLocal.get().put(s, "a"); myThreadLocal.get().remove(s); } long end = System.currentTimeMillis(); long t = (end - start); threadLocalExecTime += t; System.out.println(z+"-End thread local sample:"+t); } } }' Output: 0-Running field sample 0-End field sample:6044 0-Running thread local sample 0-End thread local sample:6015 1-Running field sample 1-End field sample:5095 1-Running thread local sample 1-End thread local sample:5720 2-Running field sample 2-End field sample:4842 2-Ru…
upvote count: 5
answers question: http://stackoverflow.com/q/609826
type: Answer
score: 3
has comment: http://stackoverflow.com/comment/107536937

http://stackoverflow.com/comment/280591
has text: Can you split the last one out into a separate answer? Let's keep it 1 per post. These are two really good ones.
score: 0
comment on: http://stackoverflow.com/a/461922
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/30896662
type: Comment
comment on: http://stackoverflow.com/a/477569
score: 3
type: AnswerComment
has text: This still seems to be the clearest solution, even with List and Iterable interfaces.

http://stackoverflow.com/comment/444623
score: 1
has text: I guess it is a classpath issue - but none of the suggestions fix the problem.
type: Comment
comment on: http://stackoverflow.com/q/631682
type: QuestionComment

http://stackoverflow.com/a/528669
has comment: http://stackoverflow.com/comment/341793
has body: You should check out Xstream. There is a 2 minute tutorial that is really simple. To get the same format, you would model the classes the same.
answers question: http://stackoverflow.com/q/528664
has comment: http://stackoverflow.com/comment/341675
downvote count: 0
score: 8
upvote count: 8
type: Answer
has comment: http://stackoverflow.com/comment/342175

http://stackoverflow.com/a/915722
type: Answer
has body: INTRO - skip if you're only interesterd in result ;) I was developing an editor for a custom programming language very simmilar to JSP. First I've implemented the editor as my thesis using NetBeans platform. After finishing school I've got a job and they wanted me to implement the same thing in Eclipse RCP, so now I can compare these two platforms at least in stuff I was facing during this project. RESULT - If I had a choice between Netbeans platform and Eclipse RCP, I would definitelly pick a NetBeans platform. Why? Great screencasts, good tutorials, very active friendly and helpful community, quite well documented and the source code is written nicely and with good code conventions. Also has some interesting gadgets (cookies, lookup). It simply suits me. And why Eclipse RCP does not suit me? The documentation is weaker and conventions and API are sometimes..ehm..too weird for me :-) It's quite ususal to see methods like: /** * Returns a description of the cursor position. * * @return a description of the cursor position * @since 2.0 */ protected String getCursorPosition() { .. } Well I thought they must be kidding me :-D How am I supposed to use this method? Or like this: /** * Returns the range of the current selection in coordinates of this viewer's document. * * @return a Point with x as the offset and y as the length of the current selection */ Point getSelectedRange(); Although the number and type of attributes fitts, I don't find the Point object ideal data structure for storing range ;-) There are numbers of theese such surpises in Eclipse RCP
score: 10
upvote count: 10
answers question: http://stackoverflow.com/q/579109
downvote count: 0

http://stackoverflow.com/comment/368680
type: Comment
comment on: http://stackoverflow.com/a/557387
has text: That would mean i would need to create another thread 'b' for every thread 'a' i track so that 'b' could wait for 'a' to join.
type: AnswerComment
score: 0

http://stackoverflow.com/q/515975
tagged with: stream
has body: Why do we need to close a FileInputStream (and streams in general) in any case before we leave the program? What would happen otherwise? If the program stops before the input stream is closed explicitly in the program, doesn't the stream also close automatically?
has answer: http://stackoverflow.com/a/515991
type: Question
has answer: http://stackoverflow.com/a/515981
tagged with: java
answer count: 6
has answer: http://stackoverflow.com/a/515988
downvote count: 1
has answer: http://stackoverflow.com/a/515994
favorite count: 0
has answer: http://stackoverflow.com/a/516014
has answer: http://stackoverflow.com/a/515989
has title: Closing Streams in Java
has comment: http://stackoverflow.com/comment/12063702
upvote count: 53
score: 52
type: UnansweredQuestion

http://stackoverflow.com/a/484251
downvote count: 0
type: Answer
score: 2
upvote count: 2
has body: If you add support for those structures to the JVM (where necessary, e.g., closures), and then create the necessary syntactic sugar in the written language and compiler. Of course if you wish to retain backwards compatibility then you have design decisions to make, which is why the Java Generics weren't as good as they could have been. You would want to break free of that to get a more perfect Java I think, but there would be very little demand because compatibility is where it is at. And 7 can go straight away. We're not running up against FAT12 file limits on a floppy disc here.
has comment: http://stackoverflow.com/comment/304632
has comment: http://stackoverflow.com/comment/301432
answers question: http://stackoverflow.com/q/484172

http://stackoverflow.com/a/425466
score: 24
type: AcceptedAnswer
upvote count: 24
accepted answer of: http://stackoverflow.com/q/425439
answers question: http://stackoverflow.com/q/425439
has body: You have more going on than you said. I ran the following expanded test from your example: public class test { public static void main(String[] args) { Object[][] someArray = new Object[5][]; someArray[0] = new Object[10]; someArray[1] = null; someArray[2] = new Object[1]; someArray[3] = null; someArray[4] = new Object[5]; for (int i=0; i&lt;=someArray.length-1; i++) { if (someArray[i] != null) { System.out.println("not null"); } else { System.out.println("null"); } } } } and got the expected output: $ /cygdrive/c/Program\ Files/Java/jdk1.6.0_03/bin/java -cp . test not null null not null null not null Are you possibly trying to check the lengths of someArray[index]?
type: Answer
downvote count: 0

http://stackoverflow.com/q/401415
has answer: http://stackoverflow.com/a/411358
tagged with: inheritance
has answer: http://stackoverflow.com/a/404030
has body: Hullo all, Wondering if there are any Java hackers who can clue me in at to why the following doesn't work: public class Parent { public Parent copy() { Parent aCopy = new Parent(); ... return aCopy; } } public class ChildN extends Parent { ... } public class Driver { public static void main(String[] args) { ChildN orig = new ChildN(); ... ChildN copy = orig.getClass().cast(orig.copy()); } } The code is quite happy to compile, but decides to throw a ClassCastException at runtime D= Edit: Whoah, really quick replies. Thanks guys! So it seems I cannot downcast using this method... is there any other way to do downcasting in Java? I did think about having each ChildN class overwrite copy(), but wasn't enthusiastic about adding the extra boilerplate code.
answer count: 7
favorite count: 0
has answer: http://stackoverflow.com/a/402015
has answer: http://stackoverflow.com/a/401426
has comment: http://stackoverflow.com/comment/226944
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/401419
accepted answer: http://stackoverflow.com/a/404030
tagged with: java
possible better answer: http://stackoverflow.com/a/401434
type: Question
has title: "Dynamic" Casting in Java
score: 5
has answer: http://stackoverflow.com/a/401439
has answer: http://stackoverflow.com/a/401434
tagged with: casting
upvote count: 5
downvote count: 0

http://stackoverflow.com/a/2792251
has body: Communication between Windows and a USB device by java. http://javausbapi.blogspot.com/2010/05/java-usb-api.html An example is conducted for a Freescale microcontroller
score: 0
answers question: http://stackoverflow.com/q/544507
type: Answer
upvote count: 1
downvote count: 1

http://stackoverflow.com/comment/342634
has text: My java program just needs the DISPLAY to be set. So isn't there any way that I can run the script from java?
comment on: http://stackoverflow.com/a/529495
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/90073792
type: Comment
comment on: http://stackoverflow.com/a/49015643
score: 0
has text: however some frameworks like jsf have a little integration problems with time API so sometimes you should use Date; plus environment java < 8
type: AnswerComment

http://stackoverflow.com/a/395456
upvote count: 9
answers question: http://stackoverflow.com/q/395401
has body: I agree with the above comments about overriding toString() on your own classes (and about automating that process as much as possible). For classes you didn't define, you could write a ToStringHelper class with an overloaded method for each library class you want to have handled to your own tastes: public class ToStringHelper { //... instance configuration here (e.g. punctuation, etc.) public toString(List m) { // presentation of List content to your liking } public toString(Map m) { // presentation of Map content to your liking } public toString(Set m) { // presentation of Set content to your liking } //... etc. } EDIT: Responding to the comment by xukxpvfzflbbld, here's a possible implementation for the cases mentioned previously. package com.so.demos; import java.util.List; import java.util.Map; import java.util.Set; public class ToStringHelper { private String separator; private String arrow; public ToStringHelper(String separator, String arrow) { this.separator = separator; this.arrow = arrow; } public String toString(List&lt;?&gt; l) { StringBuilder sb = new StringBuilder("("); String sep = ""; for (Object object : l) { sb.append(sep).append(object.toString()); sep = separator; } return sb.append(")").toString(); } public String toString(Map&lt;?,?&gt; m) { StringBuilder sb = new StringBuilder("["); String sep = ""; for (Object object : m.keySet()) { sb.append(sep) .append(object.toString()) .append(arrow) .append(m.get(object).toString()); sep = separator; } return sb.append("]").toString(); } public String toString(Set&lt;?&gt; s) { StringBuilder sb = new StringBuilder("{"); String sep = ""; for (Object object : s) { sb.append(sep).append(object.toString()); sep = separator; } return sb.append("}").toString(); } } This isn't a full-blown implementation, but just a starter.
type: Answer
score: 8
downvote count: 1

http://stackoverflow.com/a/456838
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/456778
upvote count: 14
has body: Take a look at jOpenDocument: http://www.jopendocument.org/documentation.html Especially: http://www.jopendocument.org/start_spreadsheet_3.html
accepted answer of: http://stackoverflow.com/q/456778
score: 14

http://stackoverflow.com/comment/409093
type: Comment
has text: I like this solution, though I suspect there's still a chance that between the check of available and the read() the connection can go stale somehow... I realize this is very unlikely, but it can happen, right?
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/596967

http://stackoverflow.com/q/389741
has answer: http://stackoverflow.com/a/389748
type: AnsweredQuestion
answer count: 12
has answer: http://stackoverflow.com/a/39210661
has answer: http://stackoverflow.com/a/47889874
downvote count: 3
tagged with: keyword
has body: I saw this keyword for the first time and I was wondering if someone could explain to me what it does. What is the continue keyword? How does it work? When is it used?
has answer: http://stackoverflow.com/a/389755
type: Question
linked to: http://stackoverflow.com/q/3770989
has title: What is the "continue" keyword and how does it work in Java?
has answer: http://stackoverflow.com/a/57945236
has answer: http://stackoverflow.com/a/47934171
tagged with: java
has answer: http://stackoverflow.com/a/389744
has answer: http://stackoverflow.com/a/36162818
upvote count: 320
has answer: http://stackoverflow.com/a/60796762
has answer: http://stackoverflow.com/a/390346
has answer: http://stackoverflow.com/a/55759495
tagged with: continue
favorite count: 0
has answer: http://stackoverflow.com/a/389764
accepted answer: http://stackoverflow.com/a/389744
possible better answer: http://stackoverflow.com/a/389748
score: 317

http://stackoverflow.com/q/631700
possible better answer: http://stackoverflow.com/a/631776
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/444519
has body: When encoding a java String to Latin-1 (ie. charset ISO-8859-1) I currently convert the German symbol β ('\u03B2') to ß ('\u00DF') before performing the encoding. I'm trying to avoid a question mark in the encoding where possible. Can anyone suggest other un-encodable characters which can be replaced an encodable character? Or better yet, a Java library that does it for me? Update: A bit of background: I have a Java program which exports it's data to CSV files so they can be read into a thrid-party application. A customer has complained that some characters are not converted - he gave me the example of "straβe". Although technically β is the greek symbol for Beta, a quick google search shows quite a few people use it to mean ß.
accepted answer: http://stackoverflow.com/a/631786
score: 1
has answer: http://stackoverflow.com/a/631776
tagged with: java
has answer: http://stackoverflow.com/a/631786
type: Question
type: AnsweredQuestion
has title: How to minimize question-marks when encoding a String as Latin-1?
answer count: 2
upvote count: 1

http://stackoverflow.com/comment/444679
comment on: http://stackoverflow.com/a/631839
type: Comment
score: 2
type: AnswerComment
has text: It's not entirely unreadable. You're a programmer, right? You should at least be able to realize that it's an HTML escape code, even if you don't recognize the actual value. You can always look it up. As I said before, the point of javadoc is readability of documentation, not code.

http://stackoverflow.com/comment/192650
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/362390
type: Comment
has text: whay I mean by the start is that lsb is at the start of the 4 bytes (it's a unsigned 32 bit int ) so I did mean least significant byte

http://stackoverflow.com/a/520568
has comment: http://stackoverflow.com/comment/337314
has comment: http://stackoverflow.com/comment/1882851
has comment: http://stackoverflow.com/comment/439708
has comment: http://stackoverflow.com/comment/1889072
upvote count: 170
has comment: http://stackoverflow.com/comment/336962
has comment: http://stackoverflow.com/comment/336989
type: AcceptedAnswer
score: 168
has comment: http://stackoverflow.com/comment/140268785
has comment: http://stackoverflow.com/comment/2601900
has comment: http://stackoverflow.com/comment/1887925
has comment: http://stackoverflow.com/comment/82524436
type: Answer
accepted answer of: http://stackoverflow.com/q/520527
has comment: http://stackoverflow.com/comment/337196
has comment: http://stackoverflow.com/comment/2603222
has comment: http://stackoverflow.com/comment/2602684
has comment: http://stackoverflow.com/comment/2603318
downvote count: 2
has comment: http://stackoverflow.com/comment/1887173
has comment: http://stackoverflow.com/comment/1881447
has comment: http://stackoverflow.com/comment/3606650
has comment: http://stackoverflow.com/comment/2602003
answers question: http://stackoverflow.com/q/520527
has comment: http://stackoverflow.com/comment/2603007
has body: Bad: Type information is lost at compile time, so at execution time you can't tell what type it's "meant" to be Can't be used for value types (this is a biggie - in .NET a List&lt;byte&gt; really is backed by a byte[] for example, and no boxing is required) Syntax for calling generic methods sucks (IMO) Syntax for constraints can get confusing Wildcarding is generally confusing Various restrictions due to the above - casting etc Good: Wildcarding allows covariance/contravariance to be specified at calling side, which is very neat in many situations It's better than nothing!

http://stackoverflow.com/comment/90722240
score: 0
type: AnswerComment
type: Comment
has text: Yeah, those are the coder's words, not mine. In my opinion, I think you may actually need it someday
comment on: http://stackoverflow.com/a/51863006

http://stackoverflow.com/a/361670
upvote count: 1
answers question: http://stackoverflow.com/q/361570
has comment: http://stackoverflow.com/comment/192122
downvote count: 0
type: Answer
has body: The xstream.fromXML() method will do the reading from the input stream for you. I think the problem is that you are casting the return value from xstream.fromXML(fin) into a String when it should be cast to the type of object you originally serialized (RandomTree I assume). So the code would look like this: RandomTree tree = (RandomTree)xstream.fromXML(fin); EDIT: after clarification in comments, the author's goal is to first read into a String so the XML contents can be printed before deserialization. With that goal in mind, I recommend taking a look at the IOUtils library mentioned in this thread
score: 1

http://stackoverflow.com/a/5988640
score: 2
downvote count: 0
upvote count: 2
answers question: http://stackoverflow.com/q/414583
type: Answer
has body: See Jspresso - http://www.jspresso.org/ It features multiple front-ends (Flex, pure HTML/Javascript, Swing, etc) but it does not give you much freedom on the view part. It's worth checking though.

http://stackoverflow.com/a/368294
has body: @bruno is right - you need to add the text pane to the frame's content pane. Slightly OT: If you generally want to access every component in a hierarchy, you need something recursive - your current method will only print immediate child names: void printNames(Component component) { System.out.println(component.getName()); for (Component child : component.getComponents()) { printNames(child); } } void printFrameNamesComponents(JFrame frame) { printNames(frame.getContentPane()); } (not tested, but something like this.)
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/368194
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/197590
accepted answer of: http://stackoverflow.com/q/368194

http://stackoverflow.com/q/453561
score: 6
has comment: http://stackoverflow.com/comment/71720240
downvote count: 1
type: AnsweredQuestion
tagged with: activemq-classic
tagged with: java
upvote count: 7
type: Question
has title: Using ActiveMQ via JNDI
possible better answer: http://stackoverflow.com/a/8176413
has answer: http://stackoverflow.com/a/454179
answer count: 2
tagged with: jndi
has answer: http://stackoverflow.com/a/8176413
has body: I'm trying to create simply connect with ActiveMQ using JNDI. I have: Queue named example.A. According ActiveMQ documentation touching JNDI, if I want to use ConectionFactories and Queues (Topics) via JNDI, I have to place jndi.properties file on my classpath. As I have understood, ActiveMQ classpath is %activemq%/conf directory by default. I have not changed it. So I have this property for my queue: queue.MyQueue = example.A I have created java client class for ActiveMQ which uses JNDI as below: Properties jndiParameters = new Properties() ; jndiParameters.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); jndiParameters.put(Context.PROVIDER_URL, "tcp://localhost:61616"); Context context = new InitialContext(jndiParameters); ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("ConnectionFactory"); Queue queue = (Queue) context.lookup("MyQueue"); But it cannot find my queue. It throws exception: javax.naming.NameNotFoundException: MyQueue Where are my mistakes?
accepted answer: http://stackoverflow.com/a/454179
favorite count: 0

http://stackoverflow.com/a/574027
has body: Personally, i have more trust in Linux platform as server, but want to use C# as program language.
type: Answer
score: 11
downvote count: 0
answers question: http://stackoverflow.com/q/573982
upvote count: 11

http://stackoverflow.com/comment/8065570
has text: But I thougth AspectJ were Java.
type: Comment
comment on: http://stackoverflow.com/a/2026856
type: AnswerComment
score: 0

http://stackoverflow.com/comment/31558408
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/440907
has text: So if you don't agree at all, why bother with an example? Just don't do it.
type: Comment

http://stackoverflow.com/a/16344326
has body: I have used PersistentObject extensively in production code and it serves my needs well.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/450864

maven-2
tags question: http://stackoverflow.com/q/520902
tags question: http://stackoverflow.com/q/635543
tags question: http://stackoverflow.com/q/495208
tags question: http://stackoverflow.com/q/385532
tags question: http://stackoverflow.com/q/443264
tags question: http://stackoverflow.com/q/364114
tags question: http://stackoverflow.com/q/385401
tags question: http://stackoverflow.com/q/579603
tags question: http://stackoverflow.com/q/475348
tags question: http://stackoverflow.com/q/504368
tags question: http://stackoverflow.com/q/374043
tags question: http://stackoverflow.com/q/487901
tags question: http://stackoverflow.com/q/545531
tags question: http://stackoverflow.com/q/396245
tags question: http://stackoverflow.com/q/645002
tags question: http://stackoverflow.com/q/467879
tags question: http://stackoverflow.com/q/574594
tags question: http://stackoverflow.com/q/596746
tags question: http://stackoverflow.com/q/436920
tags question: http://stackoverflow.com/q/474725
tags question: http://stackoverflow.com/q/522197
tags question: http://stackoverflow.com/q/504071
tags question: http://stackoverflow.com/q/373350
tags question: http://stackoverflow.com/q/406533
tags question: http://stackoverflow.com/q/635154
tags question: http://stackoverflow.com/q/372119
tags question: http://stackoverflow.com/q/560565
tags question: http://stackoverflow.com/q/367431
tags question: http://stackoverflow.com/q/634448
tags question: http://stackoverflow.com/q/541043
type: Tag
tags question: http://stackoverflow.com/q/475402
tags question: http://stackoverflow.com/q/567996
tags question: http://stackoverflow.com/q/444426
tags question: http://stackoverflow.com/q/472896
tags question: http://stackoverflow.com/q/602511
tag name: maven-2
tags question: http://stackoverflow.com/q/603189
tags question: http://stackoverflow.com/q/602905
tags question: http://stackoverflow.com/q/532241
tags question: http://stackoverflow.com/q/610442
tags question: http://stackoverflow.com/q/577377
tags question: http://stackoverflow.com/q/640161
tags question: http://stackoverflow.com/q/359921

http://stackoverflow.com/comment/354232
type: Comment
type: AnswerComment
has text: I would have thought so too, but unfortunately it doesn't, you still need to add the tag to get line breaks.
comment on: http://stackoverflow.com/a/542142
score: 68

http://stackoverflow.com/comment/269214
type: AnswerComment
comment on: http://stackoverflow.com/a/448152
score: 0
type: Comment
has text: From what I understand about Jython, I don't know that it would help. I'm trying to go in the opposite direction (taking a Java library and making it available to Python code). Can Jython actually do that? Or is it just used for running Py code on top of Java?

http://stackoverflow.com/a/453724
score: 17
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/453684
upvote count: 17
has body: ConcurrentHashMap is way faster than Hashtable. It's concurrent, not just synchronized. It admits multiple readers/writers at once. There is no such 'concurrent' array list though. Depending on your needs, CopyOnWriteArrayList may or may not be what you need.

http://stackoverflow.com/a/473159
downvote count: 0
type: Answer
upvote count: 2
answers question: http://stackoverflow.com/q/473088
has body: If you haven't read Joel's article on Architecture Astronauts (the Live Mesh one), I recommend it - it's a good read about this subject.
score: 2

http://stackoverflow.com/q/553031
score: 13
possible better answer: http://stackoverflow.com/a/633325
has answer: http://stackoverflow.com/a/553144
type: AnsweredQuestion
tagged with: java
type: Question
tagged with: jakarta-ee
tagged with: mocking
upvote count: 13
has answer: http://stackoverflow.com/a/633325
answer count: 2
has title: What is the best way to unit test a EJB3 component without having to deploy the component
downvote count: 0
has body: I would like to have a JUnit (or other) system where the enterprise beans can be tested in a mock environment so that all resources/beans and so on are injected locally. The enterprise beans should not have to accomplish this. All kinds of injection should be supported. I would like to have a maven plugin for this so that the tests can be run from a maven build. Transactions are not necessary during the unit tests,this would require a complete container. Do you know of such a maven plugin or test framework? Experiences with it?
tagged with: maven-plugin
favorite count: 0
tagged with: ejb-3.0
accepted answer: http://stackoverflow.com/a/553144

http://stackoverflow.com/a/573571
answers question: http://stackoverflow.com/q/573543
score: 0
type: Answer
has body: Java is now nearly 14 years old, and the age is starting to show. It's just a language. If you made all the changes you propose, I don't believe it would fly - it took 5 years for java to find its place, and a 'reboot' is going to cause problems with backwards computability. This may not seem much of an issue, but it means billions of dollars worldwide in changeover costs for many companies. Further, you'd then have the possibility of running the older version and the newer version on the same servers with interesting results or complex configurations. Are these issues preventing you from doing something you need to do? Then don't worry about it. The keepers of java know that if they don't keep it up to date the people will bail onto one of the newer languages over time, and they will change it to adapt. But keep in mind that it's good for old languages to die and new languages to come of age. It's not always best to keep a language in active use and development as computers change, or reanimate it with some backwards compatible breaking but rejuvenating potion. -Adam

http://stackoverflow.com/comment/370299
has text: OHNO! Man that sucks. If I had vista I'd be testing to see if I could find an answer. Good luck to you in figuring it out.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/558865

http://stackoverflow.com/a/433941
answers question: http://stackoverflow.com/q/433853
downvote count: 0
upvote count: 2
type: Answer
has body: It's all the little bitty syntax differences that got me. Lack of destructors. On the other hand, being able to write a main for each class (immensely handy or testing) is real nice; after you get used to it, the structure and tricks available with jar files are real nice; the fact that the semantics are completely defined (eg, int is the same everywhere) is real nice.
score: 2

http://stackoverflow.com/comment/376546
score: 0
type: AnswerComment
has text: @William, yes this almost caused me to -1 instead of +1 the question. I gave the poster a little bit of slack though ;)
comment on: http://stackoverflow.com/a/564718
type: Comment

http://stackoverflow.com/q/579729
accepted answer: http://stackoverflow.com/a/579773
score: 0
possible better answer: http://stackoverflow.com/a/585153
answer count: 2
has title: How can I port this Java code to C#?
tagged with: design-patterns
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/585153
tagged with: reflection
has body: I am looking at a pattern implemented in Java and have some questions about how it aligns to (can be ported to) C#. Java: class Foo { private Class someClass; ... } class Bar { private Field some Field; } First, Class stores an instance of a domain object. It looks like Java exposes reflection methods on the type which are used to access fields on the object through reflection. What would type would be synonymous in C#? Would I use object and then use MethodInfo or is there a better way? Second, Field is type in the framework and is assigned by using: someClass.getDeclaredField(fieldName) Is there a parallel in the .NET framework i should use? Right now I created a custom object in place of the Class in Foo, and I created a custom object for Field. Is there a preferred way to do this?
tagged with: java
type: Question
tagged with: c#
has answer: http://stackoverflow.com/a/579773

http://stackoverflow.com/comment/10352749
type: AnswerComment
comment on: http://stackoverflow.com/a/8386476
type: Comment
score: 1
has text: dirty indeed - longest distance away from the straightforward solution I have ever seen (and I _have_ seen quite a lot, creativity in doing things wrong is huge :-)

http://stackoverflow.com/q/398992
has body: So, I'm using jdbc to talk to a MySQL DB. For many a table and for many queries/views, I have created one class which encapsulates one row of the table or the query/table result. Accesses to the DB return one object of such a class (when I know exactly that there's only one matching row) or a Vector of such objects. Each class features a factory method that builds an object from a row of a ResultSet. A lot of ResultSet.getXXX() methods are needed, as is finicky bookkeeping about which value is in which column, especially after changes to the table/query/view layout. Creating and maintaining these objects is a boring, work-intensive and mind-numbing task. In other words, the sort of task that is done by a tool. It should read SQL (the MySQL variant, alas) and generate Java code. Or, at least, give me a representation (XML? DOM?) of the table/query/view, allowing me to do the java code generation myself. Can you name this tool?
type: AnsweredQuestion
tagged with: sql
downvote count: 0
possible better answer: http://stackoverflow.com/a/399004
accepted answer: http://stackoverflow.com/a/399298
has answer: http://stackoverflow.com/a/399004
favorite count: 0
type: Question
tagged with: jdbc
score: 4
has answer: http://stackoverflow.com/a/399088
has answer: http://stackoverflow.com/a/1971465
has answer: http://stackoverflow.com/a/399298
tagged with: java
answer count: 5
upvote count: 4
has answer: http://stackoverflow.com/a/399455
has title: Even easier Java/SQL data transfer needed

http://stackoverflow.com/comment/57521668
type: Comment
comment on: http://stackoverflow.com/a/14781472
score: 0
type: AnswerComment
has text: //Just remove the synchronized keywords// - Modifying the source just for making it testable should be the last option. How about an injectable boolean flag that tests whether to synchronize or not?

http://stackoverflow.com/comment/268654
type: Comment
has text: That's perfect. Thanks! I saw where I could create a UserType, but I figured there was an easier way now, and this was it.
comment on: http://stackoverflow.com/a/447507
type: AnswerComment
score: 0

http://stackoverflow.com/comment/120293484
type: QuestionComment
comment on: http://stackoverflow.com/q/556807
has text: I reposted the question on the softwarerecs SE since it got closed here: [Java to C++ converter](https://softwarerecs.stackexchange.com/q/79668/903)
score: 0
type: Comment

http://stackoverflow.com/a/618206
has body: Now you've just gone and reminded me of something I wish we had over in the C# world. Other than the links provided, there's some good links about C# and Java in relation to this topic in the answers to this question: Logic and its application to Collections.Generic and inheritance A selection of which are: Contravariance and Covariance in C# (code is C# specific, and theoretical since the syntax doesn't exist [yet], but covers the topics in general very well.) Java generics and the covariance and contravariance of arguments Java generics tutorial from Sun.
type: Answer
answers question: http://stackoverflow.com/q/618148
score: 0

plugins
tags question: http://stackoverflow.com/q/415733
tags question: http://stackoverflow.com/q/502218
tags question: http://stackoverflow.com/q/645981
tags question: http://stackoverflow.com/q/465099
tags question: http://stackoverflow.com/q/369889
tags question: http://stackoverflow.com/q/599291
tags question: http://stackoverflow.com/q/383510
tag name: plugins
tags question: http://stackoverflow.com/q/509931
type: Tag

http://stackoverflow.com/a/71939524
score: 2
upvote count: 2
has body: public boolean isBetween(LocalDate target, LocalDate min, LocalDate max) { if (target == null || min == null || max == null) { throw new IllegalArgumentException("paramettres can't be null"); } return target.compareTo(min) >= 0 && target.compareTo(max) <= 0; }
answers question: http://stackoverflow.com/q/494180
downvote count: 0
type: Answer

http://stackoverflow.com/a/413743
type: Answer
upvote count: 4
answers question: http://stackoverflow.com/q/413713
has body: It would be VERY beneficial to start working with version control. Start now, don't delay! Git is moving REALLY fast, and there's already a TortoiseGit being developed. SVN is still a great standard to work with. And I have not worked with Mercurial, but that's another VCS that's worth looking into. Other than that, I don't see why your workflow has to be enterprisey. It just has to be efficient and comfortable. That said, I think you should try working with a simple text editor and compiling from the command line. Most of the world's best programmers still use that instead of an IDE, and it will help you understand the processes underneath your favorite IDE.
score: 1
downvote count: 3
has comment: http://stackoverflow.com/comment/238517

http://stackoverflow.com/a/10035382
has comment: http://stackoverflow.com/comment/16992669
has comment: http://stackoverflow.com/comment/103056458
has comment: http://stackoverflow.com/comment/19055014
has comment: http://stackoverflow.com/comment/30990633
score: 13
has comment: http://stackoverflow.com/comment/68579952
has comment: http://stackoverflow.com/comment/42380445
has comment: http://stackoverflow.com/comment/31002050
has comment: http://stackoverflow.com/comment/30742952
downvote count: 3
upvote count: 16
has comment: http://stackoverflow.com/comment/55043862
has comment: http://stackoverflow.com/comment/43488171
has comment: http://stackoverflow.com/comment/106695523
has body: Try this: String xmlEscapeText(String t) { StringBuilder sb = new StringBuilder(); for(int i = 0; i &lt; t.length(); i++){ char c = t.charAt(i); switch(c){ case '&lt;': sb.append("&amp;lt;"); break; case '&gt;': sb.append("&amp;gt;"); break; case '\"': sb.append("&amp;quot;"); break; case '&amp;': sb.append("&amp;amp;"); break; case '\'': sb.append("&amp;apos;"); break; default: if(c&gt;0x7e) { sb.append("&amp;#"+((int)c)+";"); }else sb.append(c); } } return sb.toString(); }
answers question: http://stackoverflow.com/q/439298
has comment: http://stackoverflow.com/comment/12837077
has comment: http://stackoverflow.com/comment/105133908
type: Answer
has comment: http://stackoverflow.com/comment/43551773
has comment: http://stackoverflow.com/comment/30742767
has comment: http://stackoverflow.com/comment/31014642

http://stackoverflow.com/comment/334488
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/520954
has text: Would this suffer from the problem that kdgregory was mentioning? That, depending on your platform default encoding, you may split a single character into two meaningless pieces

http://stackoverflow.com/comment/83665211
score: 0
type: AnswerComment
type: Comment
has text: Note: the new link is broken. Can anyone post an abstract here?
comment on: http://stackoverflow.com/a/4588605

jdbc
tags question: http://stackoverflow.com/q/419021
tags question: http://stackoverflow.com/q/595222
tags question: http://stackoverflow.com/q/443222
tags question: http://stackoverflow.com/q/377745
tags question: http://stackoverflow.com/q/381370
tags question: http://stackoverflow.com/q/416432
tags question: http://stackoverflow.com/q/557667
tags question: http://stackoverflow.com/q/560063
tags question: http://stackoverflow.com/q/462534
tags question: http://stackoverflow.com/q/507556
tags question: http://stackoverflow.com/q/642249
tags question: http://stackoverflow.com/q/521669
tags question: http://stackoverflow.com/q/448036
tags question: http://stackoverflow.com/q/520585
tags question: http://stackoverflow.com/q/369460
type: Tag
tags question: http://stackoverflow.com/q/366861
tags question: http://stackoverflow.com/q/400881
tags question: http://stackoverflow.com/q/458682
tags question: http://stackoverflow.com/q/422369
tags question: http://stackoverflow.com/q/384189
tags question: http://stackoverflow.com/q/497893
tags question: http://stackoverflow.com/q/398992
tags question: http://stackoverflow.com/q/596937
tags question: http://stackoverflow.com/q/515590
tags question: http://stackoverflow.com/q/485984
tags question: http://stackoverflow.com/q/624337
tags question: http://stackoverflow.com/q/486168
tags question: http://stackoverflow.com/q/527061
tags question: http://stackoverflow.com/q/520869
tags question: http://stackoverflow.com/q/502318
tags question: http://stackoverflow.com/q/490595
tags question: http://stackoverflow.com/q/368736
tags question: http://stackoverflow.com/q/645756
tags question: http://stackoverflow.com/q/471745
tags question: http://stackoverflow.com/q/616135
tags question: http://stackoverflow.com/q/584870
tags question: http://stackoverflow.com/q/490288
tags question: http://stackoverflow.com/q/540702
tags question: http://stackoverflow.com/q/383783
tags question: http://stackoverflow.com/q/389832
tags question: http://stackoverflow.com/q/457933
tags question: http://stackoverflow.com/q/588103
tags question: http://stackoverflow.com/q/503003
tags question: http://stackoverflow.com/q/376762
tags question: http://stackoverflow.com/q/426758
tags question: http://stackoverflow.com/q/415779
tags question: http://stackoverflow.com/q/589367
tags question: http://stackoverflow.com/q/378297
tags question: http://stackoverflow.com/q/639757
tags question: http://stackoverflow.com/q/521278
tags question: http://stackoverflow.com/q/397524
tag name: jdbc
tags question: http://stackoverflow.com/q/553751
tags question: http://stackoverflow.com/q/530972
tags question: http://stackoverflow.com/q/425745
tags question: http://stackoverflow.com/q/465142
tags question: http://stackoverflow.com/q/642241
tags question: http://stackoverflow.com/q/486011
tags question: http://stackoverflow.com/q/540489
tags question: http://stackoverflow.com/q/467324
tags question: http://stackoverflow.com/q/493947
tags question: http://stackoverflow.com/q/610593
tags question: http://stackoverflow.com/q/380415
tags question: http://stackoverflow.com/q/394627

http://stackoverflow.com/comment/137697213
has text: @Priyshrm The logical core count doesn't indicate how many threads can do their work. Your OS is likely running several thousand threads even when idling. My OS is configured to allow a max of 255k threads. What the core count affects, is how many of those threads run truly *parallel* to each other. Above that, and the CPU is context-switching, mixing execution of pieces of all scheduled threads one by one. The 1 second above 10 seconds expected is that thread switching. Also, see "atomic" (like atom), which is about non-splittable pieces of execution.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/382212
type: Comment

http://stackoverflow.com/a/479107
downvote count: 1
score: -1
has comment: http://stackoverflow.com/comment/296107
upvote count: 0
has body: The simplest route is to XOR the hashcodes of each individual field. This has minor ugliness in some situations (e.g. in X,Y coordinates, it causes the potentially poor situation of having equal hashes when you flip X and Y), but is overall pretty effective. Tweak as needed to reduce collisions if necessary for efficiency.
type: Answer
answers question: http://stackoverflow.com/q/479105
has comment: http://stackoverflow.com/comment/296087

http://stackoverflow.com/a/592559
accepted answer of: http://stackoverflow.com/q/592520
type: Answer
answers question: http://stackoverflow.com/q/592520
upvote count: 12
has comment: http://stackoverflow.com/comment/50332942
has body: For a general guide have a look at these two links Fatal Error Log Troubleshooting and Crash Course on JVM Crash Analysis
downvote count: 0
has comment: http://stackoverflow.com/comment/404411
score: 12
type: AcceptedAnswer

http://stackoverflow.com/comment/240502
has text: I'd put just SomeObject so = null before try and put null check to finally clause. This way there will be no compiler warnings.
type: Comment
score: 6
comment on: http://stackoverflow.com/a/415771
type: AnswerComment

http://stackoverflow.com/a/56205766
has body: Any constructor in subclass will call the no argument contructor(or default constructor) of parent class. if you define a parameterized constructor in parent class then you have to explicitly call the parent class constructor with super keyword else it will give the compilation error. class Alpha { Alpha(int s, int p) { System.out.println("base"); } } public class SubAlpha extends Alpha { SubAlpha() { System.out.println("derived"); } public static void main(String[] args) { new SubAlpha(); } } The above code will give the compilation error: prog.java:13: error: constructor Alpha in class Alpha cannot be applied to given types; { ^ required: int,int found: no arguments reason: actual and formal argument lists differ in length 1 error The above error occurred because neither we have any no argument constructor/default constructor in parent class nor we are calling the parameterized constructor from sub class. Now to solve this either call the parameterized constructor like this: class Alpha { Alpha(int s, int p) { System.out.println("base"); } } public class SubAlpha extends Alpha { SubAlpha() { super(4, 5); // calling the parameterized constructor of parent class System.out.println("derived"); } public static void main(String[] args) { new SubAlpha(); } } Output base derived or define a no argument constructor in parent class like this: class Alpha { Alpha(){ } Alpha(int s, int p) { System.out.println("base"); } } public class SubAlpha extends Alpha { SubAlpha() { System.out.println("derived"); } public static void main(String[] args) { new SubAlpha(); } } output derived
type: Answer
answers question: http://stackoverflow.com/q/525548
score: 0

http://stackoverflow.com/a/417544
type: Answer
has body: My advice would be to say that there is a quick and dirty way to meet the requirements within X days/weeks/months and that if there are major enhancements or features then there will be a cost to move to something larger that can handle what is now required. Something to consider here is the idea of YAGNI if the client doesn't want anything more than the basics that they wanted in the first implementation. There is also the question of how much of a framework will you be building in this first go round.
answers question: http://stackoverflow.com/q/417515
score: 0

http://stackoverflow.com/comment/362609
comment on: http://stackoverflow.com/a/551024
has text: In this case though? Why would a property key name ever change? It's the value that's much more likely to change.
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/310306
comment on: http://stackoverflow.com/a/490358
type: Comment
has text: We've been using DBCP together with Spring for about 4 years with no issues - maybe we've been lucky!
score: 2
type: AnswerComment

http://stackoverflow.com/comment/438716
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/626031
has text: It's impossible to say what's wrong from that. For example, what is 'img' and how does it load the image?
score: 0

http://stackoverflow.com/a/459526
type: Answer
score: 2
answers question: http://stackoverflow.com/q/458817
upvote count: 2
has body: Netbeans with the GUI WYSIWYG editor. It makes creating Java 6 Swing forms very easy. I subclass the forms to add functionality to ensure continued tool support. I've also used SwingX for widgets like date pickers and collapsible panels. Plus there's always SwingWorker in the JRE for running background jobs that update the UI.
downvote count: 0

jax-rpc
tags question: http://stackoverflow.com/q/545496
tag name: jax-rpc
type: Tag
tags question: http://stackoverflow.com/q/541241

http://stackoverflow.com/comment/97351238
type: Comment
has text: Yes it's important to not do unrelated work inside the timed region, but your first example is still fine. There's only one call to `println`, not a separate header line or something, and `System.nanoTime()` has to be evaluated as the *first* step in constructing the string arg for that call. There's nothing a compiler can do with the first that they can't do with the second, and neither one is even encouraging them to do extra work before recording a stop time.
comment on: http://stackoverflow.com/a/42891083
score: 1
type: AnswerComment

textmatebundles
tag name: textmatebundles
type: Tag
tags question: http://stackoverflow.com/q/616344

http://stackoverflow.com/a/530465
has comment: http://stackoverflow.com/comment/343415
has comment: http://stackoverflow.com/comment/360441
type: Answer
has body: With an inner loop it's pretty trivial, the challenge would be to do it without an inner loop... Also, it depends on if you understood your teacher or your teacher misunderstood (or misrepresented) the rules of the game. I think I'd be tempted to just create an array [2..14] and place the cards in the location that corresponds to their rank. If you hit a duplicate, it's not a straight, and when you are done, you should have 8 spaces in a row. If you have less than 8 spaces in a row, it's not a straight. All the other solutions I can come up with require an inner loop--and inner loops are one of those sloppy programming things you need to avoid whenever you can if you're going to ever be a respectable programmer. edit: Also, if you misunderstood the teacher and the only wrapping condition is "10,j,q,k,a" (like in the real rules), then you need an additional test that if all of 2, 13 and 14 are set, it's also a failure (2-a-k wraparound). (Edited again to replace 1 for ace with 14 after re-reading the question)
answers question: http://stackoverflow.com/q/530208
score: 0

http://stackoverflow.com/a/509268
upvote count: 2
has body: Well, given: public class Main { /** * @param args the command line arguments */ public static void main(String argv[]) { Writer out; // Use an instance of ourselves as the SAX event handler Echo handler = new Echo(); // Use the default (non-validating) parser SAXParserFactory factory = SAXParserFactory.newInstance(); try { // Set up output stream out = new OutputStreamWriter(System.out, "UTF8"); // Parse the input SAXParser saxParser = factory.newSAXParser(); saxParser.parse(new File("/tmp/dblp.xml"), handler); } catch (Throwable t) { t.printStackTrace(); } System.out.println("Incollections = " + handler.cnt); System.exit(0); } static class Echo extends DefaultHandler { public int cnt = 0; @Override public void startElement(String namespaceURI, String sName, // simple name String qName, // qualified name Attributes attrs) throws SAXException { if (qName.equals("incollection")) { cnt = cnt + 1; } } } } This works for me under Java 5, but I do get the OOM under Java 6. I run it like this: java -DentityExpansLimit=512000 -jar xmltest.jar And it prints: Incollections = 8353 Which is convenient: grep "&lt;incollection" /tmp/dblp.xml | wc -l 8353 So, FYI, data point, etc.
score: 2
answers question: http://stackoverflow.com/q/508878
downvote count: 0
has comment: http://stackoverflow.com/comment/324885
type: Answer

http://stackoverflow.com/a/560117
score: 0
type: Answer
has body: I typically use hotdeployment of changes Java classes and JSP pages. This is the fastest way. We shared 1 server with 5 developers using hotdeployment of classes to PortalServer/installedApps/.ear/yourportlet.war and this worked great. However, now and then we did have to restart the server. If you changed deployement descriptors you still need to re-deploy the portlet WAR. Make sure the reloadingEnabled flag is set to false for the wps.war app on your development machine (restart picks up the change).
answers question: http://stackoverflow.com/q/490219

http://stackoverflow.com/a/1283487
type: Answer
has comment: http://stackoverflow.com/comment/46990989
score: 14
downvote count: 0
has comment: http://stackoverflow.com/comment/46991065
upvote count: 14
answers question: http://stackoverflow.com/q/559989
has comment: http://stackoverflow.com/comment/14647769
has comment: http://stackoverflow.com/comment/46990190
has body: Just came across this doing a web search, and thought I'd promote the new standard OSGi R4.2 way (as provided by Equinox shipped with Eclipse 3.5). If you don't have an activator, and don't want to create one just to cache the bundle context, you can use FrameworkUtil.getBundle. Modifying the previous example: import org.osgi.framework.FrameworkUtil; public class ExportClassDigestApplication implements IApplication { public Object start(IApplicationContext context) throws Exception { context.applicationRunning(); BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()) .getBundleContext(); } }

http://stackoverflow.com/a/572011
answers question: http://stackoverflow.com/q/572001
downvote count: 1
score: 5
has comment: http://stackoverflow.com/comment/383996
type: AcceptedAnswer
has body: The Console support issue in Java is well known, I am not sure that this is doable. This was not initially possible with System.in since it used to work line-based. Sun eventually added a java.io.Console class. Here are its JavaDocs: http://java.sun.com/javase/6/docs/api/java/io/Console.html Once you get the console (I think from System.console), you can get a reader and perhaps read characters from it, but I'm not sure if it includes keys. Generally, you're supposed to use Swing or AWT if you want access to the keyboard, which is silly. As of 2007, there was a feature request about it: here
has comment: http://stackoverflow.com/comment/384020
type: Answer
upvote count: 6
accepted answer of: http://stackoverflow.com/q/572001
has comment: http://stackoverflow.com/comment/384017

http://stackoverflow.com/q/385088
has body: Are there any good tools available to track memory usage In a tomcat java webapp? I'm looking for something that can give a breakdown by class or package. Thanks, J
has answer: http://stackoverflow.com/a/385210
type: AnsweredQuestion
score: 4
accepted answer: http://stackoverflow.com/a/385759
tagged with: java
type: Question
possible better answer: http://stackoverflow.com/a/385181
tagged with: memory
has answer: http://stackoverflow.com/a/385181
upvote count: 4
answer count: 3
has answer: http://stackoverflow.com/a/385759
has title: Tracking memory usage in a tomcat webapp
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/373377
score: 4
type: Answer
upvote count: 4
has body: I remember reading something about this in the book Hardcore Java: The problem with checking elements in a collection at runtime is that it is extremely expensive; the order of efficiency is only O(n). If you have only 10 addresses in your collection, checking elements is easy. However, if the collection contains 15,000 addresses, then you would incur a significant overhead whenever someone calls the setter. On the other hand, if you can prevent users from placing anything other than an address in your collection at compile time, then you wouldn't have to check the types at runtime. If they try to give you something that isn't an address, then the compiler will reject the attempt. This is exactly what parameterized types do. However, "why" questions can never really be satisfactorily answered because there are just too many variable involved with people, time, place and politics. I remember reading somewhere else that the decision had a lot to do with maintaining compatibility with the way things were already being done in the Java byte code. Here is another quote from the same book: After the compiler has resolved the type safety introduced by generics, it erases the parameterization from the type. Therefore, the information is not available at runtime. The purpose of erasure, as stated by Sun, is to allow class libraries built with an older version of the JDK to be able to run on the JDK 1.5 virtual machine. I'm curious, what are the advantages offered by runtime generics?
downvote count: 0
answers question: http://stackoverflow.com/q/373363

http://stackoverflow.com/q/492280
has comment: http://stackoverflow.com/comment/308062
tagged with: com+
has answer: http://stackoverflow.com/a/492621
has answer: http://stackoverflow.com/a/929659
score: 0
has comment: http://stackoverflow.com/comment/308043
has answer: http://stackoverflow.com/a/928818
has answer: http://stackoverflow.com/a/492530
has title: How to execute COM+ libraries from Java using a free method
answer count: 5
accepted answer: http://stackoverflow.com/a/492621
has body: I have a COM+ component developed with VB6. After registering it with the component services manager COM+ application, I can use it from ASP like this Set Comando = Server.CreateObject("JuiciosComando.clsComando") ComandoExecute = Comando.execute(Xml) Set Comando = Nothing That's all I need, the component just receives a (maybe a huge) string and returns another (also possibly huge) string... Is there some way to access this very same component from Java? What I've found so far is J-Integra but it's a commercial product. I've also found this thread on codeguru.com but my C++.NET knowledge is rather poor, besides I would rather just find a free, pure Java solution.
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/495169
tagged with: java
has answer: http://stackoverflow.com/a/495169
type: Question

http://stackoverflow.com/a/591292
downvote count: 0
answers question: http://stackoverflow.com/q/591004
type: Answer
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/404324
has body: (Disclaimer: I've never used "super" as a generic wildcard qualifier, so take this with a grain of salt...) For (A), actually you can't add Shape and its derivatives, you can only add Shape and its ancestors. I think maybe what you want is List&lt;? extends Shape&gt; shapeSuper = new ArrayList&lt;Shape&gt;(); Specifying "extends" means Shape and anything derived from Shape. Specifying "super" means Shape and anything Shape descended from. Not sure about (B), unless Object isn't implicit. What happens if you explicitly declare Shape as public class Shape extends Object?
has comment: http://stackoverflow.com/comment/403049

http://stackoverflow.com/a/383582
upvote count: 3
has comment: http://stackoverflow.com/comment/76078081
has comment: http://stackoverflow.com/comment/211211
downvote count: 1
has comment: http://stackoverflow.com/comment/211138
has comment: http://stackoverflow.com/comment/211110
answers question: http://stackoverflow.com/q/383570
has body: Since Strings in java are unbounded in length, and each character has 16 bits, and ints have 32 bits, you could only produce a unique mapping of Strings to ints if the Strings were up to two characters. But you could use BigInteger to produce a unique mapping, with something like: String s = "my string"; BigInteger bi = new BigInteger(s.getBytes()); Reverse mapping: String str = new String(bi.toByteArray());
has comment: http://stackoverflow.com/comment/212052
type: Answer
score: 2

http://stackoverflow.com/comment/25907176
has text: In very simple words, default class-loaders which come with JRE can load classes from classpath (file systems), URLs (sockets e.g. Applet class loader, RMI class loader) etc. If these are not enough or does not load your classes properly (e.g. different versions of same class need to be loaded) you need to write your own custom class loaders.
type: QuestionComment
comment on: http://stackoverflow.com/q/585991
score: 0
type: Comment

http://stackoverflow.com/q/542674
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/542917
has title: How can I access an HSQL DB from a .NET application?
score: 3
upvote count: 3
tagged with: java
type: Question
has body: Is it possible to access an HSQLDB database that is running in server mode from a .net application located on the same computer? There do not seem to be any odbc drivers for hsqldb (freely available). Am I missing it? Sun's jdbc odbc bridge seems to allow connecting to an odbc datasource through a jdbc connection, but I would need the opposite in this case: to be able to create a odbc connection that would bridge me to a jdbc source. Thanks!
tagged with: odbc
answer count: 3
has answer: http://stackoverflow.com/a/544600
has answer: http://stackoverflow.com/a/3351185
downvote count: 0
tagged with: hsqldb

http://stackoverflow.com/a/2366022
upvote count: 1
has body: I had a look at the Tomcat documentation here: http://tomcat.apache.org/tomcat-5.5-doc/config/http.html It mentions using compression="force" which worked for me. It also says you can set a minimum number. This worked fine for me &lt;Connector port="8080" compression="256000" /&gt; (compress anything over 256Kb) The default value for compressableMimeType meant that I didn't need that attribute. Also note that it doesn't list CompressionMinSize attribute.
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/550024
score: 1

http://stackoverflow.com/q/402683
score: 20
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/402793
tagged with: path
has answer: http://stackoverflow.com/a/402753
has title: How do I get just the jar URL from a jar: URL containing a "!" and a specific file in the jar?
has answer: http://stackoverflow.com/a/9189036
has answer: http://stackoverflow.com/a/402771
tagged with: file
has answer: http://stackoverflow.com/a/32556994
type: Question
upvote count: 20
tagged with: java
has answer: http://stackoverflow.com/a/12050229
has body: I get a jar file url at runtime as: jar:file:///C:/proj/parser/jar/parser.jar!/test.xml How can this be converted to a valid path as: C:/proj/parser/jar/parser.jar. I have already tried using File(URI), getPath(), getFile() in vain.
has answer: http://stackoverflow.com/a/893479
tagged with: jar
tagged with: url
downvote count: 0
answer count: 7
favorite count: 0

http://stackoverflow.com/a/10908639
has body: Are you sure you're using DBCP properly? According to the short configuration notes, it's supposed to handle timeouts pretty well thanks to the default value of testOnBorrow=true (tests the connection before used, and if it fails it is dropped from the pool and we try to get a new one instead). The only thing you need to do is to make sure you configure the validationQuery property to a non-null String, e.g. "SELECT 0" for MySQL database (here is a post about different validationQuery values per DB used).
score: 2
upvote count: 2
downvote count: 0
answers question: http://stackoverflow.com/q/527061
type: Answer

http://stackoverflow.com/comment/263933
has text: Note that it is failing in <init> not init() i.e. the problem is in the constructor
comment on: http://stackoverflow.com/q/441272
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/1268932
answers question: http://stackoverflow.com/q/587884
has comment: http://stackoverflow.com/comment/9648217
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/9648884
has body: Hsieh's hash is even better. I don't know of a java implementation - i'm writing one right now.
has comment: http://stackoverflow.com/comment/9619787
upvote count: 1
type: Answer

http://stackoverflow.com/a/28639152
has body: /** * Count file rows. * * @param file file * @return file row count * @throws IOException */ public static long getLineCount(File file) throws IOException { try (Stream&lt;String&gt; lines = Files.lines(file.toPath())) { return lines.count(); } } Tested on JDK8_u31. But indeed performance is slow compared to this method: /** * Count file rows. * * @param file file * @return file row count * @throws IOException */ public static long getLineCount(File file) throws IOException { try (BufferedInputStream is = new BufferedInputStream(new FileInputStream(file), 1024)) { byte[] c = new byte[1024]; boolean empty = true, lastEmpty = false; long count = 0; int read; while ((read = is.read(c)) != -1) { for (int i = 0; i &lt; read; i++) { if (c[i] == '\n') { count++; lastEmpty = true; } else if (lastEmpty) { lastEmpty = false; } } empty = false; } if (!empty) { if (count == 0) { count = 1; } else if (!lastEmpty) { count++; } } return count; } } Tested and very fast.
score: 5
has comment: http://stackoverflow.com/comment/45810300
has comment: http://stackoverflow.com/comment/68427257
upvote count: 5
has comment: http://stackoverflow.com/comment/45810250
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/45810171
answers question: http://stackoverflow.com/q/453018

http://stackoverflow.com/a/393057
downvote count: 0
has comment: http://stackoverflow.com/comment/5600030
score: 4
type: Answer
answers question: http://stackoverflow.com/q/390449
upvote count: 4
has comment: http://stackoverflow.com/comment/5600613
has body: As of Java 5, on Hotspot and other VMs that support it, you can use the Instrumentation interface to ask the VM the memory usage of a given object. It's fiddly but you can do it. In case you want to try this method, I've added a page to my web site on querying the memory size of a Java object using the Instrumentation framework. As a rough guide in Hotspot on 32 bit machines: objects use 8 bytes for "housekeeping" fields use what you'd expect them to use given their bit length (though booleans tend to be allocated an entire byte) object references use 4 bytes overall obejct size has a granularity of 8 bytes (i.e. if you have an object with 1 boolean field it will use 16 bytes; if you have an object with 8 booleans it will also use 16 bytes) There's nothing special about collections in terms of how the VM treats them. Their memory usage is the total of their internal fields plus -- if you're counting this -- the usage of each object they contain. You need to factor in things like the default array size of an ArrayList, and the fact that that size increases by 1.5 whenever the list gets full. But either asking the VM or using the above metrics, looking at the source code to the collections and "working it through" will essentially get you to the answer. If by "closure" you mean something like a Runnable or Callable, well again it's just a boring old object like any other. (N.B. They aren't really closures!!)

http://stackoverflow.com/comment/45420083
comment on: http://stackoverflow.com/a/5891326
has text: @AdamJensen, the class will be created/compiled at compile time, but instances will only be created if executed in the catch block.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/552003
answers question: http://stackoverflow.com/q/550919
type: Answer
upvote count: 1
score: 1
has body: My issue with switch statements is that in real world application there are rarely switch statements that exist in isolation. A lot of the code that required refactoring in my company's codebase would have entire classes riddled with multiple switch statements throughout such that you had to know of the existence of every single switch statement. Ultimately, the cleanest refactoring the entire system into a Strategy pattern with a Factory controlling the creation of the strategies based on the single remaining copy of the switch statement. Due to time constraints we didn't take it any farther because this served our needs. There was still a big giant switch statement, but there was only one, so adding additional strategies only required ipmlementing the interface and adding the creation step to the master switch statement.
downvote count: 0

http://stackoverflow.com/comment/270990
type: AnswerComment
type: Comment
has text: Sounds good, but I think I'll go with Charva, since that'll provide a more OO experience. Thanks for the suggestion.
comment on: http://stackoverflow.com/a/439807
score: 1

http://stackoverflow.com/a/511085
upvote count: 3
downvote count: 0
answers question: http://stackoverflow.com/q/511013
type: Answer
has body: In addition to some of the tips that have been give to you, as review the memory lacks and also start the JVM with more memory (-Xmx512M). Looks like you have a OutOfMemoryError cause your TopicParser is reading a line that probably is pretty big (and here is what you should avoid), you can use the FileReader (or, if the encoding is an issue, an InputStreamReader wrapping a FileInputStream). Use its read(char[]) method with a reasonably sized char[] array as a buffer. Also finally to investigate a little why is the OutOfMemoryError you can use -XX:+HeapDumpOnOutOfMemoryError Flag in the JVM to get a dump heap information to disk. Good luck!
score: 3

http://stackoverflow.com/comment/257679
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/434698
has text: @unwind: but that's pretty much the only part that's no longer relevant. Everything except the performance is unchanged since then.
score: 0

http://stackoverflow.com/a/583633
type: Answer
has body: Use a text (line) printer to print to file.
score: 0
answers question: http://stackoverflow.com/q/583615

http://stackoverflow.com/comment/365192
has text: See it this way: The fastest running + least lines of code is the "most efficient". Lesson learned: Don't waste time searching for a solution that is better "than the best". That leaves more time to learn the important things.
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/553409

http://stackoverflow.com/a/881843
type: Answer
answers question: http://stackoverflow.com/q/632716
score: 0
has body: I guess it is just too small. Try something higher, like 16m or 64m. Additionally the internal and the external size are different shoes. The heap will not be full all the time, so a less than Xmx is always possible, even a less than Xms in case the program just has been started. But externally, you will see that Xms amount of memory has been allocated.

http://stackoverflow.com/comment/45725071
comment on: http://stackoverflow.com/a/407297
score: 6
has text: @Antoops - yes, b is better for reasons that have nothing to do with the data type of the variable being declared. Why would it be different for Strings?
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/284738
score: 0
has text: I agree, although explicit casts should handle it in most cases, but it looks so ugly.
type: Comment
comment on: http://stackoverflow.com/a/466557
type: AnswerComment

http://stackoverflow.com/q/508723
has body: I'm creating a Java application that will do some processing then needs to display a message to give the user feedback. However, it appears to be incredibly slow - taking over two seconds to return. I stripped the source down to the apparent culprit, and here is the code used: package SwingPlay; import javax.swing.JFrame; public class Dialog { public static void main( String[] args ) { JFrame frame = new JFrame( "DialogDemo" ); } } I'm executing this from the command line with: java -classpath . SwingPlay.Dialog As you can see - I'm doing nothing but create a JFrame, not even displaying it. In case it is relevant, here is my java -version output: java version "1.6.0_11" Java(TM) SE Runtime Environment (build 1.6.0_11-b03) Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing) And this is (currently) running against Win XP SP2. So, first question: Why is it so slow? More importantly, I just want a simple message (GUI, not cmdline) to be displayed without delay - can anyone provide some code to do this? Update: A bit of background might be helpful: I am creating an application which will have many 'heads' (i.e. different user interfaces all using the same core classes to do the complex parts). I currently have a pure command line head which works fine - responds straight away. I will also have a standard application with a regular point &amp; click GUI, and don't foresee problems with this bit. What I am currently working on is a hybrid of these two - it will be launched from a Run box (or similar launcher), possibly with arguments, and only needs to respond with, effectively, a status message, that can be dismissed with a key press. This latter one is where the question is focused. Whilst I am not opposed to using my existing command line version with shell scripts (though didn't think it would be necessary!), the existing answers seem to suggest that things are not running as fast for me as they are for others - one example takes 1460ms for me, versus 70ms…
upvote count: 12
has answer: http://stackoverflow.com/a/509531
has answer: http://stackoverflow.com/a/508821
has answer: http://stackoverflow.com/a/508729
downvote count: 0
has title: Fastest way to create a Java message dialog (swing/awt/other)?
type: UnansweredQuestion
tagged with: swing
type: Question
has answer: http://stackoverflow.com/a/508822
has answer: http://stackoverflow.com/a/508771
tagged with: dialog
tagged with: java
score: 12
tagged with: user-interface
has answer: http://stackoverflow.com/a/509054
tagged with: awt
favorite count: 0
has answer: http://stackoverflow.com/a/508778
has answer: http://stackoverflow.com/a/508889
answer count: 10
has answer: http://stackoverflow.com/a/508845
has answer: http://stackoverflow.com/a/17373780

http://stackoverflow.com/a/460881
has body: Fractions represented with binary number types(i.e. double, float) cannot be accurately stored in those types. Double d = 13.3; BigDecimal bdNotOk = new BigDecimal(d); System.out.println("not ok: " + bdNotOk.toString()); BigDecimal bdNotOk2 = new BigDecimal(13.3); System.out.println("not ok2: " + bdNotOk2.toString()); double x = 13.3; BigDecimal ok = BigDecimal.valueOf(x); System.out.println("ok: " + ok.toString()); double y = 13.3; // pretty lame, constructor's behavior is different from valueOf static method BigDecimal bdNotOk3 = new BigDecimal(y); System.out.println("not ok3: " + bdNotOk3.toString()); BigDecimal ok2 = new BigDecimal("13.3"); System.out.println("ok2: " + ok2.toString()); Double e = 0.0; for(int i = 0; i &lt; 10; ++i) e = e + 0.1; // some fractions cannot be accurately represented with binary System.out.println("not ok4: " + e.toString()); // should be 1 BigDecimal notOk5 = BigDecimal.valueOf(e); System.out.println("not ok5: " + notOk5.toString()); // should be 1 /* * here are some fractions that can be represented exactly in binary: * 0.5 = 0.1 = 1 / 2 * 0.25 = 0.01 = 1 / 4 * 0.75 = 0.11 = 3 / 4 * 0.125 = 0.001 = 1 / 8 */ output: not ok: 13.300000000000000710542735760100185871124267578125 not ok2: 13.300000000000000710542735760100185871124267578125 ok: 13.3 not ok3: 13.300000000000000710542735760100185871124267578125 ok2: 13.3 not ok4: 0.9999999999999999 not ok5: 0.9999999999999999 Just use BigDecimal.valueOf(d) or new BigDecimal(s).
upvote count: 3
score: 3
downvote count: 0
answers question: http://stackoverflow.com/q/460755
type: Answer

http://stackoverflow.com/a/507658
answers question: http://stackoverflow.com/q/507602
has comment: http://stackoverflow.com/comment/10854631
upvote count: 1206
has comment: http://stackoverflow.com/comment/6986364
downvote count: 4
has comment: http://stackoverflow.com/comment/139654553
type: AcceptedAnswer
score: 1202
has comment: http://stackoverflow.com/comment/3023070
has comment: http://stackoverflow.com/comment/87815677
type: Answer
has comment: http://stackoverflow.com/comment/87752553
has comment: http://stackoverflow.com/comment/7111703
has comment: http://stackoverflow.com/comment/10856121
has comment: http://stackoverflow.com/comment/6769296
accepted answer of: http://stackoverflow.com/q/507602
has body: The instance initialiser is just syntactic sugar in this case, right? I don't see why you need an extra anonymous class just to initialize. And it won't work if the class being created is final. You can create an immutable map using a static initialiser too: public class Test { private static final Map&lt;Integer, String&gt; myMap; static { Map&lt;Integer, String&gt; aMap = ....; aMap.put(1, "one"); aMap.put(2, "two"); myMap = Collections.unmodifiableMap(aMap); } }
has comment: http://stackoverflow.com/comment/6971428

http://stackoverflow.com/comment/123372722
type: Comment
has text: @ChrisNitchie `a+b c` is encoded to `a%2Bb+c` with java's `URLEncoder` and to `a%2Bb%20c` with js' `encodeURIComponent`.
score: 2
comment on: http://stackoverflow.com/a/607403
type: AnswerComment

http://stackoverflow.com/a/10704593
downvote count: 0
score: 10
upvote count: 10
answers question: http://stackoverflow.com/q/469695
has body: Another late answer, but my benchmarking shows that Jetty's implementation of Base64 encoder is pretty fast. Not as fast as MiGBase64 but faster than iHarder Base64. import org.eclipse.jetty.util.B64Code; final String decoded = B64Code.decode(encoded, "UTF-8"); I also did some benchmarks: library | encode | decode ------------------+--------------+------------- 'MiGBase64' | 10146001.00 | 6426446.00 'Jetty B64Code' | 8846191.00 | 3101361.75 'iHarder Base64' | 3259590.50 | 2505280.00 'Commons-Codec' | 241318.04 | 255179.96 These are runs/sec so higher is better.
type: Answer

http://stackoverflow.com/comment/78561342
type: Comment
type: AnswerComment
has text: You forgot Cp037 (we have that one). You should suggest that the person verifies what characterset is being used.
comment on: http://stackoverflow.com/a/368632
score: 0

http://stackoverflow.com/comment/90752649
score: 0
type: Comment
comment on: http://stackoverflow.com/a/48241654
has text: There’s room for improvement. The ThreeTen Backport was developed by the original developers of java.time, though the Android adaptation is probably made by a third party. java.time comes out of the box from API level 26 (that’s fairly new, I believe).
type: AnswerComment

http://stackoverflow.com/comment/10118996
score: 0
type: AnswerComment
type: Comment
has text: yep it doesn't dim the variable again. ran into this yesterday and series of googling let to this.
comment on: http://stackoverflow.com/a/407305

http://stackoverflow.com/a/4480713
answers question: http://stackoverflow.com/q/504103
downvote count: 2
has body: http://opt.sourceforge.net/ Java Micro Benchmark - control tasks required to determine the comparative performance characteristics of the computer system on different platforms. Can be used to guide optimization decisions and to compare different Java implementations.
upvote count: 9
type: Answer
score: 7
has comment: http://stackoverflow.com/comment/12040121

http://stackoverflow.com/comment/403940
type: Comment
has text: I'm not sure what you are getting. RGB image can't be just saved to GIF, maybe you could use different kind of image?
type: AnswerComment
comment on: http://stackoverflow.com/a/592049
score: 0

http://stackoverflow.com/a/510940
has comment: http://stackoverflow.com/comment/325253
has comment: http://stackoverflow.com/comment/324921
answers question: http://stackoverflow.com/q/510462
has comment: http://stackoverflow.com/comment/324907
downvote count: 1
has comment: http://stackoverflow.com/comment/325254
has comment: http://stackoverflow.com/comment/40382219
has comment: http://stackoverflow.com/comment/328411
has comment: http://stackoverflow.com/comment/325317
upvote count: 36
has comment: http://stackoverflow.com/comment/324900
score: 35
has comment: http://stackoverflow.com/comment/70734276
has body: I did a bit of searching and found that if one is being pedantic then yes it might be considered useless...in particular situations...it depends on how time sensitive your requirements are... Check out this quote from the Java Sun site: The real-time clock and System.nanoTime() are both based on the same system call and thus the same clock. With Java RTS, all time-based APIs (for example, Timers, Periodic Threads, Deadline Monitoring, and so forth) are based on the high-resolution timer. And, together with real-time priorities, they can ensure that the appropriate code will be executed at the right time for real-time constraints. In contrast, ordinary Java SE APIs offer just a few methods capable of handling high-resolution times, with no guarantee of execution at a given time. Using System.nanoTime() between various points in the code to perform elapsed time measurements should always be accurate. Java also has a caveat for the nanoTime() method: This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time. The value returned represents nanoseconds since some fixed but arbitrary time (perhaps in the future, so values may be negative). This method provides nanosecond precision, but not necessarily nanosecond accuracy. No guarantees are made about how frequently values change. Differences in successive calls that span greater than approximately 292.3 years (263 nanoseconds) will not accurately compute elapsed time due to numerical overflow. It would seem that the only conclusion that can be drawn is that nanoTime() cannot be relied upon as an accurate value. As such, if you do not need to measure times that are mere nano seconds apart then this method is good enough even if the resulting returned value is negative. However, if you're needing higher precision, they appear to recommend that you use JAVA RTS. So to answer your question...no nanoTime() is not useless....its just not the most prudent method to us…
type: Answer

http://stackoverflow.com/a/60007016
type: Answer
downvote count: 0
score: 1
upvote count: 1
has body: ConcurrentHashMap was presented as alternative to Hashtable in Java 1.5 as part of concurrency package. With ConcurrentHashMap, you have a better choice not only if it can be safely used in the concurrent multi-threaded environment but also provides better performance than Hashtable and synchronizedMap. ConcurrentHashMap performs better because it locks a part of Map. It allows concurred read operations and the same time maintains integrity by synchronizing write operations. How ConcurrentHashMap is implemented ConcurrentHashMap was developed as alternative of Hashtable and support all functionality of Hashtable with additional ability, so called concurrency level. ConcurrentHashMap allows multiple readers to read simultaneously without using blocks. It becomes possible by separating Map to different parts and blocking only part of Map in updates. By default, concurrency level is 16, so Map is spitted to 16 parts and each part is managed by separated block. It means, that 16 threads can work with Map simultaneously, if they work with different parts of Map. It makes ConcurrentHashMap hight productive, and not to down thread-safety. If you are interested in some important features of ConcurrentHashMap and when you should use this realization of Map - I just put a link to a good article - How to use ConcurrentHashMap in Java
answers question: http://stackoverflow.com/q/510632

http://stackoverflow.com/comment/343891
type: AnswerComment
has text: i'd suggest limiting the rows you check if it is a large table. We do things where the model does not actually contain all the data, some is fetched on demand. If you try to look at 1,000,000 rows to calculate width, you'll page in a lot of data!
type: Comment
comment on: http://stackoverflow.com/a/530772
score: 0

http://stackoverflow.com/comment/1148342
type: QuestionComment
score: 2
comment on: http://stackoverflow.com/q/582126
has text: What about resumable uploads? That seems really important for me. Nobody likes to restart an upload that failed after a couple of hours.
type: Comment

http://stackoverflow.com/comment/246579
comment on: http://stackoverflow.com/a/420629
type: AnswerComment
score: 0
type: Comment
has text: I concur! but I can't find any java-friendly data acquisition hardware :(

http://stackoverflow.com/q/371495
has answer: http://stackoverflow.com/a/371688
type: Question
has answer: http://stackoverflow.com/a/371684
score: 10
answer count: 6
has answer: http://stackoverflow.com/a/371774
has answer: http://stackoverflow.com/a/13555806
downvote count: 0
has answer: http://stackoverflow.com/a/379743
tagged with: tomcat
favorite count: 0
has title: Analyze Tomcat Heap in detail on a production System
tagged with: heap-memory
type: UnansweredQuestion
tagged with: jmx
has body: Having analyzed a light-load web application running in tomcat, using JMX Console, it turns out the "PS Old Gen" is growing slowly but constant. It starts with 200MB and grows around 80MB/Hour. CPU is not an issue, it runs at 0-1% on average, but somewhere it leaks memory, so it will become unstable some days after deployment. How do i find out what objects are allocated on the heap? Are there any good tutorials or tools you know?
has answer: http://stackoverflow.com/a/423952
tagged with: java
has comment: http://stackoverflow.com/comment/4519244
upvote count: 10

http://stackoverflow.com/comment/359323
score: 0
type: Comment
type: QuestionComment
has text: I don't think it's a judgment call. First dividing by layer, then by functionality is definitely the way to go. I am updating my answer.
comment on: http://stackoverflow.com/q/533102

http://stackoverflow.com/comment/442707
type: QuestionComment
has text: How else do you expect Hibernate to populate your Entrada objects?
score: 0
comment on: http://stackoverflow.com/q/630054
type: Comment

http://stackoverflow.com/comment/17276701
score: 1
type: AnswerComment
has text: @artbristol: +1 but be careful will recursive equals: You can easily get caught in a loop when beans form cycles.
type: Comment
comment on: http://stackoverflow.com/a/472705

http://stackoverflow.com/a/29733268
has body: Eclim now supports a Java debugger. See http://eclim.org/vim/java/debug.html
upvote count: 2
score: 2
answers question: http://stackoverflow.com/q/545056
downvote count: 0
type: Answer

http://stackoverflow.com/q/619822
downvote count: 0
has answer: http://stackoverflow.com/a/17953236
tagged with: java
upvote count: 11
possible better answer: http://stackoverflow.com/a/5506298
has answer: http://stackoverflow.com/a/5506298
type: Question
has answer: http://stackoverflow.com/a/619981
tagged with: perl
has answer: http://stackoverflow.com/a/620054
favorite count: 0
has answer: http://stackoverflow.com/a/619835
has answer: http://stackoverflow.com/a/619836
answer count: 7
score: 11
has answer: http://stackoverflow.com/a/620202
type: AnsweredQuestion
has title: Is there a Perl implementation in Java?
has body: I am looking for Perl implementation in Java. Something like Jython is for Python. I found PLJava but it needs both JVM and Perl compiler installed. I need something which does not need a Perl compiler. I need to run some Perl code in a Java class. UPDATES: I figured out that PLJAVA is what I need. Does anybody know some tutorial? Has anybody played with the Inline::Java module. I also could not install Inline::Java.
accepted answer: http://stackoverflow.com/a/619981

http://stackoverflow.com/q/546874
answer count: 5
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/358859
has answer: http://stackoverflow.com/a/546895
downvote count: 4
has comment: http://stackoverflow.com/comment/358680
has answer: http://stackoverflow.com/a/547289
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/358700
tagged with: ruby-on-rails
has comment: http://stackoverflow.com/comment/358685
has answer: http://stackoverflow.com/a/546910
type: Question
has title: What are your experiences with development frameworks and tools for building web applications?
has comment: http://stackoverflow.com/comment/358712
has answer: http://stackoverflow.com/a/546971
has comment: http://stackoverflow.com/comment/358688
has body: I've been building web sites off an on for about 10 years. 2 years ago I started using ASP.Net. I'm working on 2 projects right now, one using ASP.Net MVC and the other using Java / JSF / Spring / Hibernate. I've also used other frameworks (cgi/perl, php, ASP, jsp, jsf). What do you think is the most productive programming environment for building web applications? I have not used other frameworks such as Ruby on Rails, Glass Fish, etc. Are there any frameworks that I might be missing and should look at? I'd really be interested in hearing opinions from someone with Ruby on Rails experience.
has answer: http://stackoverflow.com/a/546913
tagged with: asp.net
favorite count: 0
upvote count: 5

http://stackoverflow.com/q/435971
has body: I am working on a Java project using Netbeans for the first time. I would like to use Netbeans 6.5 to create a jar including about 50 text files. Is there a simple way to do this?
type: Question
answer count: 2
score: 2
downvote count: 0
has answer: http://stackoverflow.com/a/435999
favorite count: 0
possible better answer: http://stackoverflow.com/a/435987
has answer: http://stackoverflow.com/a/435987
tagged with: netbeans6.5
type: AnsweredQuestion
upvote count: 2
has title: How do you add files to a jar using Netbeans 6.5?
tagged with: java
accepted answer: http://stackoverflow.com/a/435999

http://stackoverflow.com/a/570232
has body: You could try using an online service like HeyWatch to convert your video. Never used it but they claim "transparent upload, send videos transparently from your website" Not a java solution, but you wouldn't have to worry about what OS your web application is on. If OS wasn't an issue I agree with the answer theBadDawg gave. I don't know of and have had not any luck finding a pure java solution.
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/502753
score: 1
upvote count: 1

http://stackoverflow.com/comment/421508
score: 0
type: AnswerComment
has text: move seems to take deltas, not absolute values, your ball is likely to fly off the edge of the universe :-)
comment on: http://stackoverflow.com/a/609038
type: Comment

http://stackoverflow.com/q/370710
tagged with: locking
score: 4
possible better answer: http://stackoverflow.com/a/370806
answer count: 2
downvote count: 0
tagged with: jvm
favorite count: 0
has body: Apologies for the long post, but I wonder if I could get some more eyeballs on this before I submit a bug report to Sun. JVM: 6u11 O/S: Windows XP SP3 Hardware: AMD Athlon 64 X2 4600+ @ 2.41GHz, with 3.25 GB RAM. I believe I have encountered a fault in the JVM where no thread is given a monitor. In the following thread traces, the monitor &lt;0x12a8f9f8&gt; was acquired by RelayedMessages-0000000001, which ended up waiting on it; that thread was subsequently notified. However, even though all of the threads listed are contending for the monitor, none are getting it. I promise the thread dump is complete for every thread which refers to monitor &lt;0x12a8f9f8&gt;. The dump was obtained using Java VisualVM, three times over a period of 16 hours, and shown to be consistent each time (these threads were unchanged). Does anyone disagree with my assessment that the JVM is failing to deliver the monitor to any of the eligible threads, when it should deliver it to one of them? "RelayedMessages-0000000001" daemon prio=6 tid=0x03694400 nid=0x1750 waiting for monitor entry [0x05e1f000..0x05e1fc94] java.lang.Thread.State: BLOCKED (on object monitor) at java.lang.Object.wait(Native Method) at com.companyremoved.thd.EzWaiter.ezWait(EzWaiter.java:249) - locked &lt;0x12a8f9f8&gt; (a com.companyremoved.system.coms.ComsSender) at com.companyremoved.ioc.IsolatedObject.waitWithinMessage(IsolatedObject.java:352) - locked &lt;0x12a8f9f8&gt; (a com.companyremoved.system.coms.ComsSender) at com.companyremoved.system.coms.ComsSender.waitForAvailablePipe(ComsSender.java:219) at com.companyremoved.system.coms.ComsSender.sendObject(ComsSender.java:185) at com.companyremoved.system.coms.ComsSender.processIocMessage(ComsSender.java:98) at com.companyremoved.ioc.IsolatedObject.deliver(IsolatedObject.java:311) - locked &lt;0x12a8f9f8&gt; (a com.companyremoved.system.coms.ComsSender) at com.companyremoved.ioc.IsolatedObject.iocMessage(IsolatedObject.java:265) at com.companyremoved.ioc.IocTarget.ioc…
has answer: http://stackoverflow.com/a/370806
has answer: http://stackoverflow.com/a/410697
accepted answer: http://stackoverflow.com/a/410697
has comment: http://stackoverflow.com/comment/200122
upvote count: 4
has comment: http://stackoverflow.com/comment/201037
type: AnsweredQuestion
has title: Java 6 JVM Hang
tagged with: java
type: Question

http://stackoverflow.com/q/494457
favorite count: 0
has answer: http://stackoverflow.com/a/1183208
has body: I am running JBOSS server by deploying my own classes.Now i started doing some operations on my application.Now i would like to know the memory used by my application before and after performing operations.please support me in this regard
has answer: http://stackoverflow.com/a/494479
score: 2
upvote count: 2
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/494476
type: Question
has title: how to get the memory used by a java process in java
tagged with: java
tagged with: memory
answer count: 3
downvote count: 0

http://stackoverflow.com/comment/324550
comment on: http://stackoverflow.com/a/462149
type: AnswerComment
score: 0
type: Comment
has text: one of those answers I wish I could give more than one point for

currency
tag name: currency
type: Tag
tags question: http://stackoverflow.com/q/611732
tags question: http://stackoverflow.com/q/522855

http://stackoverflow.com/q/512577
type: Question
score: 5
has body: When I write setters for instance methods, I use this to disambiguate between the instance variable and the parameter: public void setValue(int value) { this.value = value; } So, what do I do when value is a class variable (static) instead of a member of an instance? private static int value = 7; public static void setValue(int value) { value = value; // compile fails; ambiguous }
tagged with: naming-conventions
upvote count: 5
answer count: 1
downvote count: 0
has answer: http://stackoverflow.com/a/512585
has comment: http://stackoverflow.com/comment/326378
favorite count: 0
has title: What name do you use for the parameter in a static variable setter method?
accepted answer: http://stackoverflow.com/a/512585
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/a/14189432
has comment: http://stackoverflow.com/comment/58829863
answers question: http://stackoverflow.com/q/501653
score: 0
type: Answer
has body: Does Autoboxing and Unboxing can be applied in the following case ? Long one = 10; long two = 15; Long three = 20; if(one == three) //will this be unboxed or do we need to put a explicit //condition like if(one.intValue() == three.intValue()) System.out.println("Equal"); else System.out.println("Not Equal"); if(one == two) //will this be unboxed or do we need to put a explicit //condition like if(one.intValue() == two) System.out.println("Equal"); else System.out.println("Not Equal");

http://stackoverflow.com/comment/445372
score: 0
type: Comment
has text: Polynomials can all be expanded to a form involving no parenthetical expressions. Paren-matching is great fun, though, so you shouldn't limit yourself to expanded form only.
type: AnswerComment
comment on: http://stackoverflow.com/a/632237

http://stackoverflow.com/q/612656
tagged with: spring
tagged with: executorservice
type: AnsweredQuestion
type: Question
has answer: http://stackoverflow.com/a/612686
has answer: http://stackoverflow.com/a/612682
upvote count: 5
tagged with: java
accepted answer: http://stackoverflow.com/a/612686
has answer: http://stackoverflow.com/a/620101
possible better answer: http://stackoverflow.com/a/612682
score: 5
downvote count: 0
has body: I am looking for a generic asynchronous Java job execution framework that could handle Callables or Runnables. It would be similar to java.util.concurrent.ExecutorService, (and possibly wrap ExecutorService), but it would also have the following features: The ability to persist jobs to a database in case the application goes down while a job is being serviced, and be able to restart the unfinished jobs. (I understand that my job may have to implement Serializable which is OK.) Work with UUIDs to enable the client to obtain job tokens and inquire about job status. (Under the hood this information would be persisted to a database, as well.) I have started working on this myself by building around ExecutorService, but I would prefer an out of the box, open source solution, if one exists. Something that could work within the Spring Framework would be ideal.
favorite count: 0
has title: Searching for Generic Asynchronous Java Job Execution Framework / Library
answer count: 5
has answer: http://stackoverflow.com/a/613443
has answer: http://stackoverflow.com/a/612691

http://stackoverflow.com/a/636156
upvote count: 1
has comment: http://stackoverflow.com/comment/449564
type: Answer
downvote count: 0
has body: What about : Map&lt;String, String> s = Collections.emptyMap();
score: 1
answers question: http://stackoverflow.com/q/636126

http://stackoverflow.com/comment/37809518
comment on: http://stackoverflow.com/a/582500
type: AnswerComment
type: Comment
has text: Those top 4 code blocks are gold. Exactly what I was looking for. Thank you.
score: 11

http://stackoverflow.com/a/558727
type: Answer
has body: Try to run Powermock without Eclipse. Does the same symptoms occur? Mock veeery small units. Is the performance loss as high as before?
answers question: http://stackoverflow.com/q/554641
score: 0

http://stackoverflow.com/a/2949496
downvote count: 3
answers question: http://stackoverflow.com/q/385532
upvote count: 24
has comment: http://stackoverflow.com/comment/66403444
has comment: http://stackoverflow.com/comment/66402144
has comment: http://stackoverflow.com/comment/66404590
has body: In an EE6/CDI/JPA project, a test src/test/resources/META-INF/persistence.xml is picked up just fine without any further configuration. When using JPA in Spring, the following works in the application context used for testing: Here, /src/test/resources/META-INF/persistence.xml (copied into target/test-classes) would be preferred over /src/main/resources/META-INF/persistence.xml (copied into target/classes). Unfortunately, the location of the persistence.xml file also determines the so-called "persistence unit's root", which then determines which classes are scanned for @Entity annotations. So, using /src/test/resources/META-INF/persistence.xml would scan classes in target/test-classes, not classes in target/classes (where the classes that need to be tested would live). Hence, for testing, one would need to explicitly add <class> entries to persistence.xml, to avoid java.lang.IllegalArgumentException: Not an entity: class .... The need for <class> entries can be avoided by using a different file name, like persistence-TEST.xml, and put that file in the very same folder as the regular persistence.xml file. The Spring context from your test folder can then just refer to , and Spring will find it for you in src/main. As an alternative, one might be able to keep persistence.xml the same for the actual application and the tests, and only define one in src/main. Most configuration such as the drivers, dialect and optional credentials can be done in the Spring context instead. Also settings such as hibernate.hbm2ddl.auto can be passed in the context: #{myConfig['db.ddl']} #{myConfig['db.showSql']} true
type: Answer
has comment: http://stackoverflow.com/comment/66404074
score: 21

http://stackoverflow.com/a/17373780
upvote count: 1
score: 1
has body: Since you're interested in speeding this up, and since most of the overhead seems to be JVM startup overhead, check out Nailgun which aims to address slow JVM startup by keeping a JVM running in the background all the time. In your case, after one run the Swing library too will end up being cached (and hopefully after a few more runs JITed too), further reducing the overhead. However this approach will lead to increased memory usage due to the background JVM and also cause other problems since it may not be straightforward to determine when to shut it down.
downvote count: 0
answers question: http://stackoverflow.com/q/508723
type: Answer

http://stackoverflow.com/a/614196
type: Answer
upvote count: 4
has comment: http://stackoverflow.com/comment/740588
score: 4
has body: Script# has already been mentioned. It hasn't been updated since August 2008. Milescript is another, but also has seen very little for 6 months. Extsharp for the Ext library. Adds Ext support for Script# Javascript compiler to Java (going the wrong way for you) Java to script Eclipse plugin My issues with Script# (a known issue) is it doesn't support jQuery yet. However it comes with a very lightweight library to tie in with the .NET framework, in Nikhil's sscorlib.js file and ssfx.core.js files. And also has support for lots of other Javascript APIs (mostly Microsoft, seeing as he is in the ASP.NET team). I'd love to see a Script# extension for jQuery (I'm thinking about writing it if it's easy enough). As it stands, most don't provide full compilation yet but they're certainly getting there. Update: I wrote a small extension to enable JQuery support Script# a few months ago. The project can be found here.
downvote count: 0
answers question: http://stackoverflow.com/q/580509

http://stackoverflow.com/a/494400
accepted answer of: http://stackoverflow.com/q/468424
upvote count: 1
type: AcceptedAnswer
type: Answer
downvote count: 0
has body: I'm under the impression that, as long as you set yourself up for notifications, your code will be called for all changes to the DOM whether done on page load or dynamically by Javascript following the page load. I would initially set up an object (X) implementing the DocumentNotificationListener interface and log a message for every method called. Then set that up as a listener with Y.addDocumentNotificationListener(X) [where Y is your HTMLDocumentImpl object] and load up your page to see which methods are actually called. Worst case is that you'll have to re-render your HTML page on every method call, but you should be able to optimize most of them. For example, changing colors of a node (DOM object), which results in the X.lookInvalidated(...) being called, wouldn't require re-rendering of the whole page as the node size doesn't change.
answers question: http://stackoverflow.com/q/468424
score: 1

http://stackoverflow.com/a/362795
answers question: http://stackoverflow.com/q/362770
type: Answer
has body: When you extend AbstractList, MyList is of 'type' List already, so there is no need to explicityly stat (or implement) the interface.
score: 0

http://stackoverflow.com/a/384006
downvote count: 0
answers question: http://stackoverflow.com/q/383920
score: 5
upvote count: 5
type: Answer
has body: I think @cletus's summary is pretty good. I did want to mention that Terracotta provides a lot more than just a distributed cache in the form of a map. It clusters Java heap and synchronization primitives, turning a concurrent Java program into a distributed Java program. You can do caching with it (including using distributed versions of open source cache libs) or a bunch of other stuff. For work distribution, there are some extra libs written on top of Terracotta, in particular the tim-pipes (for messages) and tim-masterworker (for Master-Worker style distribution) are great abstractions on top of Terracotta. This library is on the Terracotta Forge: http://forge.terracotta.org/releases/projects/tim-messaging/ This recently added page may add a bit of additional info in comparison to some other potential data technologies: http://www.terracotta.org/web/display/orgsite/Terracotta+vs+Alternate+Technologies

http://stackoverflow.com/a/637468
type: Answer
answers question: http://stackoverflow.com/q/637100
has body: Just in case these small changes make a difference, try this: public static ByteBuffer getAsByteArray(URL url) throws IOException { URLConnection connection = url.openConnection(); // Since you get a URLConnection, use it to get the InputStream InputStream in = connection.getInputStream(); // Now that the InputStream is open, get the content length int contentLength = connection.getContentLength(); // To avoid having to resize the array over and over and over as // bytes are written to the array, provide an accurate estimate of // the ultimate size of the byte array ByteArrayOutputStream tmpOut; if (contentLength != -1) { tmpOut = new ByteArrayOutputStream(contentLength); } else { tmpOut = new ByteArrayOutputStream(16384); // Pick some appropriate size } byte[] buf = new byte[512]; while (true) { int len = in.read(buf); if (len == -1) { break; } tmpOut.write(buf, 0, len); } in.close(); tmpOut.close(); // No effect, but good to do anyway to keep the metaphor alive byte[] array = tmpOut.toByteArray(); //Lines below used to test if file is corrupt //FileOutputStream fos = new FileOutputStream("C:\\abc.pdf"); //fos.write(array); //fos.close(); return ByteBuffer.wrap(array); } You forgot to close fos which may result in that file being shorter if your application is still running or is abruptly terminated. Also, I added creating the ByteArrayOutputStream with the appropriate initial size. (Otherwise Java will have to repeatedly allocate a new array and copy, allocate a new array and copy, which is expensive.) Replace the value 16384 with a more appropriate value. 16k is probably small for a PDF, but I don't know how but the "average" size is that you expect to download. Since you use toByteArray() twice (even though one is in diagnostic code), I assigned that to a variable. Finally, although it shouldn't make any difference, when you are wrapping the entire array in a ByteBuffer, you only need to supply the byte array itself. Supplying the offset 0 and the length is redu…
score: 12
upvote count: 12
downvote count: 0

http://stackoverflow.com/q/538579
has answer: http://stackoverflow.com/a/538588
downvote count: 0
tagged with: .net
has answer: http://stackoverflow.com/a/538646
favorite count: 0
score: 47
accepted answer: http://stackoverflow.com/a/545348
has answer: http://stackoverflow.com/a/538890
tagged with: regex
has answer: http://stackoverflow.com/a/538709
possible better answer: http://stackoverflow.com/a/538890
tagged with: c#
type: AnsweredQuestion
has body: Both languages claim to use Perl style regular expressions. If I have one language test a regular expression for validity, will it work in the other? Where do the regular expression syntaxes differ? The use case here is a C# (.NET) UI talking to an eventual Java back end implementation that will use the regex to match data. Note that I only need to worry about matching, not about extracting portions of the matched data.
has answer: http://stackoverflow.com/a/545348
tagged with: java
has title: Are Java and C# regular expressions compatible?
answer count: 6
has answer: http://stackoverflow.com/a/42525361
type: Question
upvote count: 47

date
tags question: http://stackoverflow.com/q/428918
tags question: http://stackoverflow.com/q/460293
tag name: date
tags question: http://stackoverflow.com/q/383783
tags question: http://stackoverflow.com/q/635935
tags question: http://stackoverflow.com/q/453388
tags question: http://stackoverflow.com/q/370852
tags question: http://stackoverflow.com/q/380626
tags question: http://stackoverflow.com/q/412435
tags question: http://stackoverflow.com/q/492055
type: Tag
tags question: http://stackoverflow.com/q/590385
tags question: http://stackoverflow.com/q/601036
tags question: http://stackoverflow.com/q/530012
tags question: http://stackoverflow.com/q/567659
tags question: http://stackoverflow.com/q/535004
tags question: http://stackoverflow.com/q/494180
tags question: http://stackoverflow.com/q/460423
tags question: http://stackoverflow.com/q/589870
tags question: http://stackoverflow.com/q/624137
tags question: http://stackoverflow.com/q/424522
tags question: http://stackoverflow.com/q/427726
tags question: http://stackoverflow.com/q/368094

http://stackoverflow.com/comment/250173
type: Comment
has text: Also, if the file is opened in text mode, the native line endings will be converted to simply \n (at least on Windows; I think it's part of the C standard and thus used most everywhere)
comment on: http://stackoverflow.com/a/426404
type: AnswerComment
score: 0

http://stackoverflow.com/comment/284588
comment on: http://stackoverflow.com/a/466334
type: AnswerComment
score: 5
has text: good example. I think I'd chalk this up more generally as "composition of atomic operations is not atomic". (See volatile field++ for another simple example)
type: Comment

http://stackoverflow.com/a/13091259
upvote count: 7
has comment: http://stackoverflow.com/comment/80663743
type: Answer
downvote count: 0
score: 7
answers question: http://stackoverflow.com/q/415953
has body: For what it's worth, I stumbled upon this because I want to synthesize GUIDs from a natural key for a program that will install COM components; I want to syhthesize so as not to manage GUID lifecycle. I'll use MD5 and then use the UUID class to get a string out of it. (http://stackoverflow.com/questions/2190890/how-can-i-generate-guid-for-a-string-values/12867439 raises this issue). In any case, java.util.UUID can get you a nice String from the MD5 bytes. return UUID.nameUUIDFromBytes(md5Bytes).toString();

http://stackoverflow.com/a/790167
score: 14
has body: For the auto-reconnect issue with DBCP, has any tried using the following 2 configuration parameters? validationQuery="Some Query" testOnBorrow=true
answers question: http://stackoverflow.com/q/520585
has comment: http://stackoverflow.com/comment/9491209
downvote count: 1
upvote count: 15
type: Answer

http://stackoverflow.com/comment/314496
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/498764
has text: for(int x : z) {...} is not legal Java.
score: 0

http://stackoverflow.com/a/576916
score: 6
has body: You need to take copy of the HashMap, otherwise it looks like you are just storing the same Map over and over again, which of course gets overwritten. Use this line: polledPrice.put(pollNumber, new HashMap(Price.getPricesMap())); As the simplest fix.
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/388874
accepted answer of: http://stackoverflow.com/q/576912
answers question: http://stackoverflow.com/q/576912
type: Answer
upvote count: 6

http://stackoverflow.com/q/577280
type: Question
accepted answer: http://stackoverflow.com/a/577300
has body: I have problems with class loaders. Sometimes it works, sometimes it doesn't work. When I started, I have tested this works but not from *.jar: URL url = AcAnalyzer.class.getResource("../stuff/resource"); // and this works even from jar file: URL url = Acnalyzer.class.getResource("/stuff/resource"); URL url = AcAnalyzer.class.getClassLoader().getResource("stuff/resource"); // But I got into the problem with tomcat..when I need to deploy it into the tomcat I had to do this: URL url = Thread.currentThread().getContextClassLoader().getResource("something.xml"); where something.xml has to be in WEB-INF/classes/ ... url.getFile(); The problem is that most of the time it has to work within and not within jar at the same time. Now I have test where my class is getting resource, and the jar file is used in some project deployed under the tomcat.. and somehow it doesn't want to work anymore: I'm bit puzzled about class loaders. How to get this resource? And and the same time have working test. URL url = Thread.currentThread().getContextClassLoader().getResource("com/st/resource"); FileInputStream inputStream = new FileInputStream(url.getFile()); java.io.FileNotFoundException: file:/home/aaa/.m2/repository/com/st/module-1.1-SNAPSHOT.jar!/com/st/resource (No such file or directory)
answer count: 1
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/577300
has title: class loader: java.io.FileNotFoundException: file:/home/aaa/.m2/repository/com/st/module-1.1-SNAPSHOT.jar!/com/st/resource (No such file or directory)
tagged with: java
score: 0

http://stackoverflow.com/comment/88968710
comment on: http://stackoverflow.com/a/848719
has text: In the readMe file, I see "To run the java application, you can use the runJavaClient.cmd command file. This sets up the necessary classpath and path. You can run the .NET version without any extra setup." Couldn't locate the "runJavaClient.cmd" file. Can you please help me with this?
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/393302
score: 0
type: AnswerComment
type: Comment
has text: @jorgetown: If you require unpredictability, you could simply use sequential integer offsets into a precalculated table of negative "random numbers."
comment on: http://stackoverflow.com/a/579946

http://stackoverflow.com/comment/132554951
score: 0
comment on: http://stackoverflow.com/a/609879
type: Comment
has text: This is not at all a bad idea, in fact, it is the optimal solution. Using the enum constant's name rather than the ordinal has the drawback **that the name cannot change down the line**. In either case, your hypothetical situation requires that developers be made aware of how the system works. Using the ordinal in the URL, however, is much shorter (assuming enum constants are descriptive).
type: AnswerComment

http://stackoverflow.com/a/610674
has comment: http://stackoverflow.com/comment/73128781
has comment: http://stackoverflow.com/comment/73131098
downvote count: 0
has comment: http://stackoverflow.com/comment/424417
accepted answer of: http://stackoverflow.com/q/610458
has comment: http://stackoverflow.com/comment/85677133
has comment: http://stackoverflow.com/comment/73127097
has comment: http://stackoverflow.com/comment/73126382
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/73126674
has comment: http://stackoverflow.com/comment/73129499
has comment: http://stackoverflow.com/comment/425855
has comment: http://stackoverflow.com/comment/73130697
score: 82
type: Answer
has comment: http://stackoverflow.com/comment/424500
has comment: http://stackoverflow.com/comment/73125942
has body: Basically I believe the Java designers made a mistake when they designed the language, and it's too late to fix it due to the compatibility issues involved. Yes, it can lead to very misleading code. Yes, you should avoid it. Yes, you should make sure your IDE is configured to treat it as an error, IMO. Should you ever design a language yourself, bear it in mind as an example of the kind of thing to avoid :) Just to respond to DJClayworth's point, here's what's allowed in C#: public class Foo { public static void Bar() { } } public class Abc { public void Test() { // Static methods in the same class and base classes // (and outer classes) are available, with no // qualification Def(); // Static methods in other classes are available via // the class name Foo.Bar(); Abc abc = new Abc(); // This would *not* be legal. It being legal has no benefit, // and just allows misleading code // abc.Def(); } public static void Def() { } } Why do I think it's misleading? Because if I look at code someVariable.SomeMethod() I expect it to use the value of someVariable. If SomeMethod() is a static method, that expectation is invalid; the code is tricking me. How can that possibly be a good thing? Bizarrely enough, Java won't let you use a potentially uninitialized variable to call a static method, despite the fact that the only information it's going to use is the declared type of the variable. It's an inconsistent and unhelpful mess. Why allow it? EDIT: This edit is a response to Clayton's answer, which claims it allows inheritance for static methods. It doesn't. Static methods just aren't polymorphic. Here's a short but complete program to demonstrate that: class Base { static void foo() { System.out.println("Base.foo()"); } } class Derived extends Base { static void foo() { System.out.println("Derived.foo()"); } } public class Test { public static void main(String[] args) { Base b = new Derived(); b.foo(); // Prints "Base.foo()" b = null; b.foo(); // Still prints "Base.foo()" } } …
has comment: http://stackoverflow.com/comment/73128524
upvote count: 82
answers question: http://stackoverflow.com/q/610458

http://stackoverflow.com/comment/56866272
has text: @jpimmel How is the Grails Technology now in 2016 ?
comment on: http://stackoverflow.com/a/397308
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/68281088
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/484038
has text: Link-only answers are not sufficient for Stack Overflow. Link-rot may kill the other source.
score: 0

http://stackoverflow.com/a/368246
downvote count: 0
answers question: http://stackoverflow.com/q/368194
has body: You need to add the child to the JFrame's content pane instead: frame.getContentPane().add(comp); If you add your new component to JFrame directly, your code above never get's to it because you are only enumerating the components under frame.getContentPane().
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/q/521305
has answer: http://stackoverflow.com/a/521371
has answer: http://stackoverflow.com/a/521902
has body: I want to know why I should learn C#? What features does C# have that Java does not?
score: 7
tagged with: java
has answer: http://stackoverflow.com/a/522668
downvote count: 5
possible better answer: http://stackoverflow.com/a/521328
has answer: http://stackoverflow.com/a/521328
type: Question
has answer: http://stackoverflow.com/a/522230
has title: Why should I learn C#?
upvote count: 12
has answer: http://stackoverflow.com/a/522950
has answer: http://stackoverflow.com/a/521431
has answer: http://stackoverflow.com/a/522979
has answer: http://stackoverflow.com/a/521932
has answer: http://stackoverflow.com/a/521337
answer count: 19
has answer: http://stackoverflow.com/a/521370
has answer: http://stackoverflow.com/a/521917
has comment: http://stackoverflow.com/comment/71107557
has answer: http://stackoverflow.com/a/521348
has answer: http://stackoverflow.com/a/41964063
has answer: http://stackoverflow.com/a/521387
favorite count: 0
has answer: http://stackoverflow.com/a/522514
has answer: http://stackoverflow.com/a/521373
accepted answer: http://stackoverflow.com/a/521337
has answer: http://stackoverflow.com/a/521336
type: AnsweredQuestion
tagged with: c#
has answer: http://stackoverflow.com/a/521346

http://stackoverflow.com/a/8332975
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/371538
downvote count: 0
score: 1
has body: Even though this is an old post, the topic is still relevant. Hence, I want to share an interesting article and nice approach to solving most of the issues mentioned in the question: http://blog.codecentric.de/en/2011/04/android-persistence-accelerated-small-inhouse-orm/ Hope anyone finds this as useful as myself!

http://stackoverflow.com/comment/389612
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/577589
has text: +1 I really don't understand why this answer was so terrible

http://stackoverflow.com/a/397967
has body: If you don't fear an explosion in the number of classes, you can extend the IllegalArgumentException for this situation. public class InvalidInstance extends IllegalArgumentException{ private String[] parameter; public InvalidInstance (String[] param){ this.parameter = param; } public String getMessage() String msg = "YOUR_MESSAGE"; /* I think a string as "The currente object is invalid for parameter "+cycle for over parameter;*/ msg += super.geTMessage(); return msg; } public Constructor(parameter1,...){ String[] param = new String[number_parameters] if... throws new InvalidInstance(param); } In this way, you can log all the parameters what run the exception. This code isn't very beautiful to read: you can use if you prefer the very structured code. A simple IllegalArgumentException is more common :)
score: 0
type: Answer
answers question: http://stackoverflow.com/q/397581

http://stackoverflow.com/q/522158
type: Question
score: 3
tagged with: javascript
has answer: http://stackoverflow.com/a/522745
upvote count: 3
favorite count: 0
possible better answer: http://stackoverflow.com/a/522183
has answer: http://stackoverflow.com/a/522183
answer count: 4
has body: We have an ages old Java applet that we want to move forward to a newer version of Java (5 or 6), however until today we've always supported people using Java VMs as far back as version 1.1 (specifically for those still using the Microsoft VM) As part of the upgrade, we'd like to be able to serve a web page to people using out-of-date VMs telling them which versions we now support and where they can download them from. Ideally we want to do this without having to serve a Java 1.1 applet first just to determine the JVM version. Answers to either of the following (with code samples if possible) would be appreciated: Question 1: is it possible to determine the JVM in a script on the server using information from the HTTP headers? Question 2: is it possible to determine the information on the client using just JavaScript?
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/522955
tagged with: java
has title: Is it possible to obtain a web-browser's Java VM without using an applet?
has answer: http://stackoverflow.com/a/522956
accepted answer: http://stackoverflow.com/a/522956

http://stackoverflow.com/comment/5707104
has text: There is an error in your code, the first line of the while block must be like this: `int end = itemsRemaining >= maxListSize ? (start + maxListSize) : **(start + itemsRemaining)**;`
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2713707
score: 1

http://stackoverflow.com/a/545741
has comment: http://stackoverflow.com/comment/410072
accepted answer of: http://stackoverflow.com/q/545705
upvote count: 1
answers question: http://stackoverflow.com/q/545705
downvote count: 0
type: AcceptedAnswer
score: 1
type: Answer
has comment: http://stackoverflow.com/comment/357868
has body: We usually translate the xsd to Java objects with jaxb or some other binding mechanism (of which you have several in axis2). Those generate objects exactly like you have shown: that is, all attributes in the choices are there and you don't see anything that indicates that only one of them can be present. If you are translating the stuff back into xml, this would be only noticed if you switch on validation. There is no problem with choices if you aware that you shouldn't set both variants simultaneously in Java - the result can sometimes even be that none of them makes it into the generated XML.

http://stackoverflow.com/a/434427
answers question: http://stackoverflow.com/q/434408
score: 0
type: Answer
has body: Remember that characters in Java use a 16 bit Unicode character. The original System.in etc needed to be compatible with the environments which supported Java, which (back then at the Dawn of Time) often didn't support Unicode. That, along with the annoyingly disparate treatment of line ends, meant that byte streams were the only type that had the same semantics no matter what platform.

http://stackoverflow.com/comment/740588
comment on: http://stackoverflow.com/a/614196
has text: Last time I went to the Script# site, I saw that jQuery is on the roadmap for the next release of Script# (due some time in 2009).
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/50530128
score: 3
downvote count: 0
has body: Talking about unit tests: most people use static imports for the various static methods that mocking frameworks provide, such as when() or verify(). import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; And of course, when using the one and only assert you should be using assertThat() it comes in handy to statically import the required hamcrest matchers, as in: import static org.hamcrest.Matchers.*;
upvote count: 3
answers question: http://stackoverflow.com/q/420791
type: Answer

http://stackoverflow.com/comment/90684458
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/51863006
score: 1
has text: _Your scientists were so preoccupied with whether or not they could, they didn’t stop to think if they should. Please don't actually do this... :P_

http://stackoverflow.com/comment/423454
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/610976
has text: Technically they don't really have variables at all, just parameters to the functions being called, right?
score: 0

http://stackoverflow.com/comment/34980762
score: 2
has text: it does not work with bytes obtained from AES algorithm
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/4265472

http://stackoverflow.com/a/680058
has comment: http://stackoverflow.com/comment/511770
answers question: http://stackoverflow.com/q/363805
type: Answer
has body: Check out http://www.numiton.com
has comment: http://stackoverflow.com/comment/66416288
score: 2
downvote count: 0
upvote count: 2

http://stackoverflow.com/comment/412221
score: 0
has text: The OP said: I want to open the terminal (command prompt), so they don't want a terminal emulator - but I agree about the /usr/bin/sh (and so have editted)
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/599049

http://stackoverflow.com/comment/213019
comment on: http://stackoverflow.com/q/385332
score: 0
type: Comment
type: QuestionComment
has text: I'm not personally offended, but that title is a little coarse, don't you think? How about you edit it to something a little polite.

http://stackoverflow.com/a/499037
upvote count: 4
downvote count: 0
has body: If you don't know the encoding of your data, it is not so easy to determine, but you could try to use a library to guess it. Also, there is a similar question.
answers question: http://stackoverflow.com/q/499010
type: Answer
score: 4

http://stackoverflow.com/a/1273593
score: 7
has body: You can read about the advantages of using Wicket in the free first chapter of Wicket In Action: http://www.manning.com/dashorst/ In short, Wicket is a great framework when the application you're developing is relatively complex, you want it to be maintainable, being able to scale the team and take advantage of reuse. Object oriented programming proved to be a very useful paradigm for programming UIs, but unfortunately, most Java frameworks for developing web applications, including Spring MVC, only support a very procedural programming model where they tag the term MVC on to make it sound cool (but in fact, since the granularity they support are request/ response roundtrips rather than self contained widgets, MVC is really misleading). The DI part of Spring is great, and is something you can easily use together with Wicket.
answers question: http://stackoverflow.com/q/544049
downvote count: 0
type: Answer
upvote count: 7

http://stackoverflow.com/q/425049
has answer: http://stackoverflow.com/a/425176
favorite count: 0
has title: How to wire Interdependent beans in Spring?
has answer: http://stackoverflow.com/a/425076
accepted answer: http://stackoverflow.com/a/425076
has answer: http://stackoverflow.com/a/425778
tagged with: spring
answer count: 4
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/425129
downvote count: 0
has answer: http://stackoverflow.com/a/425129
tagged with: java
score: 19
type: Question
tagged with: dependency-injection
has body: I want to declare two beans and instantiate them using Spring dependency injection? <property name="entityInterceptor" ref="entityInterceptor"/> <property name="sessionFactory" ref="sessionFactory"/> But Spring throws an exception saying "FactoryBean which is currently in creation returned null from getObject" Why is inter-dependent bean wiring not working here? Should i specify defferred property binding anywhere?
upvote count: 19

http://stackoverflow.com/a/400832
downvote count: 0
answers question: http://stackoverflow.com/q/400338
type: Answer
has body: Hibernate source includes a lot of unit tests, I would recommend going through those and adapting a similar approach. You can also look at the CaveatEmptor which the sample application developed for the book "Java Persistence with Hibernate"
upvote count: 2
has comment: http://stackoverflow.com/comment/226239
score: 2
has comment: http://stackoverflow.com/comment/226255

jdesktop
tag name: jdesktop
type: Tag
tags question: http://stackoverflow.com/q/437097

http://stackoverflow.com/comment/401247
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/589447
type: Comment
has text: oh, so when I do (String x : currentState), it creates a NEW string, x, and copies the VALUE of the string in currentState?

http://stackoverflow.com/a/534235
type: Answer
downvote count: 0
has body: Using this notation lets you specify multiple files: classpath:/properties/rdbm.properties classpath:/properties/passwords.properties The propertyplaceholderconfigurerer just merges all of these to look like there's only one, so your bean definitions do not know where the properties come from.
upvote count: 28
has comment: http://stackoverflow.com/comment/347329
accepted answer of: http://stackoverflow.com/q/534199
has comment: http://stackoverflow.com/comment/347286
answers question: http://stackoverflow.com/q/534199
type: AcceptedAnswer
score: 28

http://stackoverflow.com/a/554511
has body: No, but there is JavaFX which can be compared to Flash/Flex &amp; SilverLight
downvote count: 0
answers question: http://stackoverflow.com/q/554493
type: Answer
upvote count: 3
score: 3

http://stackoverflow.com/q/573826
tagged with: user-interface
downvote count: 0
has answer: http://stackoverflow.com/a/575579
favorite count: 0
answer count: 4
score: 2
upvote count: 2
has answer: http://stackoverflow.com/a/573854
tagged with: look-and-feel
tagged with: multithreading
tagged with: swing
possible better answer: http://stackoverflow.com/a/573832
type: Question
has title: Java: GUIs must be initialized in the EDT thread?
has answer: http://stackoverflow.com/a/573832
accepted answer: http://stackoverflow.com/a/573854
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/573838
has body: I'm Jason. I'm having a bit of a problem with the Substance look and feel (https://substance.dev.java.net/). My problem is more general. I've already got my GUI written and it works fine, but when I use a Substance Look-and-feel, it requires all GUI initialization to take place in the EDT thread (Event Dispatching Thread or something). Right now I'm using com.sun.java.swing.plaf.windows.WindowsLookAndFeel (not sure if I spelled that right) and it doesn't require anything of this sort. So I put the main initialization into the EDT by calling SwingUtilities.invokeLater(). This made it work. However, the program also spawns several other windows during its execution. Right now I have code like: SomeNewWindow window = new SomeNewWindow(); // ... some bs emitted window.doStuff(); This code works fine because by the time window.doStuff() is called, it's already initialized. But Substance requires me to do something like this: SwingUtilities.invokeLater(new Runnable(){ public void run(){ SomeNewWindow window = new SomeNewWindow(); }}); // ... bs emitted window.doStuff(); Here it sometimes throws a NullPointerException because window is not initialized by the time window.doStuff() is called. I can't put window.doStuff() into the EDT thread because it usually takes several seconds to return and will hang the GUI. I've tried putting Thread.sleep(1000) right after I invoke the EDT thread because it's probably initialized by then. But this seems awkward. I simply need a way for the main thread to 'know' when the SomeNewWindow initialization has returned so it can continue on without having to worry about a NullPointerException. Thanks in advance.

http://stackoverflow.com/a/455192
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/275277
downvote count: 0
has comment: http://stackoverflow.com/comment/275251
has body: The Drools documentation includes a lot of useful, general purpose information. Especially chapter 2, which covers rule engine basics, knowledge representation, etc. It also includes a nice recommended reading list for coming up to speed on rule engines and expert systems. For most rule engines, a basic understanding of the rete algorithm usually comes in handy for writing efficient rules. I have personally found the Doorenbos paper referenced in the Wikipedia article to be the clearest technical explanation. Also, here is a list of open source rule engines in Java.
type: Answer
answers question: http://stackoverflow.com/q/455182
has comment: http://stackoverflow.com/comment/275276
upvote count: 12
accepted answer of: http://stackoverflow.com/q/455182
has comment: http://stackoverflow.com/comment/275265
score: 12

http://stackoverflow.com/comment/131222590
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/74285527
has text: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).

http://stackoverflow.com/a/393107
answers question: http://stackoverflow.com/q/393017
type: Answer
has body: You could also create a decorator for Collection which contains extra methods like getMaximumValue() and make it update the value returned every time element is added/removed if there's need. This would only make sense though if you'd use the maximum value a lot in your program which would mean that iterating through the list every time would cause significant overhead.
score: 0

http://stackoverflow.com/q/453960
has body: How can I make seam-gen work with NetBeans 6.5 so that completion of tags (s:, ui:, rich:, ...) works? In the free-form project that seam-gen creates, this does not seam to work. If I create a standard NetBeans web application (File -> New Project), completion does work though. Thanks, m.
type: Question
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/476823
type: UnansweredQuestion
tagged with: netbeans6.5
tagged with: netbeans
has title: seam-gen, netbeans and completion
tagged with: facelets
tagged with: seam
tagged with: java

http://stackoverflow.com/comment/90751162
comment on: http://stackoverflow.com/a/48241654
score: 0
type: Comment
has text: Yes, I have an Android device, @KonradMorawski. I have also heard about [ThreeTenABP](https://github.com/JakeWharton/ThreeTenABP/blob/master/build.gradle), the backport of java.time to earlier Android versions. More in [this question: How to use ThreeTenABP in Android Project](https://stackoverflow.com/questions/38922754/how-to-use-threetenabp-in-android-project).
type: AnswerComment

http://stackoverflow.com/comment/292475
type: Comment
has text: Thank you for links, esp. informit excerpts from EJ 2nd ed.
comment on: http://stackoverflow.com/a/473885
score: 0
type: AnswerComment

http://stackoverflow.com/a/620973
downvote count: 0
score: 1
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/620810
has body: All those answers are probably better OO answers. For once I'll go for the quick and dirty answer. I really like to simplify complex nested ifs like that by inverting them. if(!Options.isActive().booleanValue()) { System.out.println("Service not active"); return; } the rest... I know some people don't like mid-method returns, but when you are validating entry conditions that has always been an awesome pattern for me, I've never regretted using it. It really simplifies the way your method looks. If you write methods longer than a screen, don't do this or write a large comment pointing it out--It's too easy to lose the return statement and forget you did it. Better yet, don't write methods longer than a screen.

http://stackoverflow.com/comment/17415390
type: Comment
score: 1
has text: @jacktrades Why don't you try it. Just copy/paste the example and see "NotSerializableException" being thrown :)
comment on: http://stackoverflow.com/a/448233
type: AnswerComment

http://stackoverflow.com/a/2464566
upvote count: 3
downvote count: 1
answers question: http://stackoverflow.com/q/556807
type: Answer
score: 2
has body: Something neat would be a tool , that translate java to "C++ using Java API" (like GNU GCJ CNI), one problem remain is to manage array.length (array not vector) ...

http://stackoverflow.com/q/613981
answer count: 3
downvote count: 0
has title: recognise combobox deselect when using Swing + models?
tagged with: events
has body: I'm trying to write a nice GUI in Swing that uses the proper Model-Delegate pattern as much as possible. I have a JComboBox that when changed, needs to update the model with the new data. To get the currently selected item, I am using: fooCombo.addItemListener(new ItemListener() { public void itemStateChanged(final ItemEvent arg0) { fooChangedHandler((Foo) fooModel.getSelectedItem()); } }); Which returns what the data was changed to as a nice Object. However, I can't find a way to find out the old value, so I don't know which object needs to be changed. Any ideas here?
accepted answer: http://stackoverflow.com/a/617773
favorite count: 0
tagged with: model
has answer: http://stackoverflow.com/a/614151
possible better answer: http://stackoverflow.com/a/614225
has answer: http://stackoverflow.com/a/614225
tagged with: jcombobox
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
tagged with: swing
has answer: http://stackoverflow.com/a/617773
type: Question

http://stackoverflow.com/comment/80243430
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/35452697
has text: "Does not work properly under Linux - always returns true"

http://stackoverflow.com/comment/324517
type: Comment
comment on: http://stackoverflow.com/a/510481
type: AnswerComment
has text: As all implementation defined bahaviour, "caveat emptor!"
score: 0

http://stackoverflow.com/comment/6884553
type: Comment
has text: I was about to suggest this as well, that final be the default in future versions and that you have to specify "mutable" or better keyword that is conceived. Here's a nice article about this: http://lpar.ath0.com/2008/08/26/java-annoyance-final-parameters/
type: AnswerComment
score: 4
comment on: http://stackoverflow.com/a/500984

http://stackoverflow.com/a/575153
downvote count: 0
has body: It turns out that eclipse is the main issue here. I'll explain: I have wrapped our webapp in a main() method in order to test performance. We use a lot of 3rd party code, namely Apache commons-pool. It turns out we had several versions of the jar spread across the projects (eclipse projects). My app which uses these projects had commons-pool-1.3, a different project had commons-pool-1.2. When loaded using the servlet container (Tomcat6) the webapp class loader had first priority so it always loaded the webapp version. When I started the application using main() eclipse in it's not very wise behavior exported the depended projects jars in in the -classpath BEFORE the ones in the current project. The conflict was between 2 versions of commons-pool, which caused a non defined behavior - On a object borrow is SOMETIMES decided to create a new object. I haven't looked inside the implementation code, I assume that this is something to do with a static map hold by the GenericKeyedObjectPool (the problematic class). Because a new instance was created it indeed contains a null reference to the mentioned global. The solution to my luck was rather simple, commons-pool is being used only by my webapp so I could delete it from all referenced projects, otherwise I think i would just try to upgrade them all to a single version. If I couldn't do either I really don't know what would I've done. This is a very strange default of eclipse. Thank you for reading and helping. // ps. 3 days. That's the time I've spend on understanding what the hell I did wrong in my servlet replacement code. Turns out I'm not even the problem. :P
type: Answer
has comment: http://stackoverflow.com/comment/19539606
answers question: http://stackoverflow.com/q/573970
upvote count: 1
score: 1

http://stackoverflow.com/q/399924
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/404668
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/399970
tagged with: ejb-3.0
tagged with: timer
type: Question
answer count: 2
upvote count: 6
tagged with: java
tagged with: jakarta-ee
has answer: http://stackoverflow.com/a/399970
tagged with: ejb
has body: E.g. if I set a timer to expire every day at midnight, what will happen if one "misfire" (does not trigger the callback because the server is down, for instance) ? I can't find that in the documentation. Is there a way to make this timer triggers the callback as soons as the server restart ? PS: I know about Quartz, i'm evaluating EJB timers as an alternative.
has answer: http://stackoverflow.com/a/404668
score: 6
has title: Are EJB Timers supposed to be persistent/reliable?

http://stackoverflow.com/a/595513
type: AcceptedAnswer
downvote count: 0
score: 4
has body: The second approach is better. Never hide exceptions - you are relying on the assumption that c.contains(null) only throws a NullPointerException in the case that there is a null in the collection. However if the NullPointeException is thrown because of a problem with an equals method you will have a bug in your code - and you will have hidden it. Edit: From the JavaDoc for contains, NullPointerException is thrown - if the specified element is null and this collection does not permit null elements (optional). Given that it is an optional method you may wind up with an UnsupportedOperationException being thrown instead of the NullPointerExcepion (in addition to hiding the an error in equals).
answers question: http://stackoverflow.com/q/595390
type: Answer
accepted answer of: http://stackoverflow.com/q/595390
upvote count: 4

http://stackoverflow.com/a/386638
answers question: http://stackoverflow.com/q/386627
score: 0
has body: No, not as such. Microsoft isn't really fond of Java and won't let it into it's core technologies.
type: Answer
upvote count: 1
downvote count: 1

http://stackoverflow.com/comment/209437
type: AnswerComment
type: Comment
has text: Sounds good and possibly the closest real solution. Perhaps a bit overkill to add a Spring dependency where none existed to the app just for this fixup though. A custom class loader might not play nicely with Eclipse RCP, which I also use...
comment on: http://stackoverflow.com/a/381269
score: 0

http://stackoverflow.com/a/645023
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/589039
score: 2
upvote count: 2
has body: I am afraid the answer is - this cannot be done this way. Check out the IntelliJ Jira.
answers question: http://stackoverflow.com/q/589039

http://stackoverflow.com/comment/423544
score: 0
type: Comment
type: QuestionComment
has text: @R. Bemrose Well, yes, but then you're relying on getting to it before the garbage collector. I mean, as others have said, it's still around if you keep a "prev" variable set to it, but at some point you *will* run out of memory.
comment on: http://stackoverflow.com/q/610976

http://stackoverflow.com/comment/126611756
comment on: http://stackoverflow.com/a/56793934
score: 0
type: Comment
type: AnswerComment
has text: Sorry my shorthand was too cryptic and my unfortunate choice of example. But you're right, closures as built-ins came with object oriented descendants of C; not C. C permitted those who cared to, to build their own 'closures' if they so wished since a C program function and memory address namespaces can be accessed from any context. I was just giving a 'C' example of how one could reign in malicious reference to dynamic memory where sign can be neutral and always arithmetical and offsets to it behave like an algebraic Ring. Always modulo sizeof, for example.

nlp
tags question: http://stackoverflow.com/q/479825
tags question: http://stackoverflow.com/q/612102
tags question: http://stackoverflow.com/q/483348
tags question: http://stackoverflow.com/q/621880
tags question: http://stackoverflow.com/q/559510
tag name: nlp
type: Tag

http://stackoverflow.com/a/380141
has body: I have worked with both platforms since .NET was created, mostly in dual-language projects. Java is the "spanish" of languages (written spanish has changed little for the last few hundred years or so), C# is english (most of us are unable to read 200 year old english literature) C# has "all the bells and whistles" added nice and clean into the language. Java is fairly primitive in comparison. Java has a huge choice of competing libraries and different ways/styles of coding, .NET is much more "single choice"; often a good choice has been done by microsoft for you. These arguments objectively lead no-place in particular; some people may consider having a lot choice is good, others may think it is an unnecessary expense. My current java project is using NONE of the libraries I used in a similar project 5 years ago; so although the language is the same the programming environment (libraries, IDE) has improved by an astonishing amount. So as a developer I prefer C#. Still, by choice, I work in Java right now, and will continue to do so for the foreseeable future - still by choice. Although java the language evolves painfully slowly, there area a lot of really interesting things going on in java. The rest of my choice is based on all the things you specifically don't want to talk about; openness, the dark side and all that.
has comment: http://stackoverflow.com/comment/207809
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/209578
upvote count: 3
answers question: http://stackoverflow.com/q/380081
downvote count: 1

http://stackoverflow.com/comment/33999734
comment on: http://stackoverflow.com/a/1483378
type: AnswerComment
has text: Don't know, I'm using the newest version of Hibernate and haven't had to fight with it much, and I also have the option to write queries in HQL, so it gives me the best of both worlds as far as I'm concerned. I am coming from having written my own simple wrappers in JDBC for years.
type: Comment
score: 2

http://stackoverflow.com/comment/16166240
has text: In terms of readability, the code you posted is much more...cumbersome than String.format( "What do you get if you multiply %d by %d?", varSix, varNine);
score: 0
comment on: http://stackoverflow.com/a/6522436
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/378930
comment on: http://stackoverflow.com/a/567593
type: Comment
score: 0
has text: Nope... they are not :-) (but I had to find the quote...)
type: AnswerComment

http://stackoverflow.com/a/372258
score: 21
type: AcceptedAnswer
upvote count: 23
has comment: http://stackoverflow.com/comment/200985
has comment: http://stackoverflow.com/comment/7417899
accepted answer of: http://stackoverflow.com/q/372250
has body: Foo&lt;Double&gt; f = new Foo&lt;Double&gt;(); When you use this version of the generic class Foo, then for the member variable a, the compiler is essentially taking this line: private T[] a = (T[]) new Object[5]; and replacing T with Double to get this: private Double[] a = (Double[]) new Object[5]; You cannot cast from Object to Double, hence the ClassCastException. Update and Clarification: Actually, after running some test code, the ClassCastException is more subtle than this. For example, this main method will work fine without any exception: public static void main(String[] args) { Foo&lt;Double&gt; f = new Foo&lt;Double&gt;(); System.out.println(f.getA()); } The problem occurs when you attempt to assign f.getA() to a reference of type Double[]: public static void main(String[] args) { Foo&lt;Double&gt; f = new Foo&lt;Double&gt;(); Double[] a2 = f.getA(); // throws ClassCastException System.out.println(a2); } This is because the type-information about the member variable a is erased at runtime. Generics only provide type-safety at compile-time (I was somehow ignoring this in my initial post). So the problem is not private T[] a = (T[]) new Object[5]; because at run-time this code is really private Object[] a = new Object[5]; The problem occurs when the result of method getA(), which at runtime actually returns an Object[], is assigned to a reference of type Double[] - this statement throws the ClassCastException because Object cannot be cast to Double. Update 2: to answer your final question "why do arrays break this?" The answer is because the language specification does not support generic array creation. See this forum post for more - in order to be backwards compatible, nothing is known about the type of T at runtime.
has comment: http://stackoverflow.com/comment/200989
type: Answer
answers question: http://stackoverflow.com/q/372250
has comment: http://stackoverflow.com/comment/200982
downvote count: 2
has comment: http://stackoverflow.com/comment/69269666

http://stackoverflow.com/a/43392435
answers question: http://stackoverflow.com/q/522395
score: 3
has comment: http://stackoverflow.com/comment/83665324
downvote count: 0
type: Answer
upvote count: 3
has body: this works final StringWriter sw = new StringWriter(); try { TransformerFactory.newInstance().newTransformer().transform( new DOMSource(soapResponse.getSOAPPart()), new StreamResult(sw)); } catch (TransformerException e) { throw new RuntimeException(e); } System.out.println(sw.toString()); return sw.toString();

http://stackoverflow.com/q/617585
has answer: http://stackoverflow.com/a/617614
tagged with: http://stackoverflow.com/tag/html
has answer: http://stackoverflow.com/a/645099
answer count: 5
has answer: http://stackoverflow.com/a/617979
has answer: http://stackoverflow.com/a/617609
type: UnansweredQuestion
tagged with: compression
type: Question
tagged with: java
has body: Does anyone know any good java library (or single method) that can strip extra spaces (line breaks, tabs, etc) from an html file? So html file gets turned into 1 line basically. Thanks. UPDATE: Looks like there is no library that does that so I created my own open source project for solving this task: http://code.google.com/p/htmlcompressor/
score: 12
upvote count: 12
downvote count: 0
has title: Java lib to compress html file?
favorite count: 0
has answer: http://stackoverflow.com/a/617601

http://stackoverflow.com/a/930761
upvote count: 1
has body: If you had to, you could roll your own .. using single-writer/single-reader FIFO or queues.
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/565893
score: 1

http://stackoverflow.com/comment/32611745
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/449425
type: Comment
has text: No. The garbage collector is periodically executed to see if there were any objects to which no reference variables are pointing to. When you set them to null and then call `System.gc()` then it will be removed (provided there are no other references pointing to that object).

web-services
type: Tag
tags question: http://stackoverflow.com/q/646414
tags question: http://stackoverflow.com/q/543896
tags question: http://stackoverflow.com/q/505172
tags question: http://stackoverflow.com/q/581590
tags question: http://stackoverflow.com/q/507073
tags question: http://stackoverflow.com/q/564153
tags question: http://stackoverflow.com/q/615222
tags question: http://stackoverflow.com/q/485663
tags question: http://stackoverflow.com/q/567525
tags question: http://stackoverflow.com/q/473566
tags question: http://stackoverflow.com/q/442582
tags question: http://stackoverflow.com/q/377901
tags question: http://stackoverflow.com/q/434950
tags question: http://stackoverflow.com/q/359620
tags question: http://stackoverflow.com/q/635860
tags question: http://stackoverflow.com/q/644511
tags question: http://stackoverflow.com/q/402160
tags question: http://stackoverflow.com/q/578431
tags question: http://stackoverflow.com/q/430936
tags question: http://stackoverflow.com/q/472984
tags question: http://stackoverflow.com/q/428514
tags question: http://stackoverflow.com/q/638326
tags question: http://stackoverflow.com/q/573624
tags question: http://stackoverflow.com/q/578003
tags question: http://stackoverflow.com/q/520467
tags question: http://stackoverflow.com/q/612102
tags question: http://stackoverflow.com/q/581257
tags question: http://stackoverflow.com/q/456162
tags question: http://stackoverflow.com/q/415896
tag name: web-services
tags question: http://stackoverflow.com/q/369059
tags question: http://stackoverflow.com/q/373350
tags question: http://stackoverflow.com/q/435474
tags question: http://stackoverflow.com/q/367905
tags question: http://stackoverflow.com/q/420533
tags question: http://stackoverflow.com/q/511523
tags question: http://stackoverflow.com/q/635434
tags question: http://stackoverflow.com/q/528685
tags question: http://stackoverflow.com/q/464346
tags question: http://stackoverflow.com/q/626648
tags question: http://stackoverflow.com/q/444783
tags question: http://stackoverflow.com/q/540071
tags question: http://stackoverflow.com/q/462786
tags question: http://stackoverflow.com/q/432461
tags question: http://stackoverflow.com/q/359548
tags question: http://stackoverflow.com/q/602319
tags question: http://stackoverflow.com/q/590514
tags question: http://stackoverflow.com/q/458537
tags question: http://stackoverflow.com/q/440989

http://stackoverflow.com/q/359675
has answer: http://stackoverflow.com/a/597248
has answer: http://stackoverflow.com/a/359721
upvote count: 10
answer count: 4
favorite count: 0
tagged with: http://stackoverflow.com/tag/xml
downvote count: 0
has title: Java REST client without schema
has body: Goal Java client for Yahoo's HotJobs Resumé Search REST API. Background I'm used to writing web-service clients for SOAP APIs, where wsimport generates proxy stubs and you're off and running. But this is a REST API, which is new to me. Details REST API No WADL No formal XML schema (XSD or DTD files). There are example XML request/response pairs. No example code provided Progress I looked at question Rest clients for Java?, but the automated solutions there assume you are providing both the server and the client, with JAXB invoked on POJOs to generate a schema and a REST API. Using Jersey (a JAX-RS implementation), I have been able to make a manual HTTP request: import com.sun.jersey.api.client.*; ... ClientConfig clientConfig = new DefaultClientConfig(); Client client = Client.create(clientConfig); WebResource webResource = client.resource("https://hj.yahooapis.com/v1/HJAuthTokens"); webResource.accept("application/xml"); // body is a hard-coded string, with replacements for the variable bits String response = webResource.post(String.class, body); // parse response into a org.w3c.dom.Document // interface with Document via XPATH, or write my own POJO mappings The response can look like: <?xml version="1.0" encoding="utf-8"?> 0 Login successful [binary] Or, it can look like: <?xml version="1.0" encoding="utf-8"?> <yahoo:error xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" xml:lang="en-US"> <yahoo:description>description</yahoo:description> <yahoo:detail> errorCode </yahoo:detail> </yahoo:error> Questions Is there a way to auto-generate POJOs which can be marshalled/unmarshalled without a formal schema? Should I attempt to generate those POJOs by hand, with JAXB annotations? Is there some tool I should be leveraging so I don't have to do all this manually?
type: Question
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/221442
has answer: http://stackoverflow.com/a/24474313
tagged with: java
score: 10
has answer: http://stackoverflow.com/a/994150
tagged with: jaxb
accepted answer: http://stackoverflow.com/a/359721
possible better answer: http://stackoverflow.com/a/597248
tagged with: jax-rs

http://stackoverflow.com/comment/273523
score: 7
type: AnswerComment
comment on: http://stackoverflow.com/a/452981
type: Comment
has text: Exec is _extremely_ dangerous. It's easy to shoot yourself in the foot by overwriting names in your scope dynamically and just as easy to open a security flaw the size of Rhode Island.

http://stackoverflow.com/comment/83796794
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21430849
score: 1
has text: The Spring solution is the only working if run from an executable jar.

http://stackoverflow.com/comment/52675422
has text: The link must have moved. Japex is now located at: https://japex.java.net/
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/447923
score: 1

http://stackoverflow.com/comment/31271965
comment on: http://stackoverflow.com/q/459624
score: 0
type: Comment
type: QuestionComment
has text: See my code sample here: http://stackoverflow.com/a/20847683/527533

http://stackoverflow.com/comment/11501217
type: Comment
score: 16
type: AnswerComment
has text: actually Swing uses a Model-Delegate approach, which is derived from the MVC approach, where in the View and Controller are combined for a Delegate structure
comment on: http://stackoverflow.com/a/408884

http://stackoverflow.com/a/6239009
downvote count: 0
type: Answer
upvote count: 2
answers question: http://stackoverflow.com/q/469287
has body: I suspect enums in C# are just constants internal to the CLR, but not that familiar with them. I have decompiled some classes in Java and I can tell you want Enums are once you convert. Java does something sneaky. It treats the enum class as a a normal class with, as close as I can figure, using lots of macros when referencing the enum values. If you have a case statement in a Java class that uses enums, it replaces the enum references to integers. If you need to go to string, it creates an array of strings indexed by an ordinal that it uses in each class. I suspect to save on boxing. If you download this decompiler you will get to see how it creates its class an integrates it. Rather fascinating to be honest. I used to not use the enum class because I thought it was to bloated for just an array of constants. I like it better than the limited way you can use them in C#. http://members.fortunecity.com/neshkov/dj.html -- Java decompiler
score: 2

http://stackoverflow.com/comment/207927
type: AnswerComment
has text: apparently, Jython cannot run Mercurial just yet, partly because of the sections of Mercurial that are written in C.
comment on: http://stackoverflow.com/a/380400
type: Comment
score: 0

http://stackoverflow.com/a/461016
has comment: http://stackoverflow.com/comment/280496
has body: The thing about Java is that it doesn't really come 'bundled' with stuff in the same way .NET does... you generally go looking for the goods. This makes starting with web apps in Java daunting because there are so many options. Many of them are built off JSPs, which is a plus. If you are set on using vanilla JSPs you are not going to have a good time. Otherwise, I would suggest Wicket, Stripes or Spring MVC. Stripes is probably the simplest of the three (Spring is a little complicated and Wicket is conceptually different from the other two). Having said that Spring MVC is probably the most used of the three.. All Stripes really is is JSPs and ActionBeans. Action beans are Java classes that contain actions, which are methods that perform your actions. Theses ActionBean classes also contain the data for the current page. This page has more information about Stripes.
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/460850
type: Answer
accepted answer of: http://stackoverflow.com/q/460850
score: 2
upvote count: 2

http://stackoverflow.com/comment/68715182
comment on: http://stackoverflow.com/a/407323
type: Comment
score: 2
has text: Bet my finest pound sterling 99% upvoted w/o checking.
type: AnswerComment

http://stackoverflow.com/a/560948
upvote count: 7
type: Answer
answers question: http://stackoverflow.com/q/555580
downvote count: 0
has body: The usual way to handle this sort of thing is to use WeakReferences and SoftReferences. You need to use both - the weak reference means you are not holding multiple copies of things, and the soft references mean that the GC will hang onto things until it starts running out of memory. If you need to do additional cleanup, then you can add references to queues, and override the queue notification methods to trigger the cleanup. It's all good fun, but you do need to understand what these classes do.
score: 7

http://stackoverflow.com/q/500319
favorite count: 0
has answer: http://stackoverflow.com/a/500333
type: UnansweredQuestion
tagged with: c++
tagged with: java
has body: i am in need of a well documented source code of simulated annealing for placement and routing (in c++ or java). can anyone help me?
upvote count: 1
downvote count: 1
type: Question
has title: simulated annealing for placement and routing
tagged with: simulated-annealing
tagged with: routes
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/4746853

http://stackoverflow.com/q/536126
type: Question
type: AnsweredQuestion
tagged with: java
tagged with: mobile
answer count: 1
score: 0
has title: Java Mobile Games Builder for Non-Programmers?
has body: Is there any tool on the market that supports making games for mobile devices in Java, for non-programmers? I need to find the best and fastest way to do that, before we plan to build such tool (for simple games only) as an add-on to our main product.
has answer: http://stackoverflow.com/a/536194
accepted answer: http://stackoverflow.com/a/536194

http://stackoverflow.com/q/537174
has body: I have a java string, which has a variable length. I need to put the piece "&lt;br&gt;" into the string, say each 10 characters. For example this is my string: `this is my string which I need to modify...I love stackoverlow:)` How can I obtain this string?: `this is my&lt;br&gt; string wh&lt;br&gt;ich I nee&lt;br&gt;d to modif&lt;br&gt;y...I love&lt;br&gt; stackover&lt;br&gt;flow:)` Thanks
has title: Putting char into a java string for each N characters
has answer: http://stackoverflow.com/a/537212
has answer: http://stackoverflow.com/a/48951256
has answer: http://stackoverflow.com/a/47705472
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/123146982
tagged with: java
accepted answer: http://stackoverflow.com/a/537190
has answer: http://stackoverflow.com/a/49058835
linked to: http://stackoverflow.com/q/10530102
has answer: http://stackoverflow.com/a/61918295
linked to: http://stackoverflow.com/q/4169699
score: 33
type: Question
linked to: http://stackoverflow.com/q/12295711
upvote count: 33
has answer: http://stackoverflow.com/a/77417517
answer count: 13
has answer: http://stackoverflow.com/a/37977587
has answer: http://stackoverflow.com/a/61383032
has answer: http://stackoverflow.com/a/67090494
tagged with: char
linked to: http://stackoverflow.com/q/11149342
has answer: http://stackoverflow.com/a/846636
possible better answer: http://stackoverflow.com/a/537185
downvote count: 0
has answer: http://stackoverflow.com/a/537190
tagged with: string
has answer: http://stackoverflow.com/a/537185
linked to: http://stackoverflow.com/q/54345564
has answer: http://stackoverflow.com/a/537210
favorite count: 0

http://stackoverflow.com/comment/107711999
type: AnswerComment
score: 0
type: Comment
has text: Instead of m.update(plaintext.getBytes()); I would recommend specifying the encoding. such as m.update(plaintext.getBytes("UTF-8")); getBytes() does not guarantee the encoding and may vary from system to system which may result in different MD5 results between systems for the same String.
comment on: http://stackoverflow.com/a/421696

http://stackoverflow.com/comment/75511174
has text: This only works if the code is written 100% in Kotlin since Kotlin can't compile to Javascript if you are using Java libraries.
type: Comment
comment on: http://stackoverflow.com/a/39306909
score: 7
type: AnswerComment

http://stackoverflow.com/q/504071
has title: EL in a JSP stopped evaluating
accepted answer: http://stackoverflow.com/a/504186
upvote count: 3
tagged with: java
answer count: 3
downvote count: 1
has body: In a JSP page(index.jsp): ${requestContext.requestURL} is the URL just shows the expression itself. It used to be evaluated to something like "http://.../somerset/" I created the Maven project with maven-archetype-webapp archetype in Eclipse. The Jetty version is jetty-6.1.14. My web.xml is simple: Archetype Created Web Application SomersetServlet SomersetServlet com.foo.somerset.SomersetServlet SomersetServlet /som.do
has answer: http://stackoverflow.com/a/504186
type: AnsweredQuestion
score: 2
tagged with: jsp
possible better answer: http://stackoverflow.com/a/504096
tagged with: maven-2
favorite count: 0
tagged with: el
has answer: http://stackoverflow.com/a/504096
has answer: http://stackoverflow.com/a/504115
type: Question
tagged with: jetty

http://stackoverflow.com/q/423032
has body: I know that an interface must be public. However, I don't want that. I want my implemented methods to only be accessible from their own package, so I want my implemented methods to be protected. The problem is I can't make the interface or the implemented methods protected. What is a work around? Is there a design pattern that pertains to this problem? From the Java guide, an abstract class wouldn't do the job either.
has comment: http://stackoverflow.com/comment/79188863
linked to: http://stackoverflow.com/q/5376970
has comment: http://stackoverflow.com/comment/246836
has answer: http://stackoverflow.com/a/423100
downvote count: 1
has answer: http://stackoverflow.com/a/423075
type: Question
score: 31
has comment: http://stackoverflow.com/comment/246843
has title: Interfaces in Java: cannot make implemented methods protected or private
tagged with: access-specifier
has answer: http://stackoverflow.com/a/423043
has answer: http://stackoverflow.com/a/438125
has answer: http://stackoverflow.com/a/423046
has answer: http://stackoverflow.com/a/423047
linked to: http://stackoverflow.com/q/370962
has comment: http://stackoverflow.com/comment/246839
has answer: http://stackoverflow.com/a/27261295
has answer: http://stackoverflow.com/a/13840396
has comment: http://stackoverflow.com/comment/247380
favorite count: 0
has answer: http://stackoverflow.com/a/36585532
answer count: 12
has answer: http://stackoverflow.com/a/423038
type: UnansweredQuestion
tagged with: interface
has answer: http://stackoverflow.com/a/46342198
has answer: http://stackoverflow.com/a/24395109
upvote count: 32
has comment: http://stackoverflow.com/comment/246845
tagged with: java

http://stackoverflow.com/a/33376380
answers question: http://stackoverflow.com/q/379176
score: 0
type: Answer
has body: I create simply Fraction library. The library is available here: https://github.com/adamjak/Fractions Example: String s = "1.125"; Fraction f1 = Fraction.tryParse(s); f1.toString(); // return 9/8 Double d = 2.58; Fraction f2 = Fraction.createFraction(d); f2.divide(f1).toString() // return 172/75 (2.29)

http://stackoverflow.com/comment/451222
score: 0
comment on: http://stackoverflow.com/a/637366
has text: Reasoning might be that it's some sort of online Excel thingamajigger and there's nasty legacy code behind it. HashMap is extremely fast though (ConcurrentHashMap is even faster!) and if the map is called 4000 times per request, JIT will reoptimize it to its fullest on the fly anyway.
type: AnswerComment
type: Comment

http://stackoverflow.com/a/403276
upvote count: 72
score: 72
type: Answer
answers question: http://stackoverflow.com/q/403256
downvote count: 0
has comment: http://stackoverflow.com/comment/65384055
has body: Looks like you want to use java.lang.Class.getResourceAsStream(String), see https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getResourceAsStream-java.lang.String-

http://stackoverflow.com/comment/438427
type: AnswerComment
type: Comment
has text: Ok, i removed all references to applet and changed init method to public static void main(String args[]). Got the error : "Exception in thread "main" java.lang.NullPointerException at Test.main(Test.java:10)"
comment on: http://stackoverflow.com/a/625712
score: 0

http://stackoverflow.com/a/639172
type: Answer
has comment: http://stackoverflow.com/comment/453065
score: 3
has comment: http://stackoverflow.com/comment/510119
has body: This sounds like a job for.... new ObjectOutputStream(new FileOutputStream(STORAGE_DIR + "/" + key + ".dat"); !! Seriously - the simplest method is to just create a file for each data table that you want to store, serialize the data into and look it up using the key as the filename when you want to read. On a decent file system writes can be made atomic (by writing to a temp file and then renaming the file); read/write speed is measured in 10s of MBit/second; look ups can be made very efficient by creating a simple directory tree like STORAGE_DIR + "/" + key.substring(0,2) + "/" + key.substring(0,4) + "/" + key which should be still efficient with millions of entries and even more efficient if your file system uses indexed directories; lastly its trivial to implement a memory-backed LRU cache on top of this for even faster retrievals. Regarding compression - you can use Jakarta's commons-compress to affect a gzip or even bzip2 compression to the data before you store it. But this is an optimization problem and depending on your application and available disk space you may be better off investing the CPU cycles elsewhere. Here is a sample implementation that I made: http://geek.co.il/articles/geek-storage.zip. It uses a simple interface (which is far from being clean - its just a demonstration of the concept) that offers methods for storing and retrieving objects from a cache with a set maximum size. A cache miss is transfered to a user implementation for handling, and the cache will periodically check that it doesn't exceed the storage requirements and will remove old data. I also included a MySQL backed implementation for completion and a benchmark to compare the disk based and MySQL based implementations. On my home machine (an old Athlon 64) the disk benchmark scores better then twice as fast as the MySQL implementation in the enclosed benchmark (9.01 seconds vs. 18.17 seconds). Even though the DB implementation can probably tweaked for slightly better performanc…
upvote count: 3
has comment: http://stackoverflow.com/comment/493107
has comment: http://stackoverflow.com/comment/511043
has comment: http://stackoverflow.com/comment/486315
accepted answer of: http://stackoverflow.com/q/639077
has comment: http://stackoverflow.com/comment/454818
answers question: http://stackoverflow.com/q/639077
has comment: http://stackoverflow.com/comment/493196
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/371039
score: 7
upvote count: 8
answers question: http://stackoverflow.com/q/371019
downvote count: 1
has body: It’s only important if you want to use an EventListenerList or an EventListenerProxy. I like to use it on my own event listener interfaces as well, though. It makes the purpose of the interface much clearer.
has comment: http://stackoverflow.com/comment/205334
has comment: http://stackoverflow.com/comment/199863
type: Answer
has comment: http://stackoverflow.com/comment/5489852
has comment: http://stackoverflow.com/comment/92309169

http://stackoverflow.com/comment/330277
type: Comment
has text: I'd also add a semicolon to the end of the second line.
comment on: http://stackoverflow.com/a/516612
score: 0
type: AnswerComment

http://stackoverflow.com/q/586830
has answer: http://stackoverflow.com/a/586967
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/404000
has answer: http://stackoverflow.com/a/587181
tagged with: java
possible better answer: http://stackoverflow.com/a/586967
has answer: http://stackoverflow.com/a/586953
tagged with: file
score: 13
type: Question
has answer: http://stackoverflow.com/a/587382
has comment: http://stackoverflow.com/comment/403995
tagged with: locking
has answer: http://stackoverflow.com/a/600071
has answer: http://stackoverflow.com/a/587424
accepted answer: http://stackoverflow.com/a/587424
upvote count: 14
downvote count: 1
answer count: 7
has comment: http://stackoverflow.com/comment/398637
has comment: http://stackoverflow.com/comment/410692
has title: Java keeps lock on files for no apparent reason
favorite count: 0
has comment: http://stackoverflow.com/comment/403675
has comment: http://stackoverflow.com/comment/398712
has body: Despite closing streams in finally clauses I seem to constantly run into cleaning up problems when using Java. File.delete() fails to delete files, Windows Explorer fails too. Running System.gc() helps sometimes but nothing short of terminating the VM helps consistently and that is not an option. Does anyone have any other ideas I could try? I use Java 1.6 on Windows XP. UPDATE: FLAC code sample removed, the code worked if I isolated it. UPDATE: More info, this happens in Apache Tomcat, Commons FileUpload is used to upload the file and could be the culprit, also I use Runtime.exec() to execute LAME in a separate process to encode the file, but that seems unlikely to cause this since ProcessExplorer clearly indicates that java.exe has a RW lock on the file and LAME terminates fine. UPDATE: I am working with the assumption that there is a missing close() or a close() that does not get called somewhere in my code or external library. I just can't find it!
has answer: http://stackoverflow.com/a/807582

http://stackoverflow.com/a/633644
has comment: http://stackoverflow.com/comment/68958512
has body: Well, I ended up doing it myself. For those intereseted, I ended up solving it by turning the line into a rectangle (with getBounds), then using Rectangle.intersect(clipRect,lineRect,intersectLineRect) to create the intersection, then turning the intersection back into a line.
type: Answer
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/626812
score: 0
accepted answer of: http://stackoverflow.com/q/626812
type: AcceptedAnswer

http://stackoverflow.com/a/28834526
has body: Edit: the api call has been removed by google. so it is no longer functioning. Agree with Pareshkumar's answer. Now there is a python wrapper googlefinance for the url call. Install googlefinance $pip install googlefinance It is easy to get current stock price: &gt;&gt;&gt; from googlefinance import getQuotes &gt;&gt;&gt; import json &gt;&gt;&gt; print json.dumps(getQuotes('AAPL'), indent=2) [ { "Index": "NASDAQ", "LastTradeWithCurrency": "129.09", "LastTradeDateTime": "2015-03-02T16:04:29Z", "LastTradePrice": "129.09", "Yield": "1.46", "LastTradeTime": "4:04PM EST", "LastTradeDateTimeLong": "Mar 2, 4:04PM EST", "Dividend": "0.47", "StockSymbol": "AAPL", "ID": "22144" } ] Google finance is a source that provides real-time stock data. There are also other APIs from yahoo, such as yahoo-finance, but they are delayed by 15min for NYSE and NASDAQ stocks.
type: Answer
score: 11
answers question: http://stackoverflow.com/q/527703
has comment: http://stackoverflow.com/comment/139870639
downvote count: 0
upvote count: 11

http://stackoverflow.com/a/840108
downvote count: 0
score: 18
has comment: http://stackoverflow.com/comment/1766093
has comment: http://stackoverflow.com/comment/63440376
type: Answer
answers question: http://stackoverflow.com/q/489360
has comment: http://stackoverflow.com/comment/4452348
has body: this is one situation where hibernate shines: typical solution with hql query. int elementsPerBlock = 10; int page = 2; return getSession().createQuery("from SomeItems order by id asc") .setFirstResult(elementsPerBlock * (page-1) + 1 ) .setMaxResults(elementsPerBlock) .list(); hibernate will translate this to a pattern that is understood by the database according to its sql dialect. on oracle it will create a subselect with ROWNUM &lt; X. on postgresql it will issue a LIMIT / OFFSET on msSQL server it will issue a TOP.. to my knowledge it is not possible to achieve this with "pure" hql.
upvote count: 18

http://stackoverflow.com/comment/228801
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/403581
has text: Sure, you're right, but this wasn't the point of my question, sorry about me being too sparse about it...
score: 0

http://stackoverflow.com/a/554478
has body: Why not consider using another MDB to process the other message type explicitly. The priority details above still apply, further more you would have more control over concurrent processing for each message type. For most situations i prefer 1 mdb or message receiver per message type. This way if a transaction rolls back you know immediately which type of message caused the problem Karl
answers question: http://stackoverflow.com/q/387471
score: 0
type: Answer

http://stackoverflow.com/a/23987003
upvote count: 5
has comment: http://stackoverflow.com/comment/37901737
has comment: http://stackoverflow.com/comment/49895441
has comment: http://stackoverflow.com/comment/50105551
has comment: http://stackoverflow.com/comment/49717068
has comment: http://stackoverflow.com/comment/82177560
has body: Checked exceptions were, in their original form, an attempt to handle contingencies rather than failures. The laudable goal was to highlight specific predictable points (unable to connect, file not found, etc) &amp; ensure developers handled these. What was never included in the original concept, was to force a vast range of systemic &amp; unrecoverable failures to be declared. These failures were never correct to be declared as checked exceptions. Failures are generally possible in code, and EJB, web &amp; Swing/AWT containers already cater for this by providing an outermost “failed request” exception-handler. The most basic correct strategy is to rollback the transaction &amp; return an error. One crucial point, is that runtime &amp; checked exceptions are functionally equivalent. There is no handling or recovery which checked exceptions can do, that runtime exceptions can’t. The biggest argument against “checked” exceptions is that most exceptions can’t be fixed. The simple fact is, we don’t own the code/ subsystem that broke. We can’t see the implementation, we’re not responsible for it, and can’t fix it. If our application is not a DB.. we shouldn't try and fix the DB. That would violate the principle of encapsulation. Particularly problematic have been the areas of JDBC (SQLException) and RMI for EJB (RemoteException). Rather than identifying fixable contingencies as per the original “checked exception” concept, these forced pervasive systemic reliability issues, not actually fixable, to be widely declared. The other severe flaw in the Java design, was that exception-handling should correctly placed at the highest possible "business" or "request" level. The principle here is "throw early, catch late". Checked exceptions do little but get in the way of this. We have an obvious issue in Java of requiring thousands of do-nothing try-catch blocks, with a significant proportion (40%+) being miscoded. Almost none of these implement any genuine handling or reliabilit…
type: Answer
has comment: http://stackoverflow.com/comment/37887370
has comment: http://stackoverflow.com/comment/49716976
downvote count: 1
answers question: http://stackoverflow.com/q/613954
has comment: http://stackoverflow.com/comment/49635928
has comment: http://stackoverflow.com/comment/49696177
has comment: http://stackoverflow.com/comment/49807308
score: 4
has comment: http://stackoverflow.com/comment/37895381
has comment: http://stackoverflow.com/comment/49846816
has comment: http://stackoverflow.com/comment/50136143

http://stackoverflow.com/q/418197
tagged with: annotations
tagged with: spring
type: Question
type: AnsweredQuestion
upvote count: 5
tagged with: java
tagged with: hibernate
accepted answer: http://stackoverflow.com/a/418214
answer count: 2
score: 5
tagged with: jpa
downvote count: 0
possible better answer: http://stackoverflow.com/a/418217
has body: Assuming I have a class A as follows: class A{ int id; int getId(){}; void setId(int id){}; } And a class B as follows: @Entity @Table(name="B") class B extends A{ string name; @Column(length=20) string getName(){} void setName(){} } How can I annotate the inherited id field from A so that Hibernate/JPA knows it is the Id for the entity? I tried simply placing @Id on the field in A but this didn't work. I tried making A an entity as well and this also didn't work.
favorite count: 0
has answer: http://stackoverflow.com/a/418217
has answer: http://stackoverflow.com/a/418214
has title: Annotating inherited properties for persistence

http://stackoverflow.com/a/578480
has comment: http://stackoverflow.com/comment/390376
score: 0
type: Answer
answers question: http://stackoverflow.com/q/578430
has body: Look at getTime() and setTime(). They should do what you're looking for. Instead of sending it over the wire as a location-specific string, send it as the number of milliseconds since epoch using getTime() on the client, then build a new Date on the client and use setTime() with the long value on the server.
has comment: http://stackoverflow.com/comment/390330
has comment: http://stackoverflow.com/comment/390439

http://stackoverflow.com/comment/80164421
type: Comment
score: 1
comment on: http://stackoverflow.com/a/35210338
has text: It's saying `all classes are up to date` `nothing to compile` because it won't look for `*.java` anymore. You can add them back using ` **/*.java `. Yet no success for me for the jars
type: AnswerComment

http://stackoverflow.com/a/412720
has comment: http://stackoverflow.com/comment/237800
answers question: http://stackoverflow.com/q/411982
has body: how can I implement (or simulate?) getBaselineResizeBehavior() so that my class can still compile and run in a Java5 environment? You cannot compile this method declaration with the Java 5 library because the type Component.BaselineResizeBehaviour does not exist: public Component.BaselineResizeBehavior getBaselineResizeBehavior() You must compile using Java 6. Your classes can still run on Java 5 if you compile to a 1.5 target, but you must take care that they handle absent types/methods gracefully. Add tests for these cases as you encounter them. Ensure developers attempt to run their code on Java 5 prior to check-in. For example, this class... public class MyPanel extends javax.swing.JPanel { public java.awt.Component.BaselineResizeBehavior getBaselineResizeBehavior() { return java.awt.Component.BaselineResizeBehavior.OTHER; } public static void main(String[] args) { new MyPanel(); System.out.println("OK"); } } ...can be compiled and run as follows using the javac JDK compiler: X:\fallback&gt;javac -version javac 1.6.0_05 X:\fallback&gt;javac -target 1.5 MyPanel.java X:\fallback&gt;"C:\Program Files\Java\jre1.5.0_10\bin\java.exe" -cp . MyPanel OK All the popular IDEs offer options for generating older class versions. You can use reflection to test for the existence of methods/types at runtime when you need to make decisions about code paths. Failure to set the target will result in errors like this: Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version n umber in .class file at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadCl…
downvote count: 0
upvote count: 2
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/237926
has comment: http://stackoverflow.com/comment/240559

http://stackoverflow.com/a/15053268
type: Answer
score: 6
upvote count: 7
has body: With JDK8 it does have some support for them. We may yet see full support of unsigned types in Java despite Gosling's concerns.
downvote count: 1
answers question: http://stackoverflow.com/q/430346
has comment: http://stackoverflow.com/comment/29627959

http://stackoverflow.com/comment/36904879
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/1599081
has text: From the Hunting of the Snark: So the Bellman would cry: and the crew would reply "They are merely conventional signs!"

http://stackoverflow.com/comment/377071
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/562035
has text: Terracotta does not "intrude" into your code. Curious why you would say that?
type: Comment

http://stackoverflow.com/q/483379
has body: I am having a very strange behavior in JBoss, and I'd like avail myself of the Collective Wisdom of the SO Crowd. We're using JBoss (4.0.4 I think) to serve SOAP calls. In fact, it's used as glorified RPC server, no more. We're running out of memory when we have 20+ clients sending their requests at the same time. The requests consist of the incoming rather small request (proper SOAP) and the returning result packet that is essentially one long SOAP string (and the contents of the string are XML). Yes I realize this is suboptimal. Don't ask. I've traced the leak to an instance of org.jboss.axis.message.SAX2EventRecorder that hold 4 million objects (strings and Integers). Now, even the longest response does not carry 4MB of data. The requests are all smaller than 40K. Something is fishy there, but I can't find any documentation on the Web. Can someone tell me what the recorder is used for? And how do I get rid of it? Or may be configure it to be less memory-hungry? Any help is appreciated. Update: To clarify - I did do memory dump, and the dump shows an array or 4,000,000+ objects, Strings and Integers. The array is owned by a org.jboss.axis.message.SAX2EventRecorder which is in turn held by these guys: org.jboss.axis.message.SOAPEnvelopeAxisImpl@0x19c31fd8 (141 bytes) : field recorder org.jboss.axis.message.RPCParamElementImpl@0x19c32260 (123 bytes) : field recorder org.jboss.axis.message.SOAPBodyAxisImpl@0x19c32160 (121 bytes) : field recorder org.jboss.axis.message.RPCElement@0x19c321e0 (124 bytes) : field recorder org.jboss.axis.encoding.DeserializationContextImpl@0x19c332f0 (67 bytes) : field recorder org.jboss.axis.message.SAX2EventRecorder$objArrayVector@0x19c33398 (24 bytes) : field this$0 The data structures of our own app are quete bloated, but not to this degree. Another update: powers that be have found a "powers-that-be-solution": we're switching to 64-bit memory. Hurray.
has comment: http://stackoverflow.com/comment/313404
has title: Memory leak in JBoss
has comment: http://stackoverflow.com/comment/299897
tagged with: soap
score: 2
type: AnsweredQuestion
upvote count: 3
tagged with: java
downvote count: 1
possible better answer: http://stackoverflow.com/a/515850
type: Question
has comment: http://stackoverflow.com/comment/313387
has answer: http://stackoverflow.com/a/515850
tagged with: jboss
has answer: http://stackoverflow.com/a/483407
answer count: 2
accepted answer: http://stackoverflow.com/a/483407
has comment: http://stackoverflow.com/comment/299898
has comment: http://stackoverflow.com/comment/313389
favorite count: 0

http://stackoverflow.com/q/636360
has answer: http://stackoverflow.com/a/832413
answer count: 10
has answer: http://stackoverflow.com/a/816750
favorite count: 0
tagged with: http://stackoverflow.com/tag/xml
has answer: http://stackoverflow.com/a/636832
tagged with: equals
has answer: http://stackoverflow.com/a/842748
has comment: http://stackoverflow.com/comment/450729
has answer: http://stackoverflow.com/a/636372
has answer: http://stackoverflow.com/a/636789
accepted answer: http://stackoverflow.com/a/636789
type: AnsweredQuestion
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/820789
has comment: http://stackoverflow.com/comment/450728
has title: Finding out what caused equals() to return false
has answer: http://stackoverflow.com/a/835594
type: Question
tagged with: graph-theory
has comment: http://stackoverflow.com/comment/449916
has comment: http://stackoverflow.com/comment/450539
possible better answer: http://stackoverflow.com/a/820789
has answer: http://stackoverflow.com/a/844925
has body: How can I find out what caused equals() to return false? I'm not asking about a sure-way, always right approach, but of something to aid in the development process. Currently I have to step into the equals() calls (usually a tree of them) until one of them is false, then step into it, ad nauseam. I thought about using the object graph, outputting it to xml and comparing the two objects. However, XMLEncoder requires default constructors, jibx requires pre-compilation, x-stream and simple api are not used in my project. I don't mind copying a single class, or even a package, into my test area and using it there, but importing a whole jar for this just isn't going to happen. I also thought about building an object graph traverser myself, and I might still do it, but I'd hate to start dealing with special cases (ordered collections, non-ordered collections, maps...) Any idea how to go about it? Edit: I know adding jars is the normal way of doing things. I know jars are reusable units. However, the bureaucracy needed (at my project) for this doesn't justify the results - I'd keep on debugging and stepping into.
has answer: http://stackoverflow.com/a/831638
has comment: http://stackoverflow.com/comment/451224
upvote count: 3
downvote count: 2

http://stackoverflow.com/comment/306194
has text: I think the community will decide what's the best way to answer this question.
type: Comment
score: 9
type: AnswerComment
comment on: http://stackoverflow.com/a/490103

http://stackoverflow.com/comment/47134103
type: AnswerComment
score: 0
type: Comment
has text: I think you mean [fluent](http://en.wikipedia.org/wiki/Fluent_interface) not fluid.
comment on: http://stackoverflow.com/a/1483454

http://stackoverflow.com/a/567607
answers question: http://stackoverflow.com/q/566892
has body: As Mr. Shiny and New mentions, above, the right way is to place the data sources in their own files. The trick is that the file names have to conform to the suffix supported in the jbossjca-service.xml deployer file. So, create a new file per-datasource, with the name foo-ds.xml.
accepted answer of: http://stackoverflow.com/q/566892
upvote count: 2
type: Answer
score: 2
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/595681
answers question: http://stackoverflow.com/q/595631
type: Answer
score: 7
has body: Here is a discussion that relates: https://bugs.java.com/bugdatabase/view_bug?bug_id=4017593
upvote count: 7
downvote count: 0

http://stackoverflow.com/a/580456
answers question: http://stackoverflow.com/q/579833
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/394996
has body: I use a Nameable interface a lot (with getName()). Before I start, I'll suggest that you don't want to do this at all. It should be the domain of your display logic, not your domain objects. Usually it's the code consuming the FooBat that is able to make this decision in a better way than the object itself. That aside... public interface Label{ string getLabel(); boolean isDefault(); //or isValued() or use instanceof expressions } public interface Nameable{ string getName(); } public class FooBat implements Nameable { public string Name { get; set; } public Label Label { get { if (_label == null) { _label = new DefaultLabel(this); } return _label; } set { _label = value; } } } public class DefaultLabel implements Label{ public DefaultCharSequence(Nameable named){ this.named = named; } public string getLabel(){ return named.getName(); } public boolean isDefault(){ return true; } } public class StringLabel implements Label { ... } It all essentially boils down to returning a better class for your label object.

http://stackoverflow.com/comment/376927
comment on: http://stackoverflow.com/a/565656
type: AnswerComment
has text: No as I said above URL is a final class, it's from the JDK.
type: Comment
score: 1

http://stackoverflow.com/comment/125483209
comment on: http://stackoverflow.com/a/564334
type: Comment
has text: @zafar142003 it works exactly the same with primitive variables.
score: 0
type: AnswerComment

http://stackoverflow.com/q/402316
has body: I'm coming from a web-development background and I am wondering how I would make a learning algorithm in Java/C++. Not so much the algorithm part, but making the program "remember" what it learned from the previous day. I would think something like saving a file, but I suspect their might be an easier way. Apologies if this question is just over the top stupid. Thanks.
tagged with: c++
has title: Learning Algorithm and Saving Data in Software
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/402320
tagged with: algorithm
possible better answer: http://stackoverflow.com/a/402327
has answer: http://stackoverflow.com/a/402342
downvote count: 0
has answer: http://stackoverflow.com/a/402327
accepted answer: http://stackoverflow.com/a/402320
has answer: http://stackoverflow.com/a/402321
favorite count: 0
answer count: 5
has answer: http://stackoverflow.com/a/402326

http://stackoverflow.com/comment/25715639
has text: I recently came across this little tid bit, thought I'd share it. http://stackoverflow.com/a/1602139/58961
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/562231

http://stackoverflow.com/comment/432950
score: 0
type: QuestionComment
type: Comment
has text: @Oscar: It should be a language-independent question IMHO. People can find the answer for both languages here.
comment on: http://stackoverflow.com/q/619945

http://stackoverflow.com/comment/399383
type: Comment
has text: Post the output of the compiler please
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/587280

http://stackoverflow.com/comment/208547
type: Comment
comment on: http://stackoverflow.com/q/381066
type: QuestionComment
has text: Why do you sort the keys before making the regexp?
score: 0

http://stackoverflow.com/q/579109
accepted answer: http://stackoverflow.com/a/580532
type: Question
has comment: http://stackoverflow.com/comment/57681770
upvote count: 16
has answer: http://stackoverflow.com/a/579185
favorite count: 0
has title: Which Rich Client Platform to use
has answer: http://stackoverflow.com/a/626354
has comment: http://stackoverflow.com/comment/31202712
tagged with: osgi
has answer: http://stackoverflow.com/a/721935
has answer: http://stackoverflow.com/a/21731329
answer count: 10
possible better answer: http://stackoverflow.com/a/915722
has answer: http://stackoverflow.com/a/915722
downvote count: 0
has body: We recently started to develop a Java desktop app and management has requested that we make use of Rich Client Platform. I know of four for Java namely: Eclipse RCP - www link to ecipse rcp, Netbean RCP - Netbeans RCP web site, Spring RCP - spring rich client Valkyrie RCP - Valkyrie rich client Has anyone got any experience in any of these and if so what are the strength and weaknesess of each? thanks
score: 16
has answer: http://stackoverflow.com/a/3404760
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2904837
has answer: http://stackoverflow.com/a/579263
tagged with: java
has answer: http://stackoverflow.com/a/579158
has answer: http://stackoverflow.com/a/580532
tagged with: rcp

http://stackoverflow.com/a/595344
type: AcceptedAnswer
downvote count: 0
score: 11
upvote count: 11
has body: Static methods would be very slightly better performance and memory wise: Avoid (potential) overhead of virtual function calls. Eliminates memory needed for an actual instance of the class. Eliminates need to get an instance of the class when you use it. But honestly I'd probably still make it a singleton anyways. The gains you'd get by not doing it are likely so small that they would make zero difference, even in a mobile environment.
accepted answer of: http://stackoverflow.com/q/595301
type: Answer
answers question: http://stackoverflow.com/q/595301

http://stackoverflow.com/comment/265121
type: Comment
comment on: http://stackoverflow.com/a/443258
has text: How can it "receive" an instance of that class without actually instantiating it? *Something* has to create an instance in the JVM, doesn't it?
score: 0
type: AnswerComment

http://stackoverflow.com/a/431761
has comment: http://stackoverflow.com/comment/255204
accepted answer of: http://stackoverflow.com/q/431663
answers question: http://stackoverflow.com/q/431663
type: AcceptedAnswer
has body: You can dynamically build the contents of a sub panel - say based on a file or soemthing - the visual editor is not going to stop you. Generally, VE is intelligent enough to see that you are dynamically build the panel and show the contents (say contents of a file in a JList) Sometimes, VE fails to render the items because 'The control is too complex' - but this does not happen frequently.
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/255185

http://stackoverflow.com/a/72295327
has body: I will tell you why this happened. First of all you have to understand how JVM supports when we assign parent class into the child class using downcasting, because of reference . For example consider in the following code. A is the super type any class that extends from it and can store the reference B class. A a =new B(); When you assign a reference variable into the child class jvm will understand that since A can store the reference of B class that is why you can do it. B b=(B)b; The reason which is called compile time error and why you couldn't directly assign Parent class into the Child class because there is not any extends relationship. Note that casting only occurring with the key which is called extends, that is why you receive the compile time error. Another reason which is called ClassCastException by the runtime because of jvm it directly accept the rule which is okay I accept that it is true but jvm after that will understand that by the runtime it is not store any referance of Child class when code was writing by the programmer who write coding in the syntax .
type: Answer
score: 0
answers question: http://stackoverflow.com/q/380813

http://stackoverflow.com/a/10773333
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/415580
has comment: http://stackoverflow.com/comment/15241364
has body: For those running pre-java7, named groups are supported by joni (Java port of the Oniguruma regexp library). Documentation is sparse, but it has worked well for us. Binaries are available via Maven (http://repository.codehaus.org/org/jruby/joni/joni/).
upvote count: 2
type: Answer

http://stackoverflow.com/comment/40285823
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/381270
type: Comment
has text: There must be some randomness, even holding down the "F" key. For example, I bet you don't know how many nanoseconds was it held down for?

http://stackoverflow.com/a/629737
type: Answer
answers question: http://stackoverflow.com/q/629388
score: 3
upvote count: 3
accepted answer of: http://stackoverflow.com/q/629388
has comment: http://stackoverflow.com/comment/443156
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/442588
has body: Try using setAlwaysOnTop on your JFrame/JWindow.

http://stackoverflow.com/a/584673
has comment: http://stackoverflow.com/comment/12524439
upvote count: 13
type: Answer
has body: Double equals == will always check based on object identity, regardless of the objects' implementation of hashCode or equals. Of course - make sure the object references you are comparing are volatile (in a 1.5+ JVM). If you really must have the original Object toString result (although it's not the best solution for your example use-case), the Commons Lang library has a method ObjectUtils.identityToString(Object) that will do what you want. From the JavaDoc: public static java.lang.String identityToString(java.lang.Object object) Gets the toString that would be produced by Object if a class did not override toString itself. null will return null. ObjectUtils.identityToString(null) = null ObjectUtils.identityToString("") = "java.lang.String@1e23" ObjectUtils.identityToString(Boolean.TRUE) = "java.lang.Boolean@7fa"
score: 11
has comment: http://stackoverflow.com/comment/113256938
answers question: http://stackoverflow.com/q/580984
has comment: http://stackoverflow.com/comment/113217369
downvote count: 2

http://stackoverflow.com/a/453572
answers question: http://stackoverflow.com/q/453538
type: Answer
upvote count: 6
has body: Using JNI is something that should be looked into. Providing the native library for every target platform can reduce this problem.
downvote count: 1
has comment: http://stackoverflow.com/comment/274021
score: 5
has comment: http://stackoverflow.com/comment/273994
has comment: http://stackoverflow.com/comment/274042

http://stackoverflow.com/q/385195
upvote count: 6
type: AnsweredQuestion
tagged with: java
type: Question
tagged with: session
downvote count: 0
possible better answer: http://stackoverflow.com/a/451603
tagged with: controller
answer count: 3
has answer: http://stackoverflow.com/a/394446
favorite count: 0
has body: We've licensed a commercial product (product not important in this context), which is limited by the number of concurrent users. Users access this product by going through a Spring Controller. We have N licenses for this product, and if N+1 users access it, they get a nasty error message about needing to buy more licenses. I want to make sure users don't see this message, and would prefer that requests to the product simply "queue up", rather than having N+1 users actually access it. Of course, they would prefer that I purchase the licenses, so their tool won't let us do this natively. In lieu of being able to control the tool, I'd like to limit the number of concurrent sessions to the controller to never be more than N. Everyone else can wait. We're using Spring MVC. Any ideas?
tagged with: multithreading
has title: Limit Access To a Spring MVC Controller -- N sessions at a time
score: 6
has answer: http://stackoverflow.com/a/385689
accepted answer: http://stackoverflow.com/a/385689
has answer: http://stackoverflow.com/a/451603
tagged with: spring

http://stackoverflow.com/comment/32574983
comment on: http://stackoverflow.com/a/3610097
score: 0
type: AnswerComment
has text: The `if module_name` LBYL is pretty redudant, since the error you get if you simply delete those lines is: `ValueError: Empty module name`.
type: Comment

http://stackoverflow.com/comment/399312
comment on: http://stackoverflow.com/a/587397
type: Comment
score: 0
type: AnswerComment
has text: Shouldn't MyEnum be declared static?

http://stackoverflow.com/q/460542
tagged with: operators
duplicate of: http://stackoverflow.com/q/1991380
downvote count: 1
type: Question
has body: Can anyone explain the use of ^ operator in java with some examples?
type: AnsweredQuestion
score: 73
upvote count: 74
tagged with: java
has answer: http://stackoverflow.com/a/460547
has answer: http://stackoverflow.com/a/460546
has answer: http://stackoverflow.com/a/460569
has title: ^ operator in java
possible better answer: http://stackoverflow.com/a/13368593
favorite count: 0
has answer: http://stackoverflow.com/a/13368593
answer count: 5
accepted answer: http://stackoverflow.com/a/460546
has answer: http://stackoverflow.com/a/460552

http://stackoverflow.com/a/505248
type: Answer
score: 6
upvote count: 6
has body: Yeah, if you want to shut it up, then #set is your friend. Many people shortcut this with a macro like this: #macro( call $this )#set( $stfu = $this )#end Then you can abbreviate to #call( $path.add('blaablaa') )
answers question: http://stackoverflow.com/q/491549
downvote count: 0

http://stackoverflow.com/comment/375940
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/522875
has text: BigDecimal is indeed the answer

http://stackoverflow.com/q/503877
has answer: http://stackoverflow.com/a/503913
has answer: http://stackoverflow.com/a/507534
linked to: http://stackoverflow.com/q/38922754
has answer: http://stackoverflow.com/a/504017
has comment: http://stackoverflow.com/comment/318775
favorite count: 0
has body: I saw on the Internet that I was supposed to use System.nanoTime() but that doesn't work for me - it gives me the time with milliseconds precision. I just need the microseconds before and after my function executes so that I know how long it takes. I'm using Windows XP. Basically, I have this code that, for example, does 1 million up to 10 millions of insertions in a java linked list. The problem is that I can't measure the precision right; sometimes it takes less time to insert everything in the smaller list. Here's an example: class test { public static void main(String args[]) { for(int k=1000000; k&lt;=10000000; k+=1000000) { System.out.println(k); LinkedList&lt;Integer&gt; aux = new LinkedList&lt;Integer&gt;(); //need something here to see the start time for(int i=0; i&lt;k; i++) aux.addFirst(10000); //need something here to see the end time //print here the difference between both times } } } I did this many times - there was an exterior loop doing it 20 times for each k - but the result aren't good. Sometimes it takes less time to to make 10 million insertions than 1 million, because I'm not getting the correct measured time with what I'm using now (System.nanoTime()) Edit 2: Yes, I'm using the Sun JVM. Edit 3: I may have done something wrong in the code, I'll see if changing it does what I want. Edit 4: My mistake, it seems System.nanoTime() works. Phew.
has comment: http://stackoverflow.com/comment/318840
has answer: http://stackoverflow.com/a/7121284
has answer: http://stackoverflow.com/a/503905
has comment: http://stackoverflow.com/comment/319056
has comment: http://stackoverflow.com/comment/318766
linked to: http://stackoverflow.com/q/504103
has answer: http://stackoverflow.com/a/503944
has comment: http://stackoverflow.com/comment/9677033
linked to: http://stackoverflow.com/q/6373550
has comment: http://stackoverflow.com/comment/318742
has answer: http://stackoverflow.com/a/503976
has answer: http://stackoverflow.com/a/33129567
upvote count: 25
has answer: http://stackoverflow.com/a/503924
answer count: 12
tagged with: time
type: UnansweredQuestion
downvote count: 1
has answer: http://stackoverflow.com/a/42321000
has answer: http://stackoverflow.com/a/503937
tagged with: java
score: 24
has title: How can I measure time with microsecond precision in Java?
has answer: http://stackoverflow.com/a/38355758
has comment: http://stackoverflow.com/comment/318837
type: Question

http://stackoverflow.com/comment/1843003
comment on: http://stackoverflow.com/a/644823
has text: So there's both a Void.class and a void.class!
type: AnswerComment
type: Comment
score: 8

http://stackoverflow.com/a/409571
has comment: http://stackoverflow.com/comment/88719311
accepted answer of: http://stackoverflow.com/q/409563
type: Answer
has comment: http://stackoverflow.com/comment/42076757
answers question: http://stackoverflow.com/q/409563
has body: It seems odd to me that you want to catch exceptions and turn them into error codes. Why do you think the caller would prefer error codes over exceptions when the latter is the default in both Java and C#? As for your questions: You should only catch exceptions that you can actually handle. Just catching exceptions is not the right thing to do in most cases. There are a few exceptions (e.g. logging and marshalling exceptions between threads) but even for those cases you should generally rethrow the exceptions. You should definitely not have a lot of try/catch statements in your code. Again, the idea is to only catch exceptions you can handle. You may include a topmost exception handler to turn any unhandled exceptions into something somewhat useful for the end user but otherwise you should not try to catch each and every exception in every possible place.
has comment: http://stackoverflow.com/comment/42156429
has comment: http://stackoverflow.com/comment/41968139
has comment: http://stackoverflow.com/comment/42156266
upvote count: 63
downvote count: 0
has comment: http://stackoverflow.com/comment/41968113
has comment: http://stackoverflow.com/comment/42156383
has comment: http://stackoverflow.com/comment/32613987
has comment: http://stackoverflow.com/comment/42003190
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/16176791
score: 63

http://stackoverflow.com/comment/95946330
has text: ` A strategy pattern is use to perform an operation (or set of operations) in a particular manner` Does it mean operations over objects?
type: Comment
comment on: http://stackoverflow.com/a/616836
score: 2
type: AnswerComment

http://stackoverflow.com/q/510462
has answer: http://stackoverflow.com/a/10291858
has answer: http://stackoverflow.com/a/510940
upvote count: 162
favorite count: 0
accepted answer: http://stackoverflow.com/a/4588605
has body: As documented in the blog post Beware of System.nanoTime() in Java, on x86 systems, Java's System.nanoTime() returns the time value using a CPU specific counter. Now consider the following case I use to measure time of a call: long time1= System.nanoTime(); foo(); long time2 = System.nanoTime(); long timeSpent = time2-time1; Now in a multi-core system, it could be that after measuring time1, the thread is scheduled to a different processor whose counter is less than that of the previous CPU. Thus we could get a value in time2 which is less than time1. Thus we would get a negative value in timeSpent. Considering this case, isn't it that System.nanotime is pretty much useless for now? I know that changing the system time doesn't affect nanotime. That is not the problem I describe above. The problem is that each CPU will keep a different counter since it was turned on. This counter can be lower on the second CPU compared to the first CPU. Since the thread can be scheduled by the OS to the second CPU after getting time1, the value of timeSpent may be incorrect and even negative.
has answer: http://stackoverflow.com/a/5516560
score: 161
tagged with: nanotime
has answer: http://stackoverflow.com/a/54566928
has answer: http://stackoverflow.com/a/32118008
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/7498285
possible better answer: http://stackoverflow.com/a/54566928
linked to: http://stackoverflow.com/q/7866206
tagged with: java
has answer: http://stackoverflow.com/a/518438
linked to: http://stackoverflow.com/q/351565
downvote count: 1
has answer: http://stackoverflow.com/a/2553264
type: Question
has comment: http://stackoverflow.com/comment/24858873
has answer: http://stackoverflow.com/a/4588605
has answer: http://stackoverflow.com/a/4588037
has answer: http://stackoverflow.com/a/510481
has title: Is System.nanoTime() completely useless?
has answer: http://stackoverflow.com/a/35518262
has comment: http://stackoverflow.com/comment/324509
answer count: 14
has answer: http://stackoverflow.com/a/510747
has answer: http://stackoverflow.com/a/510525
has comment: http://stackoverflow.com/comment/15876670

http://stackoverflow.com/q/555804
has answer: http://stackoverflow.com/a/555997
tagged with: charts
has body: There was an earlier thread on Java graph or chart library, where JFreeChart was found to be quite good, but, as stated in its FAQ, it's not meant for real-time rendering. Can anyone recommend a comparable library that supports real-time rendering? Just some basic xy-rendering - for instance, getting a voltage signal from data acquisition system and plotting it as it comes (time on x-axis, voltage on y-axis).
has answer: http://stackoverflow.com/a/555898
has answer: http://stackoverflow.com/a/19369290
possible better answer: http://stackoverflow.com/a/555921
has comment: http://stackoverflow.com/comment/669468
has answer: http://stackoverflow.com/a/558548
has answer: http://stackoverflow.com/a/6741712
tagged with: real-time
has answer: http://stackoverflow.com/a/1870722
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/555877
has answer: http://stackoverflow.com/a/11378133
has answer: http://stackoverflow.com/a/11983481
has answer: http://stackoverflow.com/a/555851
upvote count: 29
has answer: http://stackoverflow.com/a/555921
has title: Real-time Java graph / chart library?
type: AnsweredQuestion
answer count: 12
tagged with: java
has answer: http://stackoverflow.com/a/555877
score: 29
has answer: http://stackoverflow.com/a/4259920
has comment: http://stackoverflow.com/comment/667281
type: Question
tagged with: graph

http://stackoverflow.com/q/611296
has answer: http://stackoverflow.com/a/611312
tagged with: java
possible better answer: http://stackoverflow.com/a/611316
type: Question
has comment: http://stackoverflow.com/comment/423699
has answer: http://stackoverflow.com/a/611937
has answer: http://stackoverflow.com/a/611701
tagged with: java-native-interface
has answer: http://stackoverflow.com/a/611993
has comment: http://stackoverflow.com/comment/423716
answer count: 11
has answer: http://stackoverflow.com/a/612780
accepted answer: http://stackoverflow.com/a/611937
has answer: http://stackoverflow.com/a/611320
downvote count: 0
has answer: http://stackoverflow.com/a/611318
has answer: http://stackoverflow.com/a/611324
favorite count: 0
score: 19
has answer: http://stackoverflow.com/a/770753
has answer: http://stackoverflow.com/a/611568
has title: Should we rewrite our C code in Java or use JNI instead?
has body: I'm currently developing on a project written in Java. We have a bunch of algorithms written in C/C++ (at least a couple hundred) that need to be incorporated in our project. Our two options are to use JNI to call this code, or to rewrite all the algorithms in Java. I am aware of the consequences of using JNI, it can open up a whole new set of problems, which is why rewriting all the code in Java is even being considered. But the thought of rewriting it seems...wrong. The algorithms have been tested and work as far as I know, they're just in the wrong language. In this situation, would JNI make this task easy? Or would it cause more headache than rewriting the code in Java would? FYI - Our Java project is not meant to be portable in any way. That might eliminate one of the downsides of JNI in that it supposedly reduces portability.
has answer: http://stackoverflow.com/a/611316
type: AnsweredQuestion
upvote count: 19

http://stackoverflow.com/q/460819
tagged with: http
type: Question
score: 1
tagged with: java
has body: I have a web application running on port :80, and I have an Axis web service that is part of that web application. As such, the service is running on port :80 as well. However, for security reasons our client has asked us to change the web service port to 8080 so that they can allow access only to that port for remote consumers of the web service. Therefore they won't have access to the regular web application, but have access to the service. Is this possible to do without refactoring the app and taking out the web service in a separate web app?
possible better answer: http://stackoverflow.com/a/460932
answer count: 3
has comment: http://stackoverflow.com/comment/319919
upvote count: 1
has answer: http://stackoverflow.com/a/505240
has answer: http://stackoverflow.com/a/498403
tagged with: axis
accepted answer: http://stackoverflow.com/a/505240
favorite count: 0
has comment: http://stackoverflow.com/comment/279754
tagged with: binding
tagged with: port
has title: Changing port on which an Axis web service is listening to
has answer: http://stackoverflow.com/a/460932
type: AnsweredQuestion
downvote count: 0

http://stackoverflow.com/comment/10208788
type: Comment
has text: I was getting exceptions upon transfer that I fixed by changing `localObjectFlavor` to: `private final DataFlavor localObjectFlavor = new DataFlavor(Integer.class, "Integer Row Index");`
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/4769575

http://stackoverflow.com/a/58204680
type: Answer
answers question: http://stackoverflow.com/q/606352
score: 0
has body: In the interest of completeness there is also wrapping jetty with camel to make it slightly more user friendly. make your test class extend CamelTestSupport then define a route ex: @Override protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { @Override public void configure() { from("jetty:http://localhost:" + portToUse).process( new Processor() { @Override public void process(Exchange exchange) throws Exception { // Get the request information. requestReceivedByServer = (String) exchange.getIn().getHeader(Exchange.HTTP_PATH); // For testing empty response exchange.getOut().setBody("your response"); .... example maven dependencies to get it: org.apache.camel camel-jetty 2.12.1 test org.apache.camel camel-core 2.12.1 test org.apache.camel camel-test 2.12.1 test

http://stackoverflow.com/comment/424471
comment on: http://stackoverflow.com/a/611761
type: AnswerComment
has text: @Pesto: Ya, a single primitive won't be enough, which is why I suggested a fixed point library.
type: Comment
score: 1

design-patterns
tags question: http://stackoverflow.com/q/376427
tags question: http://stackoverflow.com/q/528685
tags question: http://stackoverflow.com/q/555283
tag name: design-patterns
tags question: http://stackoverflow.com/q/484119
tags question: http://stackoverflow.com/q/562404
tags question: http://stackoverflow.com/q/474320
tags question: http://stackoverflow.com/q/448471
tags question: http://stackoverflow.com/q/481319
tags question: http://stackoverflow.com/q/496233
tags question: http://stackoverflow.com/q/606835
tags question: http://stackoverflow.com/q/409541
tags question: http://stackoverflow.com/q/516677
type: Tag
tags question: http://stackoverflow.com/q/492741
tags question: http://stackoverflow.com/q/620810
tags question: http://stackoverflow.com/q/616796
tags question: http://stackoverflow.com/q/535481
tags question: http://stackoverflow.com/q/465099
tags question: http://stackoverflow.com/q/607106
tags question: http://stackoverflow.com/q/519725
tags question: http://stackoverflow.com/q/634049
tags question: http://stackoverflow.com/q/579729
tags question: http://stackoverflow.com/q/614257
tags question: http://stackoverflow.com/q/372631
tags question: http://stackoverflow.com/q/370258
tags question: http://stackoverflow.com/q/592960
tags question: http://stackoverflow.com/q/626669

http://stackoverflow.com/comment/397090
has text: Are these sites on the same domain? e.g. site1.xxx.com, site2.xxx.com?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/581612

http://stackoverflow.com/q/390115
has body: What have others done to get around the fact that the Commons Logging project (for both .NET and Java) do not support Mapped or Nested Diagnostic Contexts as far as I know?
has answer: http://stackoverflow.com/a/1680095
score: 3
has answer: http://stackoverflow.com/a/396062
favorite count: 0
has comment: http://stackoverflow.com/comment/37096286
possible better answer: http://stackoverflow.com/a/396062
tagged with: logging
accepted answer: http://stackoverflow.com/a/1680095
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/3752386
tagged with: apache-commons
upvote count: 3
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/396163
tagged with: .net
downvote count: 0
has title: Logging Commons and Mapped Diagnostic Context

http://stackoverflow.com/a/918868
has body: So I did manage to figure this out. It's kind of complicated, or at least it was to me, as I didn't really (and still don't quite) understand the Model-View-Controller pattern used by FlexGantt. So, here's where we go. We need a TimelineObjectRenderer class that extends the DefaultTimelineObjectRenderer. That renderer has a method that returns a Component, called getTimelineObjectRendererComponent. In that method, I needed to call the methods setActivityFillColor1 and setActivityFillColor2, which are the two colors used to create the vertical blend on an item. The important code is here: public class myTimelineObjectRenderer extends DefaultTimelineObjectRenderer { public Component getTimelineObjectRendererComponent( setActivityFillColor1(new Color(r,g,b)); setActivityFillColor2(new Color(r,g,b)); } } //there is other code in this class, not mentioned here That's the first part. The next part is where we connect that Renderer with the GanttChart object itself, and tell the Chart where to find the Renderer needed for each item. The two lines I used for that are as follows: GanttChart gc = new GanttChart(); gc.getLayerContainer().setTimelineObjectRenderer( new myTimelineObject().getClass(),new myTimelineObjectRenderer()); So, I got there eventually, made it work, and am very impressed with the flexibility of the FlexGantt package.
answers question: http://stackoverflow.com/q/628542
score: 0
type: Answer
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/628542

http://stackoverflow.com/comment/299211
type: Comment
score: 0
type: AnswerComment
has text: am working in java...ms-access is my database..am using winodws vista..not linux
comment on: http://stackoverflow.com/a/482477

http://stackoverflow.com/a/12330628
upvote count: 23
has comment: http://stackoverflow.com/comment/21074444
has body: inject SessionContext, and ask it for your proxy instance: @Stateless public class UserFacade implements UserFacadeLocal { @Resource private SessionContext context; @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) private void create(User user) { System.out.println("Users Count: "+count()); //invocation#1 System.out.println("Users Count Through Context: "+context.getBusinessObject(UserFacadeLocal.class).count()); //invocation#2 } @Override @TransactionAttribute(TransactionAttributeType.NEVER) public int count() { return ((Long) q.getSingleResult()).intValue(); } } in 'invocation#1' this is a Local call, not passing through proxy, it will return the count in 'invocation#2' this is a call through the proxy, and hence you annotate it not to support transaction -which is now opened by create(user) method-, this invocation will throw a transaction exception: javax.ejb.EJBException: EJB cannot be invoked in global transaction
downvote count: 0
answers question: http://stackoverflow.com/q/427452
type: Answer
has comment: http://stackoverflow.com/comment/22579971
score: 23

http://stackoverflow.com/comment/265568
comment on: http://stackoverflow.com/a/441926
type: AnswerComment
has text: Third, Ruby is not slow. No language is slow, because speed is not a trait of the language, but the language implementation. Of the 13 or so Ruby implementations, some are slower than some of the 7 Python implementations, some are faster.
type: Comment
score: 3

http://stackoverflow.com/a/479868
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/479836
has body: without seeing the source code - you will need a complete rewrite. just "porting" will probably not work. out of all available frameworks i'd recommend two: wicket if you want clean lightweight technology. with ajax. jsf/seam if you are in a corporate environment where it it easy to get tons of experienced developers.
upvote count: 1

http://stackoverflow.com/a/440148
type: Answer
downvote count: 0
has body: You can create a transform like so public class PointTransform implements Transform&lt;Point&gt; { public Point read(String value) { return fromString(value); } public String write(Point value) { return toString(value); } // etc ... } Then pass in a Matcher to the Persister constructor so that it can resolve your Transform given the class. Transforms are used for primitives only, like attribute or text values. They should not be used to compose XML, as it will only get escaped when written to the resulting document. Best to use annotations like so. @Root public class Point { @Attribute private int x; @Attribute private int y; public int getX() { return x; } public int getY() { return y; } }
score: 1
has comment: http://stackoverflow.com/comment/262417
answers question: http://stackoverflow.com/q/440087
accepted answer of: http://stackoverflow.com/q/440087
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/133835727

http://stackoverflow.com/comment/17589988
score: 0
type: Comment
has text: I was trying to use scalr but I am getting "No such property: Scalr for class...." error. Do I have to import it? Or will I have to do something more to get it working
comment on: http://stackoverflow.com/a/12204680
type: AnswerComment

http://stackoverflow.com/comment/100833652
type: Comment
has text: It's amazing how many things that should be in the language's core API are in the Apache Commons Lang instead.
comment on: http://stackoverflow.com/a/599269
type: AnswerComment
score: 0

http://stackoverflow.com/a/602639
answers question: http://stackoverflow.com/q/602624
type: Answer
has comment: http://stackoverflow.com/comment/416450
has body: Subtract the per pixel lightness values from one image to the other. This will give you high values per pixel where something is moved, and low values for where things are the same. Total these values and check to see if it's above a certain threshold number to see if a major change has occured. I took a photo of my hand from my laptop to show this:
has comment: http://stackoverflow.com/comment/414869
score: 12
upvote count: 12
downvote count: 0
has comment: http://stackoverflow.com/comment/414902
has comment: http://stackoverflow.com/comment/431496

union
type: Tag
tag name: union
tags question: http://stackoverflow.com/q/393968

http://stackoverflow.com/comment/1155864
score: 0
type: Comment
type: AnswerComment
has text: I agree on above answer for JDK, but is there the same principle when installing JRE? JRE should set JAVA_HOME even if it was set to something else. Would you agree on that?
comment on: http://stackoverflow.com/a/560847

http://stackoverflow.com/q/644814
downvote count: 0
answer count: 1
linked to: http://stackoverflow.com/q/467282
has answer: http://stackoverflow.com/a/644897
type: Question
type: AnsweredQuestion
has body: I'm using Hibernate's implementation of JPA. My Maven pom.xml references hibernate-entitymanager. My question is, does Hibernate EntityManager (called "Standard Java Persistence API for Java SE and Java EE" on Hibernate's home page) depend on or use the Hibernate Core code? I've discovered a bug with Hibernate that is documented and fixed in Hibernate Core. I want to know if EntityManager uses Core and thus has this fix.
favorite count: 0
upvote count: 2
accepted answer: http://stackoverflow.com/a/644897
tagged with: java
tagged with: hibernate
has title: Does Hibernate EntityManager include Core?
score: 2

http://stackoverflow.com/a/509070
type: Answer
has body: You might want to take a look at generics. public static void callHorse(Set&lt;Horse&gt; xSet) { Iterator&lt;Horse&gt; hritr = xSet.iterator(); while (hritr.hasNext()) { exam(hritr.next()); } } public static void exam(Horse obj) { //I want to use exam(Horse hrr) System.out.println(obj); } Of course in your example you could always just cast the objects. Why you don’t want to do that is beyond me.
upvote count: 1
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/509042

http://stackoverflow.com/comment/112574233
type: Comment
score: 1
comment on: http://stackoverflow.com/a/495186
type: AnswerComment
has text: https://docs.oracle.com/javase/tutorial/essential/io/notification.html

http://stackoverflow.com/q/633687
favorite count: 0
answer count: 5
has answer: http://stackoverflow.com/a/14172017
has title: Can an EJB3 bean "self inject" and call its own methods via EJB container?
has answer: http://stackoverflow.com/a/634009
accepted answer: http://stackoverflow.com/a/634009
has answer: http://stackoverflow.com/a/6872424
tagged with: ejb-3.0
upvote count: 14
has comment: http://stackoverflow.com/comment/49878467
has body: Is it possible to "self inject" an EJB in order to call local methods as bean methods? There are some cases where this could be favorable, for example if container managed transactions are used and something should be accomplished in a new transaction. An example how this could work: Foo.java: @Local public interface FoO { public void doSomething(); public void processWithNewTransaction(); // this should actually be private } FooBean.java: @Stateless public class FooBean implements Foo { @EJB private Foo foo; public void doSomething() { ... foo.processWithNewTransaction(); ... } @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void processWithNewTransaction() { ... } } If I extract processWithNewTransaction() to another bean, it would need to be exposed as a public method in the interface, even though it should be called only by FooBean. (The same issue is with my code above, that's why there is a comment in the interface definition.) One solution would be to switch to bean managed transactions. However this would require changing the whole bean to manage its own transactions, and would add a lot of boiler plate to all methods.
has answer: http://stackoverflow.com/a/641009
type: Question
score: 14
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/56365315
possible better answer: http://stackoverflow.com/a/14172017
has answer: http://stackoverflow.com/a/12255700
downvote count: 0

http://stackoverflow.com/comment/51544883
score: 3
has text: After using ORM for more than 5 years my personal choice is Spring JDBC over ORM, and second best is iBatis (MyBatis), I dislike hibernate because of learning curve, less control and performance issues.
type: QuestionComment
comment on: http://stackoverflow.com/q/452385
type: Comment

http://stackoverflow.com/comment/384068
comment on: http://stackoverflow.com/q/571616
type: Comment
has text: First of all, this is a sanity check. Maybe others do not see this as problem at all, if not I would like to know why (maybe it’s just me doing something wrong?) I think it is also opportunity to learn best practices and strategies that helped others deal with the problem.
score: 0
type: QuestionComment

http://stackoverflow.com/a/589172
has body: Given a global array of Color objects named colorTable, this function will find the color from the following colorspace that is the closest* to each one in that array, and then the one of those colors that was farthest away: Red, Green, Blue components a multiple of 4 Red+Green+Blue between 256 and 512 *:"closest" is defined as the lowest sum of squares of difference for each color component. As Paul determined, this seems like a plausible, if insanely inefficiently implemented, naive approach to finding a single color that provides a high contrast with the contents of colorTable. The same result could be found with a single pass through colorTable and a bit more math, instead of some 5 million passes through colorTable, and there are much better ways to find a different color that provides a much higher average contrast.
downvote count: 0
answers question: http://stackoverflow.com/q/589145
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/q/532449
has answer: http://stackoverflow.com/a/534298
favorite count: 0
tagged with: swing
tagged with: gtk
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
has body: Anyone know of anyway to add an extra button next to the general maximize, minimize, restore, and close button on the title bar in Swing GTK L&amp;F? Thanks much.
has answer: http://stackoverflow.com/a/532893
accepted answer: http://stackoverflow.com/a/532893
possible better answer: http://stackoverflow.com/a/534298
has title: Extra button on title bar for Swing GTK L&F
type: Question
answer count: 2
downvote count: 0

http://stackoverflow.com/q/611417
tagged with: language-interoperability
tagged with: java
has comment: http://stackoverflow.com/comment/423891
has comment: http://stackoverflow.com/comment/424880
type: Question
has answer: http://stackoverflow.com/a/611856
has answer: http://stackoverflow.com/a/611424
has answer: http://stackoverflow.com/a/611953
upvote count: 5
score: 5
has answer: http://stackoverflow.com/a/611563
tagged with: perl
downvote count: 0
favorite count: 0
answer count: 5
possible better answer: http://stackoverflow.com/a/611470
has title: How can I pass data from Perl to Java?
has answer: http://stackoverflow.com/a/611470
has body: I'm working on some Java &lt;-> Perl interaction. I would like to know what the best way is to pass information from Perl to Java. (Great answers about Perl and Java here and here btw). There's a lot of text and XML(XML::Twig) I'm parsing in Perl, in a script I'm supposed to call from a Java Web App. So I have all this gathered data, and I need it to use it inside certain objects in Java. What could be a good strategy to send the information from Perl to Java? Is it even possible to return an object or other compatible data structure from Perl to Java? I guess writing to a text file and reading it from Java would make all the optimization gained by using Perl meaningless. Perlformance is an important issue here. EDIT: From what I've seen here, maybe Inline-Java would be a good option?
accepted answer: http://stackoverflow.com/a/611563
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/1454626

http://stackoverflow.com/comment/394888
has text: This is pretty inviolable. Even if you catch just to log and rethrow, there is no guarantee that you actually have the resources to log the error, and not rethrowing is one of the most glorious ways to shoot yourself in the foot. Catch one specific error if you must, but do not catch all of them.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/582014

http://stackoverflow.com/q/403583
has answer: http://stackoverflow.com/a/403632
has answer: http://stackoverflow.com/a/406040
has answer: http://stackoverflow.com/a/403655
answer count: 15
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/403800
has answer: http://stackoverflow.com/a/403626
tagged with: java
has answer: http://stackoverflow.com/a/403755
has body: I know how package level protection in java works. I read a lot of code (including lots of open source stuff) and no-one seem to be using it. The whole protection level seems slightly faulty to me (I'd have c#'s internal any day of the week). Are there any legit real-world use-cases that are in common use ? Edit: A little too late after asking this question I realized I'd forgotten to exclude the "standard" pattern of package protected implementation classes, possibly providing implementations of public interfaces. Everyone uses those, as has been noted several times in the replies. I still think there are a large number of nice replies to this question.
type: Question
possible better answer: http://stackoverflow.com/a/403621
has answer: http://stackoverflow.com/a/403701
has title: What is the use of package level protection in java?
has answer: http://stackoverflow.com/a/404284
has answer: http://stackoverflow.com/a/411303
score: 22
downvote count: 1
upvote count: 23
has answer: http://stackoverflow.com/a/403637
has answer: http://stackoverflow.com/a/403635
accepted answer: http://stackoverflow.com/a/406040
favorite count: 0
has answer: http://stackoverflow.com/a/11777029
has answer: http://stackoverflow.com/a/403621
has answer: http://stackoverflow.com/a/403762
has answer: http://stackoverflow.com/a/404859

http://stackoverflow.com/q/435238
upvote count: 2
score: 0
has answer: http://stackoverflow.com/a/435278
has answer: http://stackoverflow.com/a/435303
downvote count: 2
has comment: http://stackoverflow.com/comment/258088
has title: Universal document format converter
has body: I am looking to convert any format to/from HTML. I'd like to support DOC, DOCX, PDF, ODT, RDF, DocBook, and TXT. I have found lots of format-to-format conversion utilities, but for convenience of implementation, a single tool is best. This will also make it easier to add new formats as the vendor or open-source project expands the library. The ideal "hub" format is HTML, but I could also work with another hub format. To run server-side, this preferably should be a Java library, or alternatively a C/C++ library, COM, or a command-line tool; but not a printer driver, online service, or GUI tool. Commercial and Open Source are okay.
linked to: http://stackoverflow.com/q/391005
has answer: http://stackoverflow.com/a/435277
tagged with: java
type: UnansweredQuestion
answer count: 4
has comment: http://stackoverflow.com/comment/258067
favorite count: 0
type: Question
tagged with: converters
tagged with: http://stackoverflow.com/tag/pdf
has answer: http://stackoverflow.com/a/435304
tagged with: http://stackoverflow.com/tag/html
tagged with: ms-word

http://stackoverflow.com/comment/249067
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/424898
has text: Thanks for the answer. I was hoping that that there would be an annotation or system wide setting that would automatically add the tags in. It seems that maybe that isn't the case. I think I might be running into the fact that any and anyAttribute tags are frowned upon within Sun.

http://stackoverflow.com/a/929659
score: 1
answers question: http://stackoverflow.com/q/492280
downvote count: 0
has body: Maybe you should try com4j which works great for me and supports also com events. You can find it here: https://com4j.dev.java.net/
type: Answer
upvote count: 1

http://stackoverflow.com/comment/259975
score: 0
type: Comment
has text: Yup, that worked! Can you explain why this happens? Afterall, the file is in the src folder where the .class files are stored, why do I have to define the src folder again?
comment on: http://stackoverflow.com/a/437395
type: AnswerComment

http://stackoverflow.com/q/501511
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/501618
tagged with: jsf
tagged with: seam
score: 1
tagged with: java
upvote count: 1
has answer: http://stackoverflow.com/a/578286
type: Question
answer count: 2
has body: I am playing around with a little seam app that has session scope. The last method is sending as mail. How can I invalidate my session after having the mail sent? Right now, when the user calls the initial url again, the session still lives and all of the previously filled in form data is still there. I have found examples how to do that with conversations and ejb, but not with POJOs and sessions. Thanks, Rory
downvote count: 0
tagged with: pojo
has title: How to invalidate seam POJO session
favorite count: 0

http://stackoverflow.com/comment/32878346
type: Comment
comment on: http://stackoverflow.com/a/5741365
type: AnswerComment
has text: Yes this is exactly what I was looking for. A way to push it through for research test code. Nothing fancy. Yeah I know that that's what they all say :) The various maven plugin solutions seem to be overkill for my purposes. I have some jars that were given to me as 3rd party libs with a pom file. I want it to compile/run quickly. This solution which I trivially adapted to python worked wonders for me. Cut and pasted into my pom.
score: 0

http://stackoverflow.com/q/634059
has title: url and name spaces java convertion
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/634095
accepted answer: http://stackoverflow.com/a/634075
has answer: http://stackoverflow.com/a/634095
answer count: 2
upvote count: 1
tagged with: url
has answer: http://stackoverflow.com/a/634075
favorite count: 0
downvote count: 0
tagged with: namespaces
type: Question
type: AnsweredQuestion
has body: I need to be able to convert: (url) http://www.joe90.com/showroom to (namespace) com.joe90.showroom I can do this using tokens etc, and a enforced rule set. However, is there a way (a java package) that will do this for me? or do i need to write one myself? Thanks

http://stackoverflow.com/a/638590
has body: Use g.setComposite(AlphaComposite.Src), like so: Graphics2D g; ... g.setComposite(AlphaComposite.Src) g.copyArea(x,y,w,h,dx,dy); Thanks to unwind for suggesting the use of Graphics2D.
upvote count: 2
score: 2
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/638363
downvote count: 0
answers question: http://stackoverflow.com/q/638363
type: Answer

http://stackoverflow.com/a/722577
has body: public void replaceBackground(String newBackground, String CurrentForm, String newFile) throws Exception { PdfReader reader = new PdfReader(newBackground); PdfReader reader2 = new PdfReader(CurrentForm); PdfStamper stamp = new PdfStamper(reader2, new FileOutputStream(newFile)); stamp.replacePage(reader, 1, 1); stamp.close(); }
answers question: http://stackoverflow.com/q/431966
upvote count: 2
accepted answer of: http://stackoverflow.com/q/431966
type: AcceptedAnswer
type: Answer
score: 2
downvote count: 0

statistics
tags question: http://stackoverflow.com/q/634092
tag name: statistics
tags question: http://stackoverflow.com/q/442758
type: Tag

http://stackoverflow.com/a/640561
downvote count: 0
has body: There is one reason not mentioned by the above. You can decorate any interface easily with java.lang.reflect.Proxy allowing you to add custom code at runtime to any method in the given interface. It is very powerful. See http://tutorials.jenkov.com/java-reflection/dynamic-proxies.html for a tutorial.
answers question: http://stackoverflow.com/q/639592
type: Answer
upvote count: 1
score: 1

http://stackoverflow.com/q/370369
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/29503700
has comment: http://stackoverflow.com/comment/199417
type: Question
has body: I have a JTable with a custom TableModel called DataTableModel. I initialized the table with a set of column names and no data as follows: books = new JTable(new DataTableModel(new Vector&lt;Vector&lt;String&gt;&gt;(), title2)); JScrollPane scroll1 = new JScrollPane(books); scroll1.setEnabled(true); scroll1.setVisible(true); JSplitPane jsp1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scroll1, scroll2); JSplitPane jsp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, inventory, jsp1); myPanel.add(jsp2, BorderLayout.CENTER); I later want to update books with a set of data, and use the following: DataTableModel d = (DataTableModel)books.getModel(); d.setValues(bookList); books.setModel(d); where bookList is a Vector&lt;Vector&lt;String&gt;&gt; that definitely has data. However, although all this code is being executed, it is not displaying on the screen. The code for the setValues() method is: public void setValues(Vector&lt;Vector&lt;String&gt;&gt; v) { values = v; fireTableDataChanged(); } Am I missing something here? The class and methods for my DataTableModel are (these methods are all implemented to return correct results): public class DataTableModel extends AbstractTableModel { public DataTableModel(Vector&lt;Vector&lt;String&gt;&gt; v, Vector&lt;String&gt; c) {} public int getColumnCount() { if (values != null &amp;&amp; values.size() &gt; 0) return values.elementAt(0).size(); else return 0; } public int getRowCount() { if (values != null &amp;&amp; values.size() &gt; 0) return values.size(); else return 0; } public Object getValueAt(int arg0, int arg1) {} public void setValues(Vector&lt;Vector&lt;String&gt;&gt; v) {} public Vector&lt;Vector&lt;String&gt;&gt; getValues() {} public void setColumnNames(Vector&lt;String&gt; columns) {} public String getColumnName(int col) {} }
possible better answer: http://stackoverflow.com/a/370700
tagged with: user-interface
downvote count: 0
has answer: http://stackoverflow.com/a/370700
tagged with: jtable
has comment: http://stackoverflow.com/comment/199980
has answer: http://stackoverflow.com/a/370565
answer count: 3
has comment: http://stackoverflow.com/comment/199414
favorite count: 0
has title: JTable updates not appearing
upvote count: 1
tagged with: swing
accepted answer: http://stackoverflow.com/a/370565
type: AnsweredQuestion

http://stackoverflow.com/comment/92697026
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/11520425
type: Comment
has text: PosixFilePermission is only for the Portable operating systems. PosixFilePermission wont work with the windows systems

http://stackoverflow.com/a/618394
has comment: http://stackoverflow.com/comment/431612
upvote count: 2
answers question: http://stackoverflow.com/q/618276
downvote count: 1
has comment: http://stackoverflow.com/comment/432129
type: Answer
has comment: http://stackoverflow.com/comment/431625
score: 1
has body: It can be very hard to try to translate your though process from one langauge to another. You can, as others have pointed out, do some work arounds to maybe get what you want... but the sooner you "accept" the way that Java is designed to work the better off you will be when working in Java. I have had to do some PHP stuff... annoyed me to no end that I couldn't get it to do what I wanted... so it goes both ways. The biggest obstacle you are going to run into is likely the static typing. There are things you can try to do to work around it, but in the end they will be a very large hack. In the early days of C++ people tried to convince C++ to behave like Smalltalk... didn't work out too well. In the early days if Java people tried to take their C++ knowledge and use it in Java... didn't work out too well (which is doubly frustrating as the languages are very similar on the surface). My advice, for your Java coding learn to program like a Java developer rather than a PHP developer. For your immediate problem, is it possible that you should really be retuning differnt classes from the factory instead of creating the same kind of object with differnt variables set?

http://stackoverflow.com/comment/38230573
score: 34
comment on: http://stackoverflow.com/a/415956
type: AnswerComment
type: Comment
has text: @DanBarowy well, you *are* mutating it (i.e. calling methods that do not return values but cause other methods to return different values) so until proven otherwise you should always assume that it’s not thread-safe to do so.

http://stackoverflow.com/comment/131299158
type: Comment
comment on: http://stackoverflow.com/a/50128144
score: 0
type: AnswerComment
has text: -1 is out of range for jdk16. Message appearing: `-1 is outside the allowed range [ 0 ... 1073741823 ]`. Max range is 1073741823 maybe.

http://stackoverflow.com/a/612682
downvote count: 0
upvote count: 8
type: Answer
has body: You may want to look at Quartz. Quartz is a full-featured, open source job scheduling system that can be integrated with, or used along side virtually any J2EE or J2SE application - from the smallest stand-alone application to the largest e-commerce system. Quartz can be used to create simple or complex schedules for executing tens, hundreds, or even tens-of-thousands of jobs; jobs whose tasks are defined as standard Java components or EJBs. The Quartz Scheduler includes many enterprise-class features, such as JTA transactions and clustering.
score: 8
answers question: http://stackoverflow.com/q/612656

http://stackoverflow.com/comment/15209254
has text: @SoftwareMonk Instead of doing something with NoCloseInputStream, why not simply flush the stream and leave it open until the time when you need to close the underlying socket?
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/486088

dialog
tag name: dialog
tags question: http://stackoverflow.com/q/508723
type: Tag

http://stackoverflow.com/a/367649
downvote count: 2
score: 29
answers question: http://stackoverflow.com/q/367626
upvote count: 31
has comment: http://stackoverflow.com/comment/36309870
type: Answer
has comment: http://stackoverflow.com/comment/36315469
has body: It looks like SyndFeed is not using generics. You could either have an unsafe cast and a warning suppression: @SuppressWarnings("unchecked") List&lt;SyndEntry&gt; entries = (List&lt;SyndEntry&gt;) sf.getEntries(); or call Collections.checkedList - although you'll still need to suppress the warning: @SuppressWarnings("unchecked") List&lt;SyndEntry&gt; entries = Collections.checkedList(sf.getEntries(), SyndEntry.class);

http://stackoverflow.com/comment/422049
has text: Tomcat is written in Java - how do you think it starts if not via a main() method?
type: AnswerComment
comment on: http://stackoverflow.com/a/609409
type: Comment
score: 0

http://stackoverflow.com/a/925169
answers question: http://stackoverflow.com/q/473065
downvote count: 0
type: Answer
score: 3
upvote count: 3
has body: Logback is a rewrite of log4j. If you like log4j, you should like logback even better. Moreover, logback is a native implementation of the SLF4J API which means that is you are using logback, then you are actually using SLF4J. Thus, if for any reason you wish to switch back to another logging framework, be it log4j or j.u.l. you can do so by replacing one jar file with another.

http://stackoverflow.com/comment/395434
score: 5
comment on: http://stackoverflow.com/a/583319
has text: I've just spent over an hour debugging an app because I forgot that an Executor will not log Errors propagated out of Runnables. My code now catches, logs and re-throws. So I disagree!
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/33550259
has text: @MatthiasBraun OK, I agree with you, I didn't know about it. I edited the answer.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/17557883
type: Comment

http://stackoverflow.com/a/16949358
upvote count: 3
has body: The solutions posted above didn't work in my case, I needed an extra Javascript variable to do the transference: var codesJS=new Array(); &lt;% String[] codes=(String[])request.getAttribute("codes"); if(codes!=null){ for(int i=0; i&lt;codes.length; i++){ %&gt; var code='&lt;%= codes[i] %&gt;'; //--&gt; without this doesnt work codesJS[&lt;%= i %&gt;]=code; &lt;%} }%&gt;
has comment: http://stackoverflow.com/comment/53637941
answers question: http://stackoverflow.com/q/516565
type: Answer
downvote count: 1
score: 2

http://stackoverflow.com/a/552393
score: 1
answers question: http://stackoverflow.com/q/552320
has body: I'd add to cletus' first suggestion - the easiest way of making bar immutable would be to use a List instead of an array and return it wrapped in an unmodifiableList. That way it's immediately clear to the client of the class that the contents of bar can't be altered - an UnsupportedOperationException is thrown. Messing about with deep cloning will probably be pretty inefficient, depending on the complexity of your objects, and still returns a bunch of mutable objects - it's just that any changes made to those will be ignored by Foo. class Foo { private List&lt;String&gt; bar = new ArrayList&lt;String&gt;(); public Collection&lt;String&gt; getBar() { return Collection.unmodifiableList(bar); } } (Also might be worth noting that with generics in Java 5+, a list behaves much more like an array than it used to).
upvote count: 1
type: Answer
downvote count: 0

http://stackoverflow.com/a/3767585
type: Answer
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/564699
upvote count: 1
has body: For Java, the authoritative answer is hidden in Chapter 1 (Introduction) of the Java Language Specification ("JLS," 3rd edition, viewable online for free): Declaration order is significant only for local variables, local classes, and the order of initializers of fields in a class or interface.

http://stackoverflow.com/comment/575553
comment on: http://stackoverflow.com/a/518944
has text: I think your points on premature optimization are spot on and I second those comments.
type: Comment
score: 1
type: AnswerComment

http://stackoverflow.com/a/471382
downvote count: 0
score: 1
type: Answer
has body: I have tried to used TPTP before and I never could set it up right. I could recommend to you that you try the profiler included with netbeans to connect to your application. I've used it to profile an Application with JNI calls and it served me well. Of course, all native code is opaque to the profiler and it only tells you how long the native calls themselves took. I have a blog entry that explains how to profile Eclipse applications using netbeans, if it helps.
upvote count: 1
answers question: http://stackoverflow.com/q/453896

http://stackoverflow.com/a/586401
downvote count: 0
answers question: http://stackoverflow.com/q/586363
score: 3
has body: At a guess, because it's not used that often. The only reason I could see using it is if your direct parent has overridden some functionality and you're trying to restore it back to the original. Which seems to me to be against OO principles, since the class's direct parent should be more closely related to your class than the grandparent is.
upvote count: 3
type: Answer

http://stackoverflow.com/a/10200105
score: 1
type: Answer
has body: Adding this answer so that people know how to inject an array since this come up first on a google search. I believe either of these will work: In a Module's configure: bind(InjectedObject[].class).toInstance(someArray); or as a Provider method: @Provides InjectedObject[] getInjectedObject(@Inject Provider&lt;InjectedObject&gt; provider) { InjectedObject[] objects = new InjectedObject[5]; for (int i = 0; i &lt; objects.length; i++) { objects[i] = provider.get(); } }
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/592046

http://stackoverflow.com/a/642191
downvote count: 0
score: 12
accepted answer of: http://stackoverflow.com/q/641906
type: Answer
answers question: http://stackoverflow.com/q/641906
has body: You'll need some kind of synchronization. CyclicBarrier class has what you need: A synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point. CyclicBarriers are useful in programs involving a fixed sized party of threads that must occasionally wait for each other. The barrier is called cyclic because it can be re-used after the waiting threads are released. After each 'tick', you can let all your threads to wait for others, which were slower. When remaining threads reach the barrier, they all will continue.
upvote count: 12
type: AcceptedAnswer

http://stackoverflow.com/comment/18784767
has text: Java EE 6 Tutorial assumes understanding basic security concepts, so a little overview of JAAS won't hurt.
type: AnswerComment
type: Comment
score: 2
comment on: http://stackoverflow.com/a/694820

atomic
tags question: http://stackoverflow.com/q/421357
type: Tag
tag name: atomic
tags question: http://stackoverflow.com/q/595631
tags question: http://stackoverflow.com/q/579925

http://stackoverflow.com/q/572134
has answer: http://stackoverflow.com/a/572249
tagged with: java
has answer: http://stackoverflow.com/a/572162
upvote count: 10
has answer: http://stackoverflow.com/a/572257
possible better answer: http://stackoverflow.com/a/572250
type: Question
answer count: 8
has body: We have a huge (old legacy java) code-base, where many files (around 5k) have System.out.println's. We are planning to remove them for cleanup/performance reasons. How can we write a script that will replace them without introducing any issues in the code? The script cannot blindly delete them as following case can be an issue: if () some.code... else System.out.println(...); DB.close(); I'm thinking of replacing them with ';'. That will take care of above case. Do you see any other issues? Any other suggestions?
tagged with: performance
has answer: http://stackoverflow.com/a/572222
score: 10
has answer: http://stackoverflow.com/a/572999
has title: How to remove System.out.println's from codebase
tagged with: code-cleanup
has answer: http://stackoverflow.com/a/572643
downvote count: 0
has comment: http://stackoverflow.com/comment/384155
favorite count: 0
accepted answer: http://stackoverflow.com/a/572222
has comment: http://stackoverflow.com/comment/384401
has comment: http://stackoverflow.com/comment/385034
tagged with: scripting
has answer: http://stackoverflow.com/a/572729
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/572250

http://stackoverflow.com/a/500118
answers question: http://stackoverflow.com/q/499528
downvote count: 0
score: 1
type: Answer
upvote count: 1
has body: The code you linked to on anddev.org is for SDK version m5-rc14 which is from February, 2008 almost an entire year old. The current SDK version is 1.0, with two releases between it and m5-rc14. Given the nature of the Android project they have added and removed many interfaces in its rapid growth/adoption. A lot of people have complained that they are closing out some of the interfaces to some cool parts of the operating system, such as the Telephony interface. You can check out android.telephony (link) package and see if there is equivalent functionality there.

http://stackoverflow.com/a/581020
has comment: http://stackoverflow.com/comment/971003
type: Answer
has comment: http://stackoverflow.com/comment/392888
has comment: http://stackoverflow.com/comment/394027
has body: What exactly are you planning on doing with it (what you want to do makes a difference with what you will need to call). hashCode, as defined in the JavaDocs, says: As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the Java&trade; programming language.) So if you are using hashCode() to find out if it is a unique object in memory that isn't a good way to do it. System.identityHashCode does the following: Returns the same hash code for the given object as would be returned by the default method hashCode(), whether or not the given object's class overrides hashCode(). The hash code for the null reference is zero. Which, for what you are doing, sounds like what you want... but what you want to do might not be safe depending on how the library is implemented.
score: 125
downvote count: 0
accepted answer of: http://stackoverflow.com/q/580984
answers question: http://stackoverflow.com/q/580984
upvote count: 125
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/392883
has comment: http://stackoverflow.com/comment/393858
has comment: http://stackoverflow.com/comment/393238

http://stackoverflow.com/comment/278586
type: AnswerComment
has text: It appears that she has JDK and JRE installed, and the JDK includes a JRE, so jre/lib/rt.jar is ambiguous
score: 0
type: Comment
comment on: http://stackoverflow.com/a/459297

http://stackoverflow.com/q/503957
has comment: http://stackoverflow.com/comment/4126096
accepted answer: http://stackoverflow.com/a/503986
has title: Why do people use Velocity and/or NVelocity?
has answer: http://stackoverflow.com/a/505142
tagged with: asp.net-mvc
has body: Over the past year I have heard alot about Velocity and NVelocity. Reading their documentation and doing searches on the net hasn't given me the answers I was looking for. In what situation would I use this library in my development? What problem does it solve that didn't already have a solution?
has answer: http://stackoverflow.com/a/503978
tagged with: java
tagged with: theory
upvote count: 4
has answer: http://stackoverflow.com/a/506691
downvote count: 0
tagged with: .net
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/20744709
has answer: http://stackoverflow.com/a/505859
tagged with: templates
favorite count: 0
answer count: 6
score: 4
type: Question
has answer: http://stackoverflow.com/a/503986
possible better answer: http://stackoverflow.com/a/505859

http://stackoverflow.com/comment/360510
comment on: http://stackoverflow.com/a/545348
score: 0
type: AnswerComment
has text: Typo (I assume) in #15: "(does not have NAMED capturing groups)"
type: Comment

reserved-words
tag name: reserved-words
type: Tag
tags question: http://stackoverflow.com/q/423994

http://stackoverflow.com/comment/396851
comment on: http://stackoverflow.com/a/584889
type: AnswerComment
score: 0
type: Comment
has text: Interesting.. the schema name is MySql??

http://stackoverflow.com/comment/10294834
type: Comment
has text: Translation? Every context is a subcontext unless it's at the top of the tree - no parents.
type: AnswerComment
comment on: http://stackoverflow.com/a/409163
score: 0

http://stackoverflow.com/a/601810
type: Answer
score: 4
upvote count: 4
has body: You can use the POI library for reading from excel files
has comment: http://stackoverflow.com/comment/414032
downvote count: 0
answers question: http://stackoverflow.com/q/601795

http://stackoverflow.com/q/451385
type: UnansweredQuestion
has title: Remove uses of certain Java classes at compile time
has body: I am looking for a way to remove all uses of a particular class, including the class itself, at compile time. Basically a form of pre-processing, but I'd like to do it without having to surround all the instances with #ifdebug ... #endif. Is there any ant-based tool out there that can do this? If not, can anyone point me in the right direction for how to write such a tool? (not a minor undertaking I know, but if its the only option...) The situation is I have a helper class for debugging function calls. This is instantiated at the beginning of a function and a call is made at the end. This is a JavaME application so I'm nervous about the overhead this is adding to performance. I already have a release and debug build that have pre-processor directives using ProGuard, so I would like to exclude the use of this helper class from the release build. It doesn't appear this can be done with ProGuard.
answer count: 4
score: 2
tagged with: java
has answer: http://stackoverflow.com/a/451446
type: Question
has answer: http://stackoverflow.com/a/451444
has answer: http://stackoverflow.com/a/451493
downvote count: 0
upvote count: 2
has answer: http://stackoverflow.com/a/451472
has comment: http://stackoverflow.com/comment/272132
tagged with: preprocessor
favorite count: 0
has comment: http://stackoverflow.com/comment/11320709

http://stackoverflow.com/q/464471
has answer: http://stackoverflow.com/a/464561
score: 2
has comment: http://stackoverflow.com/comment/285915
tagged with: java
has body: How can I write a program in Java that will execute another program? Also, the input of that program should be given from our program and the output of that program should be written into a file. This is my small set of code to get its output: Process p = Runtime.getRuntime().exec("C:\\j2sdk1.4.0\bin\\helloworld.java"); BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); while ((line = input.readLine()) != null) System.out.println(line); input.close(); This was my set of code but this throws an IOException.
type: Question
has answer: http://stackoverflow.com/a/464488
has answer: http://stackoverflow.com/a/464482
upvote count: 3
downvote count: 1
has answer: http://stackoverflow.com/a/468007
has answer: http://stackoverflow.com/a/464479
tagged with: exec
favorite count: 0
has title: External program from our Java program
answer count: 5
type: UnansweredQuestion
tagged with: process

http://stackoverflow.com/comment/378604
has text: @Albert: Most currency types can handle this. Otherwise use another decimal type, or long number of 1/100 cents.
type: Comment
comment on: http://stackoverflow.com/a/522870
score: 0
type: AnswerComment

http://stackoverflow.com/q/609697
favorite count: 0
tagged with: autocad
type: Question
tagged with: http://stackoverflow.com/tag/pdf
has title: How to convert AutocadDWG To PDF?
score: 4
has answer: http://stackoverflow.com/a/1197073
answer count: 2
tagged with: dwg
tagged with: java
has answer: http://stackoverflow.com/a/822298
upvote count: 4
has body: Is there another way to convert AutocadDWG To PDF but to use third party programs? Thanks for any suggestions.
downvote count: 0
type: UnansweredQuestion

http://stackoverflow.com/comment/24457437
score: 7
type: AnswerComment
has text: Technically, this will include the documents that have been deleted. `reader.numDocs()` takes this into account.
comment on: http://stackoverflow.com/a/14029561
type: Comment

http://stackoverflow.com/comment/280736
score: 0
type: AnswerComment
has text: Package-private is sufficient, if both are put in the same package.
comment on: http://stackoverflow.com/a/462102
type: Comment

http://stackoverflow.com/a/10195927
answers question: http://stackoverflow.com/q/415953
type: Answer
has comment: http://stackoverflow.com/comment/36670250
downvote count: 1
upvote count: 23
score: 22
has body: My not very revealing answer: private String md5(String s) { try { MessageDigest m = MessageDigest.getInstance("MD5"); m.update(s.getBytes(), 0, s.length()); BigInteger i = new BigInteger(1,m.digest()); return String.format("%1$032x", i); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return null; }

http://stackoverflow.com/comment/295097
type: Comment
comment on: http://stackoverflow.com/a/478010
has text: +1: Java feature. Language works as advertised. You must create independent instances.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/454595
type: AnswerComment
has text: Ahh that one!! :) I didn't quite remember the exact API, but I hope that gave you something to search into. Also, there is the opposite method convertRowModelToIndex ( or something like that )
type: Comment
comment on: http://stackoverflow.com/a/641106
score: 0

http://stackoverflow.com/q/425281
score: 17
upvote count: 18
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/425506
has answer: http://stackoverflow.com/a/425334
has body: I keep getting stuck conceptually on deciding an Exception-handling structure for my project. Suppose you have, as an example: public abstract class Data { public abstract String read(); } And two subclasses FileData, which reads your data from some specified file, and StaticData, which just returns some pre-defined constant data. Now, upon reading the file, an IOException may be thrown in FileData, but StaticData will never throw. Most style guides recommend propagating an Exception up the call stack until a sufficient amount of context is available to effectively deal with it. But I don't really want to add a throws clause to the abstract read() method. Why? Because Data and the complicated machinery using it knows nothing about files, it just knows about Data. Moreover, there may be other Data subclasses (and more of them) that never throw exceptions and deliver data flawlessly. On the other hand, the IOException is necessary, for if the disk is unreadable (or some such) an error must be thrown. So the only way out that I see is catching the IOException and throwing some RuntimeException in its place. Is this the correct philosophy?
has answer: http://stackoverflow.com/a/425349
has title: Java Style: Properly handling exceptions
possible better answer: http://stackoverflow.com/a/425289
has answer: http://stackoverflow.com/a/425288
has answer: http://stackoverflow.com/a/425289
favorite count: 0
tagged with: exception
answer count: 5
accepted answer: http://stackoverflow.com/a/425349
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/comment/4276907
score: 0
type: Comment
has text: BTW, this is what org.apache.commons.lang.ArrayUtils does too.
comment on: http://stackoverflow.com/a/644764
type: AnswerComment

http://stackoverflow.com/comment/7718123
has text: @giraff: a priority queue is just that, a data structure that is very efficient at keeping a priority queue. You can poll from the front and get the data items in sorted order. However heaps don't maintain a total order of elements internally (that's why they are so efficient), so there is no way of accessing elements in order without executing the poll operation.
score: 10
type: AnswerComment
comment on: http://stackoverflow.com/a/2326244
type: Comment

http://stackoverflow.com/a/541506
has comment: http://stackoverflow.com/comment/134865252
has comment: http://stackoverflow.com/comment/134865133
has body: Yes: implements Runnable is the preferred way to do it, IMO. You're not really specialising the thread's behaviour. You're just giving it something to run. That means composition is the philosophically "purer" way to go. In practical terms, it means you can implement Runnable and extend from another class as well... and you can also implement Runnable via a lambda expression as of Java 8.
has comment: http://stackoverflow.com/comment/39554575
has comment: http://stackoverflow.com/comment/23100395
upvote count: 1849
has comment: http://stackoverflow.com/comment/54286587
score: 1846
has comment: http://stackoverflow.com/comment/62241479
has comment: http://stackoverflow.com/comment/62241733
has comment: http://stackoverflow.com/comment/134865188
has comment: http://stackoverflow.com/comment/114117461
accepted answer of: http://stackoverflow.com/q/541487
has comment: http://stackoverflow.com/comment/20646368
downvote count: 3
has comment: http://stackoverflow.com/comment/36685451
has comment: http://stackoverflow.com/comment/68573170
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/45931889
has comment: http://stackoverflow.com/comment/45301491
has comment: http://stackoverflow.com/comment/39555610
answers question: http://stackoverflow.com/q/541487
has comment: http://stackoverflow.com/comment/50200141
has comment: http://stackoverflow.com/comment/134865126
has comment: http://stackoverflow.com/comment/67098952
has comment: http://stackoverflow.com/comment/62241582
has comment: http://stackoverflow.com/comment/32850673
has comment: http://stackoverflow.com/comment/68569458
has comment: http://stackoverflow.com/comment/39558475
has comment: http://stackoverflow.com/comment/21516801
has comment: http://stackoverflow.com/comment/39557929
type: Answer
has comment: http://stackoverflow.com/comment/67099149
has comment: http://stackoverflow.com/comment/62241520
has comment: http://stackoverflow.com/comment/114115096
has comment: http://stackoverflow.com/comment/354282
has comment: http://stackoverflow.com/comment/45931841
has comment: http://stackoverflow.com/comment/25817939
has comment: http://stackoverflow.com/comment/39555341

http://stackoverflow.com/a/1499699
answers question: http://stackoverflow.com/q/426084
score: 94
upvote count: 94
downvote count: 0
has body: When you are coding in Eclipse, press CTRL and click on any core Java class name in your source. Eclipse will now show a screen saying you don't have the sources installed. However, in this screen there is a link saying "Attach source...". Click that link and import the src.zip file from your JDK installation directory (src.zip). This should do the trick
type: Answer

http://stackoverflow.com/a/463425
upvote count: 1
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/282907
answers question: http://stackoverflow.com/q/463282
has body: When you receive the file, parse it and put the information in the database. Make one table with a record per line that will need a getPerson request. Have one or more threads get records from this table, perform the request and put the completed record back in the table. Once all records are processed, generate the complete file and return it.

http://stackoverflow.com/a/606508
type: Answer
downvote count: 0
score: 2
has comment: http://stackoverflow.com/comment/424997
upvote count: 2
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/445092
accepted answer of: http://stackoverflow.com/q/606489
has body: Java Server Faces (JSF) has a dataTable component. If you combine that with a framework built on top of JSF such as IceFaces you will get sorting as well. But if you're looking for a quick library to drop into a JSP, check out displayTag. Doesn't handle editing of the data (should be easy enough to write some code for this anyway) but will handle paging and sorting.
has comment: http://stackoverflow.com/comment/427171
answers question: http://stackoverflow.com/q/606489

http://stackoverflow.com/comment/317641
type: Comment
comment on: http://stackoverflow.com/a/501287
has text: The reason local vars used by an inner class must be final and definitely assigned to, is because your inner class then can work on a copy of those variables to avoid scoping issues when the enclosing method exits. Not because of a mental model. Again I fail to see your point :)
type: AnswerComment
score: 0

http://stackoverflow.com/comment/394012
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/580001
has text: Yes, since there is no way the get is looking for what's being put (by definition since they have to be on different threads). If there was a possible race condition (if you could be looking for what you are putting in at the same time) it wouldn't work.
score: 0

http://stackoverflow.com/a/610783
downvote count: 0
score: 4
answers question: http://stackoverflow.com/q/610732
type: Answer
has body: Ant allows CRISP (complete, repeatable, informative, schedulable, portable) builds. You can find great info on it in this presentation by Mike Clark and in his book, Pragmatic Project Automation.
upvote count: 4

http://stackoverflow.com/comment/328976
comment on: http://stackoverflow.com/q/515133
has text: You should clarify whether your GUI class *contains* a mode or *is parent of* modes. You should certainly be doing a *contains* relationship.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/562400
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/6754154
answers question: http://stackoverflow.com/q/562273
upvote count: 3
has body: Note that the Java Sound API isn't implemented correctly on Mac OS X.
downvote count: 1

code-generation
tag name: code-generation
tags question: http://stackoverflow.com/q/452627
tags question: http://stackoverflow.com/q/441410
tags question: http://stackoverflow.com/q/443356
tags question: http://stackoverflow.com/q/530945
type: Tag
tags question: http://stackoverflow.com/q/360282
tags question: http://stackoverflow.com/q/396337

http://stackoverflow.com/a/582145
type: Answer
upvote count: 4
score: 3
has body: There are a number of free flash components that exist with nice multiple file upload capability. They make use of ActionScripts FileReference class with a PHP (or whatever) receiver on the server side. Some have recently broken with the launch of FP10 but I know for certain that swfupload will work :) Hope this helps!
answers question: http://stackoverflow.com/q/582126
downvote count: 1

http://stackoverflow.com/a/576858
downvote count: 1
answers question: http://stackoverflow.com/q/576855
score: 17
upvote count: 18
has body: Arrays.fill(). The method is overloaded for different data types, and there is even a variation that fills only a specified range of indices.
type: Answer

http://stackoverflow.com/a/586578
has comment: http://stackoverflow.com/comment/9747649
has body: I don't have enough reputation to comment so I will add this to the other answers. Jon Skeet answers excellently, with a beautiful example. Matt B has a point: not all superclasses have supers. Your code would break if you called a super of a super that had no super. Object oriented programming (which Java is) is all about objects, not functions. If you want task oriented programming, choose C++ or something else. If your object doesn't fit in it's super class, then you need to add it to the "grandparent class", create a new class, or find another super it does fit into. Personally, I have found this limitation to be one of Java's greatest strengths. Code is somewhat rigid compared to other languages I've used, but I always know what to expect. This helps with the "simple and familiar" goal of Java. In my mind, calling super.super is not simple or familiar. Perhaps the developers felt the same?
has comment: http://stackoverflow.com/comment/889332
has comment: http://stackoverflow.com/comment/399077
type: Answer
upvote count: 14
answers question: http://stackoverflow.com/q/586363
score: 13
downvote count: 1

http://stackoverflow.com/a/781161
has body: A simpler approach would be replacing the matches of this regular expression: ("[^",]+),([^"]+") By this: $1$2
score: 0
answers question: http://stackoverflow.com/q/639264
type: Answer

http://stackoverflow.com/q/407492
tagged with: transactions
score: 1
tagged with: java
tagged with: hibernate
has body: I have a DAO implementation that uses a HibernateTransactionManager for transaction management and the application has 2 session factories. I am getting an exception at the transactionManager.commit() line below. Does performing Hibernate operations within a transaction manager related to a different session factory cause problems? TransactionStatus status = transactionManager.getTransaction(def); try{ doHibernateStuff1(); //Does Hibernate stuff with session //factory related to Tx Manager doHibernateStuff2(); //Does Hibernate stuff with session //factory not related to Tx Manager } catch(DataAccessException){ transactionManager.rollback(status); } transactionManager.commit(status); //Exception happens here. The exception appears to be trying to perform the operations in doHibernateStuff2(); again in the txManager.commit(). If you want to suggest a kludge and/or proper way of dealing with this, I would appreciate it.
type: Question
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/407502
has answer: http://stackoverflow.com/a/14123680
favorite count: 0
has title: HibernateTransactionManager(Spring) with multiple Session Factories
type: UnansweredQuestion
upvote count: 1
tagged with: spring

http://stackoverflow.com/comment/7585422
has text: Any specific reason about why not to use java.nio? Actually, I am trying to implement some asynchronous i/o in my project at work and I haven't used either of these before. Hence wanted to know. Thanks.
comment on: http://stackoverflow.com/q/592303
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/602388
has body: You could read the file as you are doing just now but when you read a string that is a Class type create an instance of the correct Vehicle type. It would appear that you would then know that the next x lines of the file are properties of that particular type so you would read the properties and set them on your Vehicle instance. You then have your Vehicle instance to add to the Vehicle array.
type: Answer
has comment: http://stackoverflow.com/comment/415248
answers question: http://stackoverflow.com/q/602356
score: 0

http://stackoverflow.com/comment/238167
has text: There should be no conflict here. Might be an implementation bug. Which JSF library provider (e.g. Apache; Sun)? What version? What control is the facet of? A stack trace might help.
comment on: http://stackoverflow.com/q/412697
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/124975016
has text: `@Beta` has been recently [removed](https://github.com/google/guava/commit/9f6a38402076fc0a85a48627c16312c50887435a) from the source but as far as I know, there is yet a release with this change. Anyway, `ClassPath` itself recommends to use [classgraph](https://github.com/classgraph/classgraph/wiki) instead.
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/13477227
type: Comment

http://stackoverflow.com/comment/2468320
comment on: http://stackoverflow.com/a/2424497
has text: To illustrate my words (yet another post that illustrates the pain that people were feeling during development or why Hibernate did win the battle): http://www.mail-archive.com/open-jpa-dev@incubator.apache.org/msg04107.html. It seems obvious to me that reflection/cglib was a practical answer to people's problems (and people don't care if an API is conceptually superior if it's a pain to use) and I don't see any Hibernate key players here, just users. So at the end I wonder who is spreading FUD actually...
type: AnswerComment
type: Comment
score: 2

http://stackoverflow.com/comment/376059
score: 0
comment on: http://stackoverflow.com/a/562425
type: Comment
has text: Pleasure. Corrected the post. (Do I get an up vote? Accepted answer?)
type: AnswerComment

http://stackoverflow.com/comment/23331105
type: Comment
comment on: http://stackoverflow.com/a/500627
has text: @Sumit Desai: only the reference is copied - about the same time and space overhead as copying a primitive.
score: 0
type: AnswerComment

http://stackoverflow.com/a/420082
accepted answer of: http://stackoverflow.com/q/420013
type: AcceptedAnswer
has body: I use Subclipse and it does support moving files between packages
downvote count: 0
answers question: http://stackoverflow.com/q/420013
has comment: http://stackoverflow.com/comment/245224
has comment: http://stackoverflow.com/comment/245296
has comment: http://stackoverflow.com/comment/2184319
type: Answer
has comment: http://stackoverflow.com/comment/245537
has comment: http://stackoverflow.com/comment/245850
has comment: http://stackoverflow.com/comment/245471
score: 15
upvote count: 15

http://stackoverflow.com/comment/82879002
type: AnswerComment
score: 0
type: Comment
has text: I wish the default java packages would make handling dates less convoluted... I mean it's such a pain every time you want to deal with dates... just a rant...
comment on: http://stackoverflow.com/a/20488107

http://stackoverflow.com/a/530812
has body: So, the short answer to my question is "no." However, it's interesting to examine why. Look at the netstat output from a valid local connection. Here are the ports that I see opened up as a result of a jconsole making a local connection to itself. As you can see, port 1650 is the local port being used for the JMX information: Proto Local Address Foreign Address State TCP Gandalf:1650 Gandalf:1652 ESTABLISHED TCP Gandalf:1650 Gandalf:1653 ESTABLISHED TCP Gandalf:1650 Gandalf:1654 ESTABLISHED TCP Gandalf:1650 Gandalf:1655 ESTABLISHED TCP Gandalf:1650 Gandalf:1656 ESTABLISHED TCP Gandalf:1652 Gandalf:1650 ESTABLISHED TCP Gandalf:1653 Gandalf:1650 ESTABLISHED TCP Gandalf:1654 Gandalf:1650 ESTABLISHED TCP Gandalf:1655 Gandalf:1650 ESTABLISHED TCP Gandalf:1656 Gandalf:1650 ESTABLISHED However, it's not sufficient to try to connect jconsole to localhost:1650. Sadly, all that will net you is a "Connection failed: no such object in table" message. So, the conclusion of my original story is that, if we are going to facilitate remote monitoring using JMX for our customers, we really need to identify unique individual remote access ports for the variety of Java processes that are started in our system. Fortunately, all this requires is the judicious use of the VM argument: com.sun.management.jmxremote.port=portNum where we will almost certainly have a sequential pre-specified range of portNum so that the customer can select the correct remote application using the port number.
type: Answer
answers question: http://stackoverflow.com/q/516142
score: 2
has comment: http://stackoverflow.com/comment/343965
upvote count: 2
has comment: http://stackoverflow.com/comment/398056
downvote count: 0

http://stackoverflow.com/q/386695
favorite count: 0
has answer: http://stackoverflow.com/a/386725
has title: option for inheritance
has comment: http://stackoverflow.com/comment/214355
answer count: 4
has answer: http://stackoverflow.com/a/386787
score: 2
upvote count: 2
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/386723
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/214263
possible better answer: http://stackoverflow.com/a/386787
has answer: http://stackoverflow.com/a/386723
has body: Whats the other option we can use for multiple inheritance other than implementing interface
downvote count: 0
has answer: http://stackoverflow.com/a/386791
tagged with: multiple-inheritance

http://stackoverflow.com/comment/48192413
score: 1
has text: if you use e.g. grep '302 Found' instead of grep 'Coyote' then this can be used on non-Tomcat servers as well - e.g. to check the readyness up of a Jenkins server.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/376305

http://stackoverflow.com/comment/122986085
score: 0
type: Comment
comment on: http://stackoverflow.com/a/370966
has text: @matiasg — And this is one of many reasons we can't have nice things.
type: AnswerComment

http://stackoverflow.com/a/532575
score: 3
has body: Most likely you should really just use a Collection that suits your current need. In the most common cases, if you need a List, use ArrayList, and if you need a Map, use HashMap. For a tutorial, see e.g. http://java.sun.com/docs/books/tutorial/collections/ When your profiler shows you there is an actual memory leak related to the use of Java Collections, then do something about it.
upvote count: 3
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/532521

http://stackoverflow.com/comment/31182643
score: 0
type: Comment
comment on: http://stackoverflow.com/a/387528
type: AnswerComment
has text: @Thomas good to know: I have included your comment in the answer for more visibility.

http://stackoverflow.com/a/628231
downvote count: 0
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/628049
has body: is it better to return void and keep the sum of the polynomials in p? Not bad, not necessarily better either. or is it better to return a polynomial and keep the former value of p intact? It is better, less surprises and code easier to understand and maintain. ( although you will have to create more variables )
type: Answer

http://stackoverflow.com/a/577898
score: 1
answers question: http://stackoverflow.com/q/577868
has body: Try to keep developers working on disjoint parts of the project to reduce merge problems. If developers do overlap, encourage communication to avoid mismerges. Also, try to commit early / often to avoid massive merges but don't allow for commits which render your baseline unbuildable. A continous integration system helps.
upvote count: 1
type: Answer
downvote count: 0

http://stackoverflow.com/a/41244248
downvote count: 0
answers question: http://stackoverflow.com/q/605696
type: Answer
upvote count: 2
has body: I've found that some urls when passed directly to FilenameUtils.getName return unwanted results and this needs to be wrapped up to avoid exploits. For example, System.out.println(FilenameUtils.getName("http://www.google.com/..")); returns .. which I doubt anyone wants to allow. The following function seems to work fine, and shows some of these test cases, and it returns null when the filename can't be determined. public static String getFilenameFromUrl(String url) { if (url == null) return null; try { // Add a protocol if none found if (! url.contains("//")) url = "http://" + url; URL uri = new URL(url); String result = FilenameUtils.getName(uri.getPath()); if (result == null || result.isEmpty()) return null; if (result.contains("..")) return null; return result; } catch (MalformedURLException e) { return null; } } This is wrapped up with some simple tests cases in the following example: import java.util.Objects; import java.net.URL; import org.apache.commons.io.FilenameUtils; class Main { public static void main(String[] args) { validateFilename(null, null); validateFilename("", null); validateFilename("www.google.com/../me/you?trex=5#sdf", "you"); validateFilename("www.google.com/../me/you?trex=5 is the num#sdf", "you"); validateFilename("http://www.google.com/test.png?test", "test.png"); validateFilename("http://www.google.com", null); validateFilename("http://www.google.com#test", null); validateFilename("http://www.google.com////", null); validateFilename("www.google.com/..", null); validateFilename("http://www.google.com/..", null); validateFilename("http://www.google.com/test", "test"); validateFilename("https://www.google.com/../../test.png", "test.png"); validateFilename("file://www.google.com/test.png", "test.png"); validateFilename("file://www.google.com/../me/you?trex=5", "you"); validateFilename("file://www.google.com/../me/you?trex", "you"); } private static void validateFilename(String url, String expectedFilename){ String actualFilename = getFilename…
score: 2

http://stackoverflow.com/q/529457
has answer: http://stackoverflow.com/a/2706434
has comment: http://stackoverflow.com/comment/342434
has comment: http://stackoverflow.com/comment/342517
has answer: http://stackoverflow.com/a/541935
upvote count: 158
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/529855
tagged with: performance
has answer: http://stackoverflow.com/a/3065263
possible better answer: http://stackoverflow.com/a/8440974
tagged with: math
tagged with: java
has answer: http://stackoverflow.com/a/530384
has answer: http://stackoverflow.com/a/8440974
has answer: http://stackoverflow.com/a/7643781
has answer: http://stackoverflow.com/a/1151839
type: Question
linked to: http://stackoverflow.com/q/72593905
has answer: http://stackoverflow.com/a/2173579
has answer: http://stackoverflow.com/a/12721497
has answer: http://stackoverflow.com/a/879201
has comment: http://stackoverflow.com/comment/343326
has answer: http://stackoverflow.com/a/529597
answer count: 19
accepted answer: http://stackoverflow.com/a/3065263
has answer: http://stackoverflow.com/a/529945
score: 156
has body: We are computing something whose runtime is bound by matrix operations. (Some details below if interested.) This experience prompted the following question: Do folk have experience with the performance of Java libraries for matrix math (e.g., multiply, inverse, etc.)? For example: JAMA COLT Apache commons math I searched and found nothing. Details of our speed comparison: We are using Intel FORTRAN (ifort (IFORT) 10.1 20070913). We have reimplemented it in Java (1.6) using Apache commons math 1.2 matrix ops, and it agrees to all of its digits of accuracy. (We have reasons for wanting it in Java.) (Java doubles, Fortran real*8). Fortran: 6 minutes, Java 33 minutes, same machine. jvisualm profiling shows much time spent in RealMatrixImpl.{getEntry,isValidCoordinate} (which appear to be gone in unreleased Apache commons math 2.0, but 2.0 is no faster). Fortran is using Atlas BLAS routines (dpotrf, etc.). Obviously this could depend on our code in each language, but we believe most of the time is in equivalent matrix operations. In several other computations that do not involve libraries, Java has not been much slower, and sometimes much faster.
has answer: http://stackoverflow.com/a/9147778
tagged with: matrix
has comment: http://stackoverflow.com/comment/31211549
has comment: http://stackoverflow.com/comment/342601
favorite count: 0
has answer: http://stackoverflow.com/a/9424625
has answer: http://stackoverflow.com/a/877424
has answer: http://stackoverflow.com/a/1098839
has comment: http://stackoverflow.com/comment/3139621
has answer: http://stackoverflow.com/a/3848817
has title: Performance of Java matrix math libraries?
downvote count: 2
has answer: http://stackoverflow.com/a/1151887

http://stackoverflow.com/comment/296682
type: Comment
score: 1
comment on: http://stackoverflow.com/a/479710
has text: Right, and even if YOU don't write any unsafe or do any interop, you could be using a library that does. So that's something to watch out for.
type: AnswerComment

http://stackoverflow.com/a/457631
has comment: http://stackoverflow.com/comment/369026
has comment: http://stackoverflow.com/comment/281029
upvote count: 8
has comment: http://stackoverflow.com/comment/281026
type: Answer
has comment: http://stackoverflow.com/comment/280096
answers question: http://stackoverflow.com/q/457590
downvote count: 1
has comment: http://stackoverflow.com/comment/19404303
score: 7
has body: I think even EHCache is killing a fly with a napalm bomb. The problem is simple and so is the implementation. I suggest using a servlet filter a the top level so that as little processing as possible is done. Create a class to store the following: The number of attempts (count) The time Now, the code is simple in a sunchronized block: if userid not in attemptMap: attemptMap.add ( userid, new attemptItem ( userid, 1, now ) ) else tmp = attemptMap.get ( userid ) if (acquire lock for tmp) : if tmp.time + 30 &gt; now : tmp.count = 0 tmp.time = now tmp.count++ if tmp.count &gt; 3 : error=true release lock for tmp else : error=true thats it man (as long as the code is synchronized).

http://stackoverflow.com/a/430952
score: 0
has body: I used to really hate doing swing layouts until Netbeans came out with their gui builder. You can see a demo here. http://rghosting.co.cc
type: Answer
answers question: http://stackoverflow.com/q/428256

http://stackoverflow.com/comment/14416870
type: Comment
has text: ConcurrentHashMap can be modified while it is being iterated and it won't throw. The downside is slower performance.
comment on: http://stackoverflow.com/a/603022
score: 0
type: AnswerComment

http://stackoverflow.com/a/12825694
downvote count: 0
has comment: http://stackoverflow.com/comment/17350037
type: Answer
upvote count: 14
score: 14
answers question: http://stackoverflow.com/q/615948
has body: To run batch files using java if that's you're talking about... String path="cmd /c start d:\\sample\\sample.bat"; Runtime rn=Runtime.getRuntime(); Process pr=rn.exec(path);` This should do it.

http://stackoverflow.com/q/635170
type: UnansweredQuestion
has title: SWT DropTargetListener has empty event data under Mac OS X
tagged with: drag-and-drop
tagged with: macos
favorite count: 0
has answer: http://stackoverflow.com/a/639181
type: Question
upvote count: 2
has body: I'm currently experiencing a weird platform inconsistency between Mac OS X and Windows/Linux. I've implemented an SWT DropTargetListener and tried to analyze the data dropped in the dragEnter method. Unfortunately, the data attribute of the TransferData contained in the DropTargetEvent parameter is always null on OS X (but becomes valid in DropTargetListener.drop method where it's too late to give user feedback). It works fine under Windows and Linux. Can anybody help me out? Or is this a known limitation of SWT DND under OS X?
has comment: http://stackoverflow.com/comment/6397066
tagged with: swt
answer count: 1
linked to: http://stackoverflow.com/q/4507559
tagged with: java
tagged with: eclipse
score: 2
downvote count: 0

http://stackoverflow.com/comment/32867117
comment on: http://stackoverflow.com/q/364114
type: Comment
type: QuestionComment
has text: I want to point out that this link http://stackoverflow.com/a/339874/530153 appears to work for installing the jars one at a time.
score: 1

http://stackoverflow.com/q/489853
favorite count: 0
tagged with: reference
tagged with: parameters
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/785007
tagged with: java-native-interface
accepted answer: http://stackoverflow.com/a/489866
tagged with: java
type: Question
upvote count: 4
has answer: http://stackoverflow.com/a/489866
has title: Passing pointer from java to native
downvote count: 0
score: 4
has answer: http://stackoverflow.com/a/784983
has answer: http://stackoverflow.com/a/785007
has body: I'm making an interface to a DLL library, so i can use it with Java. I need my native function to modify the value of a jlong parameter. Like the parameter was passed by reference. My Java method must have the exact parameters as the native function MPUSBWrite shown down here. Example of actual not working code: The MPUSBWrite gets its 4th parameter as reference and modify itrs value. I always get 0 when i read the pLength passed variable. Java: public static native boolean Write(long handle, byte[] pData, int dwLen, long pLength, int dwMilliseconds); Native C++: JNIEXPORT jboolean JNICALL Java_jPicUsb_iface_Write (JNIEnv *env, jclass jc, jlong handle, jbyteArray pData, jint dwLen, jlong pLength, jint dwMilliseconds) { jniByteArray b(env, pData); DWORD res = MPUSBWrite((HANDLE)handle,b.getBytes(),dwLen,(PDWORD)pLength,dwMilliseconds); if (res) { return JNI_TRUE; } else { return JNI_FALSE; } } Is there a way my C++ code modify the value of the pLength variable by reference?
answer count: 3

http://stackoverflow.com/a/585469
answers question: http://stackoverflow.com/q/585452
type: Answer
upvote count: 1
score: 1
has body: This makes me feel like Captain Obvious, but still: just load the entire text first, and then build the label using the desired text. Or, as other posters rightly suggest, use a JTextArea since its more well-suited for multiline content.
downvote count: 0

http://stackoverflow.com/comment/418208
score: 0
type: AnswerComment
has text: A TreeSet doesn't have keys. You're thinking of TreeMap.
type: Comment
comment on: http://stackoverflow.com/a/603783

http://stackoverflow.com/q/493965
has answer: http://stackoverflow.com/a/494030
type: UnansweredQuestion
upvote count: 3
tagged with: java
tagged with: swing
type: Question
score: 3
has title: skeleton app for swing
has body: I'm starting a simple project in swing but i don't want to start from scratch i'm searching a basic starting point with toolbars, file menu and basic functionality that works (exit from the application, button toolbar with a simple actionListener ...). I know there are eclipse rcp and the netbeans one but they are too big for my project. I'm searching something similar to the jgoodies skeleton but it has to be opensource.
answer count: 1
downvote count: 0
favorite count: 0

http://stackoverflow.com/comment/20232543
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/614046
type: Comment
has text: Perhaps what Java needs is a "cantHandle" declaration which would specify that a method or try/catch block of code isn't prepared to handle a particular exception that occurs within it, and that any such exception that occurs via means other than an explicit throw within that method (as opposed to a called method) should be automatically wrapped and rethrown in a RuntimeException. IMHO, checked exceptions should *rarely* propagate up the call stack without being wrapped.

http://stackoverflow.com/comment/29638681
type: Comment
has text: I think this is a sadly neglected answer. Very insightful, IMHO.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/403800

http://stackoverflow.com/a/471431
answers question: http://stackoverflow.com/q/471342
score: 2
downvote count: 0
type: Answer
upvote count: 2
has body: Probably you'll like to learn the most basic first. Here's a sample I have just coded. It start a server, that attends only ONE client, and it sends an object and die. When the user ( you ) press enter, a new client is created, it connects to the previously created server and read the object that server will send. No exception is handled here. Just to make things simpler, but this is NOT the way exception should be handled. When you understand all the concepts here, it will be easier to understand those in the tutorial. import java.io.*; import java.net.*; import java.util.*; public class SimpleServer implements Runnable { // Creates the server, send a "date" and die. public void run() { try { ServerSocket server = new ServerSocket( 8090 ); Date creationDate = new Date(); System.out.println("(Server) Server is ready " + "and running at " + creationDate ); Socket uniqueClient = server.accept(); // We will write using this "chained" object. ObjectOutputStream out = new ObjectOutputStream( uniqueClient.getOutputStream()); out.writeObject( creationDate ); // close all, at this point forget about the exceptions. // this is lesson #1 out.close(); uniqueClient.close(); server.close(); System.out.println("(Server) The server is down"); }catch( IOException ioe ) {} } public static void main ( String [] args ) throws IOException , ClassNotFoundException { Thread serverThread = new Thread( new SimpleServer() ); serverThread.start(); // start the server thread ... doh.. System.out.println("(Client) Press enter when you want "+ " to connect to the server..."); Scanner scanner = new Scanner( System.in ); scanner.nextLine(); Socket client = new Socket("localhost", 8090 ); // Read from this object. ObjectInputStream in = new ObjectInputStream( client.getInputStream() ); Date date = ( Date ) in.readObject(); System.out.println("(Client) Current time is: " + new Date() ); System.out.println("(Client) Object read from server : " + date ); in.close(); client.close(); } } I hope this he…

http://stackoverflow.com/a/568018
type: Answer
has comment: http://stackoverflow.com/comment/379456
has body: I started using the Java API in ~1995. Any API which is that old is easy to criticize. To answer the question of Why: Java introduced enums too late - the API would be much better if it had enums from the beginning. WORA (Write Once, Run Everywhere) - or as some say "Write Once, Debug Everywhere". It is incredibly difficult to make a great API when your target is the least common demoninator. No "real" Windows or Mac or Unix or Linux developer can ever be happy with Java.
upvote count: 1
has comment: http://stackoverflow.com/comment/1668524
score: -3
downvote count: 4
has comment: http://stackoverflow.com/comment/379743
has comment: http://stackoverflow.com/comment/379866
answers question: http://stackoverflow.com/q/567987

http://stackoverflow.com/a/623998
has comment: http://stackoverflow.com/comment/72582076
has body: You might want to look at the Trie implementation that Limewire is contributing to the Google Guava.
upvote count: 38
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/16319450
type: Answer
answers question: http://stackoverflow.com/q/623892
score: 36
downvote count: 2
accepted answer of: http://stackoverflow.com/q/623892
has comment: http://stackoverflow.com/comment/72582152

http://stackoverflow.com/a/627710
answers question: http://stackoverflow.com/q/625726
score: 3
has comment: http://stackoverflow.com/comment/440383
has body: If you want to be more explicit about your locking, you could do something like this: class A { protected final Object mutex = new Object(); public void myOneMethod() { synchronized (mutex) { // ... } } } class B extends A { public void myOtherMethod() { synchronized (mutex) { // ... } } } In fact, this pattern is recommended by Brian Goetz in Java Concurrency in Practice, section 4.2.1 "The Java monitor pattern". That way you know exactly where your monitor is coming from.
has comment: http://stackoverflow.com/comment/47426419
downvote count: 0
type: Answer
upvote count: 3

http://stackoverflow.com/comment/400351
type: QuestionComment
has text: > Lightweight...portal server...quickly... There are three words I never thought I'd see in the same sentence!
score: 1
comment on: http://stackoverflow.com/q/490219
type: Comment

http://stackoverflow.com/comment/26088860
comment on: http://stackoverflow.com/a/644730
score: 0
type: AnswerComment
type: Comment
has text: @Snicolas: I did. However, you can't do this by calling `setAccessible` on the constructor as the `AccessibleObject.setAccessible` method explicitly checks you're not trying to make the `Class` constructor accessible and throws a SecurityException if you are. You have to make the `override` field in `AccessibleObject` accessible and then set that to `true` in order to make the `Class` constructor accessible. The exception I mentioned is what you get if you try to call the Class constructor once you have made it accessible.

http://stackoverflow.com/comment/669967
comment on: http://stackoverflow.com/a/441554
type: Comment
has text: Nice writeup. Small correction: While normally objects are not allocated on the stack, since Java SE 6 javac can do escape analysis, so it may even allocate objects on the stack. See http://www.ibm.com/developerworks/java/library/j-jtp09275.html. But that should all be transparent to developers anyway :-).
score: 0
type: AnswerComment

http://stackoverflow.com/a/699126
score: 229
has comment: http://stackoverflow.com/comment/52365042
answers question: http://stackoverflow.com/q/603189
upvote count: 229
has comment: http://stackoverflow.com/comment/32830441
downvote count: 0
type: Answer
has body: In Maven: The Definitive Guide, I wrote about the differences between Maven and Ant in the introduction the section title is "The Differences Between Ant and Maven". Here's an answer that is a combination of the info in that introduction with some additional notes. A Simple Comparison I'm only showing you this to illustrate the idea that, at the most basic level, Maven has built-in conventions. Here's a simple Ant build file: simple example build file <property name="src" location="src/main/java"/> <property name="build" location="target/classes"/> <property name="dist" location="target"/> <tstamp/> <mkdir dir="${build}"/> <javac srcdir="${src}" destdir="${build}"/> <mkdir dir="${dist}/lib"/> <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/> <delete dir="${build}"/> <delete dir="${dist}"/> In this simple Ant example, you can see how you have to tell Ant exactly what to do. There is a compile goal which includes the javac task that compiles the source in the src/main/java directory to the target/classes directory. You have to tell Ant exactly where your source is, where you want the resulting bytecode to be stored, and how to package this all into a JAR file. While there are some recent developments that help make Ant less procedural, a developer's experience with Ant is in coding a procedural language written in XML. Contrast the previous Ant example with a Maven example. In Maven, to create a JAR file from some Java source, all you need to do is create a simple pom.xml, place your source code in ${basedir}/src/main/java and then run mvn install from the command line. The example Maven pom.xml that achieves the same results. 4.0.0 org.sonatype.mavenbook my-project 1.0 That's all you need in your pom.xml. Running mvn install from the command line will process resources, compile source, execute unit tests, create a JAR, and install the JAR in a local repository for reuse in other projects. Without modification, you can run mvn site and then find …

http://stackoverflow.com/a/427313
upvote count: 10
type: Answer
downvote count: 0
has body: The operations you've listed block because of the underlying platform (ie. native code). You can implement a block using Java's Object.wait() and Object.notify() methods; wait() will block the calling thread until another thread calls notify() on the same lock.
score: 10
answers question: http://stackoverflow.com/q/427306

http://stackoverflow.com/comment/8020284
type: Comment
comment on: http://stackoverflow.com/a/6761383
score: 1
has text: I see, but you're creating a new instance so this wouldn't work if the object has any state.
type: AnswerComment

http://stackoverflow.com/a/502461
type: Answer
score: 8
downvote count: 0
has body: Java doesn't have anything like C++'s notion of const. It's a point of some contention, although it's interesting to note that .NET doesn't either. I believe the reasons are: Getting understandable syntax becomes pretty tricky (IMO) - telling the difference between a const list of mutable StringBuilders and a mutable list of const StringBuilders etc is difficult. (I've certainly found it hard in C++, although that could be due to a lack of practice.) I strongly suspect that it wouldn't be acceptable to allow the constness to be cast away in managed languages. It would go against the grain of the whole thing. That could make them harder to work with in many cases. Propagating the information about constness at execution time (to avoid the possibility of it being cast away) may be difficult and/or expensive in performance terms As Java (and .NET) haven't had constness in the past, introducing it late on in the game is hugely difficult - unless all common libraries support it (and get it right at every step!) you end up with a nasty mishmash, and indeed it may be completely unworkable if you need to use two libraries, one of which doesn't know about constness and the other of which only supplies const values.
upvote count: 8
answers question: http://stackoverflow.com/q/502430

http://stackoverflow.com/a/625942
type: Answer
has body: Try using getResourceAsStream() on the ClassLoader instead of new FileInputStream(). This will return an InputStream that you can pass to the AudioStream. So something like: InputStream in = getClassLoader().getResourceAsStream(getClassLoader().getResource()); AudioStream as = new AudioStream(in)
answers question: http://stackoverflow.com/q/625928
accepted answer of: http://stackoverflow.com/q/625928
score: 4
upvote count: 4
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/337178
comment on: http://stackoverflow.com/a/523881
score: 0
type: Comment
has text: The extra String manipulation you are talking about is creating subString at the end, right?
type: AnswerComment

http://stackoverflow.com/comment/296490
has text: Well one problem you've got is that text diff tools/libraries typically operate on a line-by-line basis, meaning they only delineate between lines being same or different and if they're different is it because other lines have been inserted/removed?
type: QuestionComment
type: Comment
score: 0
comment on: http://stackoverflow.com/q/479654

junit
type: Tag
tags question: http://stackoverflow.com/q/405333
tags question: http://stackoverflow.com/q/554641
tags question: http://stackoverflow.com/q/486381
tags question: http://stackoverflow.com/q/535929
tags question: http://stackoverflow.com/q/566275
tags question: http://stackoverflow.com/q/545194
tags question: http://stackoverflow.com/q/427755
tags question: http://stackoverflow.com/q/413214
tags question: http://stackoverflow.com/q/634801
tags question: http://stackoverflow.com/q/512778
tags question: http://stackoverflow.com/q/466841
tags question: http://stackoverflow.com/q/419833
tags question: http://stackoverflow.com/q/629793
tags question: http://stackoverflow.com/q/512184
tag name: junit
tags question: http://stackoverflow.com/q/589603
tags question: http://stackoverflow.com/q/461417
tags question: http://stackoverflow.com/q/589563
tags question: http://stackoverflow.com/q/425039
tags question: http://stackoverflow.com/q/473401
tags question: http://stackoverflow.com/q/440786
tags question: http://stackoverflow.com/q/495779
tags question: http://stackoverflow.com/q/530203
tags question: http://stackoverflow.com/q/588267
tags question: http://stackoverflow.com/q/461678
tags question: http://stackoverflow.com/q/423627
tags question: http://stackoverflow.com/q/466893
tags question: http://stackoverflow.com/q/427750
tags question: http://stackoverflow.com/q/604449
tags question: http://stackoverflow.com/q/631598
tags question: http://stackoverflow.com/q/428627
tags question: http://stackoverflow.com/q/457276
tags question: http://stackoverflow.com/q/400338
tags question: http://stackoverflow.com/q/531371
tags question: http://stackoverflow.com/q/385925
tags question: http://stackoverflow.com/q/521692
tags question: http://stackoverflow.com/q/491503
tags question: http://stackoverflow.com/q/466548
tags question: http://stackoverflow.com/q/549341
tags question: http://stackoverflow.com/q/606352
tags question: http://stackoverflow.com/q/528846

http://stackoverflow.com/q/401945
has body: I am a .NET dev learning Java. As a result, I understand all the fundamentals of programming like loops, variables, functions, etc. My biggest bottleneck is that I don't know my way around Java's packages like I do with .NET's. This is the reason for this thread - where do I find the following functionality in Java?: System.Diagnostics - where can I use things like stopwatch, programmatic breakpoints and loggers? Is there a Java equivalent of .NET performance counters? What are weak keys in Java? I just came across a collection which uses weak keys in Java so am asking here. :) Thanks
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/401952
tagged with: java
accepted answer: http://stackoverflow.com/a/402791
has answer: http://stackoverflow.com/a/401958
type: Question
answer count: 7
has answer: http://stackoverflow.com/a/402791
has title: Where can I find the following classes in Java
has answer: http://stackoverflow.com/a/402053
score: 0
possible better answer: http://stackoverflow.com/a/401952
has answer: http://stackoverflow.com/a/401962
has answer: http://stackoverflow.com/a/401956
has answer: http://stackoverflow.com/a/401954

http://stackoverflow.com/q/371026
tagged with: iterator
score: 36
has comment: http://stackoverflow.com/comment/199829
upvote count: 36
downvote count: 0
answer count: 7
has answer: http://stackoverflow.com/a/371091
favorite count: 0
has body: What's the shortest way to get an Iterator over a range of Integers in Java? In other words, implement the following: /** * Returns an Iterator over the integers from first to first+count. */ Iterator&lt;Integer&gt; iterator(Integer first, Integer count); Something like (first..first+count).iterator()
possible better answer: http://stackoverflow.com/a/6828887
has title: Shortest way to get an Iterator over a range of Integers in Java
has answer: http://stackoverflow.com/a/371034
accepted answer: http://stackoverflow.com/a/371034
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/97101790
has answer: http://stackoverflow.com/a/371044
has answer: http://stackoverflow.com/a/371043
has answer: http://stackoverflow.com/a/7956576
type: Question
has answer: http://stackoverflow.com/a/36742140
has comment: http://stackoverflow.com/comment/199810
has answer: http://stackoverflow.com/a/6828887
tagged with: java

http://stackoverflow.com/comment/192122
comment on: http://stackoverflow.com/a/361670
score: 0
type: AnswerComment
has text: Well, I wanted to be able to print out what I just read (in a string), so that it would print out both the XML and the deserialized version (in String format). Is that an easy fix? I would assume so, but when I did what you said, I got GeneralTree@af72d8 (where it was in my memory I guess)
type: Comment

http://stackoverflow.com/a/498308
type: Answer
has comment: http://stackoverflow.com/comment/23314685
has comment: http://stackoverflow.com/comment/323507
downvote count: 1
upvote count: 19
has comment: http://stackoverflow.com/comment/29796565
has comment: http://stackoverflow.com/comment/323431
type: AcceptedAnswer
score: 18
has comment: http://stackoverflow.com/comment/323514
accepted answer of: http://stackoverflow.com/q/498217
has body: (from comments) The issue that brought this up is that I need to pass an 'exception' to a piece of code a coworker is building if a collection does not get built. In that case, you might want to throw a checked exception. You could throw an Exception, an appropriate existing subclass of it (except RuntimeException and its subclasses which are unchecked), or a custom subclass of Exception (e.g. "CollectionBuildException"). See the Java Tutorial on Exceptions to get up to speed with Java exceptions.
answers question: http://stackoverflow.com/q/498217

perl
tags question: http://stackoverflow.com/q/611417
tag name: perl
tags question: http://stackoverflow.com/q/619822
tags question: http://stackoverflow.com/q/381066
type: Tag
tags question: http://stackoverflow.com/q/603554
tags question: http://stackoverflow.com/q/484355

http://stackoverflow.com/comment/430248
type: Comment
comment on: http://stackoverflow.com/a/617257
has text: A minor nit on your minor nit, ArrayList should not be the variable type, declare the variable as List instead. Also make the variables final and the set methods will not compile.
score: 0
type: AnswerComment

http://stackoverflow.com/a/11231090
score: 2
has body: As @Tom Hawtin - tackline said &lt;header/&gt; and &lt;header&gt;&lt;/header&gt; is same. Parsers will give you "". You have to to put nillable on your header annotation @XmlElement(nillable=true, required=true) public String getHeader() { return header; } I hope this code will generate following XML for null value. import javax.xml.bind.*; import javax.xml.bind.annotation.*; @XmlRootElement public class Request { public static void main(String[] args) throws JAXBException { final Request request = new Request(); final JAXBContext context = JAXBContext.newInstance(Request.class); final Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.marshal(request, System.out); System.out.flush(); } @XmlElement(nillable=true, required=true) private String header; } prints &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt; &lt;request&gt; &lt;header xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/&gt; &lt;/request&gt;
answers question: http://stackoverflow.com/q/594537
upvote count: 2
downvote count: 0
type: Answer

http://stackoverflow.com/a/4818650
downvote count: 0
type: Answer
score: 5
has body: I ran into this problem too, and it turned out it was because the Activity wasn't exposed to other processes. I had to add the android:exported="true" attribute to the activity tag in my manifest. See http://developer.android.com/guide/topics/manifest/activity-element.html#exported for more information.
upvote count: 5
answers question: http://stackoverflow.com/q/601294

http://stackoverflow.com/a/9186452
score: 1
accepted answer of: http://stackoverflow.com/q/618850
answers question: http://stackoverflow.com/q/618850
upvote count: 1
type: AcceptedAnswer
has body: You might try out the code that I posted here, which uses JMF and a class named FrameGrabber.
type: Answer
downvote count: 0

http://stackoverflow.com/a/487579
downvote count: 0
type: Answer
score: 1
accepted answer of: http://stackoverflow.com/q/479405
upvote count: 1
has body: I've found the problem and a workaround after a long debugging session. // incomplete code example for(Object table : db.getTables()) { ITable t = (ITable)((ITable)table).clone(true); System.out.println(t.getName()); // modifying t, bag is an existing instance of class PropertyBag t.getConnectionInfo().setAttributes(bag); // dc is an existing instance of DatabaseController dc.setTableLocation((ITable)table, t) } db.getTables() contains 3 tables A, B and C. If we'll run the code above System.out prints A, A, B to the console. If we're going to comment dc.setTableLocation((ITable)table, t) out. A, B, C will be printed. I assume that dc.setTableLocation((ITable)table, t) modifies internally the list of tables. We're using following workaround: // incomplete code example // WORKAROUND CODE Map&lt;ITable, ITable&gt; oldNewMap = new HashMap&lt;ITable, ITable&gt;(); for(Object table : db.getTables()) { ITable t = (ITable)((ITable)table).clone(true); System.out.println(t.getName()); // modifying t, bag is an existing instance of class PropertyBag t.getConnectionInfo().setAttributes(bag); // WORKAROUND CODE oldNewMap.put((ITable)table, t); } // WORKAROUND CODE for (Entry&lt;ITable, ITable&gt; e : oldNewMap.entrySet()) { dc.setTableLocation(e.getKey(), e.getValue()); } I hope somebody will save time and money with this workaround. ;-) I posted it to the official forum as well. Forum: Java Development - Crystal Reports
answers question: http://stackoverflow.com/q/479405
type: AcceptedAnswer

http://stackoverflow.com/comment/55878483
type: AnswerComment
comment on: http://stackoverflow.com/a/4480774
type: Comment
has text: @Pangea jmh is probably superior to Caliper nowadays, See also: https://groups.google.com/forum/#!msg/mechanical-sympathy/m4opvy4xq3U/7lY8x8SvHgwJ
score: 12

http://stackoverflow.com/q/600146
upvote count: 31
has answer: http://stackoverflow.com/a/7333413
linked to: http://stackoverflow.com/q/18559835
has body: I am executing an exe through my java program. The path is hardcoded in Java. I have packaged my the exe in the jar. But am stuck as I have the path name hardcoded in the Java file, so I am not able to execute my jar as a stand alone program. Any hints for packaging such jar i.e having an exe inside and able to run it as a stand alone program?
has answer: http://stackoverflow.com/a/600148
tagged with: exe
favorite count: 0
downvote count: 0
has answer: http://stackoverflow.com/a/14773787
has answer: http://stackoverflow.com/a/36402326
score: 31
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/600198
accepted answer: http://stackoverflow.com/a/600198
tagged with: java
has title: Run exe which is packaged inside jar file
possible better answer: http://stackoverflow.com/a/600148
type: Question
has answer: http://stackoverflow.com/a/600157
tagged with: jar
answer count: 6

http://stackoverflow.com/a/484987
answers question: http://stackoverflow.com/q/484119
type: Answer
has comment: http://stackoverflow.com/comment/301547
has comment: http://stackoverflow.com/comment/306731
upvote count: 2
downvote count: 2
has body: So, what's wrong with this idiom? If there's nothing wrong with this idiom, why haven't I seen it? EDIT: to clarify, PipedInputStream and PipedOutputStream replace the boilerplate buffer-by-buffer copy that shows up everywhere, and they also allow you to process incoming data concurrently with writing out the processed data. They don't use OS pipes. You have stated what it does but haven't stated why you are doing this. If you believe that this will either reduce resources used (cpu/memory) or improve performance then it won't do either. However it will make your code more complex. Basically you have a solution without a problem for which it solves.
has comment: http://stackoverflow.com/comment/58366418
has comment: http://stackoverflow.com/comment/974992
has comment: http://stackoverflow.com/comment/58366698
score: 0
has comment: http://stackoverflow.com/comment/1141945
has comment: http://stackoverflow.com/comment/58366368
has comment: http://stackoverflow.com/comment/982592

http://stackoverflow.com/q/441824
favorite count: 0
score: 260
type: Question
has title: Java "Virtual Machine" vs. Python "Interpreter" parlance?
has answer: http://stackoverflow.com/a/49241488
has body: It seems rare to read of a Python "virtual machine" while in Java "virtual machine" is used all the time. Both interpret byte codes; why call one a virtual machine and the other an interpreter?
tagged with: python
has answer: http://stackoverflow.com/a/66917426
has answer: http://stackoverflow.com/a/57942833
accepted answer: http://stackoverflow.com/a/441973
has answer: http://stackoverflow.com/a/441854
has answer: http://stackoverflow.com/a/441830
has answer: http://stackoverflow.com/a/442210
answer count: 14
tagged with: java
has answer: http://stackoverflow.com/a/58199884
has answer: http://stackoverflow.com/a/53356426
upvote count: 260
has answer: http://stackoverflow.com/a/441901
has answer: http://stackoverflow.com/a/1732383
has answer: http://stackoverflow.com/a/441926
has answer: http://stackoverflow.com/a/441973
possible better answer: http://stackoverflow.com/a/1732383
has answer: http://stackoverflow.com/a/39804828
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/59725809
tagged with: jvm

http://stackoverflow.com/q/581246
accepted answer: http://stackoverflow.com/a/581397
tagged with: serialization
favorite count: 0
upvote count: 1
type: AnsweredQuestion
score: 1
tagged with: java
has title: List serialVersionUIDs in serialized data
has answer: http://stackoverflow.com/a/581309
type: Question
has body: I have a file that contains serialized Java classes. I would like to parse this file in order to get a list of the classes in the file and the serialVersionUID of each class. Is there a tool anyone can recommend to do this, or perhaps someone could offer some pointers on where I should start to accomplish this myself? Cheers Rich
has answer: http://stackoverflow.com/a/581397
answer count: 2
downvote count: 0
possible better answer: http://stackoverflow.com/a/581309

http://stackoverflow.com/a/514386
downvote count: 0
score: 1
has body: There are some static analysis tool (findbugs) that will find these type of errors. Numerical math on computers can be hard. Order of operation matters can affect precision and accuracy in ways that you don't expect. Date math can also be surprisingly tricky. Often it is better to use the Date/Calendar routines rather than trying to do the math yourself but those routines are not the best designed ones in the java class library.
upvote count: 1
answers question: http://stackoverflow.com/q/512266
type: Answer

http://stackoverflow.com/comment/967892
score: 2
comment on: http://stackoverflow.com/a/1149055
type: AnswerComment
has text: In other words, arcsin can't always "undo" the sin function because it's impossible for arcsin to know what the original angle was. For example, the sin of both π/2 and 5π/2 give 1. But what's arcsin(1)? It obviously can't give both back, right? Therefore, the result of arcsin must be restricted to a range of 2π radians, meaning that it can't actually undo the result of the sin function unless the original angle is between 0 and 2π, or in C's case, -π/2 and π/2. (Indeed, arcsin(sin(5π/2)) = π/2.) Anyways, that was a really long explanation, but I hope that helps clear up any misconceptions.
type: Comment

http://stackoverflow.com/a/992510
type: Answer
has comment: http://stackoverflow.com/comment/840017
upvote count: 7
has body: Here is my simplified example. Sadly, you have to click the text field first, before start typing, or you'll get exceptions. If anyone can figure out why, please let me know/update this answer. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class _Autocompleter { private final static JPopupMenu textPopupMenu = new JPopupMenu("MENU") { { add(new JMenuItem("item 1")); add(new JMenuItem("item 2")); setFocusable(false); } }; private final static KeyListener textInputListener = new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { Point p = textInput.getCaret().getMagicCaretPosition(); if (textPopupMenu.isVisible()) { SwingUtilities.convertPointToScreen(p, textInput); textPopupMenu.setLocation(p.x, p.y + 20); } else { textPopupMenu.show(textInput, p.x, p.y + 20); } } }; private final static JTextArea textInput = new JTextArea("type something") { { addKeyListener(textInputListener); setCaretPosition(getText().length()); } }; private final static JFrame f = new JFrame("TEST") { { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); add(textInput); setSize(400, 60); setLocationRelativeTo(null); setVisible(true); } }; public static void main(String[] args) throws Exception { // YES, IT'S EMPTY !!! // It'll start anyway because of static initializers } }
score: 7
downvote count: 0
answers question: http://stackoverflow.com/q/485530

http://stackoverflow.com/a/579080
score: 4
upvote count: 4
has body: Another advantage to using an explicit type parameter would be to allow the service method to be implemented using a Proxy (in this case MyObj would need to be MyInterface). Without explicit type parameters, this would not be possible. You might use a Proxy under the covers for many reasons (testing for one)
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/579031
accepted answer of: http://stackoverflow.com/q/579031

http://stackoverflow.com/comment/21920217
has text: "ending up with your code pollution with tons of empty/re-throw catch blocks" - if you see this, they're not being used correctly. You can take any technique, use it wrong, and offer up a critique of it.
score: 12
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/499458

http://stackoverflow.com/a/443601
score: 5
downvote count: 0
has comment: http://stackoverflow.com/comment/265234
type: Answer
has body: Object Serialization (aka storing things to a file) Hibernate (uses a relational database but it is fairly transparent to the developer) I would suggest Hibernate because it will deal with most of the ugly details that bog developers down when using a database while still allowing for the optimizations that have been made to database software over the years.
upvote count: 5
answers question: http://stackoverflow.com/q/443558

http://stackoverflow.com/a/437995
type: AcceptedAnswer
type: Answer
upvote count: 4
accepted answer of: http://stackoverflow.com/q/437878
downvote count: 0
answers question: http://stackoverflow.com/q/437878
has body: I would definitely, suggest you to go with this. But I would like to add another really important resource, specific to java - as you labeled the question 'java' - which is Java Concurrency in Practice.
score: 4

http://stackoverflow.com/a/824794
answers question: http://stackoverflow.com/q/618265
downvote count: 0
type: Answer
upvote count: 4
score: 4
has body: If you are using a database to store jobs, check the trigger_state of your trigger. Right now I'm seeing a similar problem (or at least it has similar symptoms). A job that runs once a minute is leaving the trigger in "ACQUIRED" state and will never run again. Like you I'm seeing nothing the the log. I'm also seeing a different cause of the same problem. Again, the job just stops running, but the trigger is not in the "ACQUIRED" state. So far I don't know the cause. What I know so far is that the scheduler thread is waiting for a free worker thread. It looks like all of the worker threads are waiting for a semaphore in order to update their schedule. I haven't been able to get a thread dump yet to verify what the worker threads are waiting on. I'm running Quartz 1.6.1 RC1. See this bug report: http://jira.opensymphony.com/browse/QUARTZ-668 I think that's what I'm seeing.

http://stackoverflow.com/q/377203
has answer: http://stackoverflow.com/a/377459
tagged with: java
accepted answer: http://stackoverflow.com/a/377238
answer count: 4
tagged with: method-dispatch
tagged with: null
downvote count: 0
has answer: http://stackoverflow.com/a/377214
score: 13
has title: Java method dispatch with null argument
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/377214
favorite count: 0
has answer: http://stackoverflow.com/a/377238
type: Question
has body: Why does it (apparently) make a difference whether I pass null as an argument directly, or pass an Object that I assigned the value null? Object testVal = null; test.foo(testVal); // dispatched to foo(Object) // test.foo(null); // compilation problem -&gt; "The method foo(String) is ambiguous" public void foo(String arg) { // More-specific System.out.println("foo(String)"); } public void foo(Object arg) { // Generic System.out.println("foo(Object)"); } In other words, why is the (commented-out) second call to foo(...) not dispatched to foo(Object)? Update: I use Java 1.6. I could compile Hemal's code without problems, but mine still doesn't compile. The only difference I see is that Hemal's methods are static while mine are not. But I really don't see why this should make a difference...? Update 2: Solved. I had another method foo(Runnable) in my class, so the dispatcher couldn't unambiguously select the single most specific method. (See my comment in Hemal's second answer.) Thanks everyone for your help.
has answer: http://stackoverflow.com/a/377244
upvote count: 13

fractions
type: Tag
tags question: http://stackoverflow.com/q/474535
tag name: fractions

http://stackoverflow.com/comment/268541
type: Comment
comment on: http://stackoverflow.com/a/447127
score: 0
type: AnswerComment
has text: the function call/parens/etc create a copy of the value "i" into the variable "index", at the time of each iteration of the loop.

http://stackoverflow.com/comment/43280355
type: Comment
has text: This has nothing to do with splitting a file into lines. Consider removing your answer.
score: 2
comment on: http://stackoverflow.com/a/19125208
type: AnswerComment

http://stackoverflow.com/a/570315
has comment: http://stackoverflow.com/comment/388891
downvote count: 1
has comment: http://stackoverflow.com/comment/72172471
has body: Not sure what the "right" way would be but looking at the API, assuming you provide XMLInputSource that takes an InputStream or a Reader you could provide in an InputStream/Reader that is wrapped with a LineNumberInputStream or LineNumberReader and then query it for the line number. eg: InputStream stream; stream = ...; new XMLInputSource(stream); would become: InputStream stream; LineNumberInputStream lineStream; stream = ...; lineStream = new LineNumberInputStream(lineStream); new XMLInputSource(lineStream); // can now ask the line stream what line it is on via getLineNumber() I am guessing you would also need to pass the LineNumberInputStream/LineNumberReader to your class that extends XMLDocumentParser. Not sure if all of that is doable in your code. Alternatively dig into the source and find out how they do it. If the variables/methods you need to access are private, and you are not worried about your code breaking in the future, you could use reflection and remove the access permissions to get at it.
type: Answer
answers question: http://stackoverflow.com/q/570216
score: 1
upvote count: 2

http://stackoverflow.com/a/392213
type: Answer
upvote count: 3
score: 3
has body: I am not familiar with offline profiling. Isn't it what hprof is for?. Otherwise I've had very good experience with YourKit profiler.
answers question: http://stackoverflow.com/q/392203
downvote count: 0
has comment: http://stackoverflow.com/comment/219351

http://stackoverflow.com/comment/64699026
comment on: http://stackoverflow.com/a/407323
has text: This doesn't make any sense. It would be better if you provided a statistic. Why on the earth should A be slower than B!?
type: AnswerComment
score: 1
type: Comment

http://stackoverflow.com/comment/74846349
comment on: http://stackoverflow.com/a/34508760
score: 12
type: AnswerComment
has text: Or if you want more than 10 key-value pairs, you can use `Map.ofEntries`
type: Comment

http://stackoverflow.com/q/575706
accepted answer: http://stackoverflow.com/a/575783
tagged with: java
type: Question
tagged with: graphics
has answer: http://stackoverflow.com/a/575783
score: 18
upvote count: 18
downvote count: 0
answer count: 1
favorite count: 0
has title: Graphics2D: Drawing black on white?
has body: I'm sure this is a very stupid question but I can't find the answer, I'm not experienced with the Java2D API. I'm trying to create an image and write it to GIF or PNG, and I want it to use a black pen on a white background. If I don't set any colors, I get white on black. If I use setPaint() (intended for subsequent draw operations) I get the whole canvas repainted with that color. The following sample renders the whole thing black. The sample is in Scala but you get the idea. Feel free to answer in Java! val bi = new BufferedImage(200, 400, BufferedImage.TYPE_BYTE_BINARY ) val g = bi.createGraphics g.setBackground(Color.WHITE) g.setPaint(Color.BLACK) g.draw(new Rectangle(10, 10, 30, 20))
type: AnsweredQuestion

http://stackoverflow.com/tag/html
tags question: http://stackoverflow.com/q/476721
tags question: http://stackoverflow.com/q/622369
tags question: http://stackoverflow.com/q/387105
tags question: http://stackoverflow.com/q/475839
tags question: http://stackoverflow.com/q/465886
tags question: http://stackoverflow.com/q/395630
tags question: http://stackoverflow.com/q/633780
tags question: http://stackoverflow.com/q/617585
tags question: http://stackoverflow.com/q/560605
type: Tag
tags question: http://stackoverflow.com/q/512342
tags question: http://stackoverflow.com/q/519080
tags question: http://stackoverflow.com/q/635301
tags question: http://stackoverflow.com/q/599634
tags question: http://stackoverflow.com/q/514926
tags question: http://stackoverflow.com/q/601497
tags question: http://stackoverflow.com/q/638886
tags question: http://stackoverflow.com/q/468478
tags question: http://stackoverflow.com/q/541920
tags question: http://stackoverflow.com/q/569351
tags question: http://stackoverflow.com/q/533508
tags question: http://stackoverflow.com/q/535649
tags question: http://stackoverflow.com/q/424696
tags question: http://stackoverflow.com/q/544732
tags question: http://stackoverflow.com/q/614022
tags question: http://stackoverflow.com/q/431579
tag name: html
tags question: http://stackoverflow.com/q/457684
tags question: http://stackoverflow.com/q/646247
tags question: http://stackoverflow.com/q/435238
tags question: http://stackoverflow.com/q/602032

http://stackoverflow.com/comment/245382
has text: Note that this method will not give you the caller, but only the *type of the caller*. You will not have a reference to the object calling your method.
type: AnswerComment
comment on: http://stackoverflow.com/a/421338
type: Comment
score: 49

http://stackoverflow.com/a/360020
score: 6
downvote count: 0
has body: Reducing lines is not really a good argument for dropping braces. If your method is too big, it should probably be refactored into smaller pieces or restructured. Doing that will no doubt increase readability more than simply taking out braces.
answers question: http://stackoverflow.com/q/359732
type: Answer
upvote count: 6

http://stackoverflow.com/comment/389346
has text: @Kent: PLease update your question with this new fact -- not every clusters for HA. Some people cluster because it "seems" necessary. In your case, I think your time is better spent with Schlossnagle's book than trying to get replication to work.
type: Comment
comment on: http://stackoverflow.com/a/560704
score: 0
type: AnswerComment

http://stackoverflow.com/a/629823
has body: A standard deviation of 1.0 entails that many values will lie outside the [-1,1] range. If you need to keep within this range, you should use another method, perhaps nextDouble().
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/629798
upvote count: 1
type: Answer

http://stackoverflow.com/q/440408
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/442497
tagged with: shared-libraries
score: 2
tagged with: installation
has body: I'm integrating JNI bindings with a C++ library. The library follows the usual conventions: the installation root is /usr/local by default and can be modified with the --prefix argument to ./configure; the .a or .so files go in ${prefix}/lib; etc. The JNI binding produces two new libraries, libfoojni.so (the native part) and libfoo.jar (the Java part). Under this scheme, what is conventional place to put these files (e.g. ${prefix}/java)? Is it preferable to allow the user to supply a separate Java root directory (e.g., /usr/share/java)? Should libfoojni.so go in ${prefix}/lib or in some Java-specific sub-directory?
downvote count: 0
tagged with: java
type: Question
tagged with: java-native-interface
has title: Where to install local Java libraries by default?
upvote count: 2
tagged with: autotools
answer count: 1
favorite count: 0

http://stackoverflow.com/comment/441220
has text: so it's not the list size, it's the cell size for each item in the list.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/616958

http://stackoverflow.com/a/547454
has body: I'm not clear on what it is you really want. You say you don't want to emit elements that contain the empty string, and then give as an example this: &lt;dataset&gt; &lt;title&gt; &lt;/title&gt; &lt;/dataset&gt; in which the title element doesn't contain the empty string. It contains whitespace. So I'm going to assume that by "empty string" you mean "whitespace only." Using xsl:strip-space will eliminate whitespace-only text nodes from the source tree before processing it. If you genuinely want to abort the transform with an exception if you encounter an element containing whitespace, you can't use xsl:strip-space, as it will remove all of the exception-triggering conditions before the transform runs. I think what you want to do instead is write a template that looks like this: &lt;xsl:template match="*[not(*) and text() and not(normalize-space(text()) != '')]"&gt; ... This template will match any element for which the following is true: it doesn't have child elements it does contain at least one text node all of the text nodes it contains are whitespace-only So in your example, it won't match the dataset element (because it has a child element), but it will match the title element. It wouldn't match &lt;title/&gt; or &lt;title&gt;&lt;/title&gt;, though, because neither of those elements contains text nodes.
score: 0
has comment: http://stackoverflow.com/comment/359316
type: Answer
has comment: http://stackoverflow.com/comment/359547
answers question: http://stackoverflow.com/q/544153
has comment: http://stackoverflow.com/comment/360166
has comment: http://stackoverflow.com/comment/361001

http://stackoverflow.com/q/623923
score: 0
has answer: http://stackoverflow.com/a/624672
answer count: 2
has body: Okay, I'm using Java and JoGL. I'm trying to load and display a texture, but the texture isn't showing up at all. I'm not getting any errors at all, so I don't know what the problem could be. import javax.media.opengl.*; import javax.media.opengl.glu.*; import com.sun.opengl.util.*; import com.sun.opengl.util.j2d.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.io.*; import java.net.*; import java.nio.*; import javax.imageio.*; import javax.swing.*; public class chartest extends JFrame implements GLEventListener, KeyListener { private int texture; public void display(GLAutoDrawable gLDrawable) { final GL gl = gLDrawable.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); gl.glColor3f(1.0f, 1.0f, 1.0f); gl.glBindTexture(GL.GL_TEXTURE_2D, texture); gl.glBegin(GL.GL_QUADS); // Draw A Quad gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-12.0f, -19.0f, -15.0f); gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 12.0f, -19.0f, -15.0f); gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 12.0f, 19.0f, -15.0f); gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-12.0f, 19.0f, -15.0f); gl.glEnd(); // Done Drawing The Quad gl.glFlush(); } public void displayChanged(GLAutoDrawable g, boolean b, boolean b2){} public void init(GLAutoDrawable gLDrawable) { final GL gl = gLDrawable.getGL(); gl.glClearColor(1.0f, 0.0f, 0.0f, 0.0f); gl.glShadeModel(GL.GL_FLAT); gl.glEnable(GL.GL_TEXTURE_2D); texture = genTexture(gl); gl.glBindTexture(GL.GL_TEXTURE_2D, texture); URL url = this.getClass().getResource("test.png"); try { BufferedImage img = ImageIO.read(url); makeRGBTexture(gl, new GLU(), img, GL.GL_TEXTURE_2D, false); } catch(Exception e) { e.printStackTrace(); } gl.glTexParameteri(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MIN_FILTER,GL.GL_LINEAR); gl.glTexParameteri(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MAG_FILTER,GL.GL_LINEAR); } public void reshape(GLAutoDrawable gLDrawable, int x, int y, int width, int height) { final GL gl = gLDrawable.getGL(); final G…
has title: Why won't my texture show up?
tagged with: jogl
tagged with: textures
has comment: http://stackoverflow.com/comment/436804
accepted answer: http://stackoverflow.com/a/624672
type: AnsweredQuestion
tagged with: opengl
tagged with: java
type: Question
possible better answer: http://stackoverflow.com/a/624381
has answer: http://stackoverflow.com/a/624381

http://stackoverflow.com/a/461060
score: 4
has body: MiGLayout supports this out of the box. Either use this layout manager, or look how it does its magic.
type: AcceptedAnswer
type: Answer
upvote count: 4
accepted answer of: http://stackoverflow.com/q/461011
downvote count: 0
answers question: http://stackoverflow.com/q/461011

http://stackoverflow.com/comment/65234265
has text: FYI… the successor to Joda-Time, [java.time](http://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html), has [nanosecond](https://en.wikipedia.org/wiki/Nanosecond) resolution.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/10202678

http://stackoverflow.com/a/401036
score: 0
has comment: http://stackoverflow.com/comment/229952
type: Answer
answers question: http://stackoverflow.com/q/400994
has body: The key down event is called whenever a key is down, obviously. Its not a multiple key down event, and there is no such thing, so there is no keycode for multiple keys being down. You are just going to have to use a variable to keep track of the crtl key being pressed. This means you are also going to have to use a key up event to keep track of when the control key is released. In pusedo code: // CRTLKeyCode is whatever the code is for the ctrl key private boolean ctrlPressed = false; onKeyDown(KeyEvent event){ int key = event.getKeyCode(); if(key == CRTLKeyCode) ctrlPressed = true; else if(ctrlPressed && key == 112) //Perform your action } onKeyUp(KeyEvent event){ int key = event.getKeyCode(); if(key == CRTLKeyCode) ctrlPressed = false; }

http://stackoverflow.com/comment/63130540
has text: @Martin, in my opinion, it's a good *question*; see the title for the question, and the post content as an explanation for why the *question* is asked. Maybe I am misunderstanding the rules here, but this is exactly the question I wanted when searching for *"uses of final parameters in methods"*.
type: Comment
type: QuestionComment
score: 3
comment on: http://stackoverflow.com/q/500508

http://stackoverflow.com/a/426501
type: Answer
upvote count: 14
has comment: http://stackoverflow.com/comment/250380
accepted answer of: http://stackoverflow.com/q/426479
score: 14
answers question: http://stackoverflow.com/q/426479
type: AcceptedAnswer
downvote count: 0
has body: In adjunct to Ben's answer, a good combo is alpha-beta pruning along with a game like connect 4. The heuristic for something like tic-tac-toe is too simple, and for chess, too complex. But connect 4 or a similiar "middle of the road" game can be an excellent place to see how the heuristic makes a big difference in both efficiency and quality, and it's also complex enough to even get some "niche" heuristics that can win some scenarios over other, generally better heuristics. The rules of connect 4 in particular are simple enough that it's very easy to come up with your own successful heuristics to see these things in action. Another common AI to play with is A* for pathfinding, such as unit travel in an RTS or sandbox environment.

http://stackoverflow.com/comment/396106
type: AnswerComment
has text: OK, just tried this out. It worked pretty good on the table data, however, the column headers were messed up, probably because they are vertically aligned text.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/583631

http://stackoverflow.com/comment/33462550
comment on: http://stackoverflow.com/a/604345
type: Comment
has text: This solution is not about externalizing NamedQueries, you are just turning them into plain String properties of a class. The semantic is lost.
score: 1
type: AnswerComment

http://stackoverflow.com/a/12308589
score: 16
has comment: http://stackoverflow.com/comment/64197258
answers question: http://stackoverflow.com/q/578433
downvote count: 0
type: Answer
upvote count: 16
has body: Note that you shouldn't use hibernate.enable_lazy_load_no_trans pre Hibernate 4.1.7, as it leaks connections. See https://hibernate.onjira.com/browse/HHH-7524

http://stackoverflow.com/q/615899
tagged with: java
has comment: http://stackoverflow.com/comment/3706150
type: Question
has title: Where can I download JOGL?
has body: I'm looking to start using Java Open GL, but I can't find it.
has comment: http://stackoverflow.com/comment/46120000
has comment: http://stackoverflow.com/comment/429452
has answer: http://stackoverflow.com/a/615904
has answer: http://stackoverflow.com/a/622240
has answer: http://stackoverflow.com/a/3539980
has comment: http://stackoverflow.com/comment/428856
favorite count: 0
possible better answer: http://stackoverflow.com/a/4015776
has answer: http://stackoverflow.com/a/7521439
downvote count: 8
answer count: 5
has answer: http://stackoverflow.com/a/4015776
score: 11
type: AnsweredQuestion
upvote count: 19
accepted answer: http://stackoverflow.com/a/615904
has comment: http://stackoverflow.com/comment/10536013
tagged with: jogl
tagged with: opengl

http://stackoverflow.com/a/508710
has body: Java does not have unsigned types. As already mentioned, incure the overhead of BigInteger or use JNI to access native code.
score: 3
has comment: http://stackoverflow.com/comment/323284
type: Answer
upvote count: 3
answers question: http://stackoverflow.com/q/508630
downvote count: 0

http://stackoverflow.com/comment/279880
type: Comment
has text: Sounds like your AS/400 is incorrectly configured regarding its native tongue. If it is set up correctly jt400.jar will not require any other tweaking.
comment on: http://stackoverflow.com/a/369017
score: 1
type: AnswerComment

http://stackoverflow.com/comment/424863
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/611709
has text: read how double is stored, and why it's impossible to have a well-rounded representation of a decimal number in binary form.
type: Comment

http://stackoverflow.com/comment/196413
type: AnswerComment
comment on: http://stackoverflow.com/a/363952
score: 0
type: Comment
has text: You don't even know what his problem is, and you're suggesting a pattern? And by a very ambiguous name, too (http://tinyurl.com/5gjfjt). Otherwise, I agree with you.

http://stackoverflow.com/comment/137353650
comment on: http://stackoverflow.com/a/75692514
score: 0
type: AnswerComment
type: Comment
has text: eg. when p = new Child1(); p.doSomething() calls new Child1().doSomething(); when p = new Child2(); p.doSomething() calls new Child2().doSomething(); one might argue then whats the point if we dont call in static way like Child1.doSomething() or Child2.doSomething() ...the point is : its not always about "static way" but sometimes the need of "one per class"

http://stackoverflow.com/q/458048
favorite count: 0
tagged with: exception
has answer: http://stackoverflow.com/a/460946
type: AnsweredQuestion
tagged with: java
tagged with: hibernate
has body: I have two entities, Entity1 and Entity2, on a one to many relationship. On Entity1 I have a map which contains entries. The code I use to persist a new Entity1 with some Entity2 on the map is like this: Entity1 e1 = new Entity1(); Entity2 e2 = null; e1.setE2s(new HashMap&lt;String, Entity2&gt;()); for (String key : someKeySet()){ e2 = new Entity2(); e2.setCode(key); e2.setSwhon(true); e2.setE1(e1); e1.getE2s(key, e2); em.persist(e1.getE2s().get(key)); } em.persist(e1); em.flush(); and here is a exctract of the entities: @Entity @Table(name = "wm_Entities1") public class Entity1 implements Serializable { private static final long serialVersionUID = 6592708276573465599L; private Map&lt;String, Entity2&gt; e2s; private Long id; @Id @GeneratedValue(strategy=GenerationType.TABLE) public long getId() { return id; } public void setId(long id) { this.id = id; } public void setE2s(Map&lt;String, Entity2&gt; e2s){ this.e2s = e2s; } @OneToMany(mappedBy = "e1", fetch = FetchType.EAGER) public Map&lt;String, Entity2&gt; getE2s() { return e2s; } } @Entity @Table(name = "wm_Entities2") public class Entity2 implements Serializable { private static final long serialVersionUID = -6131765066573346790L; private long id; private Entity1 e1; @Id @GeneratedValue(strategy=GenerationType.TABLE) public long getId() { return id; } public void setId(long id) { this.id = id; } @ManyToOne() @JoinColumn(name="e1_id") public Entity1 getE1() { return this.e1; } public void setE1(Entity1 e1) { this.e1 = e1; } } This seems to work fine since it inserts both entities on the pg database, but the catch is that it is not creating-saving the MapKey of the e2 on the database (theoretically JPA generates this key), so when I get the e1 back, and I try to get the e2s map from it, I have a: javax.ejb.EJBException: org.hibernate.HibernateException: null index column for collection: How can I get this MapKey saved?? Note: I'm using JavaEE with JPA/Hibernate, running over JBoss 4.2, with PGSQL DB.
has comment: http://stackoverflow.com/comment/278510
type: Question
upvote count: 4
accepted answer: http://stackoverflow.com/a/460946
tagged with: jpa
has comment: http://stackoverflow.com/comment/278542
score: 4
has comment: http://stackoverflow.com/comment/279775
has title: Map problem with JPA / Hibernate / PG
downvote count: 0
answer count: 1

http://stackoverflow.com/a/521248
score: 76
type: Answer
has body: Map.Entry These built-in classes are an option, too. Both implement the Map.Entry interface. AbstractMap.SimpleEntry AbstractMap.SimpleImmutableEntry
upvote count: 77
downvote count: 1
answers question: http://stackoverflow.com/q/521171

http://stackoverflow.com/comment/1504102
has text: The link (GeoCities) doesn't work any more. Any updated URL?
comment on: http://stackoverflow.com/a/372005
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/139394673
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/638257
has text: Further update, as of 2024: Oracle donated Java Enterprise Edition ([Java EE](https://en.wikipedia.org/wiki/Jakarta_EE)) to the Eclipse foundation where it became [*Jakarta EE*](https://jakarta.ee/). And EJB has pretty much been put out to pasture.

http://stackoverflow.com/comment/461943
score: 0
type: Comment
type: AnswerComment
has text: Did not work after a week of trying so I turned to Stackoverflow. Just want to make sure I am not missing some poorly documented configuration issue.
comment on: http://stackoverflow.com/a/647119

http://stackoverflow.com/a/583483
has comment: http://stackoverflow.com/comment/395451
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/395497
upvote count: 1
answers question: http://stackoverflow.com/q/583454
score: 1
has body: This will make your code so much harder to read that even if it was an optimization it wouldn't be worth the trouble. And it's not an optimization. On most modern cpu's if statements are quite expensive.

http://stackoverflow.com/comment/30742767
type: AnswerComment
comment on: http://stackoverflow.com/a/10035382
type: Comment
has text: Not sure it is _subtle_ but It'd better consider the case where `t==null`.
score: 1

http://stackoverflow.com/a/397739
downvote count: 0
answers question: http://stackoverflow.com/q/397488
score: 7
has body: Scala also offers an interactive console. I was able to use it to get a result for the expression in your question by fully qualifying InetAddress, as in: java.net.InetAddress.getAllByName("localhost")
upvote count: 7
type: Answer

http://stackoverflow.com/a/545224
has comment: http://stackoverflow.com/comment/357667
upvote count: 10
answers question: http://stackoverflow.com/q/545194
has comment: http://stackoverflow.com/comment/357296
has comment: http://stackoverflow.com/comment/357231
has comment: http://stackoverflow.com/comment/357393
type: Answer
has body: It seems that your test cases are dependent, that is: the execution of case-X affects the execution of case-Y. Such a testing system should be avoided (for instance: there's no guarantee on the order at which JUnit will run your cases). You should refactor your cases to make them independent of each other. Many times the use of @Before and @After methods can help you untangle such dependencies.
downvote count: 0
score: 10

http://stackoverflow.com/q/604449
has answer: http://stackoverflow.com/a/604530
has answer: http://stackoverflow.com/a/604465
type: AnsweredQuestion
downvote count: 0
has title: Forcing FileNotFoundException
has answer: http://stackoverflow.com/a/604451
has body: I'm writing a test for a piece of code that has an IOException catch in it that I'm trying to cover. The try/catch looks something like this: try { oos = new ObjectOutputStream(new FileOutputStream(cacheFileName)); } catch (IOException e) { LOGGER.error("Bad news!", e); } finally { The easiest way seems to make FileOutputStream throw a FileNotFoundException, but perhaps I'm going about this all the wrong way. Anyone out there have any tips?
has answer: http://stackoverflow.com/a/604476
has answer: http://stackoverflow.com/a/11305174
type: Question
has answer: http://stackoverflow.com/a/604812
tagged with: testing
tagged with: filenotfoundexception
tagged with: ioexception
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/604523
accepted answer: http://stackoverflow.com/a/604523
has answer: http://stackoverflow.com/a/604468
upvote count: 1
tagged with: junit
possible better answer: http://stackoverflow.com/a/604451
favorite count: 0
has answer: http://stackoverflow.com/a/604467
answer count: 9

http://stackoverflow.com/comment/259115
score: 0
type: Comment
has text: I do appreciate you're trying to help, however from the question above: 'I've turned the console on and it quickly goes away too'.
comment on: http://stackoverflow.com/a/434852
type: AnswerComment

http://stackoverflow.com/q/554767
has answer: http://stackoverflow.com/a/555781
answer count: 28
has body: I have a data class in my application. My application will never be used as a public API and I will be the only person developing code within my project. I am trying to save every ounce of processor and memory power I can. Is it a bad idea to make my data members in my data class to have public/protected/default protection so that I don't have to use a getter? Using a getter would require slightly more memory and creation of a stack and such...which I believe isn't necessary. The only reason I can see in using a getter is for protection/privacy, but if I'm the only coder and nobody else is going to be using my API, then is it a bad idea not to use the getters? Please let me know if this is stupid.
has title: In Java, is it ever a bad idea to make an object's members publicly available?
has answer: http://stackoverflow.com/a/554822
has answer: http://stackoverflow.com/a/554807
has answer: http://stackoverflow.com/a/574248
has answer: http://stackoverflow.com/a/554806
score: 7
tagged with: java
has answer: http://stackoverflow.com/a/555131
has answer: http://stackoverflow.com/a/554938
has answer: http://stackoverflow.com/a/554811
has answer: http://stackoverflow.com/a/554888
has answer: http://stackoverflow.com/a/559107
downvote count: 1
has answer: http://stackoverflow.com/a/554787
has answer: http://stackoverflow.com/a/554794
type: Question
has answer: http://stackoverflow.com/a/556643
has answer: http://stackoverflow.com/a/574202
has answer: http://stackoverflow.com/a/5441968
has comment: http://stackoverflow.com/comment/366500
has comment: http://stackoverflow.com/comment/366514
has answer: http://stackoverflow.com/a/554838
tagged with: encapsulation
has answer: http://stackoverflow.com/a/554801
has answer: http://stackoverflow.com/a/554945
has answer: http://stackoverflow.com/a/554827
has answer: http://stackoverflow.com/a/554830
has answer: http://stackoverflow.com/a/554792
has answer: http://stackoverflow.com/a/554800
tagged with: public
has answer: http://stackoverflow.com/a/554915
has comment: http://stackoverflow.com/comment/368075
favorite count: 0
tagged with: private
has answer: http://stackoverflow.com/a/555001
upvote count: 8
has answer: http://stackoverflow.com/a/554869
tagged with: field
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/556721
has answer: http://stackoverflow.com/a/570776
has comment: http://stackoverflow.com/comment/367028
has answer: http://stackoverflow.com/a/554826

http://stackoverflow.com/a/376231
type: Answer
has comment: http://stackoverflow.com/comment/206174
upvote count: 6
score: 6
answers question: http://stackoverflow.com/q/376093
has body: The workaround proposed was to use @Column(name="dateofbirth"), which worked for my purposes.
downvote count: 0
has comment: http://stackoverflow.com/comment/204175

http://stackoverflow.com/a/438063
has comment: http://stackoverflow.com/comment/260565
accepted answer of: http://stackoverflow.com/q/438026
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/438026
has body: JSF output is HTML/XML and a ResponseWriter makes it easier to generate it correctly. Say you wanted to render some text in a tag. My random text The code would look like: ResponseWriter writer=context.getResponseWriter(); writer.startElement("span", component); writer.writeText(text, null); writer.endElement("span"); writerAttribute comes in when you need to add an ID or class attribute to the tag. ResponseWriter writer=context.getResponseWriter(); writer.startElement("span", component); writer.writeAttribute("id", id, null); writer.writeText(text, null); writer.endElement("span"); This would render: My text Note: writeAttribute immediately follows startElement. Once you start another element or write some text, you cannot call writeAttribute.
has comment: http://stackoverflow.com/comment/14860915
type: Answer
score: 11
upvote count: 11

http://stackoverflow.com/a/375603
has comment: http://stackoverflow.com/comment/9893886
answers question: http://stackoverflow.com/q/375544
downvote count: 0
type: Answer
score: 11
upvote count: 11
has comment: http://stackoverflow.com/comment/203786
has comment: http://stackoverflow.com/comment/18332850
has body: The biggest issue that we had when using Joda Time was with integration with Spring and Tapestry, as they both wanted to use the built-in Date and Time. We were constantly writing wrappers in getters/setters for date and time: either we would store it as Joda Time and one set of getters/setters passed it through and the other would convert on the fly, and some classes stored it internally as a Java Date/Time, and the Joda getter/setter had to switch it on the fly. Basically, it was a headache because the classes are similarly named, and unless you can get your entire architecture (including other libraries you're integrating) to switch to Joda Time, you are going to write more wrapper code than you are likely to save by using the Joda libraries.

http://stackoverflow.com/q/566877
has comment: http://stackoverflow.com/comment/39680653
favorite count: 0
has comment: http://stackoverflow.com/comment/24497696
has answer: http://stackoverflow.com/a/566956
type: Question
tagged with: jface
has answer: http://stackoverflow.com/a/10597678
has answer: http://stackoverflow.com/a/567000
has body: I'm a newbie to Eclipse and can't figure out how to get the JavaDocs for SWT and JFace to show up when I am editing. How do I do this? Thanks!
score: 12
has answer: http://stackoverflow.com/a/15231008
tagged with: java
tagged with: swt
has comment: http://stackoverflow.com/comment/17232242
answer count: 7
upvote count: 12
tagged with: javadoc
has title: How to get JavaDoc for SWT and JFace in Eclipse?
has answer: http://stackoverflow.com/a/567260
tagged with: eclipse
accepted answer: http://stackoverflow.com/a/567000
has answer: http://stackoverflow.com/a/25433882
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/567260
has answer: http://stackoverflow.com/a/908296
downvote count: 0

http://stackoverflow.com/q/583973
score: 227
has answer: http://stackoverflow.com/a/8295777
favorite count: 0
has answer: http://stackoverflow.com/a/55850091
tagged with: rest
has title: JAX-RS / Jersey how to customize error handling?
possible better answer: http://stackoverflow.com/a/5960659
upvote count: 227
answer count: 10
has answer: http://stackoverflow.com/a/5960659
has answer: http://stackoverflow.com/a/686720
downvote count: 0
tagged with: error-handling
has body: I'm learning JAX-RS (aka, JSR-311) using Jersey. I've successfuly created a Root Resource and am playing around with parameters: @Path("/hello") public class HelloWorldResource { @GET @Produces("text/html") public String get( @QueryParam("name") String name, @QueryParam("birthDate") Date birthDate) { // Return a greeting with the name and age } } This works great, and handles any format in the current locale which is understood by the Date(String) constructor (like YYYY/mm/dd and mm/dd/YYYY). But if I supply a value which is invalid or not understood, I get a 404 response. For example: GET /hello?name=Mark&amp;birthDate=X 404 Not Found How can I customize this behavior? Maybe a different response code (probably "400 Bad Request")? What about logging an error? Maybe add a description of the problem ("bad date format") in a custom header to aid troubleshooting? Or return a whole Error response with details, along with a 5xx status code?
linked to: http://stackoverflow.com/q/15185299
has answer: http://stackoverflow.com/a/1332506
type: AnsweredQuestion
tagged with: jersey
has answer: http://stackoverflow.com/a/29951866
has answer: http://stackoverflow.com/a/597252
tagged with: java
linked to: http://stackoverflow.com/q/32699420
has answer: http://stackoverflow.com/a/599131
accepted answer: http://stackoverflow.com/a/599131
has answer: http://stackoverflow.com/a/33245911
type: Question
has answer: http://stackoverflow.com/a/58286031
tagged with: jax-rs

http://stackoverflow.com/comment/213430
type: Comment
score: 2
comment on: http://stackoverflow.com/a/383597
has text: @warrior: As I'd got the code for "byte" already, changing it to "boolean" was pretty straightforward :)
type: AnswerComment

http://stackoverflow.com/a/400598
has comment: http://stackoverflow.com/comment/12952931
type: Answer
has comment: http://stackoverflow.com/comment/241347
has comment: http://stackoverflow.com/comment/89596057
answers question: http://stackoverflow.com/q/400338
score: 18
has comment: http://stackoverflow.com/comment/226054
has comment: http://stackoverflow.com/comment/226070
downvote count: 1
upvote count: 19
has body: Keep in mind the difference between unit testing and integration testing. Unit tests should be testing code without any outside dependencies. These dependencies are mocked using a framework like, for example, JMock. Integration tests are important too but the major drawback of them is that they take a long time to run. You can run thousands of true unit tests in a couple of seconds, but it's not the same with integration tests. Depending on the size of your project/development team you might want to prioritize true unit tests over integration tests. Both style of tests are important but if you are pressed for resources, just going with Unit testing may be a better idea. I wrote an application by myself that unit tested the Web (with Spring MVC this is easy) and Service layers, as well as domain objects. But I left the DAO alone because I didn't want to write a bunch of slow integration tests. If I had more people on staff I would have gone with integration tests as well, but in this case I didn't feel the time spent would be worth it.

http://stackoverflow.com/q/372119
answer count: 1
downvote count: 0
tagged with: maven-2
favorite count: 0
accepted answer: http://stackoverflow.com/a/372248
has body: We have this constant discussion in our project as to the granularity of our maven modules. We have come to agree that there may be differences in the needs of a framework (like spring) and an in-house application that is always deployed monolithically. We also agree that it's fairly sensible to hide implementation details of adapters to external systems behind a separate API module, so the implementation classes don't bleed into the classpath of the main implementations. as But that's as far as we go. It's a web project so we have modules like "web", "core" and "adapter(s)". We have multiple backends, but we don't require plugability. What criteria do you use for modularizing in maven ? Which modules do you make for web projects ?
type: AnsweredQuestion
upvote count: 3
tagged with: java
has title: Why do you subdivide into maven-modules for in-house projects?
type: Question
score: 3
has answer: http://stackoverflow.com/a/372248

http://stackoverflow.com/q/567682
has comment: http://stackoverflow.com/comment/379209
downvote count: 3
has comment: http://stackoverflow.com/comment/3095685
has title: Online compilers/runtime for Java, C++, Python and ObjC?
type: Question
has comment: http://stackoverflow.com/comment/379020
has answer: http://stackoverflow.com/a/567699
has answer: http://stackoverflow.com/a/567852
has answer: http://stackoverflow.com/a/567700
score: 26
possible better answer: http://stackoverflow.com/a/2566129
tagged with: runtime
has comment: http://stackoverflow.com/comment/12192482
has answer: http://stackoverflow.com/a/4766333
has answer: http://stackoverflow.com/a/567839
linked to: http://stackoverflow.com/q/523568
favorite count: 0
accepted answer: http://stackoverflow.com/a/567714
has body: Does anyone know of a good online compiler/runtime (for C++, Java, Python, ObjC etc.) that I can access on the web? What I'm looking for is something that would allow me to type in a program in a web form and to run the program and see the results online. (Let's not get into the why for now. Suffice it to say for the moment that I don't always have access to a compiler/runtime, and firing up an IDE is just overkill for testing out some code snippets) I know of codepad.org -- but I'm looking for something better.
tagged with: compiler-construction
has answer: http://stackoverflow.com/a/1552606
has answer: http://stackoverflow.com/a/567714
tagged with: c++
answer count: 9
has answer: http://stackoverflow.com/a/2566129
has answer: http://stackoverflow.com/a/3507405
tagged with: python
upvote count: 29
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/379367
tagged with: java

http://stackoverflow.com/comment/427824
has text: The split() approach will work but for large data sets will create lots of temporary objects. This could be a problem; it would be more efficient (from a memory perspective) to parse the string manually.
comment on: http://stackoverflow.com/a/614510
score: 1
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/383607
type: Comment
has text: It is possible, it's just not pretty :-\
comment on: http://stackoverflow.com/a/571451
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2695812
score: 24
has text: Ironically, this page is now the first search result on Google for `detect "java version" using javascript`
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/440229

http://stackoverflow.com/comment/458308
has text: The terms "boost" and "C++ standard library" are becomming more and more merged. It is my understanding that boost was founded during a C++ standard meeting in order to encourage the development of libraries for C++.
comment on: http://stackoverflow.com/a/641552
score: 1
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/383276
score: 0
has text: The code I'm consuming gives me a Map object, so how do I then convert it into a TreeMap or use a TreeMap to do the sorting?
comment on: http://stackoverflow.com/a/571400
type: AnswerComment
type: Comment

http://stackoverflow.com/a/627657
type: Answer
has body: If you already have Eclipse, I would recommend trying MyEclipse. This has a plug-in called Matisse4MyEclipse that is a nice GUI builder.
score: 0
answers question: http://stackoverflow.com/q/625076

http://stackoverflow.com/comment/201121
type: Comment
comment on: http://stackoverflow.com/a/372384
has text: Although just one note - I don't think ServletContextHolder has any concept of HttpSession or a way of knowing if it's operating in a web server environment - it uses ThreadLocal unless you configure it to use something else (the only other two builtin modes are InheritableThreadLocal and Global)
type: AnswerComment
score: 2

http://stackoverflow.com/a/635091
upvote count: 2
type: Answer
has body: I think Haskell's syntax is great for thinking recursively, because the pattern matching construct makes the base case and the recursive case so obvious. Translating this into another language is then fairly straightforward. sumAll [] = 0 sumAll (x:xs) = x + sumAll xs To understand this, you really only need to know that [] represents an empty list, (x:xs) splits a list into a head (x) and a tail (xs) You don't need to learn all of Haskell (which is, let's face it, hard) - but doing some of the basics certainly helps you think in recursion.
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/634963

http://stackoverflow.com/a/4769575
upvote count: 61
type: Answer
has comment: http://stackoverflow.com/comment/20387407
answers question: http://stackoverflow.com/q/638807
has comment: http://stackoverflow.com/comment/32246726
has comment: http://stackoverflow.com/comment/102495099
downvote count: 1
has body: The following allows JTable re-ordering of a single dragged row: table.setDragEnabled(true); table.setDropMode(DropMode.INSERT_ROWS); table.setTransferHandler(new TableRowTransferHandler(table)); Your TableModel should implement the following to allow for re-ordering: public interface Reorderable { public void reorder(int fromIndex, int toIndex); } This TransferHandler class handles the drag &amp; drop, and calls reorder() on your TableModel when the gesture is completed. /** * Handles drag &amp; drop row reordering */ public class TableRowTransferHandler extends TransferHandler { private final DataFlavor localObjectFlavor = new ActivationDataFlavor(Integer.class, "application/x-java-Integer;class=java.lang.Integer", "Integer Row Index"); private JTable table = null; public TableRowTransferHandler(JTable table) { this.table = table; } @Override protected Transferable createTransferable(JComponent c) { assert (c == table); return new DataHandler(new Integer(table.getSelectedRow()), localObjectFlavor.getMimeType()); } @Override public boolean canImport(TransferHandler.TransferSupport info) { boolean b = info.getComponent() == table &amp;&amp; info.isDrop() &amp;&amp; info.isDataFlavorSupported(localObjectFlavor); table.setCursor(b ? DragSource.DefaultMoveDrop : DragSource.DefaultMoveNoDrop); return b; } @Override public int getSourceActions(JComponent c) { return TransferHandler.COPY_OR_MOVE; } @Override public boolean importData(TransferHandler.TransferSupport info) { JTable target = (JTable) info.getComponent(); JTable.DropLocation dl = (JTable.DropLocation) info.getDropLocation(); int index = dl.getRow(); int max = table.getModel().getRowCount(); if (index &lt; 0 || index &gt; max) index = max; target.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); try { Integer rowFrom = (Integer) info.getTransferable().getTransferData(localObjectFlavor); if (rowFrom != -1 &amp;&amp; rowFrom != index) { ((Reorderable)table.getModel()).reorder(rowFrom, index); if (ind…
has comment: http://stackoverflow.com/comment/23477484
has comment: http://stackoverflow.com/comment/10208788
has comment: http://stackoverflow.com/comment/59400619
score: 60

http://stackoverflow.com/a/390049
upvote count: 1
has comment: http://stackoverflow.com/comment/217390
has comment: http://stackoverflow.com/comment/220545
answers question: http://stackoverflow.com/q/389831
downvote count: 0
has body: What are you trying to do? Re-inventing MNG? Even if you can write multiple PNG images in the same file, it makes a compound file understood by no program (except those you might write). If, as suggested by Marc, you want to make a movie, you might want to look at QuickTime for Java (QTJava). It is the solution used by Processing to make movies out of animations/frames. It has several quality/formats, from the worst (but small files) to the highest quality (high file sizes as result).
type: Answer
score: 1

http://stackoverflow.com/q/453388
has answer: http://stackoverflow.com/a/4982006
has answer: http://stackoverflow.com/a/459376
upvote count: 17
accepted answer: http://stackoverflow.com/a/453414
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/273841
has title: Calculating difference in dates in Java
has answer: http://stackoverflow.com/a/20375526
has comment: http://stackoverflow.com/comment/34254768
tagged with: java
has comment: http://stackoverflow.com/comment/275030
score: 17
tagged with: date
type: Question
has answer: http://stackoverflow.com/a/24008990
has body: I find it funny that Java (or the java.util library) does not have a built-in function to calculate difference in dates. I want to subtract one date from another to get the elapsed time between them. What is the best way to do this? I know the simple way is to take the difference of the time in milliseconds and then convert that into days. However, I wanted to know if this works in all cases (with daylight saving, etc.).
downvote count: 0
answer count: 7
favorite count: 0
has answer: http://stackoverflow.com/a/459348
linked to: http://stackoverflow.com/q/32366154
tagged with: datetime
possible better answer: http://stackoverflow.com/a/453393
has answer: http://stackoverflow.com/a/453414
tagged with: date-arithmetic
has answer: http://stackoverflow.com/a/453393

http://stackoverflow.com/comment/305984
type: Comment
has text: Is the string of digits in the question the full output, or does the sequence need to keep going for some duration?
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/489927

http://stackoverflow.com/a/553483
upvote count: 2
answers question: http://stackoverflow.com/q/552402
downvote count: 0
has comment: http://stackoverflow.com/comment/78463355
has body: The Java HotSpot VM does this automatically, but not in all cases... First, you must be running a "debug" session, not a "run" session. Next, some changes will force a restart. The basic idea is that if the interface to the class change (the method sigs, not an actual Java interface), the VM can't replace the class contents inline. You shouldn't need a plugin for this, just a recent-ish VM. This happens under several circumstances like adding methods removing methods changing method signatures changing the class hierarchy (superclasses, implemented interfaces) It can also happen if you introduce an error into the class. (For errors like mismatched curly braces) When you save a Java file, eclipse compiles it. If there is an error, eclipse inserts an exception throw to indicate that there is an unresolved compilation error. (It does this so when you run you don't just see the last successful compilation, making it obvious you have a compiler error)
type: Answer
score: 2

http://stackoverflow.com/a/595991
has comment: http://stackoverflow.com/comment/409444
downvote count: 0
has body: I'm sorry, but I can't tell if this is an abuse of Spring based on the two lines of code that you posted and I doubt that anyone else can, either. If you're complaining about the fact that the static type of that object is not an interface you might have a point. But even that's hard to tell from that single line of code. Is that really a service or repository class without an interface? If so, I agree. If not, I'd need to know more. If your team frowns on testing, that's too bad. I would have thought that one of the reasons for Spring would be to facilitate testing. You might have a point, but I can't be sure from your original question. Maybe you can edit in more detail. If this is an example of how you communicate with your teammates, perhaps they'd be justified if they said that you didn't explain yourself very well. Make sure that you aren't just out for self-aggrandization here.
answers question: http://stackoverflow.com/q/595554
type: Answer
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/411037

http://stackoverflow.com/q/618844
possible better answer: http://stackoverflow.com/a/618913
accepted answer: http://stackoverflow.com/a/619453
has title: How to properly handle error logs?
has answer: http://stackoverflow.com/a/619291
answer count: 6
tagged with: servlets
downvote count: 0
favorite count: 0
upvote count: 2
linked to: http://stackoverflow.com/q/618820
has answer: http://stackoverflow.com/a/619453
has answer: http://stackoverflow.com/a/619156
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/619539
has body: I tried to do several searches before posting this question. If this is a duplicate, please let me know and I will delete it. My question revolves around the proper way to handle errors produced through our web application. We currently log everything through log4j. If an error happens, it just says "An error has occurred. The IT Department has been notified and will work to correct this as soon as possible" right on the screen. This tells the user nothing... but it also does not tell the developer anything either when we try to reproduce the error. We have to go to the error log folder and try finding this error. Let me also mention that the folder is full of logs from the past week. Each time there is an error, one log file is created for that user and email is sent to the IT staff assigned to work on errors. This email does not mention the log file name but it is a copy of the same error text written that is in the log file. So if Alicia has a problem at 7:15 with something, but there are 10 other errors that happen that same minute, I have to go through each log file trying to find hers. What I was proposing to my fellow co-workers is adding an Error Log table into the database. This would write a record to the table for each error, record who it is for, the error, what page it happened on, etc. The bonus of this would be that we can return the primary key value from the table (error_log_id) and show that on the page with a message like "Error Reference Id (1337) has been logged and the proper IT staff has been notified. Please keep this reference id handy for future use". When we get the email, it would tell us the id of the error for quick reference. Or if the user is persistent, they can contact us with the id and we can find the error rather quickly. How do you setup your error logging? By the way, our system uses Java Servlets that connect to a SQL Server database.
tagged with: java
linked to: http://stackoverflow.com/q/576185
has answer: http://stackoverflow.com/a/618913
has answer: http://stackoverflow.com/a/619023
tagged with: error-handling
type: Question

http://stackoverflow.com/q/448471
has answer: http://stackoverflow.com/a/449415
type: Question
score: 3
tagged with: dependency-injection
tagged with: java
tagged with: guice
downvote count: 0
has body: I often read about dependency injection and I did research on google and I understand in theory what it can do and how it works, but I'd like to see an actual code base using it (Java/guice would be preferred). Can anyone point me to an open source project, where I can see, how it's really used? I think browsing the code and seeing the whole setup shows me more than the ususal snippets in the introduction articles you find around the web. Thanks in advance!
has answer: http://stackoverflow.com/a/455186
possible better answer: http://stackoverflow.com/a/1314861
accepted answer: http://stackoverflow.com/a/455186
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/1314861
type: AnsweredQuestion
upvote count: 3
has answer: http://stackoverflow.com/a/448497
has title: Projects with browsable source using dependency injection w/ guice?
tagged with: design-patterns

http://stackoverflow.com/comment/105391808
score: 0
type: Comment
has text: This one actually works the best, no need for adapters if you can use JAXB annotations for the classes.
comment on: http://stackoverflow.com/a/656874
type: AnswerComment

http://stackoverflow.com/a/616877
score: 57
has comment: http://stackoverflow.com/comment/138072580
has body: The strategy pattern allows you to polymorphically change behavior of a class. The factory pattern allows you to encapsulate object creation. Gary makes a great point. If you are using the principle of coding to abstractions rather than "concretions" then a lot of the patterns start looking like variations on a theme.
answers question: http://stackoverflow.com/q/616796
downvote count: 0
upvote count: 57
type: Answer

http://stackoverflow.com/a/6565735
score: 4
answers question: http://stackoverflow.com/q/590069
has comment: http://stackoverflow.com/comment/133880669
type: Answer
downvote count: 1
upvote count: 5
has body: Here is a ready-to-use CircularArrayList implementation for Java which I use in production code. By overriding AbstractList in the Java-recommended way, it supports all functionality you would expect from a standard List implementation in the Java Collections Framework (generic element type, subList, iteration etc.). The following calls complete in O(1): add(item) - adds at end of list remove(0) - removes from beginning of list get(i) - retrieves random element in list

http://stackoverflow.com/comment/298263
type: AnswerComment
has text: "Defensive Programming" is an outmoded paradigm. The bloated code which results from testing for all error conditions eventually causes more problems than it solves. TDD and handling exceptions is that modern approach IMHO
score: 0
type: Comment
comment on: http://stackoverflow.com/a/481488

http://stackoverflow.com/a/555790
score: 6
has comment: http://stackoverflow.com/comment/367386
downvote count: 0
answers question: http://stackoverflow.com/q/555580
type: Answer
upvote count: 6
has body: It is entirely normal for a JVM to go up to 100% memory usage and them back to say 10% after a GC and do this every few second. You shouldn't need to try managing the memory in this way. You cannot say how much memory is being retained until a full GC has been run. I suggest you work out what you are really trying to achieve and look at the problem another way.

http://stackoverflow.com/a/629234
has body: Check the string including the path that you are passing to Connector.open() ,Verify the file permissions,close all streams opened for that file before deleting.
score: 1
upvote count: 1
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/490421

http://stackoverflow.com/comment/354210
type: Comment
comment on: http://stackoverflow.com/a/542175
type: AnswerComment
has text: That only returns a URL, which doesn't do me any good. The AngelCodeFont constructors don't support URLs, and in either case, if it did, it would still be creating two new InputStreamReaders everytime the constructor was called.
score: 0

http://stackoverflow.com/q/548502
type: Question
has answer: http://stackoverflow.com/a/549298
score: 5
has body: There is a Java library by the name of Uncommon Maths that claims to provide better random number generators than Sun and (potentially) even BouncyCastle. How one can determine whether their library can be trusted? I trust Sun and BouncyCastle because a lot of important companies use their stuff. It's not clear if Uncommon Maths falls into the same category. Any ideas?
upvote count: 5
has comment: http://stackoverflow.com/comment/360381
tagged with: random
answer count: 3
accepted answer: http://stackoverflow.com/a/549110
downvote count: 0
favorite count: 0
type: AnsweredQuestion
has title: Can the uncommon maths library be trusted?
tagged with: java
has answer: http://stackoverflow.com/a/549110
possible better answer: http://stackoverflow.com/a/549298
has comment: http://stackoverflow.com/comment/31794285
has answer: http://stackoverflow.com/a/548504

http://stackoverflow.com/comment/52391036
score: 11
has text: Personally, because the answer has virtually no technical content -- it would have been a better comment. It doesn't have much more to say than "it's a good practice", and while we often accept such explanations for expediency in our projects, it's not a good enough answer for Stack Overflow. No personal offence meant to you, Don; I'm sure you know what you're talking about, but I prefer answers with more meat.
comment on: http://stackoverflow.com/a/516014
type: AnswerComment
type: Comment

http://stackoverflow.com/q/560956
has answer: http://stackoverflow.com/a/569067
tagged with: byte
has answer: http://stackoverflow.com/a/560971
score: 11
possible better answer: http://stackoverflow.com/a/560972
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/562611
downvote count: 0
tagged with: java
tagged with: bit-manipulation
has title: Bitwise AND, Bitwise Inclusive OR question, in Java
has answer: http://stackoverflow.com/a/560986
has answer: http://stackoverflow.com/a/560965
type: Question
upvote count: 11
has answer: http://stackoverflow.com/a/560972
has body: I've a few lines of code within a project, that I can't see the value of... buffer[i] = (currentByte &amp; 0x7F) | (currentByte &amp; 0x80); It reads the filebuffer from a file, stored as bytes, and then transfers then to buffer[i] as shown, but I can't understand what the overall purpose is, any ideas? Thanks
tagged with: operator-keyword
answer count: 7
has answer: http://stackoverflow.com/a/561182
accepted answer: http://stackoverflow.com/a/561182
favorite count: 0

http://stackoverflow.com/a/8672357
type: Answer
score: 6
upvote count: 6
downvote count: 0
has body: If you're looking for simplicity, I have created a simple library called jOOR in order to facilitate access to the reflection API in Java. It supports the most essential actions without building up a huge API. Here's an example of what jOOR code looks like: String world = on("java.lang.String") // Like Class.forName() .create("Hello World") // Call the most specific matching constructor .call("substring", 6) // Call the most specific matching substring() method .call("toString") // Call toString() .get() // Get the wrapped object, in this case a String
answers question: http://stackoverflow.com/q/364523

http://stackoverflow.com/a/1409467
score: 3
upvote count: 3
downvote count: 0
has body: See class javassist.util.proxy.ProxyFactory for details.
type: Answer
answers question: http://stackoverflow.com/q/391989

http://stackoverflow.com/a/493261
downvote count: 0
answers question: http://stackoverflow.com/q/493233
type: Answer
has body: Don't needlessly complicate your code. If you feel the need to say "a &lt; b == true", then you can follow that to its logical conflusion (conclusion + confusion) and say "((((((((...(a&lt;b) == true) == true).... == true)" "a &lt; b" is a boolean expression. If you already have a boolean, why compare it to another boolean? You're not making it more boolean that way.
score: 5
upvote count: 5

http://stackoverflow.com/q/381373
has answer: http://stackoverflow.com/a/383803
answer count: 5
has answer: http://stackoverflow.com/a/381620
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/208916
tagged with: java
possible better answer: http://stackoverflow.com/a/381384
type: Question
has comment: http://stackoverflow.com/comment/208920
tagged with: performance
has title: Insert fail then update OR Load and then decide if insert or update
tagged with: database
accepted answer: http://stackoverflow.com/a/381422
has answer: http://stackoverflow.com/a/381399
score: 0
has body: I have a webservice in java that receives a list of information to be inserted or updated in a database. I don't know which one is to insert or update. Which one is the best approach to abtain better performance results: Iterate over the list(a object list, with the table pk on it), try to insert the entry on Database. If the insert failed, run a update Try to load the entry from database. if the results retrieved update, if not insert the entry. another option? tell me about it :) In first calls, i believe that most of the entries will be new bd entries, but there will be a saturation point that most of the entries will be to update. I'm talking about a DB table that could reach over 100 million entries in a mature form. What will be your approach? Performance is my most important goal.
has answer: http://stackoverflow.com/a/381384
has answer: http://stackoverflow.com/a/381422

http://stackoverflow.com/comment/190588
has text: No, but you can make it more difficult. Read "Best Kept Secrets of Peer Code Review" by Jason Cohen (see link at the side of some pages here) to get a better idea of why you do this.
type: Comment
comment on: http://stackoverflow.com/a/359747
score: 0
type: AnswerComment

http://stackoverflow.com/a/583537
upvote count: 7
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/396351
score: 7
has body: While yes, you could do a Thread.sleep(50) like the accepted answer suggest, you could also call Thread.sleep(0) This will tell the processor to do a context switch. Other threads waiting to be executed (like the GUI drawing thread) will then be executed and the machine will stop feeling slow. The sleep(0) way will also maximise the time given by the OS to you application because the thread will immediatly go back in the processor's queue (instead of waiting 50ms before doing so) so if no other thread where waiting, you thread will continue being executed.
answers question: http://stackoverflow.com/q/580419

http://stackoverflow.com/a/385590
type: Answer
has comment: http://stackoverflow.com/comment/213257
has comment: http://stackoverflow.com/comment/213362
has comment: http://stackoverflow.com/comment/213269
score: 0
has body: When you have overloaded static methods then it calls that method that is defined immediately in the class which is invoking the method. If however, no method is defined in the calling class then it will invoke the method inherited from its immediate parent class. In your case there are two overloaded methods both of which can accept SubSub as parameter. the compiler checks for the most specific match and goes for it. But the most specific match is generally the lowest in the type hierarchy. EDITED Removed the conflicting statement. Two methods in classes that are at the same type hierarchy level can't be in ambiguous state for the compiler to choose. This ambiguity is possible only in the case of multiple inheritance.
has comment: http://stackoverflow.com/comment/213281
answers question: http://stackoverflow.com/q/385551

http://stackoverflow.com/comment/274158
type: Comment
comment on: http://stackoverflow.com/a/453707
score: 2
has text: Not quite. If you don't set the capacityIncrement on a Vector, it will default to doubling its size when additional capacity is needed.
type: AnswerComment

http://stackoverflow.com/comment/31385137
type: Comment
comment on: http://stackoverflow.com/a/542142
score: 2
has text: _Eclipse messes up the {@code} tag and replaces it with {&#064;code-_ This isn't because of Eclipse, this is because of (bugged?) javadoc utility. If you have @ character in the multiline code inside {@code ...multiline...} then javadoc fails to parse it correctly:( At least this is what I see with Oracle JDK1.7.0_45 javadoc implementation.
type: AnswerComment

http://stackoverflow.com/comment/373688
type: AnswerComment
type: Comment
has text: Thank you so much, Tom! It works now when I set the handler (It should be ErrorListener) to the transformer. Thanks again for the help! Jing
score: 0
comment on: http://stackoverflow.com/a/562425

http://stackoverflow.com/comment/340776
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/527595
has text: The input and output don't indicate how you want to do that... Do you want to split on a certain position, on a certain character, before or after a certain pattern, even with a more complex rule... In the state the question can't really be answered
type: Comment

http://stackoverflow.com/comment/332496
score: 0
type: Comment
comment on: http://stackoverflow.com/a/518758
type: AnswerComment
has text: The reason is because I'm developing for a multiscreen configuration, each screen is configured with a sperate display 0.0 0.1 0.n and so on. I don't want to have to do export DISPLAY=blah before I launch each JVM for each application. I wanted to know if I could just added it to the args :)

http://stackoverflow.com/a/884842
answers question: http://stackoverflow.com/q/566264
upvote count: 2
type: Answer
score: 2
has body: Did you consider EHCache over Terracotta? Take a look at Terracotta Hibernate Integration and Terracotta EHCache Integration Importantly the Terracotta distributed EHCache is coherent - all nodes have the same view of the cache. This is very important for one of the applications I worked with. Take a look. It works like a charm for us. /RS
downvote count: 0

http://stackoverflow.com/q/462923
has answer: http://stackoverflow.com/a/464649
tagged with: java
tagged with: database
upvote count: 103
tagged with: comparison
accepted answer: http://stackoverflow.com/a/463355
has comment: http://stackoverflow.com/comment/2500
has answer: http://stackoverflow.com/a/19965558
has answer: http://stackoverflow.com/a/463381
answer count: 18
has answer: http://stackoverflow.com/a/57143
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/586615
has comment: http://stackoverflow.com/comment/72865907
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/463005
type: Question
has answer: http://stackoverflow.com/a/57134
has comment: http://stackoverflow.com/comment/76731421
score: 103
tagged with: embedded-database
has answer: http://stackoverflow.com/a/4074780
has answer: http://stackoverflow.com/a/14678365
has answer: http://stackoverflow.com/a/57352
has answer: http://stackoverflow.com/a/57133
has title: Java Embedded Databases Comparison
has answer: http://stackoverflow.com/a/463355
has comment: http://stackoverflow.com/comment/129489025
has body: I intend to develop a small (Java) application for managing my finances. I believe I need to use an embedded database, but I have no experience regarding this issue. I tried to look at some of the available products, but I can't decide which one would be more suitable for me. H2, HSQLDB, Derby and Berkeley DB seem to be good candidates, but I still don't see how they compare to each other. I appreciate your help comparing them and helping me decide which one to use. I intend to use Hibernate for my application (unless you would recommend using DBMS-provided API), but I also want to have the ability to edit the database easily using a SQL browsing tool (modifying schema and changing data). Thank you.
has answer: http://stackoverflow.com/a/1427396
has answer: http://stackoverflow.com/a/58612
has comment: http://stackoverflow.com/comment/6895491
possible better answer: http://stackoverflow.com/a/57352
has answer: http://stackoverflow.com/a/463426
has answer: http://stackoverflow.com/a/463047
has answer: http://stackoverflow.com/a/462985
has answer: http://stackoverflow.com/a/58691

http://stackoverflow.com/q/531049
has title: Java Library? - Simplex / Linear Programming / Optimization
has answer: http://stackoverflow.com/a/14130220
tagged with: java
has answer: http://stackoverflow.com/a/1356533
has comment: http://stackoverflow.com/comment/29182508
has comment: http://stackoverflow.com/comment/344099
type: Question
score: 5
possible better answer: http://stackoverflow.com/a/1356533
upvote count: 5
downvote count: 0
accepted answer: http://stackoverflow.com/a/548365
has body: I'm looking for an optimization library. My two requirements are that it does not use JNI and that it does not have license restrictions preventing it from being used on multiple computers commercially. The only one I've found that meets these requirements is Choco, but it is unusably buggy.
favorite count: 0
answer count: 5
tagged with: linear-programming
linked to: http://stackoverflow.com/q/143020
has answer: http://stackoverflow.com/a/7520777
has answer: http://stackoverflow.com/a/548365
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/14961884
tagged with: mathematical-optimization

http://stackoverflow.com/a/454787
score: 93
downvote count: 2
answers question: http://stackoverflow.com/q/454720
type: Answer
has comment: http://stackoverflow.com/comment/109218739
has body: Assuming you mean JVM rather than Java: The LLVM is a low level register-based virtual machine. It is designed to abstract the underlying hardware and draw a clean line between a compiler back-end (machine code generation) and front-end (parsing, etc.). The JVM is a much higher level stack-based virtual machine. The JVM provides garbage collection, has the notion of objects and virtual method calls and more. Thus, the JVM provides much higher level infrastructure for language interoperability (much like Microsoft's CLR). (It is possible to build these abstractions over LLVM just as it is possible to build them on top of C.)
has comment: http://stackoverflow.com/comment/109218682
has comment: http://stackoverflow.com/comment/6913908
upvote count: 95
has comment: http://stackoverflow.com/comment/6014113

http://stackoverflow.com/q/589351
type: Question
upvote count: 0
has answer: http://stackoverflow.com/a/589360
answer count: 3
has answer: http://stackoverflow.com/a/589363
favorite count: 0
has body: I need an answer for the question i have mentioned in the title.
has answer: http://stackoverflow.com/a/589383
type: UnansweredQuestion
downvote count: 1
has title: Is there a way class that extends httpservlet and thread
tagged with: java
score: -1

http://stackoverflow.com/q/580449
answer count: 1
accepted answer: http://stackoverflow.com/a/580606
downvote count: 0
favorite count: 0
type: AnsweredQuestion
score: 3
has title: How to embed a mini-console within a Java app?
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/580606
has comment: http://stackoverflow.com/comment/392392
type: Question
has body: I'm making a small game in Java and would like to add a Quake 3 style of console to the game, that supposed to appear when toggled. Is there any implementation or any similar embedded console you folks know of? Otherwise, what would be a good way to go about it? Right now, I simply have a TextArea on top of a TextField. Just to clarify, I'm not looking for a full fledged terminal, what I need is a small little console that I can tie with the game.
has comment: http://stackoverflow.com/comment/392427

http://stackoverflow.com/a/494538
has comment: http://stackoverflow.com/comment/1646823
has comment: http://stackoverflow.com/comment/507919
has comment: http://stackoverflow.com/comment/310298
downvote count: 0
has comment: http://stackoverflow.com/comment/507734
has comment: http://stackoverflow.com/comment/310332
type: Answer
score: 7
upvote count: 7
has body: Expose your .NET API as ASMX web services and you should be good to go. EDIT: For more heavy-usage scenarios, it would be worth looking into Windows Communication Foundation (WCF). This has built-in, configurable support for security, streaming, different transport scenarios (HTTP, TCP/IP, local named pipes). You are not restricted to SOAP message encoding, but that would probably be the easiest way to interop with Java. I'm not too sure about your exact scenario, but if you're dealing with large files and the .NET code and Java code are both running locally, you can just save the file to the user's hard drive using .NET and then fetch it from your Java app.
answers question: http://stackoverflow.com/q/494389

http://stackoverflow.com/a/483134
type: Answer
has body: One way to do this would be to write a Java agent using the instrumentation API. This would allow you to record the loading of classes by the JVM. public class ClassLoadedAgent implements ClassFileTransformer { private static ClassLoadedAgent AGENT = null; /** Agent "main" equivalent */ public static void premain(String agentArguments, Instrumentation instrumentation) { AGENT = new ClassLoadedAgent(); for (Class&lt;?&gt; clazz : instrumentation.getAllLoadedClasses()) { AGENT.add(clazz); } instrumentation.addTransformer(AGENT); } private final Map&lt;ClassLoader, Set&lt;String&gt;&gt; classMap = new WeakHashMap&lt;ClassLoader, Set&lt;String&gt;&gt;(); private void add(Class&lt;?&gt; clazz) { add(clazz.getClassLoader(), clazz.getName()); } private void add(ClassLoader loader, String className) { synchronized (classMap) { System.out.println("loaded: " + className); Set&lt;String&gt; set = classMap.get(loader); if (set == null) { set = new HashSet&lt;String&gt;(); classMap.put(loader, set); } set.add(className); } } private boolean isLoaded(String className, ClassLoader loader) { synchronized (classMap) { Set&lt;String&gt; set = classMap.get(loader); if (set == null) { return false; } return set.contains(className); } } @Override public byte[] transform(ClassLoader loader, String className, Class&lt;?&gt; classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { add(loader, className); return classfileBuffer; } public static boolean isClassLoaded(String className, ClassLoader loader) { if (AGENT == null) { throw new IllegalStateException("Agent not initialized"); } if (loader == null || className == null) { throw new IllegalArgumentException(); } while (loader != null) { if (AGENT.isLoaded(className, loader)) { return true; } loader = loader.getParent(); } return false; } } META-INF/MANIFEST.MF: Manifest-Version: 1.0 Premain-Class: myinstrument.ClassLoadedAgent The downside is that you have to load the agent whe…
has comment: http://stackoverflow.com/comment/301592
score: 7
upvote count: 9
has comment: http://stackoverflow.com/comment/66235785
answers question: http://stackoverflow.com/q/482633
has comment: http://stackoverflow.com/comment/302463
downvote count: 2

http://stackoverflow.com/a/531829
has comment: http://stackoverflow.com/comment/63250675
answers question: http://stackoverflow.com/q/531779
score: 9
has comment: http://stackoverflow.com/comment/349068
has comment: http://stackoverflow.com/comment/63246981
has body: "".equals(s) Seems to be the best option, but there is also Stringutils.isEmpty(s) contained in the Apache commons lang library
has comment: http://stackoverflow.com/comment/349093
has comment: http://stackoverflow.com/comment/346765
upvote count: 9
type: Answer
has comment: http://stackoverflow.com/comment/347814
downvote count: 0

http://stackoverflow.com/q/500508
linked to: http://stackoverflow.com/q/5380177
linked to: http://stackoverflow.com/q/2236599
has answer: http://stackoverflow.com/a/500984
tagged with: java
has answer: http://stackoverflow.com/a/500595
has title: Why should I use the keyword "final" on a method parameter in Java?
has body: I can't understand where the final keyword is really handy when it is used on method parameters. If we exclude the usage of anonymous classes, readability and intent declaration then it seems almost worthless to me. Enforcing that some data remains constant is not as strong as it seems. If the parameter is a primitive then it will have no effect since the parameter is passed to the method as a value and changing it will have no effect outside the scope. If we are passing a parameter by reference, then the reference itself is a local variable and if the reference is changed from within the method, that would not have any effect from outside of the method scope. Consider the simple test example below. This test passes although the method changed the value of the reference given to it, it has no effect. public void testNullify() { Collection&lt;Integer&gt; c = new ArrayList&lt;Integer&gt;(); nullify(c); assertNotNull(c); final Collection&lt;Integer&gt; c1 = c; assertTrue(c1.equals(c)); change(c); assertTrue(c1.equals(c)); } private void change(Collection&lt;Integer&gt; c) { c = new ArrayList&lt;Integer&gt;(); } public void nullify(Collection&lt;?&gt; t) { t = null; }
has comment: http://stackoverflow.com/comment/138906644
has answer: http://stackoverflow.com/a/36068940
has answer: http://stackoverflow.com/a/500627
has answer: http://stackoverflow.com/a/10380512
has comment: http://stackoverflow.com/comment/28738827
has comment: http://stackoverflow.com/comment/66781294
has answer: http://stackoverflow.com/a/14199645
upvote count: 460
favorite count: 0
has comment: http://stackoverflow.com/comment/138846257
has answer: http://stackoverflow.com/a/502289
has answer: http://stackoverflow.com/a/37931786
downvote count: 1
tagged with: pass-by-value
has comment: http://stackoverflow.com/comment/63130540
has answer: http://stackoverflow.com/a/502252
has answer: http://stackoverflow.com/a/500537
answer count: 12
has answer: http://stackoverflow.com/a/19659347
tagged with: final
type: UnansweredQuestion
score: 459
linked to: http://stackoverflow.com/q/40480
has comment: http://stackoverflow.com/comment/28692668
tagged with: pass-by-reference
has comment: http://stackoverflow.com/comment/28739035
has answer: http://stackoverflow.com/a/500517
type: Question
has comment: http://stackoverflow.com/comment/316048

http://stackoverflow.com/q/504103
type: Question
linked to: http://stackoverflow.com/q/503877
tagged with: benchmarking
has comment: http://stackoverflow.com/comment/63738773
tagged with: jvm-hotspot
has comment: http://stackoverflow.com/comment/79367155
has comment: http://stackoverflow.com/comment/55805039
has answer: http://stackoverflow.com/a/42891083
has answer: http://stackoverflow.com/a/504119
answer count: 11
linked to: http://stackoverflow.com/q/410437
has comment: http://stackoverflow.com/comment/48526263
has comment: http://stackoverflow.com/comment/83303481
has title: How do I write a correct micro-benchmark in Java?
has body: How do you write (and run) a correct micro-benchmark in Java? I'm looking for some code samples and comments illustrating various things to think about. Example: Should the benchmark measure time/iteration or iterations/time, and why? Related: Is stopwatch benchmarking acceptable?
upvote count: 993
accepted answer: http://stackoverflow.com/a/513259
tagged with: jvm
favorite count: 0
possible better answer: http://stackoverflow.com/a/4480774
has answer: http://stackoverflow.com/a/15787478
has answer: http://stackoverflow.com/a/504120
has answer: http://stackoverflow.com/a/14440319
has answer: http://stackoverflow.com/a/4480774
score: 992
has answer: http://stackoverflow.com/a/4480713
linked to: http://stackoverflow.com/q/37067929
has answer: http://stackoverflow.com/a/504172
type: AnsweredQuestion
tagged with: microbenchmark
has comment: http://stackoverflow.com/comment/5404786
has answer: http://stackoverflow.com/a/504162
linked to: http://stackoverflow.com/q/180158
tagged with: java
has comment: http://stackoverflow.com/comment/5404785
has answer: http://stackoverflow.com/a/504632
downvote count: 1
has answer: http://stackoverflow.com/a/513259

http://stackoverflow.com/q/540729
tagged with: inversion-of-control
answer count: 5
type: UnansweredQuestion
tagged with: spring
has comment: http://stackoverflow.com/comment/352951
has answer: http://stackoverflow.com/a/540862
tagged with: java
has answer: http://stackoverflow.com/a/540824
has answer: http://stackoverflow.com/a/541680
type: Question
tagged with: dependency-injection
has answer: http://stackoverflow.com/a/540821
has comment: http://stackoverflow.com/comment/352956
has title: Null Inner Bean with Spring IoC
score: 0
has answer: http://stackoverflow.com/a/540828
has body: I have a singleton bean definition like this: &lt;bean id="exampleBean" class="com.examples.ExampleBean"&gt; &lt;property name="exampleBean2"&gt; &lt;bean class="com.examples.ExampleBean2" /&gt; &lt;/property&gt; &lt;/bean&gt; where ExampleBean could be: public class ExampleBean { private ExampleBean2 exampleBean2; public ExampleBean() { } public ExampleBean2 getExampleBean2() { return exampleBean2; } public void setExampleBean2(ExampleBean2 exampleBean2) { this.exampleBean2 = exampleBean2; } } The problem is that, in certain conditions, the com.examples.ExampleBean2 class might not exist at runtime witch will cause an error when the IoC tries to instantiate exampleBean. What I need is to ignore this error from IoC and allow the exampleBean to be created but leaving the exampleBean2 property null. So the question is: is this possible in any way? Thanks for all your help.

http://stackoverflow.com/a/10411706
has body: For a quick start on building I recommend the tutorial Headless Eclipse RCP builds with Buckminster and Hudson, though it doesn't cover materialization. As Henrik mentions the bucky book aka "The definitive guide" provides good in depth documentation, from concept overview to xml specifications.
type: Answer
answers question: http://stackoverflow.com/q/552722
score: 0

http://stackoverflow.com/comment/3586868
score: 2
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2424497
has text: @Golfman maybe it's just Kodo, but I really hate JDO, and so does every single one of my coworkers. It's to the point where half of them would rather use straight JDBC. And just to be clear, no one hates it because of the extra compile step. They hate it because it's a pain to write code with and a pain to optimize queries with. Just my personal experience.

http://stackoverflow.com/comment/431155
comment on: http://stackoverflow.com/q/617831
has text: Can your tell us which transaction isolation level is in use?
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/637100
has comment: http://stackoverflow.com/comment/450595
tagged with: java
downvote count: 1
type: Question
upvote count: 9
has answer: http://stackoverflow.com/a/2759383
has answer: http://stackoverflow.com/a/637656
has comment: http://stackoverflow.com/comment/450465
answer count: 3
tagged with: http://stackoverflow.com/tag/pdf
has title: Java: Reading a pdf file from URL into Byte array/ByteBuffer in an applet
linked to: http://stackoverflow.com/q/326390
tagged with: applet
favorite count: 0
score: 8
has body: I'm trying to figure out why this particular snippet of code isn't working for me. I've got an applet which is supposed to read a .pdf and display it with a pdf-renderer library, but for some reason when I read in the .pdf files which sit on my server, they end up as being corrupt. I've tested it by writing the files back out again. I've tried viewing the applet in both IE and Firefox and the corrupt files occur. Funny thing is, when I trying viewing the applet in Safari (for Windows), the file is actually fine! I understand the JVM might be different, but I am still lost. I've compiled in Java 1.5. JVMs are 1.6. The snippet which reads the file is below. public static ByteBuffer getAsByteArray(URL url) throws IOException { ByteArrayOutputStream tmpOut = new ByteArrayOutputStream(); URLConnection connection = url.openConnection(); int contentLength = connection.getContentLength(); InputStream in = url.openStream(); byte[] buf = new byte[512]; int len; while (true) { len = in.read(buf); if (len == -1) { break; } tmpOut.write(buf, 0, len); } tmpOut.close(); ByteBuffer bb = ByteBuffer.wrap(tmpOut.toByteArray(), 0, tmpOut.size()); //Lines below used to test if file is corrupt //FileOutputStream fos = new FileOutputStream("C:\\abc.pdf"); //fos.write(tmpOut.toByteArray()); return bb; } I must be missing something, and I've been banging my head trying to figure it out. Any help is greatly appreciated. Thanks. Edit: To further clarify my situation, the difference in the file before I read then with the snippet and after, is that the ones I output after reading are significantly smaller than they originally are. When opening them, they are not recognized as .pdf files. There are no exceptions being thrown that I ignore, and I have tried flushing to no avail. This snippet works in Safari, meaning the files are read in it's entirety, with no difference in size, and can be opened with any .pdf reader. In IE and Firefox, the files always end up being corrupted, consistently the …
has answer: http://stackoverflow.com/a/637468
type: UnansweredQuestion

http://stackoverflow.com/q/645462
answer count: 1
downvote count: 0
tagged with: .net
favorite count: 0
tagged with: remoting
has title: Establishing communication between Java client and .NET server
score: 2
has body: I would like to create a server using .NET and Java client (Android application). The client will be connected to the server through mobile network so it's impossible to use tcp socket for two-way communication. I would like to develop a logic for client login: The client sends username and password to the server and server replies (connected/not connected). Then if client is connected it starts sending data stream using tcp sockets. So far I have looked at some of the tutorials for Java/.Net interoperability and remoting but still haven't found the solution for login logic described above. I would really appreciate any suggestion on how to create a logic for login or any good tutorial recommendation. Thanks!
upvote count: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/645474
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/645474
tagged with: interop

http://stackoverflow.com/a/47602699
answers question: http://stackoverflow.com/q/363681
downvote count: 0
upvote count: 2
type: Answer
has body: There is a library at https://sourceforge.net/projects/stochunit/ for handling selection of ranges. StochIntegerSelector randomIntegerSelector = new StochIntegerSelector(); randomIntegerSelector.setMin(-1); randomIntegerSelector.setMax(1); Integer selectInteger = randomIntegerSelector.selectInteger(); It has edge inclusion/preclusion.
score: 2

http://stackoverflow.com/a/11189634
type: Answer
upvote count: 12
score: 11
has body: I do not know if this is relevant for anyone reading this, but I just had the problem that I wanted to download a file from a given URL and compare its MD5 to a known value. I wanted to do it with JRE classes only (no Apache Commons or similar). A quick web search did not show me sample code snippets doing both at the same time, only each task separately. Because this requires to read the same file twice, I figured it might be worth the while to write some code which unifies both tasks, calculating the checksum on the fly while downloading the file. This is my result (sorry if it is not perfect Java, but I guess you get the idea anyway): import java.io.FileOutputStream; import java.io.IOException; import java.math.BigInteger; import java.net.URL; import java.nio.ByteBuffer; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; import java.nio.channels.WritableByteChannel; import java.security.DigestOutputStream; // new import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; void downloadFile(String fromURL, String toFile, BigInteger md5) throws IOException, NoSuchAlgorithmException { ReadableByteChannel in = Channels.newChannel(new URL(fromURL).openStream()); MessageDigest md5Digest = MessageDigest.getInstance("MD5"); WritableByteChannel out = Channels.newChannel( //new FileOutputStream(toFile)); // old new DigestOutputStream(new FileOutputStream(toFile), md5Digest)); // new ByteBuffer buffer = ByteBuffer.allocate(1024 * 1024); // 1 MB while (in.read(buffer) != -1) { buffer.flip(); //md5Digest.update(buffer.asReadOnlyBuffer()); // old out.write(buffer); buffer.clear(); } BigInteger md5Actual = new BigInteger(1, md5Digest.digest()); if (! md5Actual.equals(md5)) throw new RuntimeException( "MD5 mismatch for file " + toFile + ": expected " + md5.toString(16) + ", got " + md5Actual.toString(16) ); }
has comment: http://stackoverflow.com/comment/14707847
answers question: http://stackoverflow.com/q/415953
downvote count: 1

http://stackoverflow.com/comment/9009852
comment on: http://stackoverflow.com/a/4937713
has text: I am using this. I am adding items dynamically to that layout. It gets added but every view is way to small say tiny. why?
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/18769079
answers question: http://stackoverflow.com/q/611732
downvote count: 0
type: Answer
has body: Commons Math - The Apache Commons Mathematics Library http://mvnrepository.com/artifact/org.apache.commons/commons-math3/3.2 According to my own benchmarking for my specific use case it's 10 - 20x slower than double (much better than 1000x) - basically for addition / multiplication. After benchmarking another algorithm which had a sequence of additions followed by an exponentiation the performance decrease was quite a bit worse: 200x - 400x. So it seems pretty fast for + and *, but not exp and log. Commons Math is a library of lightweight, self-contained mathematics and statistics components addressing the most common problems not available in the Java programming language or Commons Lang. Note: The API protects the constructors to force a factory pattern while naming the factory DfpField (rather than the somewhat more intuitive DfpFac or DfpFactory). So you have to use new DfpField(numberOfDigits).newDfp(myNormalNumber) to instantiate a Dfp, then you can call .multiply or whatever on this. I thought I'd mention this because it's a bit confusing.
score: 1
upvote count: 1

http://stackoverflow.com/a/33357365
score: 7
downvote count: 1
has comment: http://stackoverflow.com/comment/94134021
upvote count: 8
answers question: http://stackoverflow.com/q/542979
type: Answer
has body: I found it hard to decipher what is meant by "working directory of the VM". In my example, I was using the Java Service Wrapper program to execute a jar - the dump files were created in the directory where I had placed the wrapper program, e.g. c:\myapp\bin. The reason I discovered this is because the files can be quite large and they filled up the hard drive before I discovered their location.

http://stackoverflow.com/comment/433142
score: 1
comment on: http://stackoverflow.com/a/620107
type: AnswerComment
type: Comment
has text: And the default case still needs to be handled, and that's the point of the question.

http://stackoverflow.com/comment/423222
score: 0
has text: Huh? Of course it's possible to rotate a small image, it just means that some pixels will move while some won't. Consider a line going from (0,0) to (639,0) compared to one going from (0,0) to (639,1), and so on.
type: Comment
comment on: http://stackoverflow.com/a/566679
type: AnswerComment

http://stackoverflow.com/a/445158
has body: The code you listed above can't be the source of the 1fps problem... I have code doing far more than this that runs far faster. Can you benchmark that code and make sure it's the root of the problem?
upvote count: 3
answers question: http://stackoverflow.com/q/445070
type: Answer
score: 3
downvote count: 0

http://stackoverflow.com/q/605749
accepted answer: http://stackoverflow.com/a/605852
type: AnsweredQuestion
score: 1
tagged with: java
tagged with: hibernate
has body: Having in mind that each webapp has its own separate database (but all databases are in the same database server). The scenario is that I have a multi-tenant saas application - I deploy the same application for each customer. Each customer works on a database that is called db_cid, where cid is the customer id, i.e. a a unique customer identifier. Working with hibernate.
possible better answer: http://stackoverflow.com/a/605841
upvote count: 1
has answer: http://stackoverflow.com/a/605841
type: Question
has answer: http://stackoverflow.com/a/605852
answer count: 2
downvote count: 0
tagged with: tomcat
favorite count: 0
tagged with: multi-tenant
tagged with: saas
has title: How can multiple webapps in the same tomcat instance share database connection pool?

http://stackoverflow.com/q/359625
answer count: 11
possible better answer: http://stackoverflow.com/a/359632
has comment: http://stackoverflow.com/comment/190382
has answer: http://stackoverflow.com/a/359860
tagged with: string
has answer: http://stackoverflow.com/a/363249
favorite count: 0
score: 8
tagged with: parsing
has answer: http://stackoverflow.com/a/359645
has body: Is there a better, more elegant (and/or possibly faster) way than boolean isNumber = false; try{ Double.valueOf(myNumber); isNumber = true; } catch (NumberFormatException e) { } ...? Edit: Since I can't pick two answers I'm going with the regex one because a) it's elegant and b) saying "Jon Skeet solved the problem" is a tautology because Jon Skeet himself is the solution to all problems.
has comment: http://stackoverflow.com/comment/190578
has comment: http://stackoverflow.com/comment/191145
has answer: http://stackoverflow.com/a/359632
has answer: http://stackoverflow.com/a/359639
has answer: http://stackoverflow.com/a/363252
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/359691
tagged with: numbers
tagged with: java
has answer: http://stackoverflow.com/a/359674
has answer: http://stackoverflow.com/a/359845
has title: Most elegant way to detect if a String is a number?
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/368416
upvote count: 9
has answer: http://stackoverflow.com/a/359634
accepted answer: http://stackoverflow.com/a/359634

http://stackoverflow.com/a/592512
score: 1
answers question: http://stackoverflow.com/q/592494
upvote count: 1
has body: One popular way is to create a ByteCountingReader(Reader r);, I guess I don't have to be any more specific than this :-)
type: Answer
downvote count: 0

http://stackoverflow.com/a/73532923
score: 1
has comment: http://stackoverflow.com/comment/129886337
upvote count: 1
answers question: http://stackoverflow.com/q/419850
downvote count: 0
type: Answer
has body: Since the question and the existing answers are a bit old, I'd like to suggest a more recent answer. Nowadays there is the Spring Webflux project. Your use case can be easily implemented in a reactive fashion. So in your case the class MultipartHttpMessageReader would be doing all the heavy lifting. In case it does not behave exactly how you need it to, you can easily extend it and overwrite the methods to your liking. Your custom Reader can then be registered as a bean like so: @Configuration public class MultipartMessageConverterConfiguration { @Bean public CodecCustomizer myCustomMultipartHttpMessageWriter() { return configurer -&gt; configurer.customCodecs() .register(new MyCustomMultipartHttpMessageWriter()); } }

http://stackoverflow.com/comment/434314
has text: But then what about FileAccess? And FileShare? How do you model combinations of these using delegates?
comment on: http://stackoverflow.com/a/620616
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/3243869
answers question: http://stackoverflow.com/q/574240
score: 4
type: Answer
upvote count: 4
has body: Synchronized method is used for lock all the objects Synchronized block is used to lock specific object
downvote count: 0

http://stackoverflow.com/a/538612
score: 3
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/350983
has comment: http://stackoverflow.com/comment/357811
upvote count: 3
answers question: http://stackoverflow.com/q/538550
has comment: http://stackoverflow.com/comment/353450
has comment: http://stackoverflow.com/comment/352435
has body: The biggest question I'd ask is why are you changing presentation layer? That's a very expensive cost and I can see the benefits of one technology outweighing the others by as much as the cost to change...
has comment: http://stackoverflow.com/comment/355509
has comment: http://stackoverflow.com/comment/357968
has comment: http://stackoverflow.com/comment/353436
has comment: http://stackoverflow.com/comment/369367

http://stackoverflow.com/comment/402124
type: AnswerComment
has text: I didn't mean write T.class in the method. I said as an argumnet. And the calling function may no (or may have it passed as an argumnet).
type: Comment
score: 2
comment on: http://stackoverflow.com/a/590418

http://stackoverflow.com/comment/458059
type: Comment
has text: Ah! That makes sense. So the list actually tries to render items as if it were a very large canvas, each item in their proper place?
comment on: http://stackoverflow.com/a/644670
type: AnswerComment
score: 0

http://stackoverflow.com/a/399004
has comment: http://stackoverflow.com/comment/225003
has comment: http://stackoverflow.com/comment/224869
type: Answer
has comment: http://stackoverflow.com/comment/224854
has comment: http://stackoverflow.com/comment/225145
has comment: http://stackoverflow.com/comment/225095
has comment: http://stackoverflow.com/comment/225094
has body: I'm a little confused about your questions. Why don't you use an Object-relational-mapping framework like Hibernate? I used to have the same problem having to read and write a lot of SQL directly. Eventually I started writing newer projects with Hibernate and haven't looked back. The system takes care for me of building the actual tables and running the SQL in the background, and I can mostly work with the java objects.
score: 5
has comment: http://stackoverflow.com/comment/225421
answers question: http://stackoverflow.com/q/398992
upvote count: 5
has comment: http://stackoverflow.com/comment/224909
has comment: http://stackoverflow.com/comment/224934
has comment: http://stackoverflow.com/comment/225087
downvote count: 0

http://stackoverflow.com/comment/5189411
has text: Sorry, but I couldn't agree less... If that were true, than how would we get those games with near-realistic graphics? We can create virtual worlds, but can't guarantee a decent update rate for... Chart?
score: 12
type: AnswerComment
comment on: http://stackoverflow.com/a/555877
type: Comment

http://stackoverflow.com/q/579224
tagged with: security
has title: Setting catalina.policy to allow file access by servlets
has answer: http://stackoverflow.com/a/579280
type: AnsweredQuestion
tagged with: configuration
upvote count: 5
tagged with: java
has comment: http://stackoverflow.com/comment/391131
type: Question
accepted answer: http://stackoverflow.com/a/579280
score: 5
has body: We have a locally-developed triple store based on b-trees which I want to use for persistent storage in a number of servlet applications. Rather than embed the b-tree index files in the servlet .war, I would like to store them at a known location and have the servlets access them directly. This all works in Jetty, but raises a security exception when I try it in Tomcat. I'm told that Tomcat's security model requires explicit permissions for a servlet to access files outside the directory tree where the .war is unpacked. If I've understood the Tomcat (version 5.5) documentation correctly, the following added to catalina.policy should allow the servlet to access the directories where the index files are: grant codeBase "jar:file:${catalina.home}/webapps/mytestapp/-" { permission java.io.FilePermission "/var/data/tdb/-", "read, write, delete"; } However, I still get a security exception: java.io.FileNotFoundException: /var/data/tdb/kb/node2id.idn (Permission denied) at java.io.RandomAccessFile.open(Native Method) ... To tick off the obvious dumb errors: I've checked that the index files are at the correct location, with the correct permissions, and are not corrupted. Any suggestions or hints at what I've got wrong in the security settings would be gratefully received.
downvote count: 0
answer count: 1
tagged with: tomcat
has comment: http://stackoverflow.com/comment/391169
favorite count: 0

http://stackoverflow.com/a/641446
downvote count: 0
has comment: http://stackoverflow.com/comment/454945
has comment: http://stackoverflow.com/comment/455005
answers question: http://stackoverflow.com/q/641338
upvote count: 2
type: Answer
score: 2
has body: Set the property or bean that you want to display in the request attribute and fetch the value from it in the final page: The syntax for inserting a value in text box is

http://stackoverflow.com/comment/318603
has text: I don't think I understand why you would want to rebuild a ResultSet. If you rebuild the ResultSet you get right back to having this huge object on one node.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/502429

profiler
tags question: http://stackoverflow.com/q/490858
tag name: profiler
type: Tag
tags question: http://stackoverflow.com/q/483054
tags question: http://stackoverflow.com/q/368831

http://stackoverflow.com/comment/430632
type: Comment
comment on: http://stackoverflow.com/a/617672
has text: Low tech solution that is hard for the translators to get wrong :-) Are the resources done as ResourceBundle?
type: AnswerComment
score: 0

http://stackoverflow.com/comment/198449
comment on: http://stackoverflow.com/q/369383
type: Comment
type: QuestionComment
has text: I would say to use Arrays.sort then check the elements near the front and back, but it throws a NullPointerException if the array contains a null element.
score: 0

http://stackoverflow.com/q/443980
answer count: 7
has answer: http://stackoverflow.com/a/35319703
score: 131
possible better answer: http://stackoverflow.com/a/7901873
favorite count: 0
has body: Why can't enum's constructor access static fields and methods? This is perfectly valid with a class, but is not allowed with an enum. What I'm trying to do is store my enum instances in a static Map. Consider this example code which allows lookup by abbreivation: public enum Day { Sunday("Sun"), Monday("Mon"), Tuesday("Tue"), Wednesday("Wed"), Thursday("Thu"), Friday("Fri"), Saturday("Sat"); private final String abbreviation; private static final Map&lt;String, Day&gt; ABBREV_MAP = new HashMap&lt;String, Day&gt;(); private Day(String abbreviation) { this.abbreviation = abbreviation; ABBREV_MAP.put(abbreviation, this); // Not valid } public String getAbbreviation() { return abbreviation; } public static Day getByAbbreviation(String abbreviation) { return ABBREV_MAP.get(abbreviation); } } This will not work as enum doesn't allow static references in its constructor. It however works just find if implemented as a class: public static final Day SUNDAY = new Day("Sunday", "Sun"); private Day(String name, String abbreviation) { this.name = name; this.abbreviation = abbreviation; ABBREV_MAP.put(abbreviation, this); // Valid }
has title: Why can't enum's constructor access static fields?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/78433963
downvote count: 0
linked to: http://stackoverflow.com/q/2464950
tagged with: java
has answer: http://stackoverflow.com/a/77667425
upvote count: 131
has answer: http://stackoverflow.com/a/444000
accepted answer: http://stackoverflow.com/a/444000
has answer: http://stackoverflow.com/a/7901873
has answer: http://stackoverflow.com/a/35476885
type: Question
tagged with: enums
has comment: http://stackoverflow.com/comment/114042905
has answer: http://stackoverflow.com/a/23425741

http://stackoverflow.com/comment/426879
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/613746
type: Comment
has text: This method (and my method) do not actually get executed on the main thread, they are still done with Thread.currentThread == the thread where the exception occurs. Not sure if that really matters to the OP.

http://stackoverflow.com/a/395825
downvote count: 1
has body: Have you ever used Swing/AWT? Their Event hierarchy solves a similar problem. The way Java passes functions around is with an interface, for example public interface ActionHandler { public void actionPerformed(ActionArgs e); } Then, if you want to map integers onto these objects, you could use something like a java.util.HashMap&lt;Integer,ActionHandler&gt; to manage that. The actual implementations can either go in anonymous classes (Java's best approximation of "lambda") or in proper classes somewhere. Here's the anonymous class way: HashMap&lt;Integer,ActionHandler&gt; handlers; handlers.put(ACTION_FROB, new ActionHandler() { public void actionPerformed(ActionArgs e) { // Do stuff // Note that any outer variables you intend to close over must be final. } }); handlers.get(ACTION_FROB).actionPerformed(foo); (edit) If you want to be even more abusive, you can initialize the HashMap like so: HashMap&lt;Integer,String&gt; m = new HashMap&lt;Integer,String&gt;() {{ put(0,"hello"); put(1,"world"); }};
answers question: http://stackoverflow.com/q/395816
type: Answer
upvote count: 2
score: 1

http://stackoverflow.com/a/68579040
answers question: http://stackoverflow.com/q/521171
has body: Java 14+ edition You can create a record which implements equals, hashCode, and toString out of the box. Interfaces like Comparable could also be implemented, if needed. record Pair&lt;A, B&gt;(A first, B second) {} Records are immutable.
downvote count: 0
score: 13
upvote count: 13
type: Answer

http://stackoverflow.com/comment/103532401
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/5092096
type: Comment
has text: Beware that AltCodes do not support full unicode set, but only characters in IBM437 (ALT nnn) and Windows-1252 (ALT 0nnn) character sets -- see e.g. [here](https://altcodeunicode.com/). It is possible to enable full unicode support via "ALT" "+" "nnnn" (see e.g. [here](https://superuser.com/a/1024956/534074)). YMMV

http://stackoverflow.com/comment/280096
comment on: http://stackoverflow.com/a/457631
score: 0
type: AnswerComment
has text: I've asked for a solution in Java, this obviously isn't Java. Apart from that, considering your own comments: I'm looking for a solid and well tested solution, not something thrown together in five minutes. A throttling system that deadlocks after a few hours or something isn't very useful.
type: Comment

http://stackoverflow.com/comment/491743
type: Comment
has text: We can even use a jsp tag that came with JRuby Rack to embed some Ruby partials into an existing jsp page. One note that bit us... Rack or some other tool was converting session Integers to Longs... but a simple JSP filter resolved it by watching variables and converting them back when changed.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/672449

http://stackoverflow.com/comment/414989
type: Comment
has text: This exception has nothing to do with threading concurrency, it is caused by the backing store of the iterator being modified. Whether by another thread of not doesn't matter to the iterator. IMHO it is a poorly named exception since it gives an incorrect impression of the cause.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/602660

http://stackoverflow.com/q/609293
has answer: http://stackoverflow.com/a/609330
has answer: http://stackoverflow.com/a/609337
score: 7
tagged with: java
upvote count: 7
has answer: http://stackoverflow.com/a/609497
has answer: http://stackoverflow.com/a/609303
type: Question
has answer: http://stackoverflow.com/a/609299
has answer: http://stackoverflow.com/a/609342
has title: Java exception handling idioms ... who's right and how to handle it?
answer count: 11
has comment: http://stackoverflow.com/comment/421765
has answer: http://stackoverflow.com/a/609335
downvote count: 0
has answer: http://stackoverflow.com/a/609433
has answer: http://stackoverflow.com/a/609426
has comment: http://stackoverflow.com/comment/421782
accepted answer: http://stackoverflow.com/a/609299
has comment: http://stackoverflow.com/comment/421871
has comment: http://stackoverflow.com/comment/421763
favorite count: 0
has answer: http://stackoverflow.com/a/609412
has answer: http://stackoverflow.com/a/609300
has body: I currently have a technical point of difference with an acquaintance. In a nutshell, it's the difference between these two basic styles of Java exception handling: Option 1 (mine): try { ... } catch (OneKindOfException) { ... } catch (AnotherKind) { ... } catch (AThirdKind) { ... } Option 2 (his): try { ... } catch (AppException e) { switch(e.getCode()) { case Constants.ONE_KIND: ... break; case Constants.ANOTHER_KIND: ... break; case Constants.A_THIRD_KIND: ... break; default: ... } } His argument -- after I used copious links about user input validation, exception handling, assertions and contracts, etc. to back up my point of view -- boiled down to this: "It’s a good model. I've used it since me and a friend of mine came up with it in 1998, almost 10 years ago. Take another look and you'll see that the compromises we made to the academic arguments make a lot of sense." Does anyone have a knock-down argument for why Option 1 is the way to go?
has comment: http://stackoverflow.com/comment/421766
tagged with: exception
has comment: http://stackoverflow.com/comment/421825
possible better answer: http://stackoverflow.com/a/609330
type: AnsweredQuestion

http://stackoverflow.com/comment/10506487
type: Comment
score: 5
comment on: http://stackoverflow.com/a/7873389
has text: Looks quite good, but having to generate the Dao's is a turnoff for me :(
type: AnswerComment

http://stackoverflow.com/a/13063359
type: Answer
score: 2
has body: Without the static modifier you cannot figure out that the method is stateless without additional analysis which can be easily done when you (re)write the method. Then "static" modifier may give you ideas about refactoring besides other things that others may find unuseful. E.g. moving the method to some Utility class or converting it to a member method..
answers question: http://stackoverflow.com/q/538870
downvote count: 0
upvote count: 2

http://stackoverflow.com/q/590951
has answer: http://stackoverflow.com/a/590989
tagged with: java
tagged with: swing
type: Question
has answer: http://stackoverflow.com/a/590971
has title: Getting the removed text from a Java text component
score: 4
possible better answer: http://stackoverflow.com/a/590966
has answer: http://stackoverflow.com/a/590966
tagged with: jtextcomponent
answer count: 3
has body: A JTextComponent allows you to add a DocumentListener to its Document, which will tell you when text was added or removed, and the offset and length of the change. It will not, however, tell you what the text of the change was. This is not much of a problem for text addition, as you can use the offset and the length to find the added text. However, you can't use it to find the deleted text, as the text is already gone. Has anyone run into this problem before? How can you get the string that was deleted from a document?
favorite count: 0
accepted answer: http://stackoverflow.com/a/590989
upvote count: 4
tagged with: text
type: AnsweredQuestion
downvote count: 0

http://stackoverflow.com/a/561609
has comment: http://stackoverflow.com/comment/2326211
has comment: http://stackoverflow.com/comment/372835
type: AcceptedAnswer
downvote count: 0
upvote count: 50
accepted answer of: http://stackoverflow.com/q/561588
score: 50
type: Answer
has comment: http://stackoverflow.com/comment/372969
has comment: http://stackoverflow.com/comment/372747
answers question: http://stackoverflow.com/q/561588
has body: i++ : create a temporary copy of i increment i return the temporary copy ++i : increment i return i With optimizations on, it is quite possible that the resulting assembly is identical, however ++i is more efficient. edit : keep in mind that in C++, i may be whatever object that support the prefix and postfix ++ operator. For complex objects, the temporary copy cost is non negligible.

http://stackoverflow.com/comment/11442702
comment on: http://stackoverflow.com/a/2965252
score: 67
type: AnswerComment
type: Comment
has text: @Sangdol usually it's a good thing to check what SUN - oops - Oracle is doing in the same situation. And as [Enum.valueOf()](http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Enum.html#valueOf) is showing it **IS** best practice to throw a Exception in this case. *Because* it is an exceptional situation. "Performance optimization" is a bad excuse to write unreadable code ;-)

http://stackoverflow.com/comment/425142
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/612156
has text: much better. we once spent the better part of a week tracking something down because of using "this" from a constructor (nasty threading bug).

http://stackoverflow.com/a/462396
answers question: http://stackoverflow.com/q/462373
downvote count: 0
upvote count: 105
score: 105
type: Answer
has body: See Branching Statements for more details and code samples: break The break statement has two forms: labeled and unlabeled. You saw the unlabeled form in the previous discussion of the switch statement. You can also use an unlabeled break to terminate a for, while, or do-while loop [...] An unlabeled break statement terminates the innermost switch, for, while, or do-while statement, but a labeled break terminates an outer statement. continue The continue statement skips the current iteration of a for, while , or do-while loop. The unlabeled form skips to the end of the innermost loop's body and evaluates the boolean expression that controls the loop. [...] A labeled continue statement skips the current iteration of an outer loop marked with the given label.

http://stackoverflow.com/comment/106162755
type: Comment
has text: @ChrisKerekes Neh... just expect people to understand why this is a terribly bad thing to do.
comment on: http://stackoverflow.com/a/444514
type: AnswerComment
score: 0

http://stackoverflow.com/a/594826
downvote count: 1
answers question: http://stackoverflow.com/q/594789
upvote count: 2
type: Answer
has body: Doing this seems to have "Bad design decision" written all over it.
score: 1

http://stackoverflow.com/a/367801
type: Answer
has comment: http://stackoverflow.com/comment/196977
has body: i guess the problem lies in the contents of jad file - path to jar file must be invalid. besides, handsets frequently are quite picky about the format of jad file - order of rows, newline character, etc
answers question: http://stackoverflow.com/q/367781
score: 0

http://stackoverflow.com/q/543130
has answer: http://stackoverflow.com/a/2825967
tagged with: java
has title: Java 2D and resize
answer count: 5
tagged with: image
upvote count: 4
has answer: http://stackoverflow.com/a/543443
type: AnsweredQuestion
tagged with: image-scaling
downvote count: 0
has answer: http://stackoverflow.com/a/17214250
tagged with: resize
favorite count: 0
has answer: http://stackoverflow.com/a/543157
type: Question
has answer: http://stackoverflow.com/a/4914929
accepted answer: http://stackoverflow.com/a/543443
has body: I have some old Java 2D code I want to reuse, but was wondering, is this the best way to get the highest quality images? public static BufferedImage getScaled(BufferedImage imgSrc, Dimension dim) { // This code ensures that all the pixels in the image are loaded. Image scaled = imgSrc.getScaledInstance( dim.width, dim.height, Image.SCALE_SMOOTH); // This code ensures that all the pixels in the image are loaded. Image temp = new ImageIcon(scaled).getImage(); // Create the buffered image. BufferedImage bufferedImage = new BufferedImage(temp.getWidth(null), temp.getHeight(null), BufferedImage.TYPE_INT_RGB); // Copy image to buffered image. Graphics g = bufferedImage.createGraphics(); // Clear background and paint the image. g.setColor(Color.white); g.fillRect(0, 0, temp.getWidth(null),temp.getHeight(null)); g.drawImage(temp, 0, 0, null); g.dispose(); // j2d's image scaling quality is rather poor, especially when // scaling down an image to a much smaller size. We'll post filter // our images using a trick found at // http://blogs.cocoondev.org/mpo/archives/003584.html // to increase the perceived quality.... float origArea = imgSrc.getWidth() * imgSrc.getHeight(); float newArea = dim.width * dim.height; if (newArea &lt;= (origArea / 2.)) { bufferedImage = blurImg(bufferedImage); } return bufferedImage; } public static BufferedImage blurImg(BufferedImage src) { // soften factor - increase to increase blur strength float softenFactor = 0.010f; // convolution kernel (blur) float[] softenArray = { 0, softenFactor, 0, softenFactor, 1-(softenFactor*4), softenFactor, 0, softenFactor, 0}; Kernel kernel = new Kernel(3, 3, softenArray); ConvolveOp cOp = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null); return cOp.filter(src, null); }
possible better answer: http://stackoverflow.com/a/4914929
score: 4
tagged with: 2d

http://stackoverflow.com/comment/102409373
type: AnswerComment
comment on: http://stackoverflow.com/a/3303638
score: 0
type: Comment
has text: This is the perfect library that fulfills my async process integration test requirements. Really awesome. The library seems to be well maintained and has features extending from basic to advanced that I believe are sufficient to cater for most scenarios. Thanks for the awesome reference!

http://stackoverflow.com/a/433864
type: Answer
answers question: http://stackoverflow.com/q/433853
score: 3
upvote count: 3
downvote count: 0
has body: Getting used to having a garbage collector. Not being able to rely on a destructor to clean up resources that the GC does not handle. Everything is passed by value, because references are passed instead of objects. No copy constructor, unless you have a need to clone. No assignment operator. All methods are virtual by default, which is the opposite of C++. Explicit language support for interfaces - pure virtual classes in C++.

http://stackoverflow.com/a/401837
answers question: http://stackoverflow.com/q/401783
downvote count: 0
type: Answer
upvote count: 2
has body: Sorry I can't provide the whole answer, but I can say the Java float is saved into the file as a four-byte IEEE 754 representation of the float as per this document: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Float.html#floatToIntBits(float) That describes the exact structure of the value saved, so you could read it in as an int and manually parse the bits for the significand and exponent into a float. It does seem there should be a library call to parse floating point values packed into an int of this format. Hopefully someone else will know of a library call to handle this.
score: 2

http://stackoverflow.com/comment/41948657
type: Comment
comment on: http://stackoverflow.com/a/505148
type: AnswerComment
has text: @MichaelBorgwardt That sounds way better. :) Thanks for clarifying!
score: 0

http://stackoverflow.com/comment/100624166
score: 0
type: Comment
comment on: http://stackoverflow.com/a/596707
has text: I'd also add that "if `final` seems restrictive" (on both `equals` and `hashCode`) then use `getClass()` equality instead of `instanceof` in order to preserve the symmetry and transitivity requirements of the `equals` contract.
type: AnswerComment

http://stackoverflow.com/a/386166
has body: I think it's got to do with using SMTPS instead of SMTP for mail transport. Here's a different version, modeled after the JavaMail FAQ on accessing Gmail. Note that I have left out all of the finer level exception handling for clarity. private static void send( final String username, final String password, final String recipients, final String subject, final String body) throws Exception { final Session session = Session.getInstance(System.getProperties(), null); final Message msg = new MimeMessage(session); final String senderEmail = username.contains("@") ? username : (username + "@gmail.com"); msg.setFrom(new InternetAddress(senderEmail)); final Address[] recipientAddresses = InternetAddress.parse(recipients); msg.setRecipients(Message.RecipientType.TO, recipientAddresses); msg.setSentDate(new Date()); msg.setSubject(subject); msg.setText(body); final Transport transport = session.getTransport("smtps"); transport.connect(GMAIL_SMTP_HOST, GMAIL_SMTP_PORT, username, password); transport.sendMessage(msg, recipientAddresses); transport.close(); }
answers question: http://stackoverflow.com/q/386083
score: 4
has comment: http://stackoverflow.com/comment/213779
upvote count: 4
has comment: http://stackoverflow.com/comment/213794
downvote count: 0
type: Answer

http://stackoverflow.com/comment/82840661
type: Comment
comment on: http://stackoverflow.com/a/26687649
score: 1
type: AnswerComment
has text: Note: Use_the Emailvalidator in org.apache.commons.validator.routines since EmailValidator in org.apache.commons.validator is deprecated (I am using 1.6 commons Validator)

http://stackoverflow.com/a/530351
type: Answer
answers question: http://stackoverflow.com/q/530215
has comment: http://stackoverflow.com/comment/343278
has body: I've been looking into this myself and can't find a strong difference between the two. I think the big choice is in which implementation you use. For myself I've been considering the DataNucleus platform as it is a data-store agnostic implementation of both.
downvote count: 0
score: 8
upvote count: 8

http://stackoverflow.com/a/575802
has body: If we're talking specifically about spaces, you want to be testing specifically for spaces: MyString = MyString.replaceAll(" +", " "); Using \s will result in all whitespace being replaced - sometimes desired, othertimes not. Also, a simpler way to only match 2 or more is: MyString = MyString.replaceAll(" {2,}", " "); (Of course, both of these examples can use \s if any whitespace is desired to be replaced with a single space.)
score: 12
answers question: http://stackoverflow.com/q/575500
upvote count: 12
has comment: http://stackoverflow.com/comment/391076
downvote count: 0
has comment: http://stackoverflow.com/comment/391526
type: Answer

http://stackoverflow.com/a/5931718
has comment: http://stackoverflow.com/comment/30316180
type: Answer
has comment: http://stackoverflow.com/comment/22522586
upvote count: 276
downvote count: 15
has comment: http://stackoverflow.com/comment/51638719
has comment: http://stackoverflow.com/comment/11427963
has comment: http://stackoverflow.com/comment/13604365
has comment: http://stackoverflow.com/comment/34300830
answers question: http://stackoverflow.com/q/624581
has comment: http://stackoverflow.com/comment/34276315
has comment: http://stackoverflow.com/comment/21965107
has comment: http://stackoverflow.com/comment/62602919
has comment: http://stackoverflow.com/comment/44557855
has comment: http://stackoverflow.com/comment/39173267
has comment: http://stackoverflow.com/comment/51912901
has comment: http://stackoverflow.com/comment/18440537
has comment: http://stackoverflow.com/comment/45294316
has comment: http://stackoverflow.com/comment/20252923
has comment: http://stackoverflow.com/comment/82308859
has comment: http://stackoverflow.com/comment/30200901
has comment: http://stackoverflow.com/comment/45163148
score: 261
has body: Using the official java email package is the easiest: public static boolean isValidEmailAddress(String email) { boolean result = true; try { InternetAddress emailAddr = new InternetAddress(email); emailAddr.validate(); } catch (AddressException ex) { result = false; } return result; }
has comment: http://stackoverflow.com/comment/9305730
has comment: http://stackoverflow.com/comment/8760181
has comment: http://stackoverflow.com/comment/20254432
has comment: http://stackoverflow.com/comment/46543376
has comment: http://stackoverflow.com/comment/49631516

http://stackoverflow.com/comment/237533
type: Comment
score: 4
comment on: http://stackoverflow.com/a/412439
type: AnswerComment
has text: Just have to be careful of the threading problems with that! I've had the weirdest bugs arise from use of SimpleDateFormat

http://stackoverflow.com/comment/243628
type: Comment
comment on: http://stackoverflow.com/a/419459
has text: Disagree with the analogy. In many cases it's perfectly justifiable to build something that "just works", possibly because it's a demo or PoC, possibly because it's something we can iterate over time, possibly because nothing critical rides on quality. For most bridges those conditions don't apply.
score: 0
type: AnswerComment

http://stackoverflow.com/a/477855
has comment: http://stackoverflow.com/comment/93944114
answers question: http://stackoverflow.com/q/477750
score: 8
upvote count: 8
type: Answer
has comment: http://stackoverflow.com/comment/30562416
has body: Given that the "why int by default" question hasn't been answered ... First, "default" is not really the right term (although close enough). As noted by VonC, an expression composed of ints and longs will have a long result. And an operation consisting of ints/logs and doubles will have a double result. The compiler promotes the terms of an expression to whatever type provides a greater range and/or precision in the result (floating point types are presumed to have greater range and precision than integral, although you do lose precision converting large longs to double). One caveat is that this promotion happens only for the terms that need it. So in the following example, the subexpression 5/4 uses only integral values and is performed using integer math, even though the overall expression involves a double. The result isn't what you might expect... (5/4) * 1000.0 OK, so why are byte and short promoted to int? Without any references to back me up, it's due to practicality: there are a limited number of bytecodes. "Bytecode," as its name implies, uses a single byte to specify an operation. For example iadd, which adds two ints. Currently, 205 opcodes are defined, and integer math takes 18 for each type (ie, 36 total between integer and long), not counting conversion operators. If short, and byte each got their own set of opcodes, you'd be at 241, limiting the ability of the JVM to expand. As I said, no references to back me up on this, but I suspect that Gosling et al said "how often do people actually use shorts?" On the other hand, promoting byte to int leads to this not-so-wonderful effect (the expected answer is 96, the actual is -16): byte x = (byte)0xC0; System.out.println(x &gt;&gt; 2);
downvote count: 0

http://stackoverflow.com/comment/245583
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/416829
has text: In particular, the methods which return "safe" encoded representations of the byte data in string form.
type: Comment

http://stackoverflow.com/a/3485513
upvote count: 5
score: 5
downvote count: 0
type: Answer
has body: The Path Tools plugin. It adds four useful actions to Netbeans: Copy Paths Action Copy the full paths of the files/folder of selected node to the clipboard. Explore Action Launch the OS File Explorer Shell On Path Action Launch the OS shell Edit Action Launch the external editor The webpage of the Path Tools plugin looks not very active, but it works in Netbeans 6.9.1 without problems (Works on My Machine).
answers question: http://stackoverflow.com/q/509931

http://stackoverflow.com/comment/215895
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/388448
type: Comment
has text: The public clone() method in java.lang.Object could not be changed for backward-compatibility. I'm fine with this. But I don't see how the modification I'm suggesting to the interface could be harmful. I think it's backward-compatible, and also type safe. What do you think?

http://stackoverflow.com/a/573238
has comment: http://stackoverflow.com/comment/58579511
answers question: http://stackoverflow.com/q/572917
accepted answer of: http://stackoverflow.com/q/572917
has comment: http://stackoverflow.com/comment/58580945
score: 0
type: AcceptedAnswer
has body: Did you look at the Java console for the browser? It likely contains something that says that the program crashed because it could not find the AbsoluteLayout class. This is for an older version of NetBeans, but the same should apply: http://forums.sun.com/thread.jspa?threadID=597783
type: Answer

http://stackoverflow.com/comment/265001
comment on: http://stackoverflow.com/q/443239
type: Comment
type: QuestionComment
has text: Yes. Idea is that those operation instances would be exchanged as method parameters in EJBs.
score: 0

http://stackoverflow.com/comment/266881
comment on: http://stackoverflow.com/a/444953
type: AnswerComment
score: 0
type: Comment
has text: He specifically said "DFA", not "NFA". It would make more sense if he was talking about an NFA, though.

http://stackoverflow.com/a/380972
has comment: http://stackoverflow.com/comment/208644
accepted answer of: http://stackoverflow.com/q/380952
answers question: http://stackoverflow.com/q/380952
has comment: http://stackoverflow.com/comment/208584
type: AcceptedAnswer
downvote count: 0
has body: You may use the class as the parameter rather then the class name. static &lt;T extends Contract&gt; T[] buildArray(Class&lt;T&gt; clazz){ ArrayList&lt;T&gt; l=new ArrayList&lt;T&gt;(); return l.toArray((T[]) java.lang.reflect.Array.newInstance(clazz, l.size())); } EDIT: (after read Yang comment) No, You cannot use generic type with the value of a variable.
has comment: http://stackoverflow.com/comment/208416
upvote count: 8
type: Answer
score: 8

http://stackoverflow.com/comment/92847757
has text: @Kronen the question is about Java, and not 3rd party libraries.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/17167743
type: Comment

http://stackoverflow.com/comment/9635850
has text: Hey, Jon, Google Java Collections is now [Guava](http://code.google.com/p/guava-libraries/). You might want to update your post for future references :)
type: AnswerComment
score: 2
type: Comment
comment on: http://stackoverflow.com/a/629833

http://stackoverflow.com/comment/125853499
has text: This is bizarre advice. The whole point of changing context.xml is so that you can deploy the same war to different servers with different configurations.
type: Comment
comment on: http://stackoverflow.com/a/5478593
score: 0
type: AnswerComment

http://stackoverflow.com/a/601213
has body: I use try/finally in the following form : try{ Connection connection = ConnectionManager.openConnection(); try{ //work with the connection; }finally{ if(connection != null){ connection.close(); } } }catch(ConnectionException connectionException){ //handle connection exception; } I prefer this to the try/catch/finally (+ nested try/catch in the finally). I think that it is more concise and I don't duplicate the catch(Exception).
score: 1
has comment: http://stackoverflow.com/comment/413498
upvote count: 1
answers question: http://stackoverflow.com/q/601152
downvote count: 0
type: Answer

http://stackoverflow.com/q/434865
favorite count: 0
tagged with: file-handling
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/434878
score: 2
has title: How to rename a file name without change its type?
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/257773
has comment: http://stackoverflow.com/comment/257761
has comment: http://stackoverflow.com/comment/257768
has body: I have doubt in renaming java files... My application has to rename the incoming file which is mdb,dbf,xls,xml,etc. format. I used the following source code. eg: String filename = "D:/sample.mdb"; File filediriden = new File(filename); String[] filetype = filename.split("\\."); System.out.println("Filetype :"+filetype[1]); String newfilename = "D:/new."+filetype[1]; File newfilediriden = new File(newfilename); System.out.println("New File Name "+newfilename); boolean rename = filediriden.renameTo(newfilediriden); if(rename) System.out.println("File Renamed"); if(filediriden.isFile()){ System.out.println("filename" + filediriden.getName()); }else{ System.out.println("not a filename"); } OUTPUT: Filetype : mdb New File Name D:/new.mdb File Renamed not a filename After that I checked whether its a file or not but its not going into that...Help plz...
has answer: http://stackoverflow.com/a/434880
upvote count: 3
answer count: 2
downvote count: 1

http://stackoverflow.com/a/628174
has body: What you are looking for is probably the Toolbox for Java™ &amp; JTOpen from IBM. There is also an AS400 class in the toolbox for performing specific AS400 tasks. You can look here and here for more details. Just googled it and hope it's helpful.
type: AcceptedAnswer
upvote count: 9
answers question: http://stackoverflow.com/q/628082
has comment: http://stackoverflow.com/comment/756946
type: Answer
accepted answer of: http://stackoverflow.com/q/628082
downvote count: 0
score: 9

http://stackoverflow.com/comment/279881
type: Comment
has text: There are many EBCDIC code tables. It is very tedious to get right manually.
score: 4
type: AnswerComment
comment on: http://stackoverflow.com/a/370101

http://stackoverflow.com/comment/104340371
type: Comment
score: 2
comment on: http://stackoverflow.com/a/519844
type: AnswerComment
has text: I'm confused by the fact that your `compare` method has two `return` statements, one after the other. Please could you explain that?

http://stackoverflow.com/a/519270
answers question: http://stackoverflow.com/q/516677
upvote count: 5
type: Answer
downvote count: 0
score: 5
has body: I have to disagree - useful design patterns aside, this particular example is ridiculous overkill: a 15-line class with an easily-understandable process became a 50-line class with an obfuscated purpose I fail to see how this is an improvement - it violates YAGNI1 and ASAP2, bloats the code, and reduces efficiency (multiple objects instantiated to do the job when not required). As an intellectual exercise, mildly interesting. As a programming habit, terrifying! ;-) 1 YANGI = You Ain't Gonna Need It 2 ASAP = As Simple As Possible
has comment: http://stackoverflow.com/comment/335356
has comment: http://stackoverflow.com/comment/336548

http://stackoverflow.com/a/442312
has body: This is not flame bait, but IMHO Java has one of the simpler and more restricted models for threading and concurrency available. That's not necessarily a bad thing, but at the level of granularity it offers it means that the perspective it gives you of what concurrency is and how to deal with it is inherently limited if you have a "java centric" view (as someone else put it). If you're serious about concurrency, then it's worth exploring other languages precisely because different models and idioms exist. Some of the hottest areas are lock-free programming (you'll see a lot of it, but often done badly, in C++) and functional programming (which has been around for a while but arguably, is becoming increasingly relevant. A prime example in the case of concurrency is probably Erlang).
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/440036
type: Answer
upvote count: 1

http://stackoverflow.com/a/471457
accepted answer of: http://stackoverflow.com/q/471448
type: AcceptedAnswer
score: 8
has body: Take a look at this link which details many of the differences between the two languages. As for IDE many people like Eclipse or Netbeans (My favorite) - Both are free. As you already own IntelliJ you could try that. FYO some of the main differences are: Lack of properties / auto properties No 'event' type (Different way of dealing with events) foreach loop syntax 'Generics' implementation Checked exceptions and probably many more :)
type: Answer
has comment: http://stackoverflow.com/comment/289198
has comment: http://stackoverflow.com/comment/32998737
downvote count: 0
has comment: http://stackoverflow.com/comment/26639252
answers question: http://stackoverflow.com/q/471448
upvote count: 8

http://stackoverflow.com/q/359689
has title: How to undo changes on JSpinner?
type: AnsweredQuestion
tagged with: jspinner
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/359702
score: 0
has body: I need to validate the user input of a JSpinner, and if invalid, I need to undo (rollback) the value change. What is the best way to do it?
answer count: 1
tagged with: undo
accepted answer: http://stackoverflow.com/a/359702

http://stackoverflow.com/a/455723
score: 10
downvote count: 0
has body: BufferedReader in; String line1, line2; while((line1 = in.readLine()) != null &amp;&amp; (line2 = in.readLine()) != null)) { processor.doStuffWith(line1, line2); } Or you could concatenate them if you wanted.
type: Answer
answers question: http://stackoverflow.com/q/455695
upvote count: 10

http://stackoverflow.com/q/495674
has answer: http://stackoverflow.com/a/495713
has answer: http://stackoverflow.com/a/495709
has answer: http://stackoverflow.com/a/495685
has answer: http://stackoverflow.com/a/497921
favorite count: 0
has answer: http://stackoverflow.com/a/495699
upvote count: 5
has answer: http://stackoverflow.com/a/28020348
type: UnansweredQuestion
tagged with: swing
downvote count: 0
has answer: http://stackoverflow.com/a/495923
tagged with: java
has answer: http://stackoverflow.com/a/497862
has body: I have a snippet of code that prints text from a file to a JTextArea called textArea. Unfortunately the method I'm using goes line by line (not ideal) and so I have to append each line with a \n This is fine for now but a new line is created at the end. The code I have is as follows: class menuOpen implements ActionListener { public void actionPerformed(ActionEvent e) { try { File filePath = new File("c:\\test.txt"); FileInputStream file = new FileInputStream(filePath); BufferedReader br = new BufferedReader(new InputStreamReader(file)); String displayText; while ((displayText = br.readLine()) != null) { textArea.append(displayText + "\n"); } } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } } } Can anyone help me get rid of that last line?
type: Question
answer count: 8
score: 5
has title: Remove last character/line

http://stackoverflow.com/a/385546
has body: Keep two copies of persistence.xml file. One for testing and another for normal build. The default life cycle copy the build persistence.xml to src/test/resources/META-INF Create a separate profile which when run will copy the testing persistence.xml to src/test/resources/META-INF
upvote count: 4
score: 3
type: Answer
answers question: http://stackoverflow.com/q/385532
downvote count: 1

http://stackoverflow.com/a/443041
score: 3
has body: Microsoft used to have their own Java to C# Converter - Microsoft Java Language Conversion Assistant 3.0
has comment: http://stackoverflow.com/comment/3696736
downvote count: 1
answers question: http://stackoverflow.com/q/443010
type: Answer
upvote count: 4

http://stackoverflow.com/a/381080
has comment: http://stackoverflow.com/comment/211331
type: Answer
upvote count: 4
downvote count: 6
has comment: http://stackoverflow.com/comment/208522
answers question: http://stackoverflow.com/q/381066
score: -2
has comment: http://stackoverflow.com/comment/208614
has body: You can use a HashMap: Map&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); map.put("R1", "R2"); map.put("R2", "R3"); for(String key: map.keySet()) { str.replaceAll(key, map.get(key)); } replaceAll also handles regular expressions. EDIT: The above solution, as many have pointed out, doesn't work because it doesn't handle cyclic replacements. So this is my second approach: public class Replacement { private String newS; private String old; public Replacement(String old, String newS) { this.newS = newS; this.old = old; } public String getOld() { return old; } public String getNew() { return newS; } } SortedMap&lt;Integer, Replacement&gt; map = new TreeMap&lt;Integer, Replacement&gt;(); map.put(new Integer(1), new Replacement("R2", "R3")); map.put(new Integer(2), new Replacement("R1", "R2")); for(Integer key: map.keySet()) { str.replaceAll(map.get(key).getOld(), map.get(key).getNew()); } This works provided that you order the replacements properly and that you guard yourself against cyclic replacements. Some replacements are impossible: R1 -&gt; R2 R2 -&gt; R3 R3 -&gt; R1 You must use some 'temp' variables for these: R1 -&gt; R@1 R2 -&gt; R@3 R3 -&gt; R1 R@(\d{1}) -&gt; R\1 You could write a library that it would do all these for you.
has comment: http://stackoverflow.com/comment/208703
has comment: http://stackoverflow.com/comment/208619
has comment: http://stackoverflow.com/comment/208924

http://stackoverflow.com/comment/59858684
comment on: http://stackoverflow.com/a/24931253
has text: `(new char[diff])` why
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/7829772
has comment: http://stackoverflow.com/comment/11925181
has comment: http://stackoverflow.com/comment/92525384
upvote count: 264
has comment: http://stackoverflow.com/comment/45517501
has comment: http://stackoverflow.com/comment/102149068
has comment: http://stackoverflow.com/comment/97609650
score: 264
has comment: http://stackoverflow.com/comment/30917100
downvote count: 0
answers question: http://stackoverflow.com/q/367706
has comment: http://stackoverflow.com/comment/23233556
type: Answer
has comment: http://stackoverflow.com/comment/9727909
has body: I have been trying to maintain a list of Java CLI parsers. Airline Active Fork: https://github.com/rvesse/airline argparse4j argparser args4j clajr cli-parser CmdLn Commandline DocOpt.java dolphin getopt DPML CLI (Jakarta Commons CLI2 fork) Dr. Matthias Laux Jakarta Commons CLI jargo jargp jargs java-getopt jbock JCLAP jcmdline jcommander jcommando jewelcli (written by me) JOpt simple jsap naturalcli Object Mentor CLI article (more about refactoring and TDD) parse-cmd ritopt Rop TE-Code Command picocli has ANSI colorized usage help and autocomplete
has comment: http://stackoverflow.com/comment/79769390

http://stackoverflow.com/comment/130368501
score: 1
has text: @BjørnStenfeldt Good to be aware of. I'm not sure if that's a "bug" per se since those aren't subsequent requests to the same `RandomGenerator` so there's no requirement that two created `RandomGenerator` instances be distinguishable from each other. It's also not the first time in Java that creating the `Random` class each time lead to this sort of behavior. I remember `Random` behaving the same way back in the day when the starting seed was based solely on the millisecond timestamp of when it was created. They did add a "seed uniquifier" back in Java 5 or something to prevent that.
type: AnswerComment
comment on: http://stackoverflow.com/a/70529176
type: Comment

http://stackoverflow.com/a/371519
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/370818
score: 5
has body: I second the recommendations for using an ORM like Hibernate. However, there are certainly situations where that doesn't work, so I'll take this opportunity to tout some stuff that i've helped to write: SqlBuilder is a java library for dynamically building sql statements using the "builder" style. it's fairly powerful and fairly flexible.
upvote count: 5

http://stackoverflow.com/comment/10852999
type: AnswerComment
has text: I just installed Veloeclipse on Indigo Service Release 1 and all is well so far.Just wanted to add that to assuage the fears of those that are balking at the "Tested on Eclipse 3.3 and 3.4" comment on the project webpage.
comment on: http://stackoverflow.com/a/3361992
type: Comment
score: 2

http://stackoverflow.com/a/469322
answers question: http://stackoverflow.com/q/469287
has comment: http://stackoverflow.com/comment/7104085
type: Answer
score: 2
downvote count: 0
has body: A Java enum is syntactic sugar to present enumerations in an OO manner. They're abstract classes extending the Enum class in Java, and each enum value is like a static final public instance implementation of the enum class. Look at the generated classes, and for an enum "Foo" with 10 values, you'll see "Foo$1" through "Foo$10" classes generated. I don't know C# though, I can only speculate that an enum in that language is more like a traditional enum in C style languages. I see from a quick Google search that they can hold multiple values however, so they are probably implemented in a similar manner, but with far more restrictions than what the Java compiler allows.
upvote count: 2

http://stackoverflow.com/q/430787
favorite count: 0
has title: Apache Ant + Ivy build of a web application which is deployed to a local Tomcat
has answer: http://stackoverflow.com/a/431847
score: 2
has body: I will use Apache Ant and Apache Ivy to build a web application which is deployed to a local Tomcat instance (during development). I have some questions: I want to grab most of my dependencies from the Maven2 repositories which works fine, but for the servlet JAR I would like to use the one Tomcat provides. Is there a way to do that using Ivy? And what do you think about doing so? I download the Ivy JAR using Ant to "auto install" it into ~/.ivy2/jar/ivy.jar and I have the Ivy cache at its default location ~/.ivy2/cache . I keep both of these locations outside the project directory on purpose. Good idea? Do you have an example of how to use Ant for the build file, Ivy to resolve dependencies, compile a WAR file and deploy it to a local (at the moment) Tomcat installation? I'm looking for something to have as a best practice which I then can modify further. I've used some examples on the Ivy web site and modified them. Is there anything I should change? The build file can be seen at http://pastebin.com/f7b34abc2 , as I had problems pasting XML code in here. (Please notice that I'm not looking for the suggestion that I should use Maven2, even if the suggestion is well intended.)
type: AnsweredQuestion
upvote count: 2
tagged with: java
tagged with: ivy
type: Question
tagged with: ant
accepted answer: http://stackoverflow.com/a/431847
tagged with: apache
answer count: 1
downvote count: 0

http://stackoverflow.com/q/570230
has body: I have a java applet running in a browser that is calling some javascript functions and expecting a result from theses functions. This is working with the following configurations : Internet Explorer FireFox / Windows Safari / Mac BUT It's not working with Firefox on MAC OS The source of the problem seems to be the win.eval calls that always return null. I tested this with Firefox 3.0.6 on a Mac OS X 10.4.11 A bit of code : JSObject win = (JSObject) JSObject.getWindow(this); Object exp = win.eval("testfunc()"); System.out.println("exp = " + exp.toString()); This triggers a java.lang.NullPointerException (exp.toString()) statement). The testfunc javascript function just returns true. I tried with win.call and got the same result. My applet tag includes the mayscript and scriptable attributes. I found the answer thanks to Tristan. Testing his solution I created a really simple test that could work and worked my way to find the culprit. I was sure I did my tests with an empty testfunc() that just returned true, but I probably didn't because in that case it DOES work. The real problem here was that the function called a public method of the applet. Liveconnect doesn't seem to be able to handle that case in Firefox Mac. Let me give you an example : Java class : public class MyApplet extends Applet { public int getMyValue() { return 5; } public void somefunction() { JSObject win = (JSObject) JSObject.getWindow(this); Object exp = win.eval("jsfunc()"); System.out.println("exp = " + exp.toString()); } } And the javascript code : function jsfunc() { var myApplet = document.getElementById("applet_id"); return myApplet.getMyValue() + 5; } exp will be null in somefunction BECAUSE jsfunc calls the getMyValue() method of the applet. If you remove all calls to properties of the applet you're cool. To solve my problem I decided to give all the values of the applet that I neeeded as parameters of my javascript function and I'm good now. That may not be the case always, if the javasc…
has title: Are Java Applets unable to communicate with javascript within Firefox on Mac OS?
tagged with: macos
favorite count: 0
accepted answer: http://stackoverflow.com/a/576931
score: 12
answer count: 3
tagged with: java
upvote count: 12
has answer: http://stackoverflow.com/a/576931
type: AnsweredQuestion
tagged with: firefox
downvote count: 0
tagged with: javascript
tagged with: applet
possible better answer: http://stackoverflow.com/a/577054
has answer: http://stackoverflow.com/a/790337
has answer: http://stackoverflow.com/a/577054
type: Question

http://stackoverflow.com/comment/66229453
type: Comment
type: QuestionComment
score: 8
comment on: http://stackoverflow.com/q/493494
has text: Amazes me how such basic questions do get so many upvotes...

http://stackoverflow.com/a/590966
has body: Every time text is added, store the document in memory. Every time text is removed, compare the document to what was last stored to determine what was removed.
has comment: http://stackoverflow.com/comment/402630
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/590951
score: 0
type: Answer

http://stackoverflow.com/comment/65532657
comment on: http://stackoverflow.com/a/14997027
score: 0
type: AnswerComment
type: Comment
has text: Peter can you help me here. [link](http://stackoverflow.com/questions/39031175/testing-powermock-simulate-http-server-time-out-for-client-call)

http://stackoverflow.com/a/643754
upvote count: 5
has comment: http://stackoverflow.com/comment/52483334
has body: You know Qt Jambi is discontinued following the 4.5 release this month? That doesn't make it a bad choice. Qt has other community-maintained language bindings that live outside Trolltech's control. http://www.qtsoftware.com/about/news/preview-of-final-qt-jambi-release-available
score: 4
type: Answer
downvote count: 1
answers question: http://stackoverflow.com/q/530938

http://stackoverflow.com/a/580901
has comment: http://stackoverflow.com/comment/392824
upvote count: 30
has comment: http://stackoverflow.com/comment/392987
has body: I don't like setting CLASSPATH. CLASSPATH is a global variable and as such it is evil: If you modify it in one script, suddenly some java programs will stop working. If you put there the libraries for all the things which you run, and it gets cluttered. You get conflicts if two different applications use different versions of the same library. There is no performance gain as libraries in the CLASSPATH are not shared - just their name is shared. If you put the dot (.) or any other relative path in the CLASSPATH that means a different thing in each place - that will cause confusion, for sure. Therefore the preferred way is to set the classpath per each run of the jvm, for example: java -Xmx500m -cp ".:../somejar.jar:../mysql-connector-java-5.1.6-bin.jar" "folder.subfolder../dit1/some.xml If it gets long the standard procedure is to wrap it in a bash or batch script to save typing.
has comment: http://stackoverflow.com/comment/392821
downvote count: 2
has comment: http://stackoverflow.com/comment/28914947
answers question: http://stackoverflow.com/q/580860
score: 28
type: Answer

http://stackoverflow.com/comment/410171
score: 0
type: AnswerComment
type: Comment
has text: That's right TERM is not meant to hold the name of the binary, but rather a name that can be looked up in /etc/termcap. gnome-terminal & xfce-terminal both use "xterm". When running a screen-session it's "screen".
comment on: http://stackoverflow.com/a/597990

http://stackoverflow.com/comment/95970563
has text: I tried @javax.persistence.OrderBy(value = "fieldName") where fieldName is an integer. It fetches child collection in descending order and when I use @javax.persistence.OrderBy("fieldName") then it fetches the child collection in ascending order. It is quite strange to me, As per the documentation ASC and DESC should be appended with field name but it is not impacting the results.
comment on: http://stackoverflow.com/a/408522
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/596043
has body: How can I view the XML being sent to a Java Web Service from a C#-based ASP.NET page? I've created a disco object web ref in .NET from my Java WSDL, but when I use the likes of Fiddler to view the XML attached to the HTTP request, instead I see the form parameters being passed. Is there a way I can view the serialized XML?
tagged with: http://stackoverflow.com/tag/xml
has title: Can you view the XML generated by .NET when using a JavaWS service?
has answer: http://stackoverflow.com/a/596108
has answer: http://stackoverflow.com/a/596079
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/596112
has answer: http://stackoverflow.com/a/598349
tagged with: java
possible better answer: http://stackoverflow.com/a/596079
type: Question
accepted answer: http://stackoverflow.com/a/596112
tagged with: c#
tagged with: asp.net-2.0
score: 0
tagged with: java-ws

http://stackoverflow.com/a/23214686
type: Answer
answers question: http://stackoverflow.com/q/507602
score: 7
upvote count: 7
downvote count: 0
has body: I prefer using a static initializer to avoid generating anonymous classes (which would have no further purpose), so I'll list tips initializing with a static initializer. All listed solutions / tips are type-safe. Note: The question doesn't say anything about making the map unmodifiable, so I will leave that out, but know that it can easily be done with Collections.unmodifiableMap(map). First tip The 1st tip is that you can make a local reference to the map and you give it a SHORT name: private static final Map&lt;Integer, String&gt; myMap = new HashMap&lt;&gt;(); static { final Map&lt;Integer, String&gt; m = myMap; // Use short name! m.put(1, "one"); // Here referencing the local variable which is also faster! m.put(2, "two"); m.put(3, "three"); } Second tip The 2nd tip is that you can create a helper method to add entries; you can also make this helper method public if you want to: private static final Map&lt;Integer, String&gt; myMap2 = new HashMap&lt;&gt;(); static { p(1, "one"); // Calling the helper method. p(2, "two"); p(3, "three"); } private static void p(Integer k, String v) { myMap2.put(k, v); } The helper method here is not re-usable though because it can only add elements to myMap2. To make it re-usable, we could make the map itself a parameter of the helper method, but then initialization code would not be any shorter. Third tip The 3rd tip is that you can create a re-usable builder-like helper class with the populating functionality. This is really a simple, 10-line helper class which is type-safe: public class Test { private static final Map&lt;Integer, String&gt; myMap3 = new HashMap&lt;&gt;(); static { new B&lt;&gt;(myMap3) // Instantiating the helper class with our map .p(1, "one") .p(2, "two") .p(3, "three"); } } class B&lt;K, V&gt; { private final Map&lt;K, V&gt; m; public B(Map&lt;K, V&gt; m) { this.m = m; } public B&lt;K, V&gt; p(K k, V v) { m.put(k, v); return this; // Return this for chaining } }

http://stackoverflow.com/q/415863
tagged with: seam
tagged with: java
tagged with: jboss
has body: I need some ideas on how I can best solve this problem. I have a JBoss Seam application running on JBoss 4.3.3 What a small portion of this application does is generate an html and a pdf document based on an Open Office template. The files that are generated I put inside /tmp/ on the filesystem. I have tried with System.getProperties("tmp.dir") and some other options, and they always return $JBOSS_HOME/bin I would like to choose the path $JBOSS_HOME/$DEPLOY/myEAR.ear/myWAR.war/WhateverLocationHere/ However, I don't know how I can programatically choose path without giving an absolute path, or setting $JBOSS_HOME and $DEPLOY. Anybody know how I can do this? The second question; I want to easily preview these generated files. Either through JavaScript, or whatever is the easiest way. However, JavaScript cannot access the filesystem on the server, so I cannot open the file through JavaScript. Any easy solutions out there?
type: Question
has answer: http://stackoverflow.com/a/421614
has answer: http://stackoverflow.com/a/426251
tagged with: javascript
has answer: http://stackoverflow.com/a/416003
score: 0
has title: How to preview a file on the server in JBoss
has answer: http://stackoverflow.com/a/417070
tagged with: preview
answer count: 5
has answer: http://stackoverflow.com/a/431442
possible better answer: http://stackoverflow.com/a/416003
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/426251

http://stackoverflow.com/a/47256198
downvote count: 0
has body: The Google stock quote API has gone away. However, Investor's Exchange offers an API that's very easy to use for quote data.
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/527703

http://stackoverflow.com/a/3522629
has body: Take a look at the PDF Renderer Java library. I have tried it myself and it seems much faster than PDFBox. I haven't tried getting the OCR text, however. Here is an example copied from the link above which shows how to draw a PDF page into an image: File file = new File("test.pdf"); RandomAccessFile raf = new RandomAccessFile(file, "r"); FileChannel channel = raf.getChannel(); ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size()); PDFFile pdffile = new PDFFile(buf); // draw the first page to an image PDFPage page = pdffile.getPage(0); //get the width and height for the doc at the default zoom Rectangle rect = new Rectangle(0,0, (int)page.getBBox().getWidth(), (int)page.getBBox().getHeight()); //generate the image Image img = page.getImage( rect.width, rect.height, //width &amp; height rect, // clip rect null, // null for the ImageObserver true, // fill background with white true // block until drawing is done );
downvote count: 1
score: -1
answers question: http://stackoverflow.com/q/586257
upvote count: 0
type: Answer

http://stackoverflow.com/comment/442479
has text: I appreciate your comments, and I totally agree with you if I could change the code. The problem is that I cannot change the Java program, I need to pass formatted string in the command line.
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/629819

http://stackoverflow.com/q/644612
has comment: http://stackoverflow.com/comment/457992
has body: I've got my "virtual list" in swing working well, but it seems to fail when I exceed some particular number of items. By "fail" I mean that the scroll bar magically vanishes when the number of items is > Nmax, and it comes back when the number of items is &lt;= Nmax; Nmax seems to be somewhere around 119,304,000 on my system. What am I running up against?!?! (Here's a test program: on my computer, if I type in 119,304 it works ok, but I click the up arrow and the scroll bar disappears) package com.example.test; import java.awt.BorderLayout; import java.awt.Dimension; import javax.swing.AbstractListModel; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSpinner; import javax.swing.SpinnerModel; import javax.swing.SpinnerNumberModel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; // based on: // http://www.java2s.com/Tutorial/Java/0240__Swing/extendsAbstractListModel.htm // http://www.java2s.com/Tutorial/Java/0240__Swing/SpinnerNumberModel.htm // http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/SpinnerNumberModel.html // http://www.java2s.com/Tutorial/Java/0240__Swing/ListeningforJSpinnerEventswithaChangeListener.htm // http://java.sun.com/products/jfc/tsc/tech_topics/jlist_1/jlist.html public class BigVirtualList extends JFrame { public static void main(String[] args) { new BigVirtualList(); } static final int initialLength = 1; final private JList list1 = new JList(); final private BVLData bvldata = new BVLData(initialLength*1000); public BigVirtualList() { this.setTitle("Big virtual list"); this.getContentPane().setLayout(new BorderLayout()); this.setSize(new Dimension(400, 300)); list1.setModel(bvldata); list1.setPrototypeCellValue(list1.getModel().getElementAt(0)); SpinnerModel model1 = new SpinnerNumberModel(initialLength,1,1000000,1); final JSpinner spinner1 = new JSpinner(model1); this.getContentPane().add(new JScroll…
has answer: http://stackoverflow.com/a/644670
tagged with: swing
has comment: http://stackoverflow.com/comment/458048
type: AnsweredQuestion
downvote count: 0
has comment: http://stackoverflow.com/comment/458008
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/458072
has title: large virtual lists in Swing using AbstractListModel -- limit at 119,000,000 items?
type: Question
upvote count: 1
accepted answer: http://stackoverflow.com/a/644670
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/458091
has comment: http://stackoverflow.com/comment/458081
has comment: http://stackoverflow.com/comment/458011

http://stackoverflow.com/q/455182
has answer: http://stackoverflow.com/a/455192
has title: Where can I get started learning about Rule Engines?
accepted answer: http://stackoverflow.com/a/455192
possible better answer: http://stackoverflow.com/a/455546
has answer: http://stackoverflow.com/a/455546
type: AnsweredQuestion
tagged with: java
score: 10
has answer: http://stackoverflow.com/a/455253
type: Question
answer count: 3
has body: I'm currently designing a Java application where a Rule engine could be useful. Where is a good place I can learn about how to use them, how they work, how to implement them, see samples, etc.?
favorite count: 0
tagged with: rule-engine
upvote count: 10
downvote count: 0

http://stackoverflow.com/q/494389
upvote count: 53
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2179393
has answer: http://stackoverflow.com/a/694507
has comment: http://stackoverflow.com/comment/310936
has answer: http://stackoverflow.com/a/694436
tagged with: java
has answer: http://stackoverflow.com/a/1002904
possible better answer: http://stackoverflow.com/a/494413
has answer: http://stackoverflow.com/a/494504
has answer: http://stackoverflow.com/a/494878
has comment: http://stackoverflow.com/comment/310658
has answer: http://stackoverflow.com/a/1006228
type: Question
has answer: http://stackoverflow.com/a/694029
has answer: http://stackoverflow.com/a/5684367
tagged with: c#
has answer: http://stackoverflow.com/a/494511
has answer: http://stackoverflow.com/a/9058936
has comment: http://stackoverflow.com/comment/310294
has title: Why doesn't Sun do a C# to Java byte code compiler?
tagged with: .net
has answer: http://stackoverflow.com/a/494538
has answer: http://stackoverflow.com/a/494651
has answer: http://stackoverflow.com/a/494531
has answer: http://stackoverflow.com/a/1030358
has comment: http://stackoverflow.com/comment/310343
has comment: http://stackoverflow.com/comment/310322
accepted answer: http://stackoverflow.com/a/494417
has answer: http://stackoverflow.com/a/494494
tagged with: jvm
favorite count: 0
has comment: http://stackoverflow.com/comment/6491431
downvote count: 5
score: 48
has comment: http://stackoverflow.com/comment/311030
has body: We Want to Run Our C# Code on the JVM My company has a large C# code base. Well over half of this code is our core engine for creating, reading, modifying, calculating and writing Excel workbooks. We frequently get questions from customers and potential customers asking whether we are going to build a Java version of our engine - many of them are not at all interested in the UI. We even have a few customers who have taken the trouble to use our .NET library from their Java applications. So, we would like to build a Java version of our core engine, ideally without maintaining a separate Java source code base. Eric Sink described this problem very well. I am in a similar position except for the fact that our software license includes royalty free deployment, making Eric's choice of Mainsoft a nonstarter for us. I have been Googling the likes of "c# to jvm" every few months for several years now with no joy. Having spent ~7 years developing similar software for Java, I am confident that the .NET APIs we use in our core engine could easily be encapsulated and we could accomplish everything we need using the Java libraries. So, if we only had a C# -> JVM compiler we could build our core engine for Java and we would no longer have to turn away Java developers who would like to use it. I am not asking for the technical reasons why Sun does not do a C# compiler. I recognize that Java has no properties or an unsigned 64 bit long, etc... For the sake of argument, just assume that all of these technical issues could be dealt with by extending the JVM and / or other means. And I am not asking for yet another debate on why one language / stack might be better than the other. The reality in our business is that there are plenty of potential customers using each. Why Should Sun do a C# Compiler? (IMO of course) Making it easier to run C# code on the Java platform means more developers and more software for the platform. Is there anything more important to the success of a platform…
answer count: 18
has comment: http://stackoverflow.com/comment/311015
has answer: http://stackoverflow.com/a/494417
has answer: http://stackoverflow.com/a/494413
tagged with: compiler-construction

http://stackoverflow.com/comment/10856121
score: 11
comment on: http://stackoverflow.com/a/507658
has text: Jordan: it is an old topic now but I suspect @Luke was trying to use a string as a key in a map that had a different key type, e.g. Map<Integer, String>.
type: AnswerComment
type: Comment

http://stackoverflow.com/q/438875
downvote count: 0
tagged with: stack-overflow
has answer: http://stackoverflow.com/a/438995
has title: StackOverflowError when serializing an object in Java
accepted answer: http://stackoverflow.com/a/439016
tagged with: serialization
has answer: http://stackoverflow.com/a/43327778
upvote count: 11
has answer: http://stackoverflow.com/a/438996
favorite count: 0
has answer: http://stackoverflow.com/a/21212931
has body: I am writing an application in Java using Swing. I am trying to implement functionality to save and load simulation states for at simulation i am running. The entire simulation is kept as an object, disconnected from Swing. I am trying to serialize my Simulation class with this code: public void saveSimulationState(String simulationFile) { try { Serializable object = this.sm; ObjectOutputStream objstream = new ObjectOutputStream(new FileOutputStream(simulationFile)); objstream.writeObject(object); objstream.close(); } catch (IOException e) { System.out.println(e.getMessage()); } } But i get the following error (it is huge). Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError at java.io.ObjectStreamClass.processQueue(ObjectStreamClass.java:2234) at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:266) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326) at java.util.ArrayList.writeObject(ArrayList.java:570) at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1…
tagged with: swing
score: 11
has answer: http://stackoverflow.com/a/438909
possible better answer: http://stackoverflow.com/a/438928
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/438896
has answer: http://stackoverflow.com/a/438928
has answer: http://stackoverflow.com/a/439016
tagged with: java
has comment: http://stackoverflow.com/comment/261226
type: Question
answer count: 8

http://stackoverflow.com/a/585294
answers question: http://stackoverflow.com/q/585268
downvote count: 0
has body: The Java import statement does not add any size to the class file. It allows the compiler to deduce what names refer to at compile time. The only difference the line import java.util.*; makes is that you can write: Set&lt;String&gt; set; rather than: java.util.Set&lt;String&gt; set;
score: 3
upvote count: 3
type: Answer

http://stackoverflow.com/comment/20953596
type: Comment
score: 3
has text: The OP was asking for the home of an arbitrary user. But `user.home` is the one of the current user. Is this method always working if you would go from the current users home to the parent and then down to the directory with the specified users name?
type: AnswerComment
comment on: http://stackoverflow.com/a/494742

http://stackoverflow.com/a/607133
type: AcceptedAnswer
has body: Without more info it is hard to answer... but you might check out OSGi as a starting point for some ideas.
has comment: http://stackoverflow.com/comment/422593
type: Answer
accepted answer of: http://stackoverflow.com/q/607106
downvote count: 0
answers question: http://stackoverflow.com/q/607106
score: 6
upvote count: 6

http://stackoverflow.com/q/636941
tagged with: glassfish
type: AnsweredQuestion
downvote count: 0
score: 1
favorite count: 0
type: Question
has title: EJB Timers and Reliability
has body: I need a method to be called in an App Server (Glassfish) every 5 seconds, no matter what. Are timers reliable enough for this? What are my options.
tagged with: ejb-3.0
possible better answer: http://stackoverflow.com/a/637983
answer count: 2
has answer: http://stackoverflow.com/a/637983
has answer: http://stackoverflow.com/a/637232
upvote count: 1
accepted answer: http://stackoverflow.com/a/637232
tagged with: ejb
tagged with: java
tagged with: jboss

http://stackoverflow.com/a/542258
upvote count: 22
has comment: http://stackoverflow.com/comment/49111199
downvote count: 0
has body: I think you need to add a couple more slashies... String string; string = string.replaceAll("\\\\n", ""); Explanation: The number of slashies has to do with the fact that "\n" by itself is a controlled character in Java. So to get the real characters of "\n" somewhere we need to use "\n". Which if printed out with give us: "\" You're looking to replace all "\n" in your file. But you're not looking to replace the control "\n". So you tried "\n" which will be converted into the characters "\n". Great, but maybe not so much. My guess is that the replaceAll method will actually create a Regular Expression now using the "\n" characters which will be misread as the control character "\n". Whew, almost done. Using replaceAll("\\n", "") will first convert "\\n" -> "\n" which will be used by the Regular Expression. The "\n" will then be used in the Regular Expression and actually represents your text of "\n". Which is what you're looking to replace.
answers question: http://stackoverflow.com/q/542226
type: Answer
has comment: http://stackoverflow.com/comment/354435
has comment: http://stackoverflow.com/comment/354323
has comment: http://stackoverflow.com/comment/49108965
score: 22

http://stackoverflow.com/comment/131110884
score: 1
type: AnswerComment
has text: maybe "-1" doesn't work anymore in recent java versions?
comment on: http://stackoverflow.com/a/50128144
type: Comment

http://stackoverflow.com/a/387684
upvote count: 6
type: Answer
score: 6
has comment: http://stackoverflow.com/comment/11220978
answers question: http://stackoverflow.com/q/387256
downvote count: 0
has body: Each language designed with different purposes in mind, so IMO it's not fair to compare the two from one perspective, and ignore the other. Generally speaking, C++ is an open standard, designed for implementing high performance systems where speed and performance and critical, there are lots of impressing projects designed using this language like Phoenix Lander, Adobe Acrobat Reader and others. C++ gives the developer the ability to program using a very high level abstraction -using generics for example, and, when needed, go down deep to the bare metal of the machine -to handle an interrupt for instance. Java was designed with other purposes in mind, when Sun was planning Oak (later called Java), it focused on web applications so it supported the language with a bunch of heavy libraries of easy-to-use interfaces considering that. and portability (Compile once, run anywhere) using JVM, which prevents the programmer from coding to specific machine, but instead coding to a sandbox which in turn runs the code on the hosting machine, and this has obviously negative reflections on performance/speed. Comparison of those two language is a popular cause of debate between programmers, and this is due to their different working demands and nature, IMO every language has made mistakes in order to mature, for example, C++'s exported templates, and Java's lack of procedural programming (Big Mistake). plus, each one has its pros and cons regarding different aspects, hence the one that balance productivity/performance issue IS the right language. For more information Wikipedia's comprehensive article on Comparison of Java and C++ It might be interesting to take a look at what languages are used (and being used) to create major systems (like Google) from here.

http://stackoverflow.com/q/381226
answer count: 9
has title: Is it possible to monkey patch in Java?
has answer: http://stackoverflow.com/a/381281
has answer: http://stackoverflow.com/a/381240
has answer: http://stackoverflow.com/a/381538
tagged with: reflection
has answer: http://stackoverflow.com/a/33013365
has answer: http://stackoverflow.com/a/381260
score: 23
upvote count: 23
possible better answer: http://stackoverflow.com/a/381240
type: AnsweredQuestion
has body: I don't want to discuss the merits of this approach, just if it is possible. I believe the answer to be "no". But maybe someone will surprise me! Imagine you have a core widget class. It has a method calculateHeight(), that returns a height. The height is too big - this result in buttons (say) that are too big. You can extend DefaultWidget to create your own NiceWidget, and implement your own calculateHeight() to return a nicer size. Now a library class WindowDisplayFactory, instantiates DefaultWidget in a fairly complex method. You would like it to use your NiceWidget. The factory class's method looks something like this: public IWidget createView(Component parent) { DefaultWidget widget = new DefaultWidget(CONSTS.BLUE, CONSTS.SIZE_STUPIDLY); // bunch of ifs ... SomeOtherWidget bla = new SomeOtherWidget(widget); SomeResultWidget result = new SomeResultWidget(parent); SomeListener listener = new SomeListener(parent, widget, flags); // more widget creation and voodoo here return result; } That's the deal. The result has the DefaultWidget deep within a hierarchy of other objects. The question - how to get this factory method to use my own NiceWidget? Or at least get my own calculateHeight() in there. Ideally, I'd like to be able to monkey patch the DefaultWidget so that its calculateHeight did the right thing... public class MyWindowDisplayFactory { public IWidget createView(Component parent) { DefaultWidget.class.setMethod("calculateHeight", myCalculateHeight); return super.createView(parent); } } Which is what I could do in Python, Ruby, etc. I've invented the name setMethod() though. The other options open to me are: Copying and pasting the code of the createView() method into my own class that inherits from the factory class Living with widgets that are too big The factory class can't be changed - it is part of a core platform API. I tried reflection on the returned result to get to the widget that (eventually) got added, but it is several widget-layers down and s…
tagged with: java
has answer: http://stackoverflow.com/a/381252
tagged with: monkeypatching
has answer: http://stackoverflow.com/a/381269
type: Question
has answer: http://stackoverflow.com/a/43724763
has answer: http://stackoverflow.com/a/381340
downvote count: 0
accepted answer: http://stackoverflow.com/a/381269
favorite count: 0

http://stackoverflow.com/comment/432613
has text: Generally, nested forEach loops in a Jsp/jsf tells me that the controller or the resulting object is not pulling enough weight of its own - you may want to consider refactoring so only a single forEach loop is needed.
comment on: http://stackoverflow.com/q/619097
type: Comment
type: QuestionComment
score: 2

http://stackoverflow.com/comment/706492
type: AnswerComment
has text: Cool, always bugged that this feature did not exist, but it does via plug-in.
comment on: http://stackoverflow.com/a/509908
score: 0
type: Comment

http://stackoverflow.com/a/52657916
upvote count: 2
downvote count: 0
type: Answer
score: 2
has body: This is an old thread, but I ran into java.net.SocketException: Connection reset yesterday. The server-side application had its throttling settings changed to allow only 1 connection at a time! Thus, sometimes calls went through and sometimes not. I solved the problem by changing the throttling settings.
answers question: http://stackoverflow.com/q/585599

http://stackoverflow.com/a/368901
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/368802
upvote count: 2
has body: Since your callers are not Java apps and you're already foreseeing networked callers, RMI-IIOP (CORBA) might be an option. Though it's definitely not easy to implement, it has the advantage of being a widely-recognized standard.
type: Answer

http://stackoverflow.com/comment/243918
type: AnswerComment
has text: This is true and not as sad as it may sound.
comment on: http://stackoverflow.com/a/417534
score: 0
type: Comment

http://stackoverflow.com/q/525100
has answer: http://stackoverflow.com/a/525328
favorite count: 0
score: 5
answer count: 3
upvote count: 5
tagged with: java
has answer: http://stackoverflow.com/a/529365
has title: LdapContext, how to do select count(*)
downvote count: 0
has answer: http://stackoverflow.com/a/65307398
tagged with: ldap
has body: I am using an LdapContext in java to query an LDAP server (I think the server is Sun server version 5.2). I use the LdapContext.search(String name, String filter, SearchControls cons) method for the regular querys, but I don't know how to run a query equivalent to sql's "select count(*)". Any idea? Performance is important so I don't want to just run a regular query and count the results.
type: Question
accepted answer: http://stackoverflow.com/a/529365
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/525328

http://stackoverflow.com/q/401598
tagged with: swing
answer count: 4
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/19252509
has answer: http://stackoverflow.com/a/401613
accepted answer: http://stackoverflow.com/a/401613
tagged with: jtextfield
has answer: http://stackoverflow.com/a/401619
type: Question
downvote count: 0
has answer: http://stackoverflow.com/a/401676
tagged with: events
favorite count: 0
score: 8
possible better answer: http://stackoverflow.com/a/401619
upvote count: 8
has title: How can I get the length of a JTextField's contents as the user types?
has body: JTextField has a keyTyped event but it seems that at the time it fires the contents of the cell have not yet changed. Because of that .length() is always wrong if read here. There must be a simple way of getting the length as it appears to the user after a key stroke?

http://stackoverflow.com/a/457857
score: 1
answers question: http://stackoverflow.com/q/457629
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/42617013
downvote count: 0
has body: Why not create a WhateverFunctionResult object that contains your results, and the logic required to parse these results, iterate over then etc. It seems to me that either: These results objects are intimately tied together/related and belong together, or: they are unrelated, in which case your function isn't well defined in terms of what it's trying to do (i.e. doing two different things) I see this sort of issue crop up again and again. Don't be afraid to create your own container/result classes that contain the data and the associated functionality to handle this. If you simply pass the stuff around in a HashMap or similar, then your clients have to pull this map apart and grok the contents each time they want to use the results.

http://stackoverflow.com/q/491421
accepted answer: http://stackoverflow.com/a/491436
tagged with: eclipse
answer count: 1
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/491436
has title: Default value for -vm value in the eclipse.ini file
score: 2
type: AnsweredQuestion
upvote count: 2
tagged with: java
has body: What's the default value for -vm in the eclipse.ini file?. If I don't set this value, where the system will look for this value. Thanks!.
type: Question

http://stackoverflow.com/q/565871
type: Question
has title: Why does my tomcat application's memory usage keep growing?
has answer: http://stackoverflow.com/a/565883
has answer: http://stackoverflow.com/a/565906
has body: My application is running on Windows Server 2000. The memory usage keeps growing (from 145m). Is that normal? I am new to Java. The version is Tomcat5.5.
upvote count: 11
answer count: 6
has answer: http://stackoverflow.com/a/565888
has answer: http://stackoverflow.com/a/565942
tagged with: tomcat
favorite count: 0
type: UnansweredQuestion
tagged with: memory-leaks
score: 11
has answer: http://stackoverflow.com/a/567111
has answer: http://stackoverflow.com/a/566000
tagged with: memory-management
downvote count: 0
tagged with: java

http://stackoverflow.com/comment/453102
score: 0
type: AnswerComment
type: Comment
has text: This is like the first answer that I gave and there are a few others as I specified in the description. I am worried if there is something else that I am missing.
comment on: http://stackoverflow.com/a/639604

http://stackoverflow.com/a/6941492
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/8286537
upvote count: 19
has body: You need the &lt;pre&gt;&lt;/pre&gt; tags for the line breaks, and the {@code ... } inside them for generics. But then it's not allowed to place the opening brace on the same line as the &lt;generic&gt; tag, because then everything will be displayed on 1 line again. Displays on one line: * .. * &lt;pre&gt; * {@code * public List&lt;Object&gt; getObjects() { * return objects; * } * &lt;/pre&gt; * .. Displays with line breaks: * .. * &lt;pre&gt; * {@code * public List&lt;Object&gt; getObjects() * { * return objects; * } * &lt;/pre&gt; * .. Another weird thing is when you paste the closing brace of {@code, it gets displayed: * .. * &lt;pre&gt; * {@code * public List&lt;Object&gt; getObjects() * { * return objects; * } * } * &lt;/pre&gt; * .. Output: public List&lt;Object&gt; getObjects() { return objects; } }
score: 19
answers question: http://stackoverflow.com/q/541920
has comment: http://stackoverflow.com/comment/122609200

http://stackoverflow.com/comment/373456
score: 0
type: Comment
has text: Standalone == NOT DESKTOP (Main class run from the command line) 1)By adding listeners, I believe you are saying to increase the consumers(of Spring) in the same JVM and this will have a limit. Hence I belive it will NOT horizontally scale. However adding more listners in other instances is OK
comment on: http://stackoverflow.com/a/561285
type: AnswerComment

http://stackoverflow.com/a/4952225
answers question: http://stackoverflow.com/q/457276
has body: You can create a suite like so. For example an AllTest suite would look something like this. package my.package.tests; @RunWith(Suite.class) @SuiteClasses({ testMyService.class, testMyBackend.class, ... }) public class AllTests {} Now you can run this in a couple different ways: right-click and run in Eclipse as Junit test create a runable Java Application; Main class='org.junit.runner.JUnitCore' and Args='my.package.tests.AllTests' run from the command line: $ java -cp build/classes/:/usr/share/java/junit4.jar:/usr/share/java/hamcrest-core.jar org.junit.runner.JUnitCore my.package.tests.AllTests
score: 64
type: Answer
downvote count: 1
upvote count: 65
has comment: http://stackoverflow.com/comment/9548088

http://stackoverflow.com/a/460428
upvote count: 8
answers question: http://stackoverflow.com/q/460423
downvote count: 1
type: Answer
has body: The answer is portability. The class Date is not very flexible. You can define dates, but not with any transformation into other calendar formats. So Sun decided to use an additional class hierarchy (Calendar) to make it more flexible. Nonetheless, it's not very handy.
score: 7

http://stackoverflow.com/comment/103226234
type: Comment
has text: I filled a ticket to allow the password to be provided programmatically to the SunMSCAPI KeyStore, https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8232240
type: AnswerComment
comment on: http://stackoverflow.com/a/495793
score: 0

http://stackoverflow.com/comment/51771674
comment on: http://stackoverflow.com/a/2103625
type: AnswerComment
has text: In my `target/classes`, I can only see files under main resources and not test resources. Why?
type: Comment
score: 1

http://stackoverflow.com/comment/251054
score: 1
has text: This is a typical use for recursion, where you are traversing a recursive datastructure.
comment on: http://stackoverflow.com/a/426974
type: AnswerComment
type: Comment

http://stackoverflow.com/a/440576
downvote count: 0
has body: There are several ways. I would use ExecutorService... for example: ExecutorService service = Executors.newCachedThreadPool(); Callable&lt;Result&gt; task = new Callable&lt;Result&gt;() { public Result call() throws Exception { // code which will be run on background thread } }; Future&lt;Result&gt; future = service.submit(task); // Next line wait until background task is complete // without killing CPU. Of course, you can do something // different here and check your 'future' later. // // Note also that future.get() may throw various exceptions too, // you'll need to handle them properly Result resultFromBackgroundThread = future.get(); This is Java 5 code, ExecutorService, Callable, Future and similar are in java.util.concurrent package.
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/440417

http://stackoverflow.com/comment/327396
score: 0
type: Comment
has text: Well, you could do it with a dynamic Proxy, or maybe with a fancy AspectJ pool as in Spring...
comment on: http://stackoverflow.com/a/511407
type: AnswerComment

http://stackoverflow.com/q/474725
has answer: http://stackoverflow.com/a/474876
type: Question
score: 20
has answer: http://stackoverflow.com/a/2024577
upvote count: 20
downvote count: 0
has body: Do any of the IDEs (or any other tool for that matter) have the ability to generate a POM based on an existing project? I ended up generating the POM with a Maven archetype as Peter and Sal suggested and then moving the existing source in. Thanks for the help guys.
has answer: http://stackoverflow.com/a/474809
tagged with: ide
favorite count: 0
has title: Generating a Maven POM from an existing project?
possible better answer: http://stackoverflow.com/a/474876
answer count: 4
tagged with: maven-2
accepted answer: http://stackoverflow.com/a/474779
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/474779
tagged with: java

http://stackoverflow.com/comment/5879545
comment on: http://stackoverflow.com/a/519928
score: 1
type: AnswerComment
type: Comment
has text: That is certainly not true. There is always room for improved implementations. There is nothing in String and Math that should be final.

ntfs
tags question: http://stackoverflow.com/q/554641
tag name: ntfs
type: Tag
tags question: http://stackoverflow.com/q/421357

http://stackoverflow.com/a/451694
type: Answer
downvote count: 0
has body: When you said "((Object) this).clone()", you accessed your own object via its superclass Object. You performed a widening conversion to an Object. The code then attempts to call clone on Object. But, as you've noted, clone is a protected method, meaning that only if your object was in the same package of java.lang would it be able to access the OBJECT's clone method. When you say this.clone, your class extended Object and thus had access to override or use clone directly through the protected class modifier because of inheritance. But that doesn't change the Object implementation. By saying ((Object) yourObject), you get something that is only accessible through the Object class. Only public methods of the Object class are accessible ouside of the package java.lang, so you get the compile-time exception, because the compiler knows this. By saying this.clone(), you are invoking your object's clone method that it got through inheriting through Object, and is now able to be invoked because it becomes a part of your custom subclass.
has comment: http://stackoverflow.com/comment/273234
has comment: http://stackoverflow.com/comment/272355
has comment: http://stackoverflow.com/comment/272387
has comment: http://stackoverflow.com/comment/272352
score: 5
has comment: http://stackoverflow.com/comment/272393
answers question: http://stackoverflow.com/q/451647
upvote count: 5

http://stackoverflow.com/a/437984
has body: The concepts are very relevant. I seem to recall I had a very quick "flick" through this book at some point. It covers some quite interesting material. But a slight thing that concerned me as I recall is that it presents various algorithm implementations that rely on access to volatile arrays, and assuming that the individual elements have volatile access semantics when doing so. As far as I'm aware, the Java Memory Model doesn't offer this guarantee, so the implementations given may need some modification.
answers question: http://stackoverflow.com/q/437878
has comment: http://stackoverflow.com/comment/260495
type: Answer
score: 0
has comment: http://stackoverflow.com/comment/260525

http://stackoverflow.com/a/3042463
score: 478
type: Answer
has comment: http://stackoverflow.com/comment/91744530
has body: You can use jmap to get a dump of any process running, assuming you know the pid. Use Task Manager or Resource Monitor to get the pid. Then jmap -dump:format=b,file=heap.hprof &lt;pid&gt; to get the heap for that process. For systems where bash and pgrep are installed and a single Java process is running, try: jmap -dump:format=b,file=heap.hprof $(pgrep java)
downvote count: 1
has comment: http://stackoverflow.com/comment/46054665
has comment: http://stackoverflow.com/comment/134255114
answers question: http://stackoverflow.com/q/407612
upvote count: 479

http://stackoverflow.com/comment/101602548
score: 0
has text: @zehrer are they thread-safe?
type: Comment
comment on: http://stackoverflow.com/a/373940
type: AnswerComment

http://stackoverflow.com/a/11201917
has body: Here is my simplified, code-only version: package com.superliminal.android.util; import android.content.Context; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; /** * A view container with layout behavior like that of the Swing FlowLayout. * Originally from http://nishantvnair.wordpress.com/2010/09/28/flowlayout-in-android/ itself derived from * http://stackoverflow.com/questions/549451/line-breaking-widget-layout-for-android * * @author Melinda Green */ public class FlowLayout extends ViewGroup { private final static int PAD_H = 2, PAD_V = 2; // Space between child views. private int mHeight; public FlowLayout(Context context) { super(context); } public FlowLayout(Context context, AttributeSet attrs) { super(context, attrs); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { assert (MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.UNSPECIFIED); final int width = MeasureSpec.getSize(widthMeasureSpec) - getPaddingLeft() - getPaddingRight(); int height = MeasureSpec.getSize(heightMeasureSpec) - getPaddingTop() - getPaddingBottom(); final int count = getChildCount(); int xpos = getPaddingLeft(); int ypos = getPaddingTop(); int childHeightMeasureSpec; if(MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.AT_MOST) childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST); else childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); mHeight = 0; for(int i = 0; i &lt; count; i++) { final View child = getChildAt(i); if(child.getVisibility() != GONE) { child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), childHeightMeasureSpec); final int childw = child.getMeasuredWidth(); mHeight = Math.max(mHeight, child.getMeasuredHeight() + PAD_V); if(xpos + childw &gt; width) { xpos = getPaddingLeft(); ypos += mHeight; } xpos += childw + PAD_H; } } if(MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.UNSPECIFIED) { height = ypos + mHe…
has comment: http://stackoverflow.com/comment/39269562
has comment: http://stackoverflow.com/comment/39258074
score: 12
upvote count: 12
downvote count: 0
answers question: http://stackoverflow.com/q/549451
type: Answer

http://stackoverflow.com/a/368111
downvote count: 1
has body: Looking at the JDK, innermost constructor for Calendar.getInstance() has this: public GregorianCalendar(TimeZone zone, Locale aLocale) { super(zone, aLocale); gdate = (BaseCalendar.Date) gcal.newCalendarDate(zone); setTimeInMillis(System.currentTimeMillis()); } so it already automatically does what you suggest. Date's default constructor holds this: public Date() { this(System.currentTimeMillis()); } So there really isn't need to get system time specifically unless you want to do some math with it before creating your Calendar/Date object with it. Also I do have to recommend joda-time to use as replacement for Java's own calendar/date classes if your purpose is to work with date calculations a lot.
score: 47
upvote count: 48
type: Answer
answers question: http://stackoverflow.com/q/368094

http://stackoverflow.com/comment/399269
has text: Enums are implicitly static when they are declared as member classes, the same way as interfaces are implicitly static, so you don't need to use the 'static' keyword. Just have it public.
type: AnswerComment
comment on: http://stackoverflow.com/a/587403
score: 0
type: Comment

http://stackoverflow.com/q/514721
has answer: http://stackoverflow.com/a/10566257
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/49129366
tagged with: java
score: 10
type: Question
has answer: http://stackoverflow.com/a/514747
downvote count: 0
tagged with: string
has body: Is it possible to truncate a Java string to the closest word boundary after a number of characters. Similar to the PHP wordwrap() function, shown in this example.
favorite count: 0
has title: Truncate String on closest word boundary
upvote count: 10
answer count: 4
has answer: http://stackoverflow.com/a/514740
possible better answer: http://stackoverflow.com/a/514747
accepted answer: http://stackoverflow.com/a/514740

sqlite
tags question: http://stackoverflow.com/q/537596
type: Tag
tags question: http://stackoverflow.com/q/539288
tags question: http://stackoverflow.com/q/540702
tags question: http://stackoverflow.com/q/371538
tag name: sqlite

http://stackoverflow.com/comment/193935
score: 0
type: AnswerComment
type: Comment
has text: What you described is exactly what i am running into. I don't have to do a line by line rewrite, as long as the java does the same thing as the php, everything is good. The PHP is too slow. Not only does java run faster(near the speed of C) it also has better caching.
comment on: http://stackoverflow.com/a/363853

http://stackoverflow.com/a/508451
score: 3
downvote count: 0
has body: The best explanation of streams I've seen is chapter 3 of SICP. (You may need to read the first 2 chapters for it to make sense, but you should anyway. :-) They don't use sterams for bytes at all, but rather integers. The big points that I got from it were: Streams are delayed lists The computational overhead [of eagerly computing everything ahead of time, in some cases] is outrageous We can use streams to represent sequences that are infinitely long
upvote count: 3
has comment: http://stackoverflow.com/comment/324034
has comment: http://stackoverflow.com/comment/62856012
type: Answer
answers question: http://stackoverflow.com/q/507747

http://stackoverflow.com/a/2019203
downvote count: 1
upvote count: 5
score: 4
has body: I found a nice third party library which can detect actual encoding: http://glaforge.free.fr/wiki/index.php?wiki=GuessEncoding I didn't test it extensively but it seems to work.
answers question: http://stackoverflow.com/q/499010
type: Answer
has comment: http://stackoverflow.com/comment/41775361

http://stackoverflow.com/comment/372556
score: 2
comment on: http://stackoverflow.com/q/561245
has text: There is several other applications running in the system, which is embedded. And the system does have a virtual memory limit.
type: Comment
type: QuestionComment

http://stackoverflow.com/a/560074
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/559949
upvote count: 2
has body: http://www.icu-project.org/ holds all the source code for icu4j which IBM has released under an open source license. This includes the boundary analysis stuff like dictionary- and rule-based break iterators. However, there doesn't appear to be a text file suitable for perusing. I not sure that IBM would have released their rule set as open source (since it's a pretty big technological advantage to them). Instead, the idea is to create your own rule set, a tutorial of which is here. That same tutorial states that you can dump the default rules by running: RuleBasedBreakIterator rbbi = (RuleBasedBreakIterator) BreakIterator.getWordInstance(Locale.getDefault()); String defaultRules = rbbi.toString();
type: Answer

http://stackoverflow.com/a/462241
type: Answer
upvote count: 3
answers question: http://stackoverflow.com/q/462198
has body: An interface defines just that - an interface (contract) with the world outside the implementing class. The public methods of a (abstract or not) superclass do the same. You shouldn't try to require subclasses to have certain private members - you are trying to specify implementation which is what OOP is all about avoiding. You use an abstract class when you want to define some shared behaviour in a superclass - but that class can't stand on its own (it needs to be subclassed). It may be that the shared behaviour needs some state of its own - in which case it can define private fields, and it may also have private methods which only it can use. Even if you inherit from an abstract class, you won't be able to access its private fields/methods.
score: 3
downvote count: 0

http://stackoverflow.com/q/609351
tagged with: performance
tagged with: java
tagged with: hibernate
answer count: 2
downvote count: 0
possible better answer: http://stackoverflow.com/a/68453193
has answer: http://stackoverflow.com/a/609430
accepted answer: http://stackoverflow.com/a/609430
favorite count: 0
upvote count: 11
has title: In hibernate statistics whats the difference between load and fetch
has answer: http://stackoverflow.com/a/68453193
score: 11
has body: Im mainly looking at the EntityStatics (http://www.hibernate.org/hib_docs/v3/api/org/hibernate/stat/EntityStatistics.html). I can see a lot of fetch, loads and updates and i cant find anywhere that says what the difference between them are.
type: Question
type: AnsweredQuestion

size
type: Tag
tags question: http://stackoverflow.com/q/585268
tag name: size
tags question: http://stackoverflow.com/q/396156

http://stackoverflow.com/comment/78230442
comment on: http://stackoverflow.com/a/382206
has text: @MatthiasBraun I can't reproduce your error on 2.4.12: it works with `GString`s.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/606790
upvote count: 5
has comment: http://stackoverflow.com/comment/46962559
type: Answer
has body: It depends as always. Yes BitSet is more memory efficent, but as soon as you require multithreaded access boolean[] might be the better choice. For example for computing primes you only set the boolean to true and therefore you don't really need synchronization. Hans Boehm has written some paper about this and the same technique can be used for marking nodes in graph.
score: 3
answers question: http://stackoverflow.com/q/605226
has comment: http://stackoverflow.com/comment/419003
downvote count: 2
has comment: http://stackoverflow.com/comment/46962164

http://stackoverflow.com/q/479565
has comment: http://stackoverflow.com/comment/296451
has answer: http://stackoverflow.com/a/479586
tagged with: class-constants
favorite count: 0
has answer: http://stackoverflow.com/a/68313269
has answer: http://stackoverflow.com/a/479572
has comment: http://stackoverflow.com/comment/296453
has answer: http://stackoverflow.com/a/479582
has body: Suppose you need to define a class which all it does is hold constants. public static final String SOME_CONST = "SOME_VALUE"; What is the preferred way of doing this? Interface Abstract Class Final Class Which one should I use and why? Clarifications to some answers: Enums - I'm not going to use enums, I am not enumerating anything, just collecting some constants which are not related to each other in any way. Interface - I'm not going to set any class as one that implements the interface. Just want to use the interface to call constants like so: ISomeInterface.SOME_CONST.
has comment: http://stackoverflow.com/comment/296460
score: 117
has comment: http://stackoverflow.com/comment/359912
has answer: http://stackoverflow.com/a/479641
has answer: http://stackoverflow.com/a/32517021
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/479841
possible better answer: http://stackoverflow.com/a/479632
tagged with: java
has answer: http://stackoverflow.com/a/479579
downvote count: 2
has answer: http://stackoverflow.com/a/479632
has title: How do you define a class of constants in Java?
type: Question
accepted answer: http://stackoverflow.com/a/479582
upvote count: 119
has answer: http://stackoverflow.com/a/726720
has comment: http://stackoverflow.com/comment/296591
has answer: http://stackoverflow.com/a/479583
answer count: 11

http://stackoverflow.com/comment/422178
score: 0
type: Comment
type: QuestionComment
has text: A bit more context would be nice, yes.
comment on: http://stackoverflow.com/q/609762

http://stackoverflow.com/comment/3941558
has text: I came here looking for an answer to a slightly different problem: and you told me exactly what I needed! Thanks!
score: 1
comment on: http://stackoverflow.com/a/509106
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/452688
score: 0
has text: @stager : comma after "Anders" is also removed. @ Lina : what programming language do you use ? There are sometime differences...
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/639264

upgrade
tags question: http://stackoverflow.com/q/565225
tag name: upgrade
type: Tag

http://stackoverflow.com/a/51221150
answers question: http://stackoverflow.com/q/605696
upvote count: 12
downvote count: 0
score: 12
has comment: http://stackoverflow.com/comment/102098005
has body: There are some ways: Java 7 File I/O: String fileName = Paths.get(strUrl).getFileName().toString(); Apache Commons: String fileName = FilenameUtils.getName(strUrl); Using Jersey: UriBuilder buildURI = UriBuilder.fromUri(strUrl); URI uri = buildURI.build(); String fileName = Paths.get(uri.getPath()).getFileName(); Substring: String fileName = strUrl.substring(strUrl.lastIndexOf('/') + 1);
type: Answer

http://stackoverflow.com/a/621497
has comment: http://stackoverflow.com/comment/434485
answers question: http://stackoverflow.com/q/614257
type: Answer
has comment: http://stackoverflow.com/comment/2662691
has body: Can't believe java.util.Timer was voted as the answer. Quartz is really a much better choice. A big advantage of quartz over java.util.Timer is that with quartz the jobs can be stored in the db. As a result one jvm can schedule and another can execute. Also (obviously) the request survives across jvm restarts.
has comment: http://stackoverflow.com/comment/2203179
has comment: http://stackoverflow.com/comment/2598143
score: 0

http://stackoverflow.com/a/450964
downvote count: 0
type: Answer
has body: I'm not sure I understand your needs, but how about creating a JPanel (you can use layouts, labels, other shapes ...) and save it as an image? Here you can find information about how to save a JPanel as an image.
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/450486

http://stackoverflow.com/a/74900186
score: 0
type: Answer
has body: If you are using JUnit 5 you can cherry pick which tests you want to run: import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.Suite; import tests.Test1; import tests.Test2; import tests.Test3; @Suite @SelectClasses({ Test1.class, Test2.class, Test3.class }) public class AllMyTests { } If you want to select which packages to run you can: import org.junit.platform.suite.api.SelectPackages; import org.junit.platform.suite.api.Suite; @Suite @SelectPackages({ "com.package1", "com.package2", "com.package3" }) public class AllMyTests { } If you need to be able to exclude certain sub-packages you can do: import org.junit.platform.suite.api.ExcludePackages; import org.junit.platform.suite.api.SelectPackages; import org.junit.platform.suite.api.Suite; @Suite @SelectPackages({ "com.package1", "com.package2", "com.package3" }) @ExcludePackages({ "com.package1.subpackage", "com.package2.othersubpackage" }) public class AllMyTests { } Other useful annotations: To match a particular pattern: @IncludeClassNamePatterns({"^.*ATests?$"}) To exclude a particular pattern: @ExcludeClassNamePatterns({"^.*ATests?$"}) Examples were based on: https://howtodoinjava.com/junit5/junit5-test-suites-examples/
answers question: http://stackoverflow.com/q/413214

http://stackoverflow.com/comment/927713
type: Comment
comment on: http://stackoverflow.com/a/380633
has text: One thing to note about Joda time, if you're writing mobile or embedded apps it is HUGE (like 500k).
score: 0
type: AnswerComment

http://stackoverflow.com/comment/25962444
comment on: http://stackoverflow.com/q/541832
has text: There's a commercial product JClarity Censum, which i haven't tried. However, this talk by its author was quite informative on Java GC in general: http://www.infoq.com/presentations/Visualizing-Java-GC
score: 2
type: Comment
type: QuestionComment

http://stackoverflow.com/q/564550
score: 6
favorite count: 0
has answer: http://stackoverflow.com/a/564590
tagged with: proxy
answer count: 3
has body: I would like to fetch a SSL page in Java. The problem is, that I have to authenticate against a http proxy. So I want a simple way to fetch this page. I tried the Apache Commons httpclient, but it's too much overhead for my problem. I tried this piece of code, but it does not contain an authentication action: import java.io.*; import java.net.*; public class ProxyTest { public static void main(String[] args) throws ClientProtocolException, IOException { URL url = new URL("https://ssl.site"); Socket s = new Socket("proxy.address", 8080); Proxy proxy = new Proxy(Proxy.Type.HTTP, s.getLocalSocketAddress()); URLConnection connection = url.openConnection(proxy); InputStream inputStream = connection.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); String tmpLine = ""; while ((tmpLine = br.readLine()) != null) { System.out.println(tmpLine); } } } Can anyone provide some information how to implement it on an easy way? Thanks in advance
accepted answer: http://stackoverflow.com/a/564590
upvote count: 6
has answer: http://stackoverflow.com/a/564585
type: Question
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/564585
tagged with: ssl
has title: Easiest way to fetch SSL page via a proxy in Java
tagged with: http-proxy
downvote count: 0
has answer: http://stackoverflow.com/a/564647

http://stackoverflow.com/comment/121229583
comment on: http://stackoverflow.com/q/381502
score: 0
type: Comment
type: QuestionComment
has text: Blimey, I had no idea about this thing... I guess you learn something every day!

http://stackoverflow.com/a/523941
type: Answer
upvote count: 4
downvote count: 0
score: 4
has body: I'd explicitly specify javassist in your project as a dependency and seee if that works. As to why it's listed as optional, there are several reasons someone would do that, but in this case, it looks like the Hibernate team just hasn't decided on the actual dependency scope: &lt;!-- optional deps for bytecode providers until those are finally properly scoped --&gt;
answers question: http://stackoverflow.com/q/520902

http://stackoverflow.com/a/580408
upvote count: 2
has comment: http://stackoverflow.com/comment/392362
answers question: http://stackoverflow.com/q/580391
has body: Implement a MouseListener and add it to the JMenuItems. Then you can catch when the mouse enters and leaves each JMenuItem.
accepted answer of: http://stackoverflow.com/q/580391
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 2

http://stackoverflow.com/comment/435426
comment on: http://stackoverflow.com/a/621606
score: 0
type: Comment
has text: Thanks, my problems were mostly between the chair and keyboard and due to hacking way too late in the night. However, your tip for Apache Exec paid off and improved the quality of the solution.
type: AnswerComment

task
type: Tag
tag name: task
tags question: http://stackoverflow.com/q/627269

http://stackoverflow.com/a/430093
has comment: http://stackoverflow.com/comment/254075
has comment: http://stackoverflow.com/comment/253775
has comment: http://stackoverflow.com/comment/257285
accepted answer of: http://stackoverflow.com/q/430089
answers question: http://stackoverflow.com/q/430089
downvote count: 0
has body: Java Docs says it will throw ClassNotFoundException if the class cannot be found so I'd say it never returns null.
score: 12
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/254045
type: Answer
has comment: http://stackoverflow.com/comment/253721
upvote count: 12

http://stackoverflow.com/a/497385
answers question: http://stackoverflow.com/q/497343
score: 3
upvote count: 3
has comment: http://stackoverflow.com/comment/1343776
has body: Unfortunately, the output of an FTP servers directory listing is not mandated by the standard. In fact, it is explicitly described as not intended for machine parsing. The format will vary quite a bit between servers on some operating systems. RFC 3659 describes some extensions to the FTP standard including the "MDTM" command for querying modification times. If you are lucky, the servers that you want to talk to have implemented this extension.
downvote count: 0
has comment: http://stackoverflow.com/comment/1343748
type: Answer

http://stackoverflow.com/a/437821
score: 202
type: Answer
has body: Just to add a little detail to Oscar's (pleasingly succinct!) answer, the relevant section on the Java Language Specification is 8.4.3.6, 'synchronized Methods': A synchronized method acquires a monitor (§17.1) before it executes. For a class (static) method, the monitor associated with the Class object for the method's class is used. For an instance method, the monitor associated with this (the object for which the method was invoked) is used.
upvote count: 202
downvote count: 0
answers question: http://stackoverflow.com/q/437620
has comment: http://stackoverflow.com/comment/260341

http://stackoverflow.com/comment/287091
type: Comment
score: 9
type: AnswerComment
comment on: http://stackoverflow.com/a/469315
has text: It's this sort of type-safe enum that us poor people forced to use Java 1.4 and below have to implement...Java 5's enums are perhaps the best feature of Java 5+, especially since they can be used in switch statements.

http://stackoverflow.com/q/473862
score: 19
upvote count: 19
has comment: http://stackoverflow.com/comment/291405
tagged with: java
has comment: http://stackoverflow.com/comment/15230844
has answer: http://stackoverflow.com/a/474202
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/3600550
has answer: http://stackoverflow.com/a/473870
downvote count: 0
has title: Is there a Many to Many Collection in Java using Generics (Domain Model, not Persistence Layer)?
tagged with: data-structures
has comment: http://stackoverflow.com/comment/291378
has body: I seem to be using the wrong search terms for this in Google... I have written a Generic Class for Many-To-Many Associations, but I'm guessing this has already been done. It is highly likely that it exists in an implementation much better than my own. This is my first foray into writing a generic class. For a better idea of what I'm looking for, I am including some snippets of my own: I've backed it with 2 hashmaps: private final Map&lt;T, List&lt;S&gt;&gt; ssForTs = new HashMap&lt;T, List&lt;S&gt;&gt;(); private final Map&lt;S, List&lt;T&gt;&gt; tsForSs = new HashMap&lt;S, List&lt;T&gt;&gt;(); Here is the instantiation: new ManyToManyAssociations&lt;Integer, Integer&gt;(); Some of the methods available: public void addAssociation(T t, S s) public void removeAssociation(T t, S s) public List&lt;T&gt; getListOfTs() public List&lt;S&gt; getListOfSs() public List&lt;T&gt; getTsForSs(S s) public List&lt;S&gt; getSsForTs(T t) The names of the methods are quite poor... I apologize. Basic usage is: I can find all S for T and the reverse quite easily. Can you post the link to a polished library that already includes this functionality?
tagged with: generics
linked to: http://stackoverflow.com/q/2571652
has comment: http://stackoverflow.com/comment/291352
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/3467861

http://stackoverflow.com/a/6461694
type: Answer
score: 10
has comment: http://stackoverflow.com/comment/27117557
answers question: http://stackoverflow.com/q/388439
upvote count: 10
downvote count: 0
has body: If Cloneable was Cloneable&lt;T&gt;, then it would be impossible to do this: class A extends B implements Cloneable&lt;A&gt; class B implements Cloneable&lt;B&gt; You can't implement the same interface with different parameters, and class A implements Cloneable&lt;A&gt; and Cloneable&lt;B&gt;.

http://stackoverflow.com/a/19277247
has comment: http://stackoverflow.com/comment/100852941
has body: If I'm going to be using values() a lot: enum Suit { Hearts, Diamonds, Spades, Clubs; public static final Suit values[] = values(); } Meanwhile wherever.java: Suit suit = Suit.values[ordinal]; If you want the array to be private, be my guest: private static final Suit values[] = values(); public static Suit get(int ordinal) { return values[ordinal]; } ... Suit suit = Suit.get(ordinal); Mind your array bounds.
has comment: http://stackoverflow.com/comment/76394161
has comment: http://stackoverflow.com/comment/89735021
has comment: http://stackoverflow.com/comment/94554206
answers question: http://stackoverflow.com/q/609860
score: 117
has comment: http://stackoverflow.com/comment/80417657
upvote count: 118
type: Answer
downvote count: 1

http://stackoverflow.com/q/444623
score: 21
tagged with: java
has title: How do I force a spring container not to return a singleton instance of a bean?
answer count: 2
has answer: http://stackoverflow.com/a/444637
downvote count: 0
has body: When I call getBean(name) on a BeanFactory, I get back an instance of the bean defined in the application context. However, when I call getBean(name) again (with the same name,) I get the same instance of the bean back. I understand how this would be desirable in some (many?) cases, but how do I tell the BeanFactory to give me a new instance? Example Spring configuration (tersely...I've left out some verbosity, but this should get the point across): &lt;beans&gt; &lt;bean id="beanA" class="misc.BeanClass"/&gt; &lt;/beans&gt; Example Java: for(int i = 0;i++;i&lt;=1) { ApplicationContext context = ClassPathXmlApplicationContext("context.xml"); Object o = context.getBean("beanA"); System.out.println(o.toString()); // Note: misc.BeanA does not implement // toString(), so this will display the OOID // so that we can tell if it's the same // instance } When I run this, I get something like: misc.BeanClass@139894 misc.BeanClass@139894 Note that both have the same OOID...so these are the same instances...but I wanted different instances.
favorite count: 0
possible better answer: http://stackoverflow.com/a/444636
has answer: http://stackoverflow.com/a/444636
accepted answer: http://stackoverflow.com/a/444637
upvote count: 21
tagged with: spring
type: Question
type: AnsweredQuestion

http://stackoverflow.com/comment/320566
score: 0
comment on: http://stackoverflow.com/a/505935
type: AnswerComment
type: Comment
has text: @Vinegar, the actual help text is "not helpful" rather than wrong. Having said that, I didn't downvote this one (see the smiley on my comment) because it's not "not helpful". I didn't upvote it either since I believe mP's is more helpful and I restrict myself to upvoting the one best answer IMNSHO.

http://stackoverflow.com/a/79114388
answers question: http://stackoverflow.com/q/447478
score: 0
type: Answer
has body: For me the following did the thing: @Type(type = "org.hibernate.type.NumericBooleanType") @Column(name = "STATUS", columnDefinition = "CHAR(1)", length = 1) private Boolean status; Column definition: STATUS NOT NULL CHAR(1) Technologies: Spring framework 4.0.6.RELEASE Hibernate 4.3.9.Final

http://stackoverflow.com/a/488757
score: 1
upvote count: 1
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/488727
has body: Only one object is created, both contractors are running on the same object. The reason is simple, as you know B has all the variables and methods of A, so if some variable of A needs initializing so methods of A can work someone has to initialize it - and that someone is A's constructor. for example: public class A { public A() { x = 1; } private int x; public int getX() { return x; } } public class B extends A { public B() { } public static void main(String[] args) { B b = new B(); System.out.println(b.getX()); // should print 1 } }

http://stackoverflow.com/a/502187
has body: I think that since you make myArray store 10 elements, it's (effectively) adding 7 nulls to the end, and then Arrays.sort() can't sort a null element against a string.
type: Answer
score: 1
answers question: http://stackoverflow.com/q/502178
upvote count: 2
downvote count: 1

http://stackoverflow.com/a/540653
answers question: http://stackoverflow.com/q/540071
score: 0
has body: unless you have tried multiple methods, you wont know which one is "better". The best way is to prototype each, and try it! it doesnt even have to do all you want to do, just do the basic bits (like returning predefined data), and you can load test it to see which one is better. i suspect that these days, modern machines will perform fast enough for http to work reasonably well, and with the added benefit of being more standardized, other services can take advantage of your server without needing a specialized client.
type: Answer

http://stackoverflow.com/a/589968
accepted answer of: http://stackoverflow.com/q/589732
has comment: http://stackoverflow.com/comment/405459
type: Answer
answers question: http://stackoverflow.com/q/589732
score: 7
upvote count: 7
has body: After getting responses about 3rd party libraries I decided to fix it myself and thought I would post my solution in case anyone else needs to see it. I just added two static methods to the enum that take care of what to send back and forth to XML... public enum e_Type { e_Unknown, e_Categoric, e_Numeric; public static e_Type type(String token) { return e_Type.valueOf(token); } public static String token(e_Type t) { return t.name(); } } This is a good approach for me because it means I can call my getters and setters with the type() and token() methods during serialisation/deserialisation. I have extended this into all my enums. I have two main problems with using a 3rd party library for something like this: Bloat. That's a lot of sledgehammer for my little nut Dependency. Adding a new 3rd party library means I have to go through licensing and legal checks and ESCROW etc. Really not worth it for 8 lines of code.
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/9645898
type: Comment
has text: What do you do if you want to *write* to the file? getResourceAsStream returns an InputStream, right?
type: AnswerComment
comment on: http://stackoverflow.com/a/536260
score: 3

http://stackoverflow.com/q/541194
has comment: http://stackoverflow.com/comment/34152850
linked to: http://stackoverflow.com/q/33684965
has answer: http://stackoverflow.com/a/541209
has answer: http://stackoverflow.com/a/541212
has answer: http://stackoverflow.com/a/541198
has comment: http://stackoverflow.com/comment/54167336
score: 358
has comment: http://stackoverflow.com/comment/353377
has answer: http://stackoverflow.com/a/541348
accepted answer: http://stackoverflow.com/a/541348
tagged with: synchronization
upvote count: 359
favorite count: 0
answer count: 5
has answer: http://stackoverflow.com/a/17835547
possible better answer: http://stackoverflow.com/a/541209
type: AnsweredQuestion
has body: Does c# have its own version of the java "synchronized" keyword? I.e. in java it can be specified either to a function, an object or a block of code, like so: public synchronized void doImportantStuff() { // dangerous code goes here. } or public void doImportantStuff() { // trivial stuff synchronized(someLock) { // dangerous code goes here. } }
tagged with: java
tagged with: multithreading
has title: C# version of java's synchronized keyword?
downvote count: 1
type: Question
tagged with: c#

http://stackoverflow.com/a/618541
has body: I would start by scaling down the image to something like 30K to 60K pixels. This not only will speed up calculation, but also get rid of minute irrelevant changes. For instance you don't want to detect a curtain near an open window moved by the wind. Next, sum the squared differences of the pixel values. If you want to do it thoroughly, you can do it for R, G and B separately: Delta := 0; for y := 0 to Im1.Height do begin for x := 0 to Im1.Width do begin DeltaR := ( Im1[x,y].Red - Im2[x,y].Red ) ^ 2; DeltaG := ( Im1[x,y].Green - Im2[x,y].Green ) ^ 2; DeltaB := ( Im1[x,y].Blue - Im2[x,y].Blue ) ^ 2; Delta := Delta + DeltaR + DeltaG + DeltaB; end; end; if (Delta &gt; Treshold) then Say( 'Hi Bob!' ); (this is just pseudo-code and as code would process rather slowly, google for "scanline" if you want to process all pixels in an image quickly) You may want to define the treshold value empirically: walk slowly by the camera, preferably wearing clothes matching the background color and see what delta's you get. Skipping frames should increase sensitivity.
upvote count: 2
answers question: http://stackoverflow.com/q/602624
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/comment/217035
has text: Thanks for the response, Dan. I've posted an edit which hopefully explains a little better what I'm after and why.
type: Comment
score: 0
comment on: http://stackoverflow.com/a/389696
type: AnswerComment

http://stackoverflow.com/q/609609
has answer: http://stackoverflow.com/a/17511930
has answer: http://stackoverflow.com/a/609629
tagged with: java
type: Question
downvote count: 0
favorite count: 0
has title: creating final variables inside a loop
answer count: 5
has answer: http://stackoverflow.com/a/609611
upvote count: 54
has answer: http://stackoverflow.com/a/10380826
score: 54
tagged with: final
has body: is this allowed in java: for(int i=0;i&lt;5;i++){ final int myFinalVariable = i; } The keyword of my question is final. Is it allowed to do a final variable that changes with every run of the loop? I was wondering this because final says that you can't change the value of the variable (calling only myFinalVariable = i), but i'm redefining the whole variable with final int. Are they two completely different variables just with the same name - with the variable from the previous run of the loop already heading down the road to the garbage collector?
accepted answer: http://stackoverflow.com/a/609611
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/609629
has answer: http://stackoverflow.com/a/609644

http://stackoverflow.com/q/383551
has answer: http://stackoverflow.com/a/17716385
has answer: http://stackoverflow.com/a/383554
has title: What is the size of a boolean variable in Java?
favorite count: 0
linked to: http://stackoverflow.com/q/605226
has body: Can any one tell the bit size of boolean in Java?
possible better answer: http://stackoverflow.com/a/383597
has answer: http://stackoverflow.com/a/383563
linked to: http://stackoverflow.com/q/229886
type: AnsweredQuestion
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/13548613
score: 89
has answer: http://stackoverflow.com/a/383616
type: Question
answer count: 8
has comment: http://stackoverflow.com/comment/2380622
has answer: http://stackoverflow.com/a/384003
has answer: http://stackoverflow.com/a/383556
accepted answer: http://stackoverflow.com/a/383554
has answer: http://stackoverflow.com/a/383597
upvote count: 89
tagged with: boolean

http://stackoverflow.com/a/6127726
has body: I assume you want to find the home directory of a DIFFERENT user. Obviously getting the "user.home" property would be the easiest way to get the current user home directory. To get an arbitrary user home directory, it takes a bit of finesse with the command line: String[] command = {"/bin/sh", "-c", "echo ~root"}; //substitute desired username Process outsideProcess = rt.exec(command); outsideProcess.waitFor(); String tempResult; StringBuilder sb = new StringBuilder(); while((tempResult = br.readLine()) != null) sb.append(tempResult); br.close(); return sb.toString().trim(); Now technically, we should have a thread waiting on the stdout and stderr so the buffers don't fill up and lock up the process, but I'd sure hope the buffer could at least hold a single username. Also, you might want to check the result to see if it starts with ~root (or whatever username you used) just to make sure the user does exist and it evaluated correctly. Hope that helps. Vote for this answer if it does as I'm new to contributing to SO and could use the points.
score: 3
answers question: http://stackoverflow.com/q/491877
upvote count: 3
type: Answer
downvote count: 0

http://stackoverflow.com/q/527846
score: 2
has answer: http://stackoverflow.com/a/527875
tagged with: java
has answer: http://stackoverflow.com/a/1158170
tagged with: emma
type: Question
answer count: 2
tagged with: ant
downvote count: 0
favorite count: 0
tagged with: code-coverage
upvote count: 2
type: UnansweredQuestion
has title: Emma doesn't provide code coverage across projects
has body: I was wondering if any of you EMMA users have encountered this issue. Basically I have multiple projects each with different build.xml ANT scripts that are all called from one main ANT script individually. The code is covered appropriately but when a JUnit method calls another method in a different project, that external method call is not covered by EMMA. Has anyone encountered this issue? Can anyone spare any advice? Thanks

http://stackoverflow.com/a/492687
has comment: http://stackoverflow.com/comment/308396
type: Answer
has body: The print() method can buffer, the write() method is inherited from the Writer class and cannot - so you may get better performance from the JspWriter's print() method. In addition, the print() method is overloaded to take many different types of objects as an argument, whereas the write method deals in Strings and chars only. See the JspWriter javadocs for more details.
has comment: http://stackoverflow.com/comment/308391
answers question: http://stackoverflow.com/q/492672
upvote count: 9
score: 9
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/492672
downvote count: 0

http://stackoverflow.com/q/414811
has answer: http://stackoverflow.com/a/653857
accepted answer: http://stackoverflow.com/a/1080710
possible better answer: http://stackoverflow.com/a/653857
type: AnsweredQuestion
has body: Hmm, sounds easy enough but after looking at the ones that come with StringTemplate, there is no way this is easy for me the average developer. Where does one start? From doing some more digging it seems to accomplish this one would also have to learn the ANTLR tool to create the language file? Is that correct? Or can I just copy one that came with StringTemplate?
upvote count: 1
tagged with: stringtemplate
type: Question
has title: How to build your own lexical analyzer for StringTemplate?
score: 1
tagged with: java
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/1080710
favorite count: 0

http://stackoverflow.com/a/45297429
answers question: http://stackoverflow.com/q/494180
type: Answer
has body: you can use like this Interval interval = new Interval(date1.getTime(),date2.getTime()); Interval interval2 = new Interval(date3.getTime(), date4.getTime()); Interval overlap = interval.overlap(interval2); boolean isOverlap = overlap == null ? false : true
score: 0

http://stackoverflow.com/q/431654
type: AnsweredQuestion
answer count: 7
has answer: http://stackoverflow.com/a/431746
has answer: http://stackoverflow.com/a/434526
favorite count: 0
upvote count: 61
type: Question
has body: Trying to build a GUI application in Java/Swing. I'm mainly used to "painting" GUIs on the Windows side with tools like VB (or to be more precise, Gupta SQLWindows... wonder how many people know what that is ;-)). I can't find an equivalent of a Group Box in Swing... With a group box, you have a square box (usually with a title) around a couple of related widgets. One example is a group box around a few radio buttons (with the title explaining what the radio buttons are about, e.g. Group Box entitled "Sex" with "Male" and "Female" radio buttons). I've searched around a bit... the only way I found was to add a sub-pane, set the border on the sub-pane and then add all the widgets in the "group" to the sub-pane. Is there a more elegant way to do that?
possible better answer: http://stackoverflow.com/a/434526
tagged with: grouping
score: 60
has answer: http://stackoverflow.com/a/54377075
accepted answer: http://stackoverflow.com/a/431746
tagged with: java
tagged with: swing
downvote count: 1
has comment: http://stackoverflow.com/comment/255062
has answer: http://stackoverflow.com/a/431674
has answer: http://stackoverflow.com/a/431678
has comment: http://stackoverflow.com/comment/255067
has title: Is there a "Group Box" equivalent in Java Swing?
has answer: http://stackoverflow.com/a/431750
has answer: http://stackoverflow.com/a/436281

http://stackoverflow.com/a/616516
type: Answer
upvote count: 6
score: 6
answers question: http://stackoverflow.com/q/616484
downvote count: 0
has body: Use poll to get the first element, and add to add a new last element. That's it, no synchronization or anything else.

http://stackoverflow.com/a/4321449
answers question: http://stackoverflow.com/q/619761
score: 7
has comment: http://stackoverflow.com/comment/51578063
upvote count: 7
has comment: http://stackoverflow.com/comment/59173090
has body: Create a custom ObjectFactory to instantiate the desired class during unmarshalling. Example: JAXBContext context = JAXBContext.newInstance("com.whatever.mypackage"); Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setProperty("com.sun.xml.internal.bind.ObjectFactory", new ReceiverPersonObjectFactory()); return unmarshaller; public class ReceiverPersonObjectFactory extends ObjectFactory { public Person createPerson() { return new ReceiverPerson(); } }
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/6682761

http://stackoverflow.com/comment/66314804
comment on: http://stackoverflow.com/a/25231384
score: 0
type: AnswerComment
has text: Why has the target type of the dynamic cast "const"?
type: Comment

http://stackoverflow.com/q/557268
tagged with: seam
tagged with: java
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/557313
type: Question
tagged with: openldap
has title: Best Framework For Accessing OpenLDAP With Seam & JBoss AS?
has answer: http://stackoverflow.com/a/557278
score: 0
answer count: 3
possible better answer: http://stackoverflow.com/a/557276
accepted answer: http://stackoverflow.com/a/557313
has body: We are currently implementing a portal to our web based services. The portal and services are written with Seam and we are using OpenLDAP to store the security data such as users, groups and permissions. So far we have looked at writing our own code to access LDAP but are there any existing APIs that we could use?
has answer: http://stackoverflow.com/a/557276

http://stackoverflow.com/comment/427740
score: 0
type: Comment
has text: (Using ZipInputStream rather than ZipFile.)
type: AnswerComment
comment on: http://stackoverflow.com/a/614821

http://stackoverflow.com/comment/530902
score: 2
type: AnswerComment
has text: Nick, I think it's because atomic CAS is usually even faster than volatile. If you're developing for 1.4 your only safe option IMHO is to use synchronized as volatile in 1.4 hasn't got the strong memory barrier guarantees as it has in Java 5.
type: Comment
comment on: http://stackoverflow.com/a/462648

http://stackoverflow.com/comment/367605
has text: Don't ever name Seam and Richfaces to a newbie. My experience is not good in getting them going with these frameworks
comment on: http://stackoverflow.com/a/556051
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/644754
has comment: http://stackoverflow.com/comment/472595
has body: I have used DataInputStream for reading binary files and I write the rules in Java. ;) Binary files can have just about any format so there is no general rule for how to read them. Frameworks don't always make things simpler. In your case, the description file is longer than the code to just read the data using a DataInputStream. public static void parse(DataInput in) throws IOException { // file: // header: FIXED("MAGIC") String header = readAsString(in, 5); assert header.equals("MAGIC"); // body: content(10) // ?? not sure what this means // content: for(int i=0;i&lt;10;i++) { // value1: BYTE byte value1 = in.readByte(); // value2: LONG long value2 = in.readLong(); // value3: STRING(10) String value3 = readAsString(in, 10); } } public static String readAsString(DataInput in, int len) throws IOException { byte[] bytes = new byte[len]; in.readFully(bytes); return new String(bytes); } If you want to have a configuration file you could use a Java Configuration File. http://www.google.co.uk/search?q=java+configuration+file
has comment: http://stackoverflow.com/comment/461906
has comment: http://stackoverflow.com/comment/473617
answers question: http://stackoverflow.com/q/644737
has comment: http://stackoverflow.com/comment/466716
has comment: http://stackoverflow.com/comment/458156
has comment: http://stackoverflow.com/comment/460737
has comment: http://stackoverflow.com/comment/460291
has comment: http://stackoverflow.com/comment/469715
score: 9
downvote count: 1
has comment: http://stackoverflow.com/comment/477029
has comment: http://stackoverflow.com/comment/477452
has comment: http://stackoverflow.com/comment/477602
upvote count: 10
type: Answer
has comment: http://stackoverflow.com/comment/458165

http://stackoverflow.com/a/3303638
has comment: http://stackoverflow.com/comment/86573227
type: Answer
downvote count: 1
has comment: http://stackoverflow.com/comment/102409373
score: 103
has comment: http://stackoverflow.com/comment/78460212
upvote count: 104
has body: You can try using the Awaitility library. It makes it easy to test the systems you're talking about.
answers question: http://stackoverflow.com/q/631598

http://stackoverflow.com/a/431678
type: Answer
has comment: http://stackoverflow.com/comment/255112
has body: I'm responding based on the Uri's comment which explaind what the OP meant by Group Box: Uri: I think he means the control group you see in many dialog boxes, where you have a square around a bunch of widgets such as radio buttons, for example. As far as I know, every JComponent can set a border for itself, so you don't need a second panel.
answers question: http://stackoverflow.com/q/431654
downvote count: 1
upvote count: 0
has comment: http://stackoverflow.com/comment/255096
score: -1

http://stackoverflow.com/q/492248
favorite count: 0
tagged with: 64-bit
has answer: http://stackoverflow.com/a/524477
upvote count: 1
type: Question
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/524329
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/492510
tagged with: java-web-start
has answer: http://stackoverflow.com/a/492510
has answer: http://stackoverflow.com/a/11514235
has title: Why does Java Web Start not work with 64-bit Java environments?
downvote count: 0
has answer: http://stackoverflow.com/a/524329
has body: Java Web Start does not come with 64-bit builds of the JDK. Why is this? What is lacking that keeps it from building and working?
answer count: 4

http://stackoverflow.com/q/621974
has title: How do I bind to this JList so I can change what gets displayed to the user?
score: 0
answer count: 1
tagged with: jlist
has answer: http://stackoverflow.com/a/621978
type: AnsweredQuestion
tagged with: java
tagged with: swing
type: Question
has body: I have a JList which i want to use to display a list a caches that are added in from another form, I've got this working and I want to be able to add the caches directly to the list... Is there a way to change what gets displayed to the user? or would it simply be a case of making to the toString method of my object what i want to be displayed? public void update(Observable o, Object arg) { GeoGolfHole hole = (GeoGolfHole)arg; model.add(0, hole); jlHolesInGame.setText(Integer.toString(model.getSize())); }
accepted answer: http://stackoverflow.com/a/621978

http://stackoverflow.com/comment/240188
has text: Yes, but one might argue that it lets the programmer know if he or she has left the variable uninitialized by mistake.
type: Comment
score: 2
comment on: http://stackoverflow.com/a/415703
type: AnswerComment

http://stackoverflow.com/a/516827
has comment: http://stackoverflow.com/comment/334607
answers question: http://stackoverflow.com/q/516798
has body: My experience indicates that this kind of layout is best: mylib/ src/ java/ python/ perl/ .../ bin/ java/ python/ perl/ stage/ dist/ src is your source, and is the only thing checked in. bin is where "compilation" occurs to during the build, and is not checked in. stage is where you copy things during the build to prepare them for packaging dist is where you put the build artifacts I put the module/component/library at the top of the hierarchy, because I build every module separately, and use a dependency manager to combine them as needed. Of course, naming conventions vary. But I've found this to work quite satisfactorily.
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/516798
has comment: http://stackoverflow.com/comment/334614
type: Answer
upvote count: 6
score: 6
has comment: http://stackoverflow.com/comment/332912

http://stackoverflow.com/comment/21458442
comment on: http://stackoverflow.com/a/2424561
score: 0
type: AnswerComment
has text: I just found an interesting performance comparison between JPA implementations (DataNucleus is both a JDO and JPA implementation). While Hibernate does ok with a 1000 inserts into a single flat file DataNucleus really excels when you persist objects with relationships to other objects - you know, kind of like in a real application :) Here's the link: http://s3-eu-west-1.amazonaws.com/presentations2012/50_presentation.pdf
type: Comment

http://stackoverflow.com/q/520328
linked to: http://stackoverflow.com/q/15159847
has comment: http://stackoverflow.com/comment/31719661
favorite count: 0
has answer: http://stackoverflow.com/a/44817646
has answer: http://stackoverflow.com/a/39006103
has answer: http://stackoverflow.com/a/520339
has answer: http://stackoverflow.com/a/44202417
linked to: http://stackoverflow.com/q/15519626
linked to: http://stackoverflow.com/q/9316726
tagged with: package
has answer: http://stackoverflow.com/a/56332568
linked to: http://stackoverflow.com/q/2543439
has answer: http://stackoverflow.com/a/19000174
has answer: http://stackoverflow.com/a/22462785
has answer: http://stackoverflow.com/a/20358207
has answer: http://stackoverflow.com/a/61525596
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/34292253
has answer: http://stackoverflow.com/a/71739824
tagged with: reflection
has title: Can you find all classes in a package using reflection?
tagged with: java
has answer: http://stackoverflow.com/a/72179391
possible better answer: http://stackoverflow.com/a/9571146
has answer: http://stackoverflow.com/a/2373928
has comment: http://stackoverflow.com/comment/48408223
has answer: http://stackoverflow.com/a/9571146
has comment: http://stackoverflow.com/comment/2238820
accepted answer: http://stackoverflow.com/a/520339
has answer: http://stackoverflow.com/a/14002663
type: Question
has answer: http://stackoverflow.com/a/21840860
has answer: http://stackoverflow.com/a/21430849
has answer: http://stackoverflow.com/a/42111223
answer count: 30
has answer: http://stackoverflow.com/a/46575084
has answer: http://stackoverflow.com/a/520344
has comment: http://stackoverflow.com/comment/102866119
has answer: http://stackoverflow.com/a/32828953
upvote count: 655
has answer: http://stackoverflow.com/a/58773038
linked to: http://stackoverflow.com/q/1156552
downvote count: 0
has comment: http://stackoverflow.com/comment/126233398
has answer: http://stackoverflow.com/a/71886472
has answer: http://stackoverflow.com/a/13477227
linked to: http://stackoverflow.com/q/10910510
has body: Is it possible to find all classes or interfaces in a given package? (Quickly looking at e.g. Package, it would seem like no.)
score: 655
linked to: http://stackoverflow.com/q/862106
linked to: http://stackoverflow.com/q/519816
has answer: http://stackoverflow.com/a/78499778
has answer: http://stackoverflow.com/a/38680038
has answer: http://stackoverflow.com/a/13058324
has comment: http://stackoverflow.com/comment/69074464
has answer: http://stackoverflow.com/a/58911838
has answer: http://stackoverflow.com/a/20476490
linked to: http://stackoverflow.com/q/176527
has answer: http://stackoverflow.com/a/520335

http://stackoverflow.com/comment/210761
type: AnswerComment
has text: public fields causes a leak in the implementation.
type: Comment
comment on: http://stackoverflow.com/a/381784
score: 0

http://stackoverflow.com/a/56866220
downvote count: 1
has body: You won't be able to check if char appears at all in some string without atleast going over the string once using loop / recursion ( the built-in methods like indexOf also use a loop ) If the no. of times you look up if a char is in string x is more way more than the length of the string than I would recommend using a Set data structure as that would be more efficient than simply using indexOf String s = "abc"; // Build a set so we can check if character exists in constant time O(1) Set&lt;Character&gt; set = new HashSet&lt;&gt;(); int len = s.length(); for(int i = 0; i &lt; len; i++) set.add(s.charAt(i)); // Now we can check without the need of a loop // contains method of set doesn't use a loop unlike string's contains method set.contains('a') // true set.contains('z') // false Using set you will be able to check if character exists in a string in constant time O(1) but you will also use additional memory ( Space complexity will be O(n) ).
type: Answer
answers question: http://stackoverflow.com/q/506105
upvote count: 0
score: -1

http://stackoverflow.com/a/1656938
downvote count: 0
answers question: http://stackoverflow.com/q/417515
has body: Allow your boss to learn from their mistakes. If you always strive to protect them from themselves then they will never be able learn from their bad decisions, and you will always be trying to mitigate their next bad decision. It is also important that you don't shield them from the repercussions of a bad decision, for example by quietly putting in a weekend for something that you feel guilty for. You can and should of course do all this graciously with no hint of spite. Better still, diplomatically talking through the reasons for each approach as early as possible can work wonders. Of course some people never learn ;-)
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/a/456448
has body: Try this instead: String workingDir = "F:\\Games\\COD4\\"; String cmd = workingDir + "iw3mp.exe"; Runtime.getRuntime().exec(cmd,null,new File(workingDir)); iw3mp.exe probably isn't on your system path so you have to give Java an absolute path to the executable.
score: 6
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/456388
upvote count: 6

http://stackoverflow.com/comment/89842521
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/49784982
has text: Is there a reason why the example includes a `.parallel()`? It seems to me like generating a 100 random numbers would be too trivial to warrant parallelism.

http://stackoverflow.com/q/479530
has body: Is it possible to configure Resin to serve static files such that navigating to e.g. http://localhost:8888/foo/bar/ will serve the file foo/bar/index.html (without performing a redirect)? I can't find the answer in the Resin docs, though I might be looking in the wrong place. The equivalent in Apache would be the DirectoryIndex directive.
tagged with: resin
answer count: 2
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/487448
has answer: http://stackoverflow.com/a/487453
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/487448
possible better answer: http://stackoverflow.com/a/487453
score: 1
tagged with: java
has title: How do you get resin to serve index.html by default if you navigate to a directory? (equivalent of DirectoryIndex in Apache)
upvote count: 1
type: Question

http://stackoverflow.com/comment/33899946
has text: This doesn't actually work. `new Holder<Thing>[10]` is a generic array creation.
type: AnswerComment
score: 4
comment on: http://stackoverflow.com/a/10021028
type: Comment

http://stackoverflow.com/a/440483
score: 4
has body: You can get the Developer Documentation, which includes the source. The download requires you to have an ADC account.
type: Answer
has comment: http://stackoverflow.com/comment/262794
has comment: http://stackoverflow.com/comment/262573
downvote count: 1
upvote count: 5
answers question: http://stackoverflow.com/q/440441
has comment: http://stackoverflow.com/comment/262594

http://stackoverflow.com/a/477882
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/477881
has comment: http://stackoverflow.com/comment/294978
has comment: http://stackoverflow.com/comment/294983
type: Answer
has comment: http://stackoverflow.com/comment/295109
score: 6
answers question: http://stackoverflow.com/q/477881
upvote count: 6
has body: No. You can't separate allocation from initialization, at least not for arrays. What, exactly, are you trying to benchmark? The reason that I ask is that there are a lot of variables within a running JVM that will affect any object allocation timing, ranging from the size of the object (which determines where it's allocated), to what else is happening in the JVM at the same time (once you start allocating objects, they'll get shuffled between the various generations), to whether or not Hotspot decides that your code isn't doing anything and can be replaced by a no-op. Incidentally, there are a similar but non-overlapping set of variables that get in the way of benchmarking malloc() ...

http://stackoverflow.com/q/430346
tagged with: language-design
has answer: http://stackoverflow.com/a/430754
has comment: http://stackoverflow.com/comment/56156145
has answer: http://stackoverflow.com/a/45536475
has body: Why doesn't Java include support for unsigned integers? It seems to me to be an odd omission, given that they allow one to write code that is less likely to produce overflows on unexpectedly large input. Furthermore, using unsigned integers can be a form of self-documentation, since they indicate that the value which the unsigned int was intended to hold is never supposed to be negative. Lastly, in some cases, unsigned integers can be more efficient for certain operations, such as division. What's the downside to including these?
has answer: http://stackoverflow.com/a/430354
has comment: http://stackoverflow.com/comment/89010905
has comment: http://stackoverflow.com/comment/33970600
has answer: http://stackoverflow.com/a/430361
has answer: http://stackoverflow.com/a/75111844
has answer: http://stackoverflow.com/a/6850755
linked to: http://stackoverflow.com/q/397867
has comment: http://stackoverflow.com/comment/3765088
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/430553
has comment: http://stackoverflow.com/comment/2086280
has answer: http://stackoverflow.com/a/35165138
tagged with: unsigned
has comment: http://stackoverflow.com/comment/27347114
tagged with: java
has answer: http://stackoverflow.com/a/40367054
has title: Why doesn't Java support unsigned ints?
has comment: http://stackoverflow.com/comment/89011031
has answer: http://stackoverflow.com/a/1553151
type: Question
has comment: http://stackoverflow.com/comment/11659571
has answer: http://stackoverflow.com/a/434067
has answer: http://stackoverflow.com/a/15053268
has comment: http://stackoverflow.com/comment/89029973
has comment: http://stackoverflow.com/comment/39682222
has comment: http://stackoverflow.com/comment/56141272
downvote count: 1
has comment: http://stackoverflow.com/comment/254145
has comment: http://stackoverflow.com/comment/89010726
has answer: http://stackoverflow.com/a/21452192
score: 412
answer count: 17
favorite count: 0
has answer: http://stackoverflow.com/a/9650388
possible better answer: http://stackoverflow.com/a/430553
has comment: http://stackoverflow.com/comment/56180508
has answer: http://stackoverflow.com/a/430389
has answer: http://stackoverflow.com/a/430357
accepted answer: http://stackoverflow.com/a/430357
has answer: http://stackoverflow.com/a/56793934
has comment: http://stackoverflow.com/comment/46546883
tagged with: integer
upvote count: 413
has comment: http://stackoverflow.com/comment/56140917

http://stackoverflow.com/q/381370
tagged with: postgresql
score: 0
tagged with: jdbc
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/381489
tagged with: java
has answer: http://stackoverflow.com/a/401104
type: Question
has body: Which JDBC jar should I use with java 1.5.0_16 and PostgreSQL 8.3.5?
answer count: 2
has title: Which JDBC jar should I use with java 1.5.0_16 and PostgreSQL 8.3.5?

http://stackoverflow.com/a/4611177
score: 0
type: Answer
answers question: http://stackoverflow.com/q/453479
has body: See the answer in my blog post: http://code-o-matic.blogspot.com/2010/12/how-long-is-period-of-random-numbers.html Random has a maximal period for its state (a long, i.e. 2^64 period). This can be directly generalized to 2^k - invest as many state bits as you want, and you get the maximal period. 2Mersenne Twister has actually a very short period, comparatively (see the comments in said blog post). --Oops. Random restricts itself to 48bits, instead of using the full 64 bits of a long, so correspondingly, its period is 2^48 after all, not 2^64.

http://stackoverflow.com/q/456388
has body: I'm trying to get an application (a game) to start with a Java script. There is a long explanation behind why, so I'll skip that part. The game won't run unless it is executed from its own directory, IE: Just telling Java to launch the EXE gives errors within the game. It must be launched from its directory. I've Googled for hours over this and can't seem to find any real answers. After a lot of Googleing, I've learned this should be right: String workingDir = "F:\\Games\\COD4\\"; String cmd = "iw3mp.exe"; Runtime.getRuntime().exec(cmd,null,new File(workingDir)); However, I get this error: Exception in thread "main" java.io.IOException: Cannot run program "iw3mp.exe" (in directory "F:\Games\COD4"): CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at cod4launcher.main(cod4launcher.java:29) Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.&lt;init&gt;(Unknown Source) at java.lang.ProcessImpl.start(Unknown Source) ... 4 more Please help! Thanks.
tagged with: java
type: Question
answer count: 2
has title: Make application run in its own directory
downvote count: 0
tagged with: runtime
has answer: http://stackoverflow.com/a/7433481
score: 1
tagged with: exec
favorite count: 0
has answer: http://stackoverflow.com/a/456448
type: UnansweredQuestion
upvote count: 1

http://stackoverflow.com/comment/279553
type: Comment
has text: That definitely sounds like it could be the cause - will check that when I can (I'm away from that code right now as well :)
comment on: http://stackoverflow.com/a/460516
score: 0
type: AnswerComment

http://stackoverflow.com/q/578165
has body: I got to setup the following two variables: export LD_LIBRARY_PATH=/usr/java/jdk1.6.0/jre/lib/i386/:/usr/java/jdk1.6.0/jre/lib/i386/client/:./ export JAVA_HOME=/usr/java/jdk1.6.0/ Since, the above is for the version of JDK installed via SunJDK, what could be the equivalent path for the openjdk-6-jdk package? My OpenJDK is installed at: /usr/lib/jvm/java-6-openjdk I couldn't find the folder i386/, though. To which path should I point?
score: 2
upvote count: 2
tagged with: java
tagged with: ubuntu-8.04
has answer: http://stackoverflow.com/a/578203
accepted answer: http://stackoverflow.com/a/578203
type: Question
type: AnsweredQuestion
tagged with: ubuntu
has title: What is the equivalent of the following jdk path in Ubuntu 8.04?
answer count: 1
downvote count: 0
favorite count: 0

http://stackoverflow.com/comment/140190904
score: 0
type: Comment
comment on: http://stackoverflow.com/a/607281
has text: @PashaSkender i think this is the way to get value: https://stackoverflow.com/a/38034571/5581893
type: AnswerComment

http://stackoverflow.com/comment/458091
has text: @Steve Kuo: I adapted this program from an example, the example used "this" in the way you're talking about. I can't really think of a reason to do so; member variables it makes sense to disambiguate.
comment on: http://stackoverflow.com/q/644612
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/q/544824
has answer: http://stackoverflow.com/a/12713625
has answer: http://stackoverflow.com/a/544985
tagged with: java
type: Question
has body: I'm begginner in Java, I'm writing ("FLASH").getbytes() like this to serialport. After I'll get FLASH_OK as response, again I've to send file request. After that I'll get response as FILE_OK then I have read file up to end of the file. I'm not getting how to do this, so please help me. Thanks for reply.
answer count: 2
downvote count: 0
favorite count: 0
has title: Read file from serial port using Java
upvote count: 8
type: UnansweredQuestion
tagged with: serial-port
score: 8

http://stackoverflow.com/a/486423
has comment: http://stackoverflow.com/comment/302899
has body: The test code is: Calendar cal = Calendar.getInstance(); Date today = new Date(); cal.set(2001, 0, 15, 9, 26, 07); // Jan 15 2001, 09:26:07 // format 4 = ddd mmm dd hh:mm:ss TTT yyyy (with gettime) assertEquals("UtilityTest.testParseDate(4t): Mon Jan 15 09:26:07 PST 2001", cal.getTime(), Utility.parseDate("Mon Jan 15 09:26:07 PST 2001", today, true)); Here's what parseDate looks like (just the method signature as the code was long): public static Date parseDate(String date, Date today, boolean gettime) { I think you may have it though - even though it does not DISPLAY the milliseconds, they would be different.
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/486381
upvote count: 1
type: Answer

http://stackoverflow.com/a/359747
answers question: http://stackoverflow.com/q/359732
type: Answer
has comment: http://stackoverflow.com/comment/190650
score: 6
has comment: http://stackoverflow.com/comment/190588
upvote count: 9
has comment: http://stackoverflow.com/comment/190511
downvote count: 3
has body: Let's say you have some code: if (foo) bar(); and then someone else comes along and adds: if (foo) snafu(); bar(); According to the way it's written, bar(); is now executed unconditionally. By including the curly braces, you prevent this kind of accidental error. Code should be written in such a way as to make such mistakes difficult or impossible to make. If I was doing a code review and saw the missing braces, especially spread across multiple lines, I would create a defect. In cases where it is justified, keep it on one line so that the chance of making such an error is again kept to a minimum.
has comment: http://stackoverflow.com/comment/190526
has comment: http://stackoverflow.com/comment/190551

http://stackoverflow.com/a/45040199
answers question: http://stackoverflow.com/q/557903
type: Answer
score: 1
upvote count: 1
downvote count: 0
has body: I have used a wait/notify to implement this. Just for your reference. final Clip clip = AudioSystem.getClip(mixerInfo); clip.addLineListener(new LineListener(){ @Override public void update(LineEvent e) { if (e.getType()==LineEvent.Type.STOP){ synchronized(clip){ clip.notifyAll(); } System.err.println("STOP!"); } } }); clip.open(as); clip.start(); while (true){ synchronized(clip){ clip.wait(); } if (!clip.isRunning()){ break; } } clip.drain(); clip.stop(); clip.close();

http://stackoverflow.com/q/446023
has answer: http://stackoverflow.com/a/6405424
has answer: http://stackoverflow.com/a/446072
has answer: http://stackoverflow.com/a/459335
has answer: http://stackoverflow.com/a/448178
tagged with: java
type: Question
score: 5
upvote count: 5
downvote count: 0
has title: Tracing IO in java application?
tagged with: io
tagged with: trace
favorite count: 0
has body: I am trying to find out why Apache CXF is running away doing "something" upon first-time initialization of a web-service. "Something" is probably some kind of IO, and I'm guessing it's trying to resolve an external address/schema/DTD of some sort. So I'm trying to find some kind of hook where I can monitor all IO. Either at VM level or at OS level (I can run on both linux and windows but I'm not allowed to run wireshark, and there is a theoretical possibility that it could be file IO). Any suggestions on how I can track down what is happening ?
answer count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/446106

http://stackoverflow.com/a/491241
answers question: http://stackoverflow.com/q/490970
score: 0
type: Answer
has body: Java can run on many platforms only if any platform specific coding is not done for example file separator are different in windows, linux and Mac. You need Jboss for linux and deploy your web application it should just work fine.

http://stackoverflow.com/comment/283937
score: 0
has text: Better (IMHO) String implementations drop the offset and length. Still, you probably have to deal with not so good implementations.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/465639

http://stackoverflow.com/comment/43755817
score: 0
has text: @Huxi Your comment is partly, the actual answer. Thanks!
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/4066868

http://stackoverflow.com/comment/131771944
type: Comment
has text: For Gradle see the stackoverflow post: [Create fat/Uber JAR in Gradle](https://stackoverflow.com/a/71092054/8583692).
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/574594

http://stackoverflow.com/q/421381
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/421413
tagged with: swing
possible better answer: http://stackoverflow.com/a/421403
has answer: http://stackoverflow.com/a/421416
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/421403
score: 3
has answer: http://stackoverflow.com/a/421534
upvote count: 3
tagged with: java
type: Question
has body: I've built a form with Netbeans's visual editor. When I press one of the buttons it should do the following : set it to disabled perform a task that takes some time when the task finishes the button will be enabled again However, the following happens: the button remains in a pressed state until the task finishes when the task finishes, the enabling/disabling of buttons will be very fast (they will happen, but you won't notice them) This behaviour is not something I want. I tried using repaint on the JButton, on the JFrame and even on the JPanel containing the button, but I can't seem to get it to do what I want. Some hints?
has title: Swing buttons don't react immediately! How can I change that?
accepted answer: http://stackoverflow.com/a/421416
downvote count: 0

http://stackoverflow.com/q/581878
has title: Why catch Exceptions in Java, when you can catch Throwables?
has answer: http://stackoverflow.com/a/581893
has answer: http://stackoverflow.com/a/79263461
has comment: http://stackoverflow.com/comment/395212
has answer: http://stackoverflow.com/a/583330
downvote count: 1
has answer: http://stackoverflow.com/a/582196
has comment: http://stackoverflow.com/comment/395275
type: Question
possible better answer: http://stackoverflow.com/a/581889
has answer: http://stackoverflow.com/a/582175
has answer: http://stackoverflow.com/a/581889
upvote count: 86
has body: We recently had a problem with a Java server application where the application was throwing Errors which were not caught because Error is a separate subclass of Throwable and we were only catching Exceptions. We solved the immediate problem by catching Throwables rather than Exceptions, but this got me thinking as to why you would ever want to catch Exceptions, rather than Throwables, because you would then miss the Errors. So, why would you want to catch Exceptions, when you can catch Throwables?
tagged with: java
has answer: http://stackoverflow.com/a/581931
has answer: http://stackoverflow.com/a/35535300
has answer: http://stackoverflow.com/a/581935
linked to: http://stackoverflow.com/q/2416316
has answer: http://stackoverflow.com/a/582014
has answer: http://stackoverflow.com/a/581938
accepted answer: http://stackoverflow.com/a/581935
has answer: http://stackoverflow.com/a/583277
has answer: http://stackoverflow.com/a/583319
has comment: http://stackoverflow.com/comment/393793
favorite count: 0
has answer: http://stackoverflow.com/a/581907
has comment: http://stackoverflow.com/comment/61106746
has comment: http://stackoverflow.com/comment/106897451
has answer: http://stackoverflow.com/a/582522
answer count: 15
score: 85
has comment: http://stackoverflow.com/comment/134064014
type: AnsweredQuestion

http://stackoverflow.com/a/459305
type: Answer
answers question: http://stackoverflow.com/q/459268
score: 0
has body: On Both. They are two different JVM's installations. One used to compile ( JDK stands for Java Development Kit ) and the other is the java environment which most customers machine have ( JRE stands for Java Runtime Environment ) Look on any of those two for a file named: rt.jar That where the core of the platform resides.

http://stackoverflow.com/q/502960
has comment: http://stackoverflow.com/comment/24023951
tagged with: eclipse
tagged with: classpath
type: Question
has answer: http://stackoverflow.com/a/2279279
has answer: http://stackoverflow.com/a/511805
tagged with: jar
answer count: 6
has answer: http://stackoverflow.com/a/20831666
has answer: http://stackoverflow.com/a/502988
has answer: http://stackoverflow.com/a/502978
upvote count: 47
downvote count: 0
tagged with: external
has title: Eclipse: How to build an executable jar with external jar?
favorite count: 0
has comment: http://stackoverflow.com/comment/24023948
has answer: http://stackoverflow.com/a/2739583
type: UnansweredQuestion
score: 47
has body: I am trying to build an executable jar program which depends on external jar downloaded. In my project, I included them in the build path and can be run and debug within eclipse. When I tried to export it to a jar, I can run the program but I can't when I try to press a button which includes function calls and classes from the external jar. I have edited the environment variables (Windows XP) CLASSPATH to include paths of all the external jar, but it doesn't work. A point to note is that I got compile warnings while exporting my executable jar, but it doesn't show up any description about the warnings. Would someone kindly provide a thorough guide on how to include an external jar program using eclipse?
tagged with: java
linked to: http://stackoverflow.com/q/26744783

http://stackoverflow.com/comment/12213511
score: 3
has text: In the question you ask for an XSLT 2.0 processor. But this answer is about an XPath 2.0 processor.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/6695906

http://stackoverflow.com/a/39903784
has comment: http://stackoverflow.com/comment/86042553
upvote count: 21
has comment: http://stackoverflow.com/comment/79657297
downvote count: 5
type: Answer
has body: Using Java 7 Files class http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#probeContentType(java.nio.file.Path) boolean isBinaryFile(File f) throws IOException { String type = Files.probeContentType(f.toPath()); if (type == null) { //type couldn't be determined, assume binary return true; } else if (type.startsWith("text")) { return false; } else { //type isn't text return true; } }
answers question: http://stackoverflow.com/q/620993
has comment: http://stackoverflow.com/comment/69031916
score: 16
has comment: http://stackoverflow.com/comment/130686913

http://stackoverflow.com/a/17693407
score: 0
has body: I had this same issue on Tomcat on Linux. I would get this message intermittently. It was due to maxing out the number of open File Descriptors on the OS. I'm not sure how Java loads classes as required, but I assume this limit stopped it from loading classes that it needed from the runtime. I followed these instructions outlined here: How do I change the number of open files limit in Linux? Namely: Setting a hard limit in /etc/security/limits.conf * hard nofile 64000 Logging out and logging in again, then running: ulimit -n 64000 in my shell session before starting Tomcat. I added the above command to my .bashrc file to make sure that the limits were set each time I logged on.
type: Answer
answers question: http://stackoverflow.com/q/427482

http://stackoverflow.com/q/462094
has answer: http://stackoverflow.com/a/462103
type: Question
score: 5
possible better answer: http://stackoverflow.com/a/464695
upvote count: 5
has body: As an example: public class Foo { private Foo() {} } public class Bar extends Foo { private Bar() {} static public doSomething() { } } That's a compilation error right there. A class needs to, at least, implicitly call its superclass's default constructor, which in this case is isn't visible in Foo. Can I call Object's constructor from Bar instead?
accepted answer: http://stackoverflow.com/a/462102
downvote count: 0
favorite count: 0
tagged with: constructor
has answer: http://stackoverflow.com/a/464695
has answer: http://stackoverflow.com/a/462102
has comment: http://stackoverflow.com/comment/280717
answer count: 4
has answer: http://stackoverflow.com/a/462119
type: AnsweredQuestion
has title: In java, how do I make a class with a private constructor whose superclass also has a private constructor?
tagged with: java
has comment: http://stackoverflow.com/comment/280762

http://stackoverflow.com/a/480624
type: Answer
has comment: http://stackoverflow.com/comment/297529
score: 0
has body: No, I don't think it is not safe. In practice you will almost certainly get away with it. However, the Java Memory Model is surprising. Indeed there was only last week discussion on the JMM mailing list about plans to add a method to "keep objects alive". Currently the finaliser can be run without a happens-before relationship from the execution of a member method. At the moment, you technically need to introduce a happens-before realitionship by synchronising all over the place or writing some volatile at the end of each method and a read of that volatile in the finaliser. As Darron points out, if you can get of the Thread object (through Thread.enumerate for instance) then you can call run on it, which calls the Runnable's run. However, I still don't think there is a happens-before in there. My advice: Don't try to be too "clever".
has comment: http://stackoverflow.com/comment/297670
has comment: http://stackoverflow.com/comment/297939
answers question: http://stackoverflow.com/q/480566
upvote count: 4
downvote count: 4
has comment: http://stackoverflow.com/comment/297308

http://stackoverflow.com/comment/73128524
type: Comment
comment on: http://stackoverflow.com/a/610674
has text: @Jon Skeet : Well, the C++ designers seemed to think this syntax is OK. It also allows the practical use I mentioned in my comment on another answer to this question http://stackoverflow.com/questions/610458/why-isnt-calling-a-static-method-by-way-of-an-instance-an-error-for-the-java-co/610674?noredirect=1#comment73126254_610463 .
type: AnswerComment
score: 0

http://stackoverflow.com/comment/371424
has text: This appears to be a duplicate of this question: http://stackoverflow.com/questions/325299/cross-platform-way-to-open-a-file-using-java-1-5
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/560077
type: Comment

remote-debugging
tag name: remote-debugging
type: Tag
tags question: http://stackoverflow.com/q/461544

http://stackoverflow.com/q/490091
has comment: http://stackoverflow.com/comment/306397
has answer: http://stackoverflow.com/a/33360761
tagged with: generics
has answer: http://stackoverflow.com/a/490178
has answer: http://stackoverflow.com/a/490137
has body: Can someone explained, as detailed as possible, the differences between the following types? List List&lt;Object&gt; List&lt;?&gt; Let me make this more specific. When would I want to use // 1 public void CanYouGiveMeAnAnswer(List l) { } // 2 public void CanYouGiveMeAnAnswer(List&lt;Object&gt; l) { } // 3 public void CanYouGiveMeAnAnswer(List&lt;?&gt; l) { }
linked to: http://stackoverflow.com/q/6783316
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/490225
type: Question
has answer: http://stackoverflow.com/a/490211
has answer: http://stackoverflow.com/a/19306727
has title: Java Generics: List, List<Object>, List<?>
upvote count: 74
tagged with: java
has answer: http://stackoverflow.com/a/490103
has answer: http://stackoverflow.com/a/11533966
linked to: http://stackoverflow.com/q/6231973
answer count: 13
has comment: http://stackoverflow.com/comment/72625153
has answer: http://stackoverflow.com/a/70618634
has answer: http://stackoverflow.com/a/9642824
downvote count: 0
has comment: http://stackoverflow.com/comment/21251969
favorite count: 0
has answer: http://stackoverflow.com/a/490181
score: 74
has answer: http://stackoverflow.com/a/490114
has answer: http://stackoverflow.com/a/490140

http://stackoverflow.com/a/442789
answers question: http://stackoverflow.com/q/442747
has comment: http://stackoverflow.com/comment/107778190
has comment: http://stackoverflow.com/comment/7106050
has comment: http://stackoverflow.com/comment/10757922
downvote count: 5
score: 143
has comment: http://stackoverflow.com/comment/10755304
has comment: http://stackoverflow.com/comment/107777819
has body: January 2009: A full code would be (to use with @Bombe's caveat in mind): /** * Get the method name for a depth in call stack. &lt;br /&gt; * Utility function * @param depth depth in the call stack (0 means current method, 1 means call method, ...) * @return method name */ public static String getMethodName(final int depth) { final StackTraceElement[] ste = Thread.currentThread().getStackTrace(); //System. out.println(ste[ste.length-depth].getClassName()+"#"+ste[ste.length-depth].getMethodName()); // return ste[ste.length - depth].getMethodName(); //Wrong, fails for depth = 0 return ste[ste.length - 1 - depth].getMethodName(); //Thank you Tom Tresansky } More in this question. Update December 2011: bluish comments: I use JRE 6 and gives me incorrect method name. It works if I write ste[2 + depth].getMethodName(). 0 is getStackTrace(), 1 is getMethodName(int depth) and 2 is invoking method. virgo47's answer (upvoted) actually computes the right index to apply in order to get back the method name.
type: Answer
has comment: http://stackoverflow.com/comment/107773418
has comment: http://stackoverflow.com/comment/7107978
upvote count: 148
has comment: http://stackoverflow.com/comment/107777785

http://stackoverflow.com/a/606320
has comment: http://stackoverflow.com/comment/421922
has comment: http://stackoverflow.com/comment/421529
score: 0
has comment: http://stackoverflow.com/comment/419848
answers question: http://stackoverflow.com/q/576937
type: Answer
has body: To specify logging to a Log4j Logger instead of the default Java Logging: * When you start the Administration Server, include the following Java option in the weblogic.Server command: -Dweblogic.log.Log4jLoggingEnabled=true From: http://edocs.bea.com/wls/docs103/logging/config_logs.html#wp1014610

http://stackoverflow.com/a/491341
has body: Subrange types are not actually very useful in practice. We do not often allocate fixed length arrays, and there is also no reason for fixed sized integers. Usually where we do see fixed sized arrays they are acting as an enumeration, and we have a better (although "heavier") solution to that. Subrange types also complicate the type system. It would be much more useful to bring in constraints between variables than to fixed constants. (Obligatory mention that integers should be arbitrary size in any sensible language.)
has comment: http://stackoverflow.com/comment/313574
type: Answer
has comment: http://stackoverflow.com/comment/3465191
has comment: http://stackoverflow.com/comment/312869
has comment: http://stackoverflow.com/comment/3465235
has comment: http://stackoverflow.com/comment/3464735
has comment: http://stackoverflow.com/comment/132475967
has comment: http://stackoverflow.com/comment/3464750
accepted answer of: http://stackoverflow.com/q/491199
upvote count: 9
downvote count: 5
score: 4
has comment: http://stackoverflow.com/comment/3465229
has comment: http://stackoverflow.com/comment/317885
has comment: http://stackoverflow.com/comment/10621703
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/307260
has comment: http://stackoverflow.com/comment/3464210
answers question: http://stackoverflow.com/q/491199

http://stackoverflow.com/comment/436054
type: Comment
has text: Well it could be due to the speed increase that they are more able to target you... or it could be that they add some randomness that they reduce as you get higher in levels.
type: AnswerComment
comment on: http://stackoverflow.com/a/623108
score: 0

http://stackoverflow.com/a/7525865
downvote count: 6
answers question: http://stackoverflow.com/q/559510
has comment: http://stackoverflow.com/comment/33814095
has comment: http://stackoverflow.com/comment/28929358
score: 2
has comment: http://stackoverflow.com/comment/37983896
has comment: http://stackoverflow.com/comment/109616131
upvote count: 8
type: Answer
has body: Look at this: http://code.google.com/p/google-api-spelling-java/ This is a simple Java API that makes it very easy to call Google's spell checker service from Java applications. I tried it and it works very well.

mapping
tags question: http://stackoverflow.com/q/506317
tags question: http://stackoverflow.com/q/374302
tags question: http://stackoverflow.com/q/432347
tags question: http://stackoverflow.com/q/641388
tags question: http://stackoverflow.com/q/605986
tag name: mapping
tags question: http://stackoverflow.com/q/387806
type: Tag

http://stackoverflow.com/a/77480875
score: 0
type: Answer
has body: For a quick and dirty test you can use this: String myString = "hello"; for(;myString.length() < 32; hello = "0" + hello); //pad left for(;myString.length() < 32; hello += "0"); //pad rigth I found it usefull printing a long value in a binary representation: String wildCardBinaryString = Long.toBinaryString(255); for(;wildCardBinaryString.length() < 32; wildCardBinaryString = "0" + wildCardBinaryString); System.out.println(String.format("|%s|", Long.toBinaryString(wildcard))); It prints: |00000000000000000000000011111111|
answers question: http://stackoverflow.com/q/388461

http://stackoverflow.com/q/447898
has answer: http://stackoverflow.com/a/447917
has answer: http://stackoverflow.com/a/44345344
tagged with: object-serialization
has answer: http://stackoverflow.com/a/34331417
has answer: http://stackoverflow.com/a/447921
has answer: http://stackoverflow.com/a/71095124
has answer: http://stackoverflow.com/a/58942502
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/448233
has answer: http://stackoverflow.com/a/32622685
has comment: http://stackoverflow.com/comment/59651585
tagged with: java
has answer: http://stackoverflow.com/a/31651945
score: 427
has answer: http://stackoverflow.com/a/78182672
linked to: http://stackoverflow.com/q/2475448
accepted answer: http://stackoverflow.com/a/447920
has answer: http://stackoverflow.com/a/6242725
has answer: http://stackoverflow.com/a/6322836
answer count: 16
upvote count: 435
favorite count: 0
tagged with: serialization
has answer: http://stackoverflow.com/a/447918
has answer: http://stackoverflow.com/a/447920
possible better answer: http://stackoverflow.com/a/448233
downvote count: 8
linked to: http://stackoverflow.com/q/817853
linked to: http://stackoverflow.com/q/17748078
has answer: http://stackoverflow.com/a/12384653
has title: What is object serialization?
has answer: http://stackoverflow.com/a/43622996
has body: What is meant by "object serialization"? Can you please explain it with some examples?

http://stackoverflow.com/comment/210658
type: Comment
score: 0
has text: you are right that adding the \b around the regex will make sure R122 that should be left alone is not matched by R12 and changed to R212
type: QuestionComment
comment on: http://stackoverflow.com/q/381066

http://stackoverflow.com/comment/230200
comment on: http://stackoverflow.com/a/405053
score: 0
type: AnswerComment
has text: I don't think so, insofar as your action is essentially taking place on a surface that can be viewed from above as a plan. In this case adding 3d graphics should be quite straightforward. Just keep all your rendering code seperate and loosely coupled from the rest of the app.
type: Comment

http://stackoverflow.com/comment/311834
comment on: http://stackoverflow.com/a/493503
score: 0
type: Comment
has text: Also worth understanding the details behind the library call. Especially if there are side effects to the library call, or performance issues like Paul mentions.
type: AnswerComment

http://stackoverflow.com/a/421127
accepted answer of: http://stackoverflow.com/q/420791
has body: This is from Sun's guide when they released the feature (emphasis in original): So when should you use static import? Very sparingly! Only use it when you'd otherwise be tempted to declare local copies of constants, or to abuse inheritance (the Constant Interface Antipattern). ... If you overuse the static import feature, it can make your program unreadable and unmaintainable, polluting its namespace with all the static members you import. Readers of your code (including you, a few months after you wrote it) will not know which class a static member comes from. Importing all of the static members from a class can be particularly harmful to readability; if you need only one or two members, import them individually. (https://docs.oracle.com/javase/8/docs/technotes/guides/language/static-import.html) There are two parts I want to call out specifically: Use static imports only when you were tempted to "abuse inheritance". In this case, would you have been tempted to have BusinessObject extend some.package.DA? If so, static imports may be a cleaner way of handling this. If you never would have dreamed of extending some.package.DA, then this is probably a poor use of static imports. Don't use it just to save a few characters when typing. Import individual members. Say import static some.package.DA.save instead of DA.*. That will make it much easier to find where this imported method is coming from. Personally, I have used this language feature very rarely, and almost always only with constants or enums, never with methods. The trade-off, for me, is almost never worth it.
has comment: http://stackoverflow.com/comment/114342005
answers question: http://stackoverflow.com/q/420791
downvote count: 1
type: AcceptedAnswer
score: 175
upvote count: 176
type: Answer
has comment: http://stackoverflow.com/comment/245189

http://stackoverflow.com/a/471317
has body: float i = Float.NaN; while(i == i) ; System.out.println("Not infinite!");
type: Answer
score: 9
upvote count: 9
answers question: http://stackoverflow.com/q/471296
downvote count: 0

http://stackoverflow.com/comment/109175971
comment on: http://stackoverflow.com/a/565555
has text: This is marked as an accepted answer, is there an example of how you were able to write a wrapper and test the wrapper instead of `new URL`?
type: AnswerComment
type: Comment
score: 2

http://stackoverflow.com/a/608551
score: 0
has comment: http://stackoverflow.com/comment/422025
type: Answer
has body: This is a slight riff on the initial question, but arguably the more complex the SQL is the more it belongs in the database (or in a services layer) and not in your Java code. Otherwise, as code matures, issues like this arise.
answers question: http://stackoverflow.com/q/606062

http://stackoverflow.com/q/578363
possible better answer: http://stackoverflow.com/a/32246313
has answer: http://stackoverflow.com/a/32246313
favorite count: 0
has answer: http://stackoverflow.com/a/11463551
score: 57
upvote count: 58
answer count: 4
has answer: http://stackoverflow.com/a/578387
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/578382
tagged with: java
tagged with: javadoc
downvote count: 1
type: Question
has title: javadoc: @version and @since
accepted answer: http://stackoverflow.com/a/578387
tagged with: documentation
has body: Is there a reason to include both @version and @since as part of a class? They seem to be mutually exclusive. Also, what does %I% and %G% mean, and how to set/use them? @version %I%, %G%

http://stackoverflow.com/comment/5267198
type: Comment
has text: Well, not quite pure Java, there a whole lot of AspectJ in there by default, and I've heard varying reports as to how completely it can be removed without some elbow grease being applied.
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/2026856

http://stackoverflow.com/q/397852
favorite count: 0
has answer: http://stackoverflow.com/a/3304277
answer count: 5
possible better answer: http://stackoverflow.com/a/398175
has answer: http://stackoverflow.com/a/398175
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/3304253
has comment: http://stackoverflow.com/comment/225158
has answer: http://stackoverflow.com/a/6864480
score: 11
has answer: http://stackoverflow.com/a/398177
downvote count: 1
type: Question
tagged with: java
has title: Java Validation Frameworks
accepted answer: http://stackoverflow.com/a/3304253
upvote count: 12
tagged with: frameworks
tagged with: validation
has body: I once came across a validation framework for java, where you wrote one method that protected the integrity of the data-type and any CRUD operations on that data-type automatically called this method. Does anyone know what this framework is? I simply want to avoid repetitive validation on every CRUD method attached to a data-type.

http://stackoverflow.com/comment/59759940
comment on: http://stackoverflow.com/a/21840860
type: AnswerComment
score: 1
type: Comment
has text: For a package "com.mycompany.beans", replace "test" with "com/mycompany/beans"

http://stackoverflow.com/q/562894
has comment: http://stackoverflow.com/comment/374912
has answer: http://stackoverflow.com/a/75525906
upvote count: 126
has answer: http://stackoverflow.com/a/44896993
answer count: 17
has body: How could I go about detecting (returning true/false) whether an ArrayList contains more than one of the same element in Java? I am not looking to compare "Blocks" with each other but their integer values. Each "block" has an int and this is what makes them different. I find the int of a particular Block by calling a method named "getNum" (e.g. table1[0][2].getNum()).
favorite count: 0
has answer: http://stackoverflow.com/a/1404807
has answer: http://stackoverflow.com/a/563016
score: 125
has answer: http://stackoverflow.com/a/562906
has answer: http://stackoverflow.com/a/563553
has answer: http://stackoverflow.com/a/59355409
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/99649256
has answer: http://stackoverflow.com/a/33294387
has answer: http://stackoverflow.com/a/56532893
possible better answer: http://stackoverflow.com/a/600319
tagged with: java
tagged with: duplicates
has answer: http://stackoverflow.com/a/600319
has title: Detect duplicates in ArrayList
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/54793580
accepted answer: http://stackoverflow.com/a/562906
has answer: http://stackoverflow.com/a/39137025
has answer: http://stackoverflow.com/a/9133979
tagged with: arrays
has answer: http://stackoverflow.com/a/26839327
has answer: http://stackoverflow.com/a/35001661
has answer: http://stackoverflow.com/a/562918
has answer: http://stackoverflow.com/a/19674599
tagged with: arraylist

http://stackoverflow.com/q/532360
has answer: http://stackoverflow.com/a/814924
tagged with: multithreading
has answer: http://stackoverflow.com/a/532408
type: AnsweredQuestion
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/3158273
type: Question
has answer: http://stackoverflow.com/a/532496
tagged with: ejb
has comment: http://stackoverflow.com/comment/348031
accepted answer: http://stackoverflow.com/a/588180
has answer: http://stackoverflow.com/a/532440
answer count: 6
tagged with: glassfish
possible better answer: http://stackoverflow.com/a/532496
has comment: http://stackoverflow.com/comment/345385
score: 12
has answer: http://stackoverflow.com/a/588180
has body: I have a Java program/thread that I want to deploy into an Application Server (GlassFish). The thread should run as a "service" that starts when the Application Server starts and stops when the Application Server closes. How would I go about doing this? It's not really a Session Bean or MDB. It's just a thread.
tagged with: application-server
has title: Threading in an Application Server
favorite count: 0
upvote count: 12

http://stackoverflow.com/a/54742578
upvote count: 14
answers question: http://stackoverflow.com/q/428918
score: 13
downvote count: 1
has comment: http://stackoverflow.com/comment/96269864
has body: startCalendar.add(Calendar.DATE, 1); //Add 1 Day to the current Calender
has comment: http://stackoverflow.com/comment/118509896
type: Answer

http://stackoverflow.com/comment/137143104
comment on: http://stackoverflow.com/a/23940391
type: Comment
has text: Upvoted for actually answering how to do X instead of giving general advice around why it is not necessary to do X.
type: AnswerComment
score: 0

http://stackoverflow.com/a/1323536
answers question: http://stackoverflow.com/q/484995
score: 0
type: Answer
has body: To remove unneccesary tags probably such code can be used: DOMConfiguration config = serializer.getDomConfig(); config.setParameter("canonical-form", true); But it will not always work, because "canonical-form=true" is optional

http://stackoverflow.com/a/6138222
answers question: http://stackoverflow.com/q/531282
has body: Constructor is like an Application Setup Wizard where you do only configuration. If the Instance is ready to take any (possible) Action on itself then Constructor doing well.
score: 0
type: Answer

http://stackoverflow.com/comment/38697552
score: 1
comment on: http://stackoverflow.com/a/464640
type: AnswerComment
has text: I tried in my side, using jdk7, but it did catch the OutOfMemory Error !
type: Comment

http://stackoverflow.com/q/473685
has answer: http://stackoverflow.com/a/716391
type: Question
has title: Does it help GC to null local variables in Java
has answer: http://stackoverflow.com/a/474021
has answer: http://stackoverflow.com/a/473699
tagged with: null
has answer: http://stackoverflow.com/a/473726
possible better answer: http://stackoverflow.com/a/473715
has answer: http://stackoverflow.com/a/473715
tagged with: local
has answer: http://stackoverflow.com/a/474601
has answer: http://stackoverflow.com/a/473784
has answer: http://stackoverflow.com/a/473732
has answer: http://stackoverflow.com/a/473705
has answer: http://stackoverflow.com/a/503714
downvote count: 0
tagged with: variables
has answer: http://stackoverflow.com/a/473719
favorite count: 0
has answer: http://stackoverflow.com/a/473885
has answer: http://stackoverflow.com/a/583387
has answer: http://stackoverflow.com/a/473711
upvote count: 41
has answer: http://stackoverflow.com/a/721776
answer count: 15
has body: I was 'forced' to add myLocalVar = null; statement into finally clause just before leaving method. Reason is to help GC. I was told I will get SMS's during night when server crashes next time, so I better did it :-). I think this is pointless, as myLocalVar is scoped to method, and will be 'lost' as soon as method exits. Extra nulling just pollutes the code, but is harmless otherwise. My question is, where does this myth about helping GC come from? (I was referred to "Java memory books") Do you know any article from 'authorities' which explain it in more depth? Is there possibility this is not a myth, but really helps somehow? If so, how? May nulling local variables cause any harm? To clarify, method look like this: void method() { MyClass myLocalVar = null; try { myLocalVar = get reference to object; ... do more here ... } finally { if (myLocalVar != null) { myLocalVar.close(); // it is resource which we should close } myLocalVar = null; // THIS IS THE LINE I AM TALKING ABOUT } }
type: AnsweredQuestion
score: 41
accepted answer: http://stackoverflow.com/a/503714
tagged with: java
tagged with: garbage-collection

http://stackoverflow.com/a/648183
type: Answer
score: 6
downvote count: 0
upvote count: 6
answers question: http://stackoverflow.com/q/647779
has body: If you are confusing between PB &amp; native java serialization on speed and efficiency, just go for PB. PB was designed to achieve such factors. See http://code.google.com/apis/protocolbuffers/docs/overview.html PB data is very small while java serialization tends to replicate a whole object, including its signature. Why I always get my class name, field name... serialized, even though I know it inside out at receiver? Think about across language development. It's getting hard if one side uses Java, one side uses C++... Some developers suggest Thrift, but I would use Google PB because "I believe in google" :-).. Anyway, it's worth for a look: http://stuartsierra.com/2008/07/10/thrift-vs-protocol-buffers

http://stackoverflow.com/comment/123145228
has text: This won't work for copying from a read-only `ByteBuffer`, as `.array()` is not allowed (there's unfortunately no such thing as a read-only array in Java).
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/570374

http://stackoverflow.com/a/435378
has comment: http://stackoverflow.com/comment/5125471
has comment: http://stackoverflow.com/comment/8750023
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/36291908
score: 111
has comment: http://stackoverflow.com/comment/5127764
accepted answer of: http://stackoverflow.com/q/417062
type: Answer
has body: using hibernate or JPA annotations: class User { @Enumerated(EnumType.STRING) UserType type } UserType is just a standard java 5 enum. I can't imagine this is just limited to just annotations but I don't actually know how to do this with hbm files. It may be very version dependant, I'm guessing but I'm pretty sure that hibernate 3.2+ is required. edit: it is possible in a hbm, but is a little messy, have a look at this forum thread
answers question: http://stackoverflow.com/q/417062
downvote count: 0
has comment: http://stackoverflow.com/comment/8750875
upvote count: 111

http://stackoverflow.com/a/586317
has body: Are you using Java 1.5? Why not return List&lt;Integer&gt; and use ArrayList&lt;Integer&gt;? If you do need to return an int[], you can do it by converting List to int[] at the end of processing.
answers question: http://stackoverflow.com/q/586284
type: Answer
upvote count: 2
score: 2
downvote count: 0

http://stackoverflow.com/a/440778
downvote count: 0
upvote count: 2
answers question: http://stackoverflow.com/q/440745
has body: Hmm… without any testing and completely from the top of my head: JPanel panel = new JPanel(); panel.setBorder(new TitledBorder("Title")); menu.add(panel); Most Swing containers eat anything so that might even work. Another approach would be to create a custom component (maybe with a horizontal BoxLayout) and add a JSeparator, a JLabel, and another JSeparator to it, then add it to the menu.
type: Answer
score: 2

http://stackoverflow.com/comment/323201
type: Comment
has text: Sorry, when I said "real time", I meant the plotting has to occur in read time, but the data is static.
comment on: http://stackoverflow.com/a/508748
score: 0
type: AnswerComment

http://stackoverflow.com/q/553759
answer count: 3
has body: I have a very specific problem, and I wanted to know if there is a way to change the owner of a JDialog (it can be set using the constructor). I suppose there is no "official" possibility (other than a hack), but I wanted to make sure I didn't miss something. Any ideas or hints on the topic would be helpful, thanks already...
accepted answer: http://stackoverflow.com/a/555607
possible better answer: http://stackoverflow.com/a/553923
has answer: http://stackoverflow.com/a/11906277
favorite count: 0
score: 8
tagged with: swing
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/555607
type: Question
has comment: http://stackoverflow.com/comment/365638
downvote count: 0
has title: Is there a way to change the owner of a JDialog?
has answer: http://stackoverflow.com/a/553923
tagged with: jdialog
upvote count: 8

http://stackoverflow.com/a/553945
type: Answer
upvote count: 4
answers question: http://stackoverflow.com/q/545056
score: 1
has comment: http://stackoverflow.com/comment/6371609
downvote count: 3
has body: Eclim offers integration between Vim and Eclipse. It should allow you to use Eclipse's debugger in Vim

http://stackoverflow.com/q/550633
downvote count: 0
score: 4
favorite count: 0
has comment: http://stackoverflow.com/comment/362276
possible better answer: http://stackoverflow.com/a/550648
has answer: http://stackoverflow.com/a/550648
answer count: 4
has title: Use Java to identify lines in a graph
accepted answer: http://stackoverflow.com/a/551295
has answer: http://stackoverflow.com/a/550739
has answer: http://stackoverflow.com/a/1135793
has comment: http://stackoverflow.com/comment/362283
type: AnsweredQuestion
tagged with: java
has body: I am working on an idea wherein I have to identify lines in a JPG or PNG file. The PNG file contains one graph of a single value - one x,y combination. For example, the graph looks like Y = mx+c. I would like to identify the line in the graph - if I can indentify the position of the pixel in the frame, I believe I can get back the values (x,y) which were used to plot the graph. The assumptions here is - I know the scale i.e 1 pixel = what unit of Y ? Can somebody please help me to write a code which will identify the pixels of a specific color in one PNG file? EDIT Lets take an example to make it clear. Lets say I have a set of data values X and Y like this - X = 1, Y = 10 X = 2, Y = 20 X = 3, Y = 30 X = 4, Y = 40 X = 5, Y = 50 X = 6, Y = 60 In this case, if I use jfreechart type of charting tool and make a chart, it tools like a straight line. So the input is the dataset and output is the .PNG file (using jchart or jfreechart) containing this line graph for Y values. Question is - if we reverse the flow, can we develop one program which will take the PNG file (that contains the graph) and give me back the dataset. The context of the problem is -- I want to store the PNG files in my application and not the raw dataset. But given a PNG file, I should be able to get back my dataset.
tagged with: image
type: Question
upvote count: 4
has answer: http://stackoverflow.com/a/551295

http://stackoverflow.com/comment/28647884
score: 1
type: AnswerComment
has text: [Official eclipse link](http://wiki.eclipse.org/FAQ_How_do_I_set_up_a_Java_project_to_share_in_a_repository%3F)
comment on: http://stackoverflow.com/a/445252
type: Comment

http://stackoverflow.com/a/5478593
has comment: http://stackoverflow.com/comment/125853499
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/16584117
has comment: http://stackoverflow.com/comment/70530638
answers question: http://stackoverflow.com/q/415520
has comment: http://stackoverflow.com/comment/125957539
score: 3
has comment: http://stackoverflow.com/comment/16588855
has body: The advice from Adeel Ansari is flawed: you should never modify CATALINA_HOME/conf/context.xml with webapp-specific configuration. That's what your-webapp/META-INF/context.xml is for. You should also never specify the "docBase" attribute of &lt;Context&gt;. You should also never specify the "path" attribute of &lt;Context&gt;. The OP has several options: Use the manager to reload the web app (undeploy/redeploy should not be necessary: a simple reload should work) ( http://tomcat.apache.org/tomcat-6.0-doc/manager-howto.html#Reload_An_Existing_Application ) Set the element in META-INF/context.xml to have reloadable="true" ( http://tomcat.apache.org/tomcat-6.0-doc/config/context.html ) With all due respect to SO, if you need help with Tomcat, join the users' mailing list and get some real answers.
upvote count: 3

http://stackoverflow.com/q/625433
score: 633
has answer: http://stackoverflow.com/a/24799838
tagged with: time
has answer: http://stackoverflow.com/a/9311087
has answer: http://stackoverflow.com/a/11357074
downvote count: 2
has answer: http://stackoverflow.com/a/50676846
has answer: http://stackoverflow.com/a/41563212
has answer: http://stackoverflow.com/a/47290114
has answer: http://stackoverflow.com/a/77364355
has answer: http://stackoverflow.com/a/625439
has body: I want to record the time using System.currentTimeMillis() when a user begins something in my program. When he finishes, I will subtract the current System.currentTimeMillis() from the start variable, and I want to show them the time elapsed using a human readable format such as "XX hours, XX mins, XX seconds" or even "XX mins, XX seconds" because its not likely to take someone an hour. What's the best way to do this?
has title: How to convert Milliseconds to "X mins, x seconds" in Java?
type: Question
has comment: http://stackoverflow.com/comment/492215
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/625624
tagged with: java
possible better answer: http://stackoverflow.com/a/7663966
has answer: http://stackoverflow.com/a/6128018
has answer: http://stackoverflow.com/a/35082080
has answer: http://stackoverflow.com/a/7663966
has answer: http://stackoverflow.com/a/23176621
has answer: http://stackoverflow.com/a/625444
linked to: http://stackoverflow.com/q/266825
upvote count: 635
has answer: http://stackoverflow.com/a/10224110
has answer: http://stackoverflow.com/a/77764946
has answer: http://stackoverflow.com/a/9196808
has answer: http://stackoverflow.com/a/56144002
has answer: http://stackoverflow.com/a/57926287
has answer: http://stackoverflow.com/a/29114063
has answer: http://stackoverflow.com/a/5554673
linked to: http://stackoverflow.com/q/38922754
has answer: http://stackoverflow.com/a/38931440
has answer: http://stackoverflow.com/a/25973149
favorite count: 0
accepted answer: http://stackoverflow.com/a/625624
has answer: http://stackoverflow.com/a/17301076
has answer: http://stackoverflow.com/a/625456
answer count: 31
has answer: http://stackoverflow.com/a/5554050
has answer: http://stackoverflow.com/a/31390999
has answer: http://stackoverflow.com/a/52466906
linked to: http://stackoverflow.com/q/1555262
has answer: http://stackoverflow.com/a/65577979
has answer: http://stackoverflow.com/a/72136724
has answer: http://stackoverflow.com/a/19956227

http://stackoverflow.com/a/11289663
answers question: http://stackoverflow.com/q/481584
score: 1
upvote count: 1
downvote count: 0
type: Answer
has body: Have a look at OpenMOLE: http://www.openmole.org/ This tool enables you to distribute a computing workflow to several resources: from multicores machines, to clusters and computing grids. It is nicely documented and can be controlled through groovy code or a GUI. Distributing a jar on a cluster should be very easy to do with OpenMOLE.

http://stackoverflow.com/q/521171
type: AnsweredQuestion
has body: I like how Java has a Map where you can define the types of each entry in the map, for example &lt;String, Integer&gt;. What I'm looking for is a type of collection where each element in the collection is a pair of values. Each value in the pair can have its own type (like the String and Integer example above), which is defined at declaration time. The collection will maintain its given order and will not treat one of the values as a unique key (as in a map). Essentially I want to be able to define an ARRAY of type &lt;String,Integer&gt; or any other 2 types. I realize that I can make a class with nothing but the 2 variables in it, but that seems overly verbose. I also realize that I could use a 2D array, but because of the different types I need to use, I'd have to make them arrays of OBJECT, and then I'd have to cast all the time. I only need to store pairs in the collection, so I only need two values per entry. Does something like this exist without going the class route? Thanks!
has comment: http://stackoverflow.com/comment/25973244
has answer: http://stackoverflow.com/a/75160923
score: 455
tagged with: java
has answer: http://stackoverflow.com/a/521379
has title: A Java collection of value pairs? (tuples?)
upvote count: 457
possible better answer: http://stackoverflow.com/a/11253710
type: Question
has answer: http://stackoverflow.com/a/19730154
has answer: http://stackoverflow.com/a/54908669
has answer: http://stackoverflow.com/a/39329419
has answer: http://stackoverflow.com/a/11253710
answer count: 23
has answer: http://stackoverflow.com/a/72283776
has answer: http://stackoverflow.com/a/521205
has answer: http://stackoverflow.com/a/11095455
has answer: http://stackoverflow.com/a/68579040
accepted answer: http://stackoverflow.com/a/521235
has answer: http://stackoverflow.com/a/17798375
downvote count: 2
has answer: http://stackoverflow.com/a/24315923
linked to: http://stackoverflow.com/q/156275
has comment: http://stackoverflow.com/comment/82367661
has answer: http://stackoverflow.com/a/15124421
has answer: http://stackoverflow.com/a/25615100
has answer: http://stackoverflow.com/a/78872022
favorite count: 0
has answer: http://stackoverflow.com/a/521235
has comment: http://stackoverflow.com/comment/132633002
has answer: http://stackoverflow.com/a/521217
has answer: http://stackoverflow.com/a/33712473
has answer: http://stackoverflow.com/a/23670487
has answer: http://stackoverflow.com/a/51834839
tagged with: collections
has answer: http://stackoverflow.com/a/521248
has answer: http://stackoverflow.com/a/13830541
has comment: http://stackoverflow.com/comment/127310945
has answer: http://stackoverflow.com/a/57561655

http://stackoverflow.com/q/570218
upvote count: 4
answer count: 4
favorite count: 0
possible better answer: http://stackoverflow.com/a/570246
downvote count: 0
has answer: http://stackoverflow.com/a/570268
has answer: http://stackoverflow.com/a/570244
type: AnsweredQuestion
tagged with: java
tagged with: javadoc
type: Question
has title: Downloading Sun javadocs / mirror websites
has body: The network between our company and Sun's javadocs seems to be down. Where can I get a copy of the javadocs for a given package, so that I can keep my own stash to handle network outages in the future? Are there any mirrors for the Sun javadocs?
score: 4
has answer: http://stackoverflow.com/a/570590
has answer: http://stackoverflow.com/a/570246
accepted answer: http://stackoverflow.com/a/570268

http://stackoverflow.com/a/576255
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/576253
type: Answer
upvote count: 22
downvote count: 0
has body: No. true and false are literals.
score: 22
accepted answer of: http://stackoverflow.com/q/576253

http://stackoverflow.com/a/373237
accepted answer of: http://stackoverflow.com/q/373193
answers question: http://stackoverflow.com/q/373193
downvote count: 1
upvote count: 37
score: 36
has body: Classpath hell is an unfortunate consequence of dynamic linking of the kind carried out by Java. Your program is not a fixed entity but rather the exact set of classes loaded by a JVM in a particular instance. It is very possible to be in situations where the same command line on different platforms or even on the same one would result in completely different results because of the resolution rules. There could be differences in standard libraries (very common). Libraries could be hidden by one another (an an older version may even be used instead of a newer one). The directory structure could mess resolution. A different version of the same class may appear in multiple libraries and the first one encountered will be used, etc. Since Java, by specification, uses a first-encountered policy, unknown ordering dependencies can lead to problems. Of course, since this is the command line and it is part of the spec, there are no real warnings. It is very much still a problem. For example on Mac OS the horrible support from Apple means that you machine ends up with several JVMs and several JREs, and you can never easily poart things from place to place. If you have multiple libraries that were compiled against specific but different versions of other libraries, you coulld have problems, etc. However, this problem is not inherent in Java. I remember my share of DLL hell situations while programming windows in the 90s. Any situation where you have to count on something in the file system to assemble your program rather than having a single well defined executable is a problem. However, the benefits of this model are still great, so I'm willing to tolerate this hell. There are also steps in the right direction on the side of Sun. For example, Java6 allows you to simply specify a directory with jars rather than have to enumerate them. BTW: Classpaths are also a problem if you are using an environment that uses a non-default classloader. For example, I have had a lot of problems…
type: AcceptedAnswer
type: Answer

http://stackoverflow.com/comment/127759909
comment on: http://stackoverflow.com/a/522737
type: AnswerComment
type: Comment
has text: What “Incompatability with Annotations” are you talking about?
score: 1

http://stackoverflow.com/a/389068
has comment: http://stackoverflow.com/comment/15928911
has comment: http://stackoverflow.com/comment/216477
type: Answer
downvote count: 1
upvote count: 24
has comment: http://stackoverflow.com/comment/128352500
answers question: http://stackoverflow.com/q/389051
has comment: http://stackoverflow.com/comment/15909637
has comment: http://stackoverflow.com/comment/217213
score: 23
has body: I strongly recommend Java for cross-platform GUI development. In particular, I recommend the GUI builder that comes with the Netbeans IDE. It's very simple and very powerful. You can point and click and drag and drop to create a GUI, and easily customize the actions which various buttons and other components take. I much prefer Python as a language, but none of the free tools for GUI development come anywhere close to this, and the same thing seems to be true for the other languages I've used. (I should point out that QT has wonderful GUI developers for various languages such as C and Python, but it's only free when used on open source projects.) EDIT: QT has recently been relicensed as LGPL, so you're free to use it in commercial applications. The Python bindings for this (PyQT) have not been re-licensed, but another project called PySide has been created to provide Python QT bindings.
has comment: http://stackoverflow.com/comment/221240
has comment: http://stackoverflow.com/comment/128695112

http://stackoverflow.com/q/487126
has title: Is usage of anonymous classes in Java considered bad style or good?
has answer: http://stackoverflow.com/a/10928780
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/487158
tagged with: java
has answer: http://stackoverflow.com/a/487162
score: 40
has body: I know anonymous classes save typing when it comes to implementing Listener and similar stuff. They try to be a replacement for some usages of closures. But what does the community think about the value of this language-feature? Does it make sense and do you use it regularly? Does it make the code clearer, more understandable and more maintainable? Or do anonymous classes make the code less readable? What is your opinion, and please have examples/arguments handy to support your opinion?
type: Question
has answer: http://stackoverflow.com/a/65162817
has answer: http://stackoverflow.com/a/487140
has answer: http://stackoverflow.com/a/487556
accepted answer: http://stackoverflow.com/a/487162
has comment: http://stackoverflow.com/comment/58052708
has answer: http://stackoverflow.com/a/487293
has answer: http://stackoverflow.com/a/487942
has answer: http://stackoverflow.com/a/487183
has answer: http://stackoverflow.com/a/487146
has answer: http://stackoverflow.com/a/4584563
tagged with: anonymous-class
has answer: http://stackoverflow.com/a/487256
linked to: http://stackoverflow.com/q/1028850
answer count: 15
favorite count: 0
has answer: http://stackoverflow.com/a/13638919
tagged with: coding-style
has answer: http://stackoverflow.com/a/43722750
upvote count: 41
has answer: http://stackoverflow.com/a/487145
possible better answer: http://stackoverflow.com/a/10928780
downvote count: 1

http://stackoverflow.com/comment/340173
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/527020
has text: Wouldn't it be good if there were a convention saying: If a method does not need access to internals of the object and does not change the state of the object, then it should not be a member (or should be static?) String.replace() seems to be a good example.

http://stackoverflow.com/q/517502
upvote count: 17
tagged with: jvm
favorite count: 0
has body: Why does the jvm require around 10 MB of memory for a simple hello world but the clr doesn't. What is the trade-off here, i.e. what does the jvm gain by doing this? Let me clarify a bit because I'm not conveying the question that is in my head. There is clearly an architectural difference between the jvm and clr runtimes. The jvm has a significantly higher memory footprint than the clr. I'm assuming there is some benefit to this overhead otherwise why would it exist. I'm asking what the trade-offs are in these two designs. What benefit does the jvm gain from it's memory overhead?
possible better answer: http://stackoverflow.com/a/855138
has answer: http://stackoverflow.com/a/855138
has answer: http://stackoverflow.com/a/876685
has answer: http://stackoverflow.com/a/871724
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/871724
has comment: http://stackoverflow.com/comment/672677
has answer: http://stackoverflow.com/a/517622
tagged with: java
has comment: http://stackoverflow.com/comment/674034
score: 16
type: Question
tagged with: .net
has title: jvm design decision
answer count: 6
has comment: http://stackoverflow.com/comment/674000
has answer: http://stackoverflow.com/a/518363
tagged with: clr
has comment: http://stackoverflow.com/comment/663137
has answer: http://stackoverflow.com/a/866890
downvote count: 1

http://stackoverflow.com/a/496605
type: Answer
has comment: http://stackoverflow.com/comment/2930610
has comment: http://stackoverflow.com/comment/2931749
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/495792
has comment: http://stackoverflow.com/comment/4993087
has body: No experience with Pitchfork, but lots with Spring. Foregoing EJBs hasn't been a problem. POJOs have been more than adequate. Two other alternatives to consider: You can use OpenEJB with Tomcat if you need EJBs, want to stick with Tomcat, and don't want to switch to a purchased or open source Java EE app server. You can try Spring dm Server with OSGi. Eat the shell and the egg - go all the way.
answers question: http://stackoverflow.com/q/495792
has comment: http://stackoverflow.com/comment/4988606
has comment: http://stackoverflow.com/comment/4988476
upvote count: 1
type: AcceptedAnswer

http://stackoverflow.com/comment/19264434
has text: Neither link to exampledepot is working. Do you have any references to what library the examples used, or any other info that might help?
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/550172

http://stackoverflow.com/comment/45888940
score: 9
has text: At least as of Java 7, `AbstractCollection@toString` (and thus `String + Stack`) already prints it like you want it.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/395401

http://stackoverflow.com/comment/262124
type: Comment
comment on: http://stackoverflow.com/a/438162
has text: If you're relying on the data to be visible externally, then, no there's no other way. You'll have to clear and reinstantiate your fixtures after every run. You can do this without writing extra code by adding `fixtures :model1, :model2, ...` to your test class.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/351872
type: Comment
has text: The advantage of not making it static is that someone can subclass and override the method's behavior.
comment on: http://stackoverflow.com/a/538922
type: AnswerComment
score: 4

http://stackoverflow.com/a/567690
type: Answer
has body: The octal (leading 0) and hexadecimal (leading 0x) were inherited from C. For comparison, try System.out.println(0x123);
upvote count: 4
downvote count: 0
score: 4
answers question: http://stackoverflow.com/q/565634

http://stackoverflow.com/comment/78460212
comment on: http://stackoverflow.com/a/3303638
type: AnswerComment
has text: A friendly disclaimer: Johan is the main contributor to the project.
score: 39
type: Comment

http://stackoverflow.com/comment/251373
score: 0
has text: What do you mean by override a variable? You can access it if it is protected or public, but not private.
comment on: http://stackoverflow.com/q/427756
type: QuestionComment
type: Comment

http://stackoverflow.com/a/435080
downvote count: 0
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/435069
has body: Since the queue is thread-safe, you do not need to perform any synchronizations to ensure thread-safety. However, you should ensure all threads have equal access to the queue to avoid starvation, busy-waiting, etc... Since the queue is unbounded, the size of the queue is limited only by the amount of memory you have available.

http://stackoverflow.com/comment/282362
comment on: http://stackoverflow.com/a/463636
score: 0
type: AnswerComment
type: Comment
has text: But I'm not suggesting that you should not learn C++, my suggestion is to start with C, and then move to C++, which is much better suited for moderns projects, and give you something really powerfull like templates (boost, stl, etc).

http://stackoverflow.com/comment/361235
has text: Not sure if "nice" is the term, especially in the absence of closure syntax - but it gets the job done :-) See my blog posting on the subject here, too: http://metatechnology.blogspot.com/2007/02/raii-and-closures-in-java.html
type: Comment
comment on: http://stackoverflow.com/a/549108
score: 1
type: AnswerComment

http://stackoverflow.com/a/641188
downvote count: 1
answers question: http://stackoverflow.com/q/641172
has body: The way that I would do is: frame.toFront(); frame.setState(Frame.NORMAL); and If you also want have more control on it you should use requestFocuse. BTW, here is an example : http://coding.derkeiler.com/Archive/Java/comp.lang.java.gui/2006-06/msg00152.html
upvote count: 5
score: 4
has comment: http://stackoverflow.com/comment/454672
type: Answer

http://stackoverflow.com/comment/449016
type: QuestionComment
has text: "ab" is not a string, but a char* in c++, they can't be concatenated using the + operator.
score: 0
comment on: http://stackoverflow.com/q/635807
type: Comment

http://stackoverflow.com/a/596558
downvote count: 0
type: Answer
upvote count: 3
score: 3
has body: instanceof works for instences of the same class or its subclasses You can use it to test if an object is an instance of a class, an instance of a subclass, or an instance of a class that implements a particular interface. ArryaList and RoleList are both instanceof List While getClass() == o.getClass() will be true only if both objects ( this and o ) belongs to exactly the same class. So depending on what you need to compare you could use one or the other. If your logic is: "One objects is equals to other only if they are both the same class" you should go for the "equals", which I think is most of the cases.
answers question: http://stackoverflow.com/q/596462

http://stackoverflow.com/a/484757
score: 1
upvote count: 1
has body: As java is becoming open source, you can take the source(if it is all available) and make your own version of java. If this gets wide scale adoption then great, if not then it may not be a set of features that are needed.
answers question: http://stackoverflow.com/q/484172
downvote count: 0
type: Answer

http://stackoverflow.com/comment/79711983
type: Comment
has text: Either java.nio.file.Path nor java java.nio.file.Paths seem to have a static method "isValidPath". I am using JDK 8
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/35452697

http://stackoverflow.com/comment/1549801
has text: Java reg ex: one caveat, they behave as if they started with "^" and ended with "$", frequently requiring ".*" to be added to the edges if you are looking for a pattern *somewhere within* the searched string, rather than a "complete" match.
comment on: http://stackoverflow.com/a/484454
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/400124
type: Comment
comment on: http://stackoverflow.com/a/588065
has text: @mmyers: And test frameworks too of course. Ok, then, what I've posted is how the annotation is declared. Then to use it I just annotate the class I need ( does it applies to methods and interfaces too ) What about attributes? And then, using an annotation processing tool you read them. Am I right?
score: 0
type: AnswerComment

http://stackoverflow.com/q/610458
has answer: http://stackoverflow.com/a/610482
score: 81
has answer: http://stackoverflow.com/a/610610
answer count: 12
has answer: http://stackoverflow.com/a/610472
has comment: http://stackoverflow.com/comment/14955567
has answer: http://stackoverflow.com/a/610469
has answer: http://stackoverflow.com/a/610487
has body: I'm sure you all know the behaviour I mean - code such as: Thread thread = new Thread(); int activeCount = thread.activeCount(); provokes a compiler warning. Why isn't it an error? EDIT: To be clear: question has nothing to do with Threads. I realise Thread examples are often given when discussing this because of the potential to really mess things up with them. But really the problem is that such usage is always nonsense and you can't (competently) write such a call and mean it. Any example of this type of method call would be barmy. Here's another: String hello = "hello"; String number123AsString = hello.valueOf(123); Which makes it look as if each String instance comes with a "String valueOf(int i)" method.
has answer: http://stackoverflow.com/a/60448158
downvote count: 1
possible better answer: http://stackoverflow.com/a/610610
has answer: http://stackoverflow.com/a/612190
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/610674
tagged with: java
tagged with: methods
has answer: http://stackoverflow.com/a/610488
has answer: http://stackoverflow.com/a/611922
has answer: http://stackoverflow.com/a/610521
upvote count: 82
has title: Why isn't calling a static method by way of an instance an error for the Java compiler?
favorite count: 0
accepted answer: http://stackoverflow.com/a/610674
tagged with: static
has answer: http://stackoverflow.com/a/612307

http://stackoverflow.com/q/470430
has body: In plain Java SE 6 environment: Logger l = Logger.getLogger("nameless"); l.setLevel(Level.ALL); l.fine("somemessage"); Nothing shows up in Eclipse console. l.info("") and above works just fine, but anything below fine just doesn't seem to work. What's could be wrong? TIA.
type: Question
has answer: http://stackoverflow.com/a/25601484
possible better answer: http://stackoverflow.com/a/981230
has answer: http://stackoverflow.com/a/470492
has title: java.util.logging.Logger doesn't respect java.util.logging.Level?
has answer: http://stackoverflow.com/a/7958284
has answer: http://stackoverflow.com/a/981230
answer count: 6
has comment: http://stackoverflow.com/comment/15415331
downvote count: 0
has answer: http://stackoverflow.com/a/4773443
favorite count: 0
accepted answer: http://stackoverflow.com/a/470492
upvote count: 56
tagged with: logging
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/16616386
has comment: http://stackoverflow.com/comment/1503894
linked to: http://stackoverflow.com/q/6307648
score: 56
tagged with: java
has comment: http://stackoverflow.com/comment/16124363
has answer: http://stackoverflow.com/a/1609263

http://stackoverflow.com/comment/197281
type: Comment
comment on: http://stackoverflow.com/a/367882
score: 0
type: AnswerComment
has text: But in this case: filenames are cannot contain line breaks. And besides, in normal mode the dot does not match newline characters, so using [^\r\n] seems like overkill to me.

http://stackoverflow.com/comment/3558100
score: 0
type: AnswerComment
has text: You have to do more processing on the result of each of the count calls before returning (adding them to the return register's current value), so I don't think you have a proper tail call here. :-(
type: Comment
comment on: http://stackoverflow.com/a/3418307

http://stackoverflow.com/a/510892
downvote count: 0
upvote count: 2
type: Answer
score: 2
accepted answer of: http://stackoverflow.com/q/510869
has body: If you have Java installed on your machine then zip that whole directory and give that to those guys. They can extract it to their machine, they don;t need admin rights for that. Thats it you are done and can use javac and java to compile and run. You can add the bin directory to your PATH then you can executes these command from anywhere. Also you can login to a remote machine where JDK is installed and the logged in user have execute permission.
answers question: http://stackoverflow.com/q/510869
type: AcceptedAnswer

http://stackoverflow.com/comment/12599625
has text: and very unexpected stuff that is caused by inconsistencies and stuff, like you expected X to be resolved to Y but Y was not found even though it should be. But unfortionately you often find completely irrelevant logging like 'Entered method XY'. Funny that such logging is often done by people that have very easy-breakable code and/or dislike debuggers.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/1998619

http://stackoverflow.com/comment/452281
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/638602
type: Comment
has text: hmmm, I have offered a solution to the guy in New Zealand who are looking for help on this. But I need to wait for tomorrow (11 hrs ahead) to see if they get anywhere. Then I will place my finding here. thanks man

http://stackoverflow.com/a/11126667
has body: The best way that i find when solve simulare problem import java.awt.AWTException; import java.awt.Robot; public class MyRobot { public static void typeString(String s) { try { Robot robik = new Robot(); byte[] bytes = s.getBytes(); for (byte b : bytes) { int code = b; // keycode only handles [A-Z] (which is ASCII decimal [65-90]) if (code &gt; 96 &amp;&amp; code &lt; 123) code = code - 32; robik.delay(40); robik.keyPress(code); robik.keyRelease(code); } } catch (AWTException e){ } } } http://www.devdaily.com/java/java-robot-class-example-mouse-keystroke\
answers question: http://stackoverflow.com/q/397113
has comment: http://stackoverflow.com/comment/14590015
downvote count: 1
type: Answer
upvote count: 0
score: -1

http://stackoverflow.com/a/529629
type: Answer
answers question: http://stackoverflow.com/q/529593
has body: You could use the KeyListener interface, and on each keyTyped event you copy the text to the "duplicate" field.
score: 0

http://stackoverflow.com/a/405115
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/405078
score: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/230265
has body: To be honest, having tried both, if you use JOGL instead you'll find there's tonnes of OpenGL examples to copy that sort of thing from, and you won't have to code around the limits of the scene graph Java3D gives you. I tried Java3D a couple of years ago in a simple wireframe viewer, and it was such a pain to get the camera control right and the rendering anywhere near OK that I gave up on it.

http://stackoverflow.com/a/10021028
upvote count: 1
answers question: http://stackoverflow.com/q/529085
has comment: http://stackoverflow.com/comment/33899946
type: Answer
has body: An easy, albeit messy workaround to this would be to nest a second "holder" class inside of your main class, and use it to hold your data. public class Whatever&lt;Thing&gt;{ private class Holder&lt;OtherThing&gt;{ OtherThing thing; } public Holder&lt;Thing&gt;[] arrayOfHolders = new Holder&lt;Thing&gt;[10] }
score: -1
downvote count: 2

unicode
tags question: http://stackoverflow.com/q/469874
tag name: unicode
tags question: http://stackoverflow.com/q/577846
type: Tag
tags question: http://stackoverflow.com/q/450676
tags question: http://stackoverflow.com/q/607176
tags question: http://stackoverflow.com/q/397113
tags question: http://stackoverflow.com/q/482466
tags question: http://stackoverflow.com/q/411631
tags question: http://stackoverflow.com/q/404733

http://stackoverflow.com/comment/1899427
has text: Netty is asynchronous and event-driven like MINA. Check out the testimonials and performance reports written by real users in the home page. :)
type: AnswerComment
score: 1
type: Comment
comment on: http://stackoverflow.com/a/592592

http://stackoverflow.com/a/584245
has comment: http://stackoverflow.com/comment/7361091
score: 1
upvote count: 1
has body: I'd suggest JBoss Seam. It has a very different dependency injection model than Spring. Seam's DI is bidirectional and able to inject values at every stage in an object's life (not just during initialization). It's certainly not a good for everything, but if your looking to try different things in DI, this is interesting. Look at Seam's home page.
downvote count: 0
answers question: http://stackoverflow.com/q/582098
type: Answer

http://stackoverflow.com/comment/51345876
type: Comment
has text: Quite poor library, written with incredible amounts of bugs. Barely can imagine who dare to use it.
comment on: http://stackoverflow.com/a/3944206
score: 0
type: AnswerComment

http://stackoverflow.com/q/502218
tagged with: sandbox
type: Question
upvote count: 96
has answer: http://stackoverflow.com/a/20036246
has answer: http://stackoverflow.com/a/502293
has answer: http://stackoverflow.com/a/502364
has answer: http://stackoverflow.com/a/24225075
answer count: 7
possible better answer: http://stackoverflow.com/a/502364
favorite count: 0
has answer: http://stackoverflow.com/a/29022478
score: 96
has body: In a simulation server environment where users are allowed to submit their own code to be run by the server, it would clearly be advantageous for any user-submitted code to be run in side a sandbox, not unlike Applets are within a browser. I wanted to be able to leverage the JVM itself, rather than adding another VM layer to isolate these submitted components. This kind of limitation appears to be possible using the existing Java sandbox model, but is there a dynamic way to enable that for just the user-submitted parts of a running application?
has title: Sandbox against malicious code in a Java application
has answer: http://stackoverflow.com/a/502388
accepted answer: http://stackoverflow.com/a/502388
tagged with: plugins
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/25497153
linked to: http://stackoverflow.com/q/65503490
downvote count: 0
tagged with: java

http://stackoverflow.com/a/629850
upvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/629798
score: 2
downvote count: 0
has body: Gaussian distribution with your parameters. is has density e^(-x^2/2). In general it is of the form e^(linear(x)+linear(x^2)) which means whatever settings you give it, you have some probability of getting very large and very small numbers. You are probably looking for some other distribution.

http://stackoverflow.com/comment/444375
type: QuestionComment
score: 0
has text: How does your performance compare to CLI/gzip performance for the same operation?
comment on: http://stackoverflow.com/q/631484
type: Comment

http://stackoverflow.com/comment/43546538
score: 0
type: Comment
has text: This business everyone has installed in their heads from pretenders that dynamic_cast is "generally a sign of poor design" need to rethink how the language was developed. I'm pretty sure Stroustrup had his reasons and it most likely much more in the know about how and why than any pretenders...
comment on: http://stackoverflow.com/a/500495
type: AnswerComment

http://stackoverflow.com/a/69203657
type: Answer
has body: With all above said... Notice this property is called dll.auto and should only control dll operations(create/drop schema/table), I found surprisingly that it has to do with dml, too: only update will allow insert data, which is dml operation. Got caught by this when trying to populate data into a in-memory database; only update works.
score: 0
answers question: http://stackoverflow.com/q/438146

http://stackoverflow.com/q/573194
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/573217
tagged with: java
tagged with: multithreading
has comment: http://stackoverflow.com/comment/384866
type: Question
tagged with: jakarta-ee
has answer: http://stackoverflow.com/a/574850
accepted answer: http://stackoverflow.com/a/573217
has title: Thread safety in Java web application data access class
has body: A hobby project of mine is a Java web application. It's a simple web page with a form. The user fills out the form, submits, and is presented with some results. The data is coming over a JDBC Connection. When the user submits, I validate the input, build a "CREATE ALIAS" statement, a "SELECT" statement, and a "DROP ALIAS" statement. I execute them and do whatever I need to do with the ResultSet from the query. Due to an issue with the ALIASes on the particular database/JDBC combination I'm using, it's required that each time the query is run, these ALIASes are created with a unique name. I'm using an int to ensure this which gets incremented each and every time we go to the database. So, my data access class looks a bit like: private final static Connection connection = // initialized however private static int uniqueInvocationNumber = 0; public static Whatever getData(ValidatedQuery validatedQuery) { String aliasName = "TEMPALIAS" + String.valueOf(uniqueInvocationNumber); // build statements, execute statements, deal with results uniqueInvocationNumber++; } This works. However, I've recently been made aware that I'm firmly stuck in Jon Skeet's phase 0 of threading knowledge ("Complete ignorance - ignore any possibility of problems.") - I've never written either threaded code or thread-aware code. I have absolutely no idea what can happen when many users are using the application at the same time. So my question is, (assuming I haven't stumbled to thread-safety by blind luck / J2EE magic): How can I make this safe? I've included information here which I believe is relevant but let me know if it's not sufficient. Thanks a million. EDIT: This is a proper J2EE web application using the Wicket framework. I'm typically deploying it inside Jetty. EDIT: A long story about the motivation for the ALIASes, for those interested: The database in question is DB2 on AS400 (i5, System i, iSeries, whatever IBM are calling it these days) and I'm using jt400. Although DB2 on AS400 is…
score: 0
answer count: 3
possible better answer: http://stackoverflow.com/a/573216
has answer: http://stackoverflow.com/a/573216

http://stackoverflow.com/comment/235121
type: Comment
has text: Ah? Somebody already told me, but before posting, I checked and found lot of jar files (in program/classes). It has lot of DLL and exe files too, indeed. Confusing, at least.
comment on: http://stackoverflow.com/a/407493
type: AnswerComment
score: 0

http://stackoverflow.com/q/457933
possible better answer: http://stackoverflow.com/a/45868848
score: 5
has answer: http://stackoverflow.com/a/45868848
upvote count: 5
tagged with: java
accepted answer: http://stackoverflow.com/a/458090
tagged with: associative-array
has title: Creating package-level associative array in java
answer count: 2
downvote count: 0
linked to: http://stackoverflow.com/q/25619803
favorite count: 0
tagged with: oracle-database
tagged with: jdbc
has answer: http://stackoverflow.com/a/458090
type: AnsweredQuestion
has body: Is it possible to create a java representation of a package-level oracle associative array. For example, given the following: CREATE OR REPLACE PACKAGE MyPackage AS TYPE t_numbers IS TABLE OF NUMBER INDEX BY PLS_INTEGER; I find I cannot write the following java: ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("MyPackage.t_numbers", connection); (throws a SQLException "Invalid name pattern"). What is the correct syntax for an ArrayDescriptor referencing a package-level associative array? Does such a thing even exist?
type: Question

http://stackoverflow.com/a/533847
has comment: http://stackoverflow.com/comment/14939154
upvote count: 85
has body: It is discouraged because all resources within the environment are meant to be managed, and potentially monitored, by the server. Also, much of the context in which a thread is being used is typically attached to the thread of execution itself. If you simply start your own thread (which I believe some servers will not even allow), it cannot access other resources. What this means, is that you cannot get an InitialContext and do JNDI lookups to access other system resources such as JMS Connection Factories and Datasources. There are ways to do this "correctly", but it is dependent on the platform being used. The commonj WorkManager is common for WebSphere and WebLogic as well as others More info here And here Also somewhat duplicates this one from this morning UPDATE: Please note that this question and answer relate to the state of Java EE in 2009, things have improved since then!
has comment: http://stackoverflow.com/comment/41671952
has comment: http://stackoverflow.com/comment/28762065
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/41680934
type: Answer
accepted answer of: http://stackoverflow.com/q/533783
score: 85
answers question: http://stackoverflow.com/q/533783
downvote count: 0

http://stackoverflow.com/a/14039026
upvote count: 14
type: Answer
has body: Here are some features of apache wicket: POJO Component Model Pages and Components in Wicket are real Java objects that support encapsulation, inheritance and events. Ease of Development Because Wicket is Java and HTML, you can leverage what you know about Java or your favorite HTML editor to write Wicket applications. Separation of Concerns Wicket does not mix markup with Java code and adds no special syntax to your markup files. The worlds of HTML and Java are parallel and associated only by Wicket ids, which are attributes in HTML and Component properties in Java. Since Wicket HTML is just HTML and Wicket Java is just Java, coders and designers can work independently to a large degree and without relying on any special tools. Secure Wicket is secure by default. URLs do not expose sensitive information and all component paths are session-relative. Explicit steps must be taken to share information between sessions. Furthermore URL encryption allows highly secure web sites. Transparent, Scalable Clustering Support All Wicket applications will work on a cluster automatically and without additional work. Once bottlenecks are understood, Wicket enables tuning of page state replication. The next version of Wicket will support client-side models for zero-state scalability. Transparent Back Button Support Wicket supports configurable page version management. When users submit a form or follow a link from a page they accessed with the back button in their browser, Wicket is able to revert the page object to the state it was in when the page was originally rendered. This means you can write web applications that support the back button with very little work. Multi-tab and multi-window support Wicket provides an easy way to write application that supports multi-window and multi-tab usage allowing developer to react properly when users open new browser window or tab Reusable Components Reusable components in Wicket are particularly easy to create. Not only can you extend exis…
score: 14
answers question: http://stackoverflow.com/q/544049
downvote count: 0

http://stackoverflow.com/comment/21868877
type: AnswerComment
has text: in that case if I give -XX:CompileThreshold=10, then we are good to test it for a loop of 10000(yup, I know it will run only for some millisecs only)
type: Comment
comment on: http://stackoverflow.com/a/599608
score: 0

http://stackoverflow.com/comment/25803023
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/428146
has text: It can be done with statics... public static final HasAge INSTANCE = new HasAge() { private int age; @Override public int getAge() { return age; } }; ... so I'm still wondering what is good or better about the enum method. I suppose if you needed to implement two interfaces?

http://stackoverflow.com/a/587344
type: Answer
upvote count: 4
answers question: http://stackoverflow.com/q/587317
downvote count: 0
has body: OpenJDK should have everything you search for, e.g. the Java 7 mercurial (hg) repository. A zip file with everything from Feb 21th is also available. If you don't want the brand new developer stuff from Java 7, there is also everything for the well known Java 6.
score: 4

http://stackoverflow.com/comment/290443
comment on: http://stackoverflow.com/a/467429
score: 0
type: Comment
has text: java.lang.SecurityManager. Not very fashionable. Mostly used for applets and WebStart.
type: AnswerComment

http://stackoverflow.com/a/601843
has body: Once a report is created, it is available to anyone who can see it. that is quite telling - it means that the reports are sharable, and you also would like to "cache" reports so that it doesnt have to be regenerated. one way to do this would be to work out a way to hash the parameters together, in such a way that different parameter combinations (that result in different a report) hash to different values. then, you can use those hash as a key into a large cache of reports stored in disk in zip (may be the name of the file is the hash?) that way, every time someone requests a report, you hash the parameters, and check if that report was already generated, and serve that up, either as a zip download, or, you can unzip it, and serve up the html as per normal. If the report doesnt exist, generate it, and zip it, make sure to be able to identify it later on as being produced by these parameters (i.e., record the hash). one thing to be careful of is that file system writes tends to be non-atomic, so if you are not careful, you will regenerate the report twice, which sucks, but luckily in your case, not too harmful. to avoid, you can use a single thread to do it (slower), or implement some kind of lock.
answers question: http://stackoverflow.com/q/601497
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/422543
downvote count: 0
has comment: http://stackoverflow.com/comment/414207
type: Answer

http://stackoverflow.com/a/569409
type: Answer
has body: You can probably do this with the ColorSpace class. I would be surprised if you needed to convert each YCbCr value individually. I'm sure the java.awt.image package will provide classes for handling this. You may find something in Chapter 5 of Java Advanced Imaging.
upvote count: 3
accepted answer of: http://stackoverflow.com/q/568994
score: 3
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/568994

http://stackoverflow.com/comment/336284
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/521370
type: Comment
has text: Are you actually using the Windows look and feel?

http://stackoverflow.com/a/462629
has comment: http://stackoverflow.com/comment/281195
answers question: http://stackoverflow.com/q/462501
upvote count: 4
has comment: http://stackoverflow.com/comment/282119
has comment: http://stackoverflow.com/comment/390977
has body: Basically in java (opposed to .NET) you have two types of exceptions: Checked Exception: All classes that inherit from exception. Client code has to handle this kind of exceptions (enforced in the compiler) via try-catch or throws clause. Unchecked Exception: All classes that inherit from RuntimeException. Client code does not have to handle this type of exceptions. May I suggest the following O'Reilly On Java Exception article.
downvote count: 2
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/391201

http://stackoverflow.com/a/577581
has body: "this" is a reference to the current object. See details here
answers question: http://stackoverflow.com/q/577575
score: 6
downvote count: 0
type: Answer
upvote count: 6

http://stackoverflow.com/q/362740
has answer: http://stackoverflow.com/a/61805013
tagged with: java
has answer: http://stackoverflow.com/a/2594106
tagged with: concurrency
score: 37
has answer: http://stackoverflow.com/a/362750
possible better answer: http://stackoverflow.com/a/362844
linked to: http://stackoverflow.com/q/106591
has body: For years and years, I've tried to understand the part of Java specification that deals with memory model and concurrency. I have to admit that I've failed miserably. Yes' I understand about locks and "synchronized" and wait() and notify(). And I can use them just fine, thank you. I even have a vague idea about what "volatile" does. But all of that was not derived from the language spec - rather from general experience. Here are two sample questions that I am asking. I am not so much interested in particular answers, as I need to understand how the answers are derived from the spec (or may be how I conclude that the spec has no answer). What does "volatile" do, exactly? Are writes to variable atomic? Does it depend on variable's type?
accepted answer: http://stackoverflow.com/a/362804
has answer: http://stackoverflow.com/a/362844
downvote count: 0
has answer: http://stackoverflow.com/a/371550
has answer: http://stackoverflow.com/a/65382087
favorite count: 0
has answer: http://stackoverflow.com/a/363009
linked to: http://stackoverflow.com/q/12825847
answer count: 10
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/517532
has title: Java memory model - can someone explain it?
has answer: http://stackoverflow.com/a/362804
type: Question
has answer: http://stackoverflow.com/a/362880
upvote count: 37
has answer: http://stackoverflow.com/a/20075960

http://stackoverflow.com/a/405276
answers question: http://stackoverflow.com/q/405078
upvote count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/230379
has body: To be perfectly honest, most "clever" user interfaces are ineffective for a number of reasons: They favor complexity (for the sake of coolness) over simplicity and usability. They are likely to be totally unfamiliar to the user. You have to implement them yourself without some library having done the hard work for you. I think the interface you describe runs the risk of falling into this trap. What's wrong with the current interface? Won't it be really hard to get an overview due to foreground stuff getting in the way? Now of course you could take it a step further and zoom out/rotate to get an overview but that complicates things. Having said all that, if you can make it easy to use and really slick, then it can make an application. Users will have a lower tolerance for failure in "fancy" UIs, so perhaps this isn't the best first 3D project. I do think there is a need for more examples geared towards visualisation rather than games.
type: Answer
score: 2

http://stackoverflow.com/q/606086
has body: I have output messages displayed on the Java console for an application that started using webstart. Instead of the user manually clearing message, is there a way of clearing console messages in code? These messages are printed at the rate of about 1000 per second and seem to end up using too much memory, i could have stopped the printing to console, but the requirement is to always have it.
has answer: http://stackoverflow.com/a/606323
type: AnsweredQuestion
score: 3
has comment: http://stackoverflow.com/comment/5426121
upvote count: 3
tagged with: java
linked to: http://stackoverflow.com/q/2979383
type: Question
accepted answer: http://stackoverflow.com/a/606323
tagged with: java-web-start
has answer: http://stackoverflow.com/a/606111
answer count: 2
duplicate of: http://stackoverflow.com/q/2979383
has title: How do you clear the Java Console?
downvote count: 0
possible better answer: http://stackoverflow.com/a/606111
tagged with: console
favorite count: 0
has comment: http://stackoverflow.com/comment/418482
tagged with: jnlp
has comment: http://stackoverflow.com/comment/418617

http://stackoverflow.com/comment/354668
type: Comment
comment on: http://stackoverflow.com/a/542655
has text: +1. I love regex, but use the right tool for the job. regex is the wrong tool for this job.
score: 0
type: AnswerComment

http://stackoverflow.com/a/402838
has comment: http://stackoverflow.com/comment/228465
accepted answer of: http://stackoverflow.com/q/402833
upvote count: 4
has comment: http://stackoverflow.com/comment/228307
has body: You can think about using scripting from Java 6. The reference JDK comes with a JavaScript implementation, and you can plug in other languages too.
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/228014
has comment: http://stackoverflow.com/comment/228006
type: Answer
has comment: http://stackoverflow.com/comment/227998
answers question: http://stackoverflow.com/q/402833
has comment: http://stackoverflow.com/comment/228001
has comment: http://stackoverflow.com/comment/228016
downvote count: 1
score: 3

http://stackoverflow.com/comment/1062951
score: 3
comment on: http://stackoverflow.com/a/463437
type: AnswerComment
type: Comment
has text: @Jared: "until the string is interned" makes no sense. Strings don't magically "become" interned. String.intern() returns a different object, unless you already have the canonical instance of the specified String. Also, all literal strings and string-valued constant expressions are interned. Always. See the docs for String.intern() and §3.10.5 of the JLS.

http://stackoverflow.com/comment/431811
has text: do you have an example of your code?
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/618919

http://stackoverflow.com/a/360718
score: 5
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/360026
has body: Couple of options: add the one-to-many to the parent with cascading delete, but mitigate the performance loss using lazy loading. use a Hibernate Interceptor (or an aspect in an AOP environment) to detect parent record deletions and delete children. Personally I would favour the first option, as it lets your data model more closely reflect the real relationships in your data. Edit: there's a third option, but it's not pleasant - use a database trigger, and flush your Hibernate cache (or use a non-caching session).
type: Answer
has comment: http://stackoverflow.com/comment/6750096
upvote count: 5
accepted answer of: http://stackoverflow.com/q/360026
has comment: http://stackoverflow.com/comment/948722

http://stackoverflow.com/a/646233
answers question: http://stackoverflow.com/q/646224
has comment: http://stackoverflow.com/comment/459689
has comment: http://stackoverflow.com/comment/8529833
has body: If you create the hash on the client side, there should be no need to think about this problem. The plain password is never submitted to the server.
has comment: http://stackoverflow.com/comment/459784
type: Answer
has comment: http://stackoverflow.com/comment/459727
score: 3
has comment: http://stackoverflow.com/comment/459771
has comment: http://stackoverflow.com/comment/13834072
downvote count: 1
upvote count: 4

http://stackoverflow.com/comment/201191
has text: Value types in .NET resides on the stack unless they are part of a reference type in which case they are on the heap.
score: 3
type: AnswerComment
comment on: http://stackoverflow.com/a/372555
type: Comment

http://stackoverflow.com/comment/391131
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/579224
has text: Can you maybe post how you are opening the file / what code you are using to do so?
score: 0

http://stackoverflow.com/comment/441951
has text: I understand that, which is why I said you need it for getNode(). You only want the case insensitive search when looking up the node, not inserting, so perhaps have a flag on compareCharsAlphabetically() to do case insensitive or not
type: AnswerComment
comment on: http://stackoverflow.com/a/618122
score: 0
type: Comment

http://stackoverflow.com/a/624504
upvote count: 4
has comment: http://stackoverflow.com/comment/437443
downvote count: 0
has comment: http://stackoverflow.com/comment/437380
has comment: http://stackoverflow.com/comment/439176
score: 4
answers question: http://stackoverflow.com/q/624468
has comment: http://stackoverflow.com/comment/438239
accepted answer of: http://stackoverflow.com/q/624468
has body: I am currently using declarative transaction management in the two Java projects I work on, specifying which methods need transactional scope with @Transactional annotation. In my opinion, it is a good mix of flexibility and robustness: you are able to see which methods have transactional behavior via a simple text search, can adjust isolation and propagation attributes by hand if needed, and the additional amount of typing is practically negligent. On one of those projects, I have security/logging implemented via aspects and have occasionally stumbled on same obstacles you when renaming a method or changing signatures. In the worst case, I lost some logging data of user accessing contracts, and in one release, some user roles were not able to access all application features. Nothing major, but, as far as database transactions go, though, I think it's simply not worth it, and I it is better to type @Transactional bit yourself. Spring does the hard part, anyway.
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/437408
has comment: http://stackoverflow.com/comment/438205
type: Answer

http://stackoverflow.com/comment/22184609
comment on: http://stackoverflow.com/a/527069
type: Comment
score: 2
has text: @Stoffe: I've suggested an edit fixing the links thanks to your comments. You can gain reputation by suggesting edits, so why not do that in future?
type: AnswerComment

http://stackoverflow.com/a/602687
type: Answer
score: 2
upvote count: 2
has body: I don't think you should have a system classpath environment variable on Linux or any other operating system. Each and every project should have its own classpath settings. They're usually set by scripts or convention, so there's no need for a system environment variable. Besides, what would you do if two projects had conflicting JARs required? Will that environment classpath include every JAR needed by every project on your machine? That's not practical. A classpath environment variable might have been the standard with Java 1.0, but I don't think it should be now.
has comment: http://stackoverflow.com/comment/418189
downvote count: 0
answers question: http://stackoverflow.com/q/602651

accessibility
tags question: http://stackoverflow.com/q/462198
type: Tag
tags question: http://stackoverflow.com/q/437517
tag name: accessibility

http://stackoverflow.com/comment/20470412
type: Comment
has text: Ah sorry I didn't see your answer but your right you can use AspectJ: http://stackoverflow.com/questions/7403321/what-is-a-short-example-of-inter-type-declarations-in-aspectj-which-demonstrates/7403617#7403617
type: AnswerComment
comment on: http://stackoverflow.com/a/8848324
score: 0

http://stackoverflow.com/comment/22884160
has text: The syntax is `a instanceof Bref` not `a instanceof Bref.class`. The second argument to the instanceof operator is a class name, not an expression resolving to a class object instance.
score: 80
type: AnswerComment
comment on: http://stackoverflow.com/a/497001
type: Comment

http://stackoverflow.com/a/447510
upvote count: 2
has body: CharBooleanType is probably what you are looking for http://www.hibernate.org/hib_docs/v3/api/org/hibernate/type/class-use/CharBooleanType.html edit: dtsazza's answer is probably more useful if you just want to get going and use characters y/n or t/f. If those don't match your usage you can implement your own type using CharBooleanType.
answers question: http://stackoverflow.com/q/447478
type: Answer
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/268693

communication
tag name: communication
tags question: http://stackoverflow.com/q/443543
tags question: http://stackoverflow.com/q/368802
tags question: http://stackoverflow.com/q/581612
type: Tag

http://stackoverflow.com/a/468491
score: 10
upvote count: 10
downvote count: 0
type: Answer
has body: As already mentioned in the UPDATE of the question I've implemented a simpler way of replacing transparent pixels with predefined color: public static BufferedImage fillTransparentPixels( BufferedImage image, Color fillColor ) { int w = image.getWidth(); int h = image.getHeight(); BufferedImage image2 = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g = image2.createGraphics(); g.setColor(fillColor); g.fillRect(0,0,w,h); g.drawRenderedImage(image, null); g.dispose(); return image2; } and I call this method before jpeg conversion in this way: if( inputImage.getColorModel().getTransparency() != Transparency.OPAQUE) { inputImage = fillTransparentPixels(inputImage, Color.WHITE); }
answers question: http://stackoverflow.com/q/464825
has comment: http://stackoverflow.com/comment/23185338

http://stackoverflow.com/q/413292
possible better answer: http://stackoverflow.com/a/413323
type: Question
score: 9
upvote count: 9
has answer: http://stackoverflow.com/a/414144
tagged with: java
has answer: http://stackoverflow.com/a/414218
has title: Detecting Java Project Cruft
has answer: http://stackoverflow.com/a/413323
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/413738
accepted answer: http://stackoverflow.com/a/413738
has body: I'm a NetBeans 6.5 user and am searching for a way of generating a list of methods/classes that are not used within a set project group. I know I can right click on each method and select "Find Usages" but I'm looking for an automation to that process. I'm willing to look at something that runs outside of netbeans, as long as it generates a list of cruft methods/classes. Thanks.
answer count: 4
type: AnsweredQuestion
tagged with: netbeans
tagged with: refactoring

http://stackoverflow.com/comment/27777698
comment on: http://stackoverflow.com/a/6992265
type: AnswerComment
has text: aye, but in regard to clean ways to build sql, this would be a bit messy code in my eyes if you are not using JOOQ to execute. in this example you set A to 1, B to 2 etc, but you have to do it one more time when you execute if you are not executing with JOOQ.
score: 0
type: Comment

http://stackoverflow.com/a/409579
downvote count: 0
upvote count: 1
type: Answer
score: 1
answers question: http://stackoverflow.com/q/371751
has body: I would really recommend looking at Blackberry as a target platform to play with, for the following reasons: Lots of documentation Access to cheap devices for testing No walled garden (approval system or closed marketplace), you can distribute your app via over the air downloads (user just has to point their browser to the appropriate JAD file and download/install begins) Large user base (at least within the US) Quality forum support for blackberry developers Supports J2ME. You can either develop Blackberry specific apps of J2ME specific apps, both run on blackberry devices. Blackberry specific apps have a more elegent UI library (lots of J2ME witdgets you need to roll your own or use a library like LWUIT) and you won't be able to run Blackberry specific apps to other devices (though the underlying logic will be the same) Both Blackberry and J2ME specific apps can still access and use underlying non-ui classes of each framework. The only cons: Not as sexy as Android or iPhone development Initial setup can be clumsy Tough to monetize because no formal blackberry store to manage transactions and installs You can get more info about Blackberry development here: http://na.blackberry.com/eng/developers/started/

http://stackoverflow.com/q/425439
has answer: http://stackoverflow.com/a/425469
accepted answer: http://stackoverflow.com/a/425466
has title: How to check if array element is null to avoid NullPointerException in Java
type: Question
answer count: 8
has answer: http://stackoverflow.com/a/49170558
tagged with: arrays
downvote count: 0
has comment: http://stackoverflow.com/comment/4450317
tagged with: nullpointerexception
tagged with: exception
has answer: http://stackoverflow.com/a/425476
has answer: http://stackoverflow.com/a/42139984
has answer: http://stackoverflow.com/a/31917356
favorite count: 0
has answer: http://stackoverflow.com/a/425466
has body: I have a partially nfilled array of objects, and when I iterate through them I tried to check to see whether the selected object is null before I do other stuff with it. However, even the act of checking if it is null seem to through a NullPointerException. array.length will include all null elements as well. How do you go about checking for null elements in an array? For example in the following code will throw an NPE for me. Object[][] someArray = new Object[5][]; for (int i=0; i&lt;=someArray.length-1; i++) { if (someArray[i]!=null) { //do something } }
upvote count: 21
possible better answer: http://stackoverflow.com/a/425479
has comment: http://stackoverflow.com/comment/249306
has answer: http://stackoverflow.com/a/425479
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/425505
score: 21
tagged with: java

http://stackoverflow.com/q/498043
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/4615054
tagged with: java
score: 16
upvote count: 16
type: Question
has answer: http://stackoverflow.com/a/4462077
has title: What is the currently popular Java SIP library?
has answer: http://stackoverflow.com/a/498227
accepted answer: http://stackoverflow.com/a/498227
downvote count: 0
tagged with: sip
favorite count: 0
has body: I'm working on developing a SIP application in Java and wondering what is the most used SIP library currently. MJSIP?
answer count: 5
possible better answer: http://stackoverflow.com/a/498307
has answer: http://stackoverflow.com/a/5132852
has comment: http://stackoverflow.com/comment/13327245
has answer: http://stackoverflow.com/a/498307

http://stackoverflow.com/comment/291868
comment on: http://stackoverflow.com/a/474357
has text: That's interesting material, but not quite what I need, though. The Differential Execution is too slow for my purpose (because of the repeated scan-compare), and I also fear threading issues. The callback would help only if there was sth triggering the proper event upon data change.
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/281295
comment on: http://stackoverflow.com/a/462714
type: AnswerComment
score: 0
has text: I find this mildly surprising, but I know you're a smart dude Tim so I'll take it w/o a reference. :) However, if a was final, this would not be a concern, correct? You would then be bound by final freeze semantics during construction?
type: Comment

http://stackoverflow.com/q/518354
has body: I have an instance of the following object in the jsp page context: Class User{ private boolean isAdmin; public boolean isAdmin(){return isAdmin} } How can I query the isAdmin property from the EL? This doesn't seem to work: ${user.admin} nor does this: ${user.isAdmin} thanks! -Morgan
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/521069
has answer: http://stackoverflow.com/a/518549
possible better answer: http://stackoverflow.com/a/518417
has answer: http://stackoverflow.com/a/518417
type: Question
score: 9
has answer: http://stackoverflow.com/a/518525
tagged with: jsp
has answer: http://stackoverflow.com/a/4761388
favorite count: 0
has title: getting boolean properties from objects in jsp el
answer count: 5
upvote count: 9
downvote count: 0
accepted answer: http://stackoverflow.com/a/521069

http://stackoverflow.com/comment/528353
type: Comment
has text: I know it's been a long time but... the problem was my machine. The default program assiciation in my Windows XP are not ok and I'm having issue in other programs. I tried with other machines since then and this method work just fine ! Accepted !
type: AnswerComment
score: 5
comment on: http://stackoverflow.com/a/550336

http://stackoverflow.com/comment/203285
score: 0
type: Comment
comment on: http://stackoverflow.com/a/369436
has text: I remembered coming across it earlier. Everything I would have mentioned had been said over there already.
type: AnswerComment

http://stackoverflow.com/a/633536
upvote count: 27
has body: No performance penalty from an execution point of view. Slight performance penalty from a compiling point of view as there is more to parse, but if anyone were actually that concerned about it they would have to write their code all on one line :-) And now for the opinion part of our post... I always put in the { and } because there is a penalty for maintainability in that you will likely have to put them in at a later date, and it can be a pain putting them in later... but that is 103% personal preference.
score: 27
downvote count: 0
has comment: http://stackoverflow.com/comment/26810397
answers question: http://stackoverflow.com/q/633497
has comment: http://stackoverflow.com/comment/26797437
type: Answer

http://stackoverflow.com/a/1267316
has comment: http://stackoverflow.com/comment/17986363
downvote count: 1
has comment: http://stackoverflow.com/comment/18033367
score: 7
upvote count: 8
answers question: http://stackoverflow.com/q/587458
type: Answer
has comment: http://stackoverflow.com/comment/19304114
has body: The simplest approach is to use static imports. It allows for code reuse that 'looks' like it's part of the class, but is really defined elsewhere. Pros: really easy you can 'mixin' as many static imports as you like Cons: the static methods won't have access to 'this', so you'd have to pass it in manually no state: your static methods can't have their own instance fields. They can only define their own static fields, which are then shared by any object calling the static method. can't define public methods on the client class (the one with code being mixed into it). In Ruby, importing a mixin will actually define those public methods as public methods on your class. In Java, inheritance would be a better solution in this case (assuming you don't need to extend multiple classes) Example: import static my.package.MyHelperUtility.methodDefinedInAnotherClass; public class MyNormalCode { public void example() { methodDefinedInAnotherClass(); } }
has comment: http://stackoverflow.com/comment/18028433

http://stackoverflow.com/comment/437028
score: 0
type: Comment
comment on: http://stackoverflow.com/a/624146
has text: If anyone else is using the machine, they will not be happy. If the simulation crashes, your machine's clock is wrong. If you create files during the simulation, their timestamps will be in the future afterwards.
type: AnswerComment

http://stackoverflow.com/comment/137457124
comment on: http://stackoverflow.com/a/19877310
score: 0
type: AnswerComment
type: Comment
has text: Although this is the command provided in the linked article, it doesn't work as written. The property must be specified via -J-D, not just -D.

http://stackoverflow.com/comment/428591
score: 0
has text: I don't see how that's going to make much difference. Even if the raw XML parsing is significantly faster, you've still got the IPC overhead.
type: Comment
comment on: http://stackoverflow.com/a/611856
type: AnswerComment

scheduling
tags question: http://stackoverflow.com/q/614257
type: Tag
tags question: http://stackoverflow.com/q/409932
tag name: scheduling
tags question: http://stackoverflow.com/q/438312
tags question: http://stackoverflow.com/q/562652

http://stackoverflow.com/q/441240
tagged with: properties
has answer: http://stackoverflow.com/a/441405
has comment: http://stackoverflow.com/comment/263218
has answer: http://stackoverflow.com/a/16338878
possible better answer: http://stackoverflow.com/a/444922
tagged with: java
has answer: http://stackoverflow.com/a/444922
has comment: http://stackoverflow.com/comment/263446
has answer: http://stackoverflow.com/a/442220
upvote count: 12
has answer: http://stackoverflow.com/a/442849
downvote count: 0
has answer: http://stackoverflow.com/a/442805
has answer: http://stackoverflow.com/a/441262
has answer: http://stackoverflow.com/a/441615
tagged with: javabeans
has answer: http://stackoverflow.com/a/441273
has title: JavaBeans alternatives?
has body: I hate the JavaBeans pattern with a passion that burns like the fire of a thousand suns. Why? Verbose. It's 2009. I shouldn't have to write 7 LOC for a property. If they have event listeners then hold on to your hat. No type-safe references. There is no type-safe way to reference a property. The whole point of Java is that it is type safe, and its most popular pattern is not at all typesafe. What I would like is something like: class Customer { public Property&lt;String&gt; name = new Property(); } I am a web developer mostly, so it needs JPA and Wicket support. Help me off the javabean train!
type: Question
has comment: http://stackoverflow.com/comment/263250
type: AnsweredQuestion
favorite count: 0
has answer: http://stackoverflow.com/a/1188192
answer count: 11
has answer: http://stackoverflow.com/a/27624170
score: 12
has comment: http://stackoverflow.com/comment/264072
accepted answer: http://stackoverflow.com/a/441615

http://stackoverflow.com/comment/91598067
score: 0
type: AnswerComment
type: Comment
has text: The key value "{60254CA5-953B-11CF-8C96-00AA00B8708C}" is better for this - it's the WSH drop handler that handles long filenames better. (obtained from here: https://stackoverflow.com/a/142854/638544)
comment on: http://stackoverflow.com/a/11291625

http://stackoverflow.com/a/407537
upvote count: 2
score: 0
downvote count: 2
answers question: http://stackoverflow.com/q/407506
has comment: http://stackoverflow.com/comment/834572
type: Answer
has body: GWT is conceptually similar to Swing, but is more a replacement for JSPs than anything else.

http://stackoverflow.com/a/69455848
answers question: http://stackoverflow.com/q/411331
type: Answer
downvote count: 0
has body: I just spent quite a bit of time figuring out how to use JavaMail to send emails with gmail or office365. I couldn't find the answer in the faq, but was helped a bit by the javadoc. If you forget props.put("mail.smtp.starttls.enable","true") you get com.sun.mail.smtp.SMTPSendFailedException: 451 5.7.3 STARTTLS is required to send mail. If you forget props.put("mail.smtp.ssl.protocols", "TLSv1.2"); you get javax.mail.MessagingException: Could not convert socket to TLS; and No appropriate protocol (protocol is disabled or cipher suites are inappropriate). Apparently this is only necessary for JavaMail versions 1.5.2 and older. Here is the minimal code I required to get it to work: import java.util.Properties; import javax.mail.Authenticator; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; public class SendEmail { public static void main(String[] args) { Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable","true"); // smtp.gmail.com supports TLSv1.2 and TLSv1.3 // smtp.office365.com supports only TLSv1.2 props.put("mail.smtp.ssl.protocols", "TLSv1.2"); props.put("mail.smtp.host", "smtp.office365.com"); props.put("mail.smtp.port", "587"); Session session = Session.getInstance(props, new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("test@example.com", "******"); } }); try { Message message = new MimeMessage(session); message.setFrom(new InternetAddress("sender@example.com")); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("recipient@example.com")); message.setSubject("You got mail"); message.setText("This email was sent with JavaMail."); Transport.send(message); System.out.println("Email sent."); } catch (MessagingEx…
score: 7
upvote count: 7

http://stackoverflow.com/a/518742
score: 1
has body: Most of these cause unpredictable behavior. To quote Steve McConnell's Code Complete 2nd Edition "Using pointers is inherently complicated, and using them correctly requires that you have an excellent understanding of your compiler's memory-management scheme".
answers question: http://stackoverflow.com/q/518708
has comment: http://stackoverflow.com/comment/332338
upvote count: 1
type: Answer
downvote count: 0

tcp
type: Tag
tags question: http://stackoverflow.com/q/483963
tags question: http://stackoverflow.com/q/572831
tag name: tcp

http://stackoverflow.com/a/440273
type: Answer
has body: You do it by assigning an input / action map for the Enter key. Something like the following: // save the command mapping for space Object spaceMap = button.getInputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true)); // add a mapping from enter to the same command. button.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true),spaceMap);
answers question: http://stackoverflow.com/q/440209
has comment: http://stackoverflow.com/comment/262568
score: 0
has comment: http://stackoverflow.com/comment/262578

http://stackoverflow.com/a/637632
has body: Surround the Callable.call method or the Runnable.run method with a try/catch... eg: public void run() { try { // ... code } catch(final IOException ex) { // handle it } catch(final RuntimeException ex) { // handle it } catch(final Exception ex) { // handle it } catch(final Error ex) { // handle it } catch(final Throwable ex) { // handle it } } Note that catching anything other than what the compiler tells you too (the IOException in my sample) isn't a good idea, but there are some times, and this sounds like one of them, that it can work out if you handle it properly. Remember that things like Error are very bad - the VM ran out of memory etc... so be careful how you handle them (which is why I separated them out into their own handlers rather than just doing catch(final Throwable ex) and nothing else).
has comment: http://stackoverflow.com/comment/46670806
downvote count: 0
score: 7
has comment: http://stackoverflow.com/comment/450939
accepted answer of: http://stackoverflow.com/q/637618
upvote count: 7
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/637618
type: Answer
has comment: http://stackoverflow.com/comment/452016

http://stackoverflow.com/a/79143602
answers question: http://stackoverflow.com/q/394616
has body: I changed the registry by creating .reg file and paste this bellow code. Should update the path of java.exe before running reg file. [HKEY_CLASSES_ROOT\Applications\java.exe\shell\open\command] @="\"C:\\Program Files\\Java\\jdk-22\\bin\\java.exe\" -jar \"%1\""
has comment: http://stackoverflow.com/comment/139555763
type: Answer
has comment: http://stackoverflow.com/comment/139561688
has comment: http://stackoverflow.com/comment/139561204
has comment: http://stackoverflow.com/comment/139561217
score: 0

http://stackoverflow.com/a/463636
has comment: http://stackoverflow.com/comment/496673
has comment: http://stackoverflow.com/comment/282319
has comment: http://stackoverflow.com/comment/282325
has comment: http://stackoverflow.com/comment/282153
has comment: http://stackoverflow.com/comment/283806
downvote count: 2
has comment: http://stackoverflow.com/comment/282362
has body: I think that C++ would be much easier for you to become proficient in than C. If you've been using Java, you'd have a hard time doing away with conveniences like classes, exceptions, a form of references, dynamic binding, etc. and of course, decent libraries. However, you should learn C first to make sure you really understand what's under the hood and get to experience pointers and their use and the feeling of working "with no protective gear". Once you master that, learn about the inheritance mechanisms in C++ and how it's different from Java (e.g., multiple inheritance).
has comment: http://stackoverflow.com/comment/282160
has comment: http://stackoverflow.com/comment/284998
has comment: http://stackoverflow.com/comment/282352
upvote count: 5
type: Answer
has comment: http://stackoverflow.com/comment/282259
has comment: http://stackoverflow.com/comment/282190
answers question: http://stackoverflow.com/q/463618
score: 3
has comment: http://stackoverflow.com/comment/282165

http://stackoverflow.com/a/461134
has body: If you extract the src.jar (rename it to src.zip and extract) and open the java class jh2.0/src/src/javax/help/resources/Constants.java you will notice that in the section // Tooltips for Actions is located entry for localization: { "tooltip.FavoritesAction", "Add to Favorites"}, This constant is missing from the jh2.0/src/src/javax/help/resources/Constants_de.java which is used in your case. Just add the right translation, compile the source or just this class and add it to the jh.jar (you may treat the jar as a simple zip archive) Yes, I know this is dirty hack, but generally JavaHelp is quite useful
type: Answer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/460978
answers question: http://stackoverflow.com/q/460978
score: 1
upvote count: 1
type: AcceptedAnswer

http://stackoverflow.com/comment/106260549
comment on: http://stackoverflow.com/a/10125367
score: 0
has text: Well, it's still working with Java 8, even though exceptions are thrown and logged if you have a logger installed. With Java 9 and up I haven't tried but would be very surprised if it still worked, because of the implications of project Jigsaw.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/237775
has text: I suggest getting a stack trace with ctrl-break on the console (ctrl-\ on Linux/Solaris) or with jstack or jconsole.
type: Comment
comment on: http://stackoverflow.com/q/411945
score: 0
type: QuestionComment

http://stackoverflow.com/a/484949
answers question: http://stackoverflow.com/q/484925
type: Answer
has comment: http://stackoverflow.com/comment/38698582
upvote count: 10
score: 10
has body: As @Eddie said (seconds before me! :) ), closing the writer and/or the reader will close the underlying socket streams and the socket itself: However, I believe the socket itself will not be closed . Closing the returned InputStream will close the associated socket. You shouldn't close the writer nor the reader. Just flush the writer to make sure your messages will arrive in time. Closing the socket later on will close the respective streams, so you don't need to close them yourself. Just leave your reader/writer objects to the GC.
downvote count: 0

http://stackoverflow.com/a/32517021
score: -2
downvote count: 3
upvote count: 1
has body: One of the disadvantage of private constructor is the exists of method could never be tested. Enum by the nature concept good to apply in specific domain type, apply it to decentralized constants looks not good enough The concept of Enum is "Enumerations are sets of closely related items". Extend/implement a constant interface is a bad practice, it is hard to think about requirement to extend a immutable constant instead of referring to it directly. If apply quality tool like SonarSource, there are rules force developer to drop constant interface, this is a awkward thing as a lot of projects enjoy the constant interface and rarely to see "extend" things happen on constant interfaces
type: Answer
has comment: http://stackoverflow.com/comment/61541254
answers question: http://stackoverflow.com/q/479565

http://stackoverflow.com/a/493960
score: 1
has body: You may well be able to do it using accessibility APIs, which are designed to let screen-readers and so on interact with programs. Have a look at: http://en.wikipedia.org/wiki/Microsoft_UI_Automation
answers question: http://stackoverflow.com/q/492550
upvote count: 1
accepted answer of: http://stackoverflow.com/q/492550
type: AcceptedAnswer
type: Answer
has comment: http://stackoverflow.com/comment/321694
downvote count: 0

http://stackoverflow.com/comment/2872029
type: Comment
has text: @jpdaigle I just tried this in Eclipse Galileo and Helios and the formatter does not replace anything for me (on Mac OS, but I have never seen the formatter do anything like that on other platforms either).
score: 3
comment on: http://stackoverflow.com/a/542142
type: AnswerComment

http://stackoverflow.com/a/1925847
downvote count: 1
upvote count: 17
has comment: http://stackoverflow.com/comment/17612409
score: 16
answers question: http://stackoverflow.com/q/592046
has body: Not sure if this suits your needs, but Multibindings worked for me when I needed to inject multiple elements of the same kind (it produces a set though).
type: Answer

jtable
tags question: http://stackoverflow.com/q/423524
tags question: http://stackoverflow.com/q/528618
tags question: http://stackoverflow.com/q/375265
tags question: http://stackoverflow.com/q/641065
type: Tag
tags question: http://stackoverflow.com/q/609492
tags question: http://stackoverflow.com/q/380482
tags question: http://stackoverflow.com/q/530752
tags question: http://stackoverflow.com/q/561881
tags question: http://stackoverflow.com/q/478726
tags question: http://stackoverflow.com/q/458114
tags question: http://stackoverflow.com/q/377924
tags question: http://stackoverflow.com/q/638807
tags question: http://stackoverflow.com/q/457463
tags question: http://stackoverflow.com/q/561231
tags question: http://stackoverflow.com/q/625698
tag name: jtable
tags question: http://stackoverflow.com/q/371839
tags question: http://stackoverflow.com/q/479317
tags question: http://stackoverflow.com/q/593765
tags question: http://stackoverflow.com/q/366107
tags question: http://stackoverflow.com/q/591610
tags question: http://stackoverflow.com/q/566186
tags question: http://stackoverflow.com/q/370369
tags question: http://stackoverflow.com/q/476721
tags question: http://stackoverflow.com/q/639397
tags question: http://stackoverflow.com/q/400235

http://stackoverflow.com/q/523767
type: AnsweredQuestion
tagged with: java
tagged with: set
has answer: http://stackoverflow.com/a/523818
tagged with: background
tagged with: image
type: Question
upvote count: 22
has body: I am developing a simple platform game using Java using BlueJ as the IDE. Right now I have player/enemy sprites, platforms and other items in the game drawn using polygons and simple shapes. Eventually I hope to replace them with actual images. For now I would like to know what is the simplest solution to setting an image (either URL or from local source) as the 'background' of my game window/canvas? I would appreciate it if it isn't something long or complex as my programming skills aren't very good and I want to keep my program as simple as possible. Kindly provide example codes with comments to elaborate on their function, and also if it's in its own class, how to call on relevant methods used by it on other classes. Thank you very much.
possible better answer: http://stackoverflow.com/a/607855
accepted answer: http://stackoverflow.com/a/523818
downvote count: 0
has answer: http://stackoverflow.com/a/607855
score: 22
has answer: http://stackoverflow.com/a/10326251
has answer: http://stackoverflow.com/a/55457394
has title: How to set background image in Java?
favorite count: 0
answer count: 5
has answer: http://stackoverflow.com/a/10019574

cxf
tags question: http://stackoverflow.com/q/439629
tags question: http://stackoverflow.com/q/462786
type: Tag
tags question: http://stackoverflow.com/q/578970
tags question: http://stackoverflow.com/q/543896
tag name: cxf

http://stackoverflow.com/comment/35533572
has text: You forgot to include a REALLY important part of this code `import java.lang.reflect.Array; import java.lang.reflect.Field;` (I just worked out how to edit your post to add it)
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/4272554
score: 1

http://stackoverflow.com/a/489267
answers question: http://stackoverflow.com/q/489204
score: 0
has body: I have done the 'brute search' - the problem is, with a 5x5 grid there are SO many combinations that it just takes forever. I left it running whilst I went to work...8 hours later, it was still going, the queue arraylist size was up to 100k different states and my pc sounded like it was going to overheat and explode lol I know my code works (eventually, like I said) so I would be happy to submit it. I'm just worried about the time it takes to find a solution and wondered whether there is a better approach I could take, other than using an arraylist to create a queue.
type: Answer

http://stackoverflow.com/a/482587
answers question: http://stackoverflow.com/q/482560
has comment: http://stackoverflow.com/comment/113649201
score: 8
has comment: http://stackoverflow.com/comment/113659134
type: Answer
downvote count: 1
has comment: http://stackoverflow.com/comment/131794196
upvote count: 9
has body: You could check the system class path property for the Equinox launcher: if (System.getProperty("java.class.path").contains("org.eclipse.equinox.launcher")) { System.out.println("You're running inside Eclipse"); } There are some other potential properties that you may check for, which you can find in Eclipse through Help -&gt; About -&gt; Configuration Details. Jon's answer is good if you want to know whether you'r running from a JAR versus running from a bunch of class files. But if you use a JAR in both cases then it won't tell you what you need.

http://stackoverflow.com/a/26981063
type: Answer
score: 8
has comment: http://stackoverflow.com/comment/137113729
has comment: http://stackoverflow.com/comment/66660058
answers question: http://stackoverflow.com/q/508630
has body: Java 8 provides a set of unsigned long operations that allows you to directly treat those Long variables as unsigned Long, here're some commonly used ones: String toUnsignedString(long i) int compareUnsigned(long x, long y) long divideUnsigned(long dividend, long divisor) long remainderUnsigned(long dividend, long divisor) And additions, subtractions, and multiplications are the same for signed and unsigned longs.
downvote count: 0
upvote count: 8
has comment: http://stackoverflow.com/comment/137129011

http://stackoverflow.com/comment/70734388
comment on: http://stackoverflow.com/a/518438
type: AnswerComment
type: Comment
score: 1
has text: Unfortunately the proposed method will commonly be highly imprecise because each event falling into the +/- 100ms wall clock update slot will often return zero for sub-second operations. The sum of 9 operations each with duration of zero is, well, zero, divided by nine is ... zero. Conversely, using System.nanoTime() will provide relatively accurate (non-zero) event durations, which then summed and divided by the number of events will provide a highly precise average.

http://stackoverflow.com/comment/199829
type: QuestionComment
comment on: http://stackoverflow.com/q/371026
has text: It's a framework that requires me to write an iterator
score: 0
type: Comment

http://stackoverflow.com/comment/257942
type: Comment
score: 0
type: AnswerComment
has text: SeamRedirectFilter is not in my web.xml and never has been. org.jboss.seam.servlet.SeamFilter is the only filter I have apart from the UrlRewriteFilter and the the Faces filter
comment on: http://stackoverflow.com/a/434857

http://stackoverflow.com/a/607171
answers question: http://stackoverflow.com/q/607106
type: Answer
score: 2
downvote count: 0
has body: This is precisely the same problem set that the servlet containers have when dealing with hot-swapping of servlets. The webserver/container should run continuously, but must be able to load new servlets on demand. I'd suggest you start out by taking a look at the Tomcat source code (available via these subversion URLs.)
upvote count: 2

http://stackoverflow.com/q/359851
has title: debug a dll from java java->jni.dll ->app.dll -> app.dll
score: 5
has body: how can I debug a dll that is not loaded by the java application. The scenario is this: my java app is loading the jni.dll that is using another dll and that dll is using another dll. java&lt;->jni.dll&lt;->dll&lt;->dll I have the source code for all modules I am using visual studio express when debugging the jni.dll but what should I do to be able to debug the other dlls?
tagged with: dll
has answer: http://stackoverflow.com/a/362091
upvote count: 5
tagged with: java-native-interface
has answer: http://stackoverflow.com/a/2211768
downvote count: 0
has answer: http://stackoverflow.com/a/360223
favorite count: 0
answer count: 5
has answer: http://stackoverflow.com/a/359950
has answer: http://stackoverflow.com/a/856179
type: UnansweredQuestion
tagged with: java
type: Question

http://stackoverflow.com/comment/499260
comment on: http://stackoverflow.com/a/553898
score: 0
type: AnswerComment
has text: Hmm... I'll see if I can can find time to look into it more. I may well not have time though :(
type: Comment

http://stackoverflow.com/q/483087
downvote count: 0
upvote count: 162
favorite count: 0
has answer: http://stackoverflow.com/a/27803015
has answer: http://stackoverflow.com/a/26863931
accepted answer: http://stackoverflow.com/a/531110
score: 162
has title: Overriding Binding in Guice
has answer: http://stackoverflow.com/a/531110
has answer: http://stackoverflow.com/a/25528276
answer count: 5
tagged with: unit-testing
type: AnsweredQuestion
has body: I've just started playing with Guice, and a use-case I can think of is that in a test I just want to override a single binding. I think I'd like to use the rest of the production level bindings to ensure everything is setup correctly and to avoid duplication. So imagine I have the following Module public class ProductionModule implements Module { public void configure(Binder binder) { binder.bind(InterfaceA.class).to(ConcreteA.class); binder.bind(InterfaceB.class).to(ConcreteB.class); binder.bind(InterfaceC.class).to(ConcreteC.class); } } And in my test I only want to override InterfaceC, while keeping InterfaceA and InterfaceB in tact, so I'd want something like: Module testModule = new Module() { public void configure(Binder binder) { binder.bind(InterfaceC.class).to(MockC.class); } }; Guice.createInjector(new ProductionModule(), testModule); I've also tried the following, with no luck: Module testModule = new ProductionModule() { public void configure(Binder binder) { super.configure(binder); binder.bind(InterfaceC.class).to(MockC.class); } }; Guice.createInjector(testModule); Does anyone know if it's possible to do what I want or am I completely barking up the wrong tree?? --- Follow up: It would seem I can achieve what I want if I make use of the @ImplementedBy tag on the interface and then just provide a binding in the test case, which works nicely when there is a 1-1 mapping between the interface and implementation. Also, after discussing this with a colleague it would seem we'd head down the road of overriding an entire module and ensuring we have our modules defined correctly. This seems like it might cause a problem though where a binding is misplaced in a module and needs to be moved, thus possibly breaking a load of tests as bindings may no longer be available to be overriden.
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/29901970
possible better answer: http://stackoverflow.com/a/25528276
tagged with: guice

http://stackoverflow.com/comment/303862
has text: Now I get at least the same file size, thank you for the tipp. But the CRC check still fails...
type: AnswerComment
comment on: http://stackoverflow.com/a/487637
score: 0
type: Comment

http://stackoverflow.com/comment/46482654
has text: It is not correct because **b is an array of Objects**. You should just write `Object[] b = new Object[1]`, anything else is cheating yourself and the compiler (perhaps getting it to let you know, if it was your intention to only store Strings inside, when you are not being consistent). You can store a String in an array of Objects because String inherits from Object, but you certainly have **not** created an array of Strings.
type: Comment
score: 1
comment on: http://stackoverflow.com/a/2924453
type: AnswerComment

http://stackoverflow.com/a/1920861
score: 15
has body: Just for reference: as Carsten said, the eclipse.ini file is quite picky about the order and format of its lines. Here's their Wiki page, with some example configurations. As they say, remember that: Each option and each argument to an option must be on its own line. All lines after -vmargs are passed as arguments to the JVM, so all arguments and options for eclipse must be specified before -vmargs (just like when you use arguments on the command-line) So, for example, you can set the MaxPermSize with an Eclipse launcher-specific option (option name on the first line, option value on the next): --launcher.XXMaxPermSize 256m Then, after the -vmargs option name, you can pass the parameters relative to the garbage collector. For example: -vmargs -XX:-UseParallelGC Hope it helps.
answers question: http://stackoverflow.com/q/477871
type: Answer
upvote count: 15
downvote count: 0

http://stackoverflow.com/a/613857
has body: You could use the catalina.base system property: File confDir = new File(System.getProperty("catalina.base"), "conf"); File confFile = new File(confDir, "myprops.properties"); InputStream in = new FileInputStream(confFile); try { props.load(in); } finally { in.close(); }
type: Answer
score: 1
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/605127
accepted answer of: http://stackoverflow.com/q/605127
type: AcceptedAnswer

http://stackoverflow.com/comment/60912650
type: Comment
comment on: http://stackoverflow.com/a/599181
type: AnswerComment
has text: I am trying to convert an ArrayList to string in a project of mine. I was able to get the string, but it seems like there is an extra space between the characters. Does anyone know how to fix this?
score: 0

regex
tags question: http://stackoverflow.com/q/461631
tags question: http://stackoverflow.com/q/499504
tags question: http://stackoverflow.com/q/538579
tag name: regex
tags question: http://stackoverflow.com/q/485023
tags question: http://stackoverflow.com/q/627545
tags question: http://stackoverflow.com/q/507265
tags question: http://stackoverflow.com/q/610333
tags question: http://stackoverflow.com/q/462048
tags question: http://stackoverflow.com/q/514407
tags question: http://stackoverflow.com/q/375009
tags question: http://stackoverflow.com/q/559254
tags question: http://stackoverflow.com/q/542564
tags question: http://stackoverflow.com/q/606325
tags question: http://stackoverflow.com/q/629721
tags question: http://stackoverflow.com/q/393121
tags question: http://stackoverflow.com/q/637907
tags question: http://stackoverflow.com/q/514313
tags question: http://stackoverflow.com/q/454908
tags question: http://stackoverflow.com/q/567851
tags question: http://stackoverflow.com/q/387008
tags question: http://stackoverflow.com/q/465979
tags question: http://stackoverflow.com/q/600733
tags question: http://stackoverflow.com/q/639264
tags question: http://stackoverflow.com/q/478594
tags question: http://stackoverflow.com/q/554691
tags question: http://stackoverflow.com/q/404733
tags question: http://stackoverflow.com/q/366202
tags question: http://stackoverflow.com/q/501435
tags question: http://stackoverflow.com/q/415580
tags question: http://stackoverflow.com/q/604464
tags question: http://stackoverflow.com/q/367862
tags question: http://stackoverflow.com/q/375420
tags question: http://stackoverflow.com/q/505922
tags question: http://stackoverflow.com/q/628583
tags question: http://stackoverflow.com/q/444602
tags question: http://stackoverflow.com/q/372148
tags question: http://stackoverflow.com/q/381066
tags question: http://stackoverflow.com/q/575500
tags question: http://stackoverflow.com/q/614469
type: Tag
tags question: http://stackoverflow.com/q/530441
tags question: http://stackoverflow.com/q/585379
tags question: http://stackoverflow.com/q/632204
tags question: http://stackoverflow.com/q/512342

http://stackoverflow.com/comment/16148100
type: Comment
score: 2
comment on: http://stackoverflow.com/a/1305966
type: AnswerComment
has text: This is insecure. See comment by Joachim Sauer in the first (equally insecure) option. Proper way to check for existence of a file or dir and than to grab the filename, atomically, is by creating the file or dir.

http://stackoverflow.com/comment/301878
has text: I found that both ends need to be closed.
type: AnswerComment
comment on: http://stackoverflow.com/a/485087
type: Comment
score: 1

http://stackoverflow.com/a/502189
downvote count: 1
answers question: http://stackoverflow.com/q/502178
type: Answer
score: 0
upvote count: 1
has body: You defining the array size by 10 but only initializing 3 indexes. Change your array size to 3 or initialize all ten.

http://stackoverflow.com/a/440835
answers question: http://stackoverflow.com/q/440018
score: 5
upvote count: 5
type: AcceptedAnswer
downvote count: 0
has body: You can get rid of the two source path lines, because by default GWT will pick up anything that is relative to the root, and in the client package like you have. You also need to move your gui package into your client package, so it would become: -com.mycompany -public MyApplication.html MyApplication.gwt.xml -com.mycompany.client MyApp.java -com.mycompany.client.gui TableLayout.java &lt;module&gt; &lt;inherits name="com.google.gwt.user.User" /&gt; &lt;entry-point class="com.mycompany.client.MyApp" /&gt; &lt;/module&gt; Assuming your MyApp.java is an actual EntryPoint, then this should work just fine. One other thing to note is that you cannot use java classes that are not part of the GWT JRE Emulation library, and your project won't compile if you do. You should get very specific errors about this though. For example you cannot use library classes like java.math.BigDecimal, if they are not emulated. All of your own classes you create can be used though.
type: Answer
accepted answer of: http://stackoverflow.com/q/440018

http://stackoverflow.com/q/520467
has answer: http://stackoverflow.com/a/520535
has answer: http://stackoverflow.com/a/520623
has answer: http://stackoverflow.com/a/520534
tagged with: glassfish
downvote count: 0
has comment: http://stackoverflow.com/comment/334101
favorite count: 0
has title: How to read the web.xml from a WebApp
type: UnansweredQuestion
answer count: 4
has answer: http://stackoverflow.com/a/520582
upvote count: 3
tagged with: java
has body: For WebApps, web.xml can be used to store application settings. How can I read this file. My servlets run in a GlassFish v2 server.
tagged with: web-services
type: Question
has comment: http://stackoverflow.com/comment/334117
tagged with: jakarta-ee
score: 3

http://stackoverflow.com/a/590372
downvote count: 1
score: -1
answers question: http://stackoverflow.com/q/590352
upvote count: 0
has body: You should check for recursion - both direct recursion (when a function calls itsself) and indirect recursion (when A calls B and B calls A again). The easiest way to do this is to attach a debugger and look at the call stack at the moment you've got stack overflow.
type: Answer

http://stackoverflow.com/a/397550
answers question: http://stackoverflow.com/q/397524
score: 0
has body: I think I understood you now. :) No, it’s not possible to do it that way. The ResultSet changes its internal state on each call to ResultSet.next() so storing the reference to it won’t get you anywhere. You have to extract the data you want into some custom object and store that. CustomData cd = new CustomData(); cd.setString1(rs.getString(1)); cd.setInt1(rs.getInt(2)); ... You can then store the cd variable and get on with processing your ResultSet.
type: Answer

http://stackoverflow.com/a/553712
upvote count: 3
has comment: http://stackoverflow.com/comment/365579
score: 3
answers question: http://stackoverflow.com/q/553546
has comment: http://stackoverflow.com/comment/365641
downvote count: 0
has body: No - to both questions. Access to all servlet contexts would be a security problem. You would be able to inspect and/or manipulate other webapps. The only one knowing all servlet contexts is the container itself. But this is internal implementation, there is no api. Spring context access is similar, but if you mean all spring contexts in one webapp, they will create a hierarchy - those for controllers for example. Implementing an org.springframework.context.ApplicationListener as bean in the root spring context (as initialized by the org.springframework.web.context.ContextLoaderListener configured in the web.xml) can notify you about contexts started, stopped, closed or refreshed.
type: Answer

http://stackoverflow.com/comment/10172025
score: 0
type: Comment
has text: @Ole: That's right, I don't know how I came to read width and end up giving a height example. Ah well, now there for others who may need it I guess.
comment on: http://stackoverflow.com/a/8110384
type: AnswerComment

http://stackoverflow.com/comment/389465
score: 1
comment on: http://stackoverflow.com/a/577582
has text: could it be to avoid strange constructs like that?
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/365554
type: Comment
has text: Oh and as for anonymous inner classes, it's a great way to prototype things. Eventually I'd refactor it away from there but it's not my priority to make beautiful code at the first time, I want correctly behaving code first.
comment on: http://stackoverflow.com/a/553415
score: 0
type: AnswerComment

http://stackoverflow.com/q/472129
type: Question
has answer: http://stackoverflow.com/a/472138
has comment: http://stackoverflow.com/comment/289733
answer count: 6
tagged with: return-type
has answer: http://stackoverflow.com/a/474744
has answer: http://stackoverflow.com/a/486824
downvote count: 1
has comment: http://stackoverflow.com/comment/289748
has comment: http://stackoverflow.com/comment/289887
accepted answer: http://stackoverflow.com/a/472138
has title: why do functions dont have parameterized return types, as it has parameterized input?
tagged with: java
has answer: http://stackoverflow.com/a/472224
upvote count: 4
possible better answer: http://stackoverflow.com/a/472145
has comment: http://stackoverflow.com/comment/289840
type: AnsweredQuestion
tagged with: function
score: 3
has answer: http://stackoverflow.com/a/474676
has answer: http://stackoverflow.com/a/472145
favorite count: 0
has body: This always forces us to return a single parameter in case I need to return multiple, say a List and a String. This restriction is not there in function arguments.

http://stackoverflow.com/comment/16384085
type: AnswerComment
has text: I thought one shouldn't catch unchecked exceptions!
score: 0
type: Comment
comment on: http://stackoverflow.com/a/464640

http://stackoverflow.com/comment/27384783
type: Comment
comment on: http://stackoverflow.com/a/402527
has text: +1 for the paper. The one problem I have with it is that it doesn't take into account how much time and pain is spent with runtime defects for each case. Sometimes the compiler / language constrains me in ways that I don't like and slows me down, but the payoff is huge compared to tracking down problems in a live runtime scenario. So, if there is information that the class MUST have to operate and trying do use it without that information would cause strange behaviour then parameters in the constructor seem to make sense to me.
type: AnswerComment
score: 0

http://stackoverflow.com/a/605901
has comment: http://stackoverflow.com/comment/124071454
answers question: http://stackoverflow.com/q/605891
type: Answer
has comment: http://stackoverflow.com/comment/418234
upvote count: 274
has comment: http://stackoverflow.com/comment/35704830
has comment: http://stackoverflow.com/comment/418667
has comment: http://stackoverflow.com/comment/52234072
score: 273
has comment: http://stackoverflow.com/comment/418696
downvote count: 1
has body: toCharArray followed by Arrays.sort followed by a String constructor call: import java.util.Arrays; public class Test { public static void main(String[] args) { String original = "edcba"; char[] chars = original.toCharArray(); Arrays.sort(chars); String sorted = new String(chars); System.out.println(sorted); } } EDIT: As tackline points out, this will fail if the string contains surrogate pairs or indeed composite characters (accent + e as separate chars) etc. At that point it gets a lot harder... hopefully you don't need this :) In addition, this is just ordering by ordinal, without taking capitalisation, accents or anything else into account.
has comment: http://stackoverflow.com/comment/35702434
has comment: http://stackoverflow.com/comment/52236284

http://stackoverflow.com/comment/105615913
type: AnswerComment
has text: "the memory address whose array(number array) declared is printed" That's not true at all, its system hash code of object, and this can be based on many things, including memory address, but this could change later and hash code would not change. And currently its mostly a random number. https://gotofinal.dev/java/2017/10/08/java-default-hashcode.html
comment on: http://stackoverflow.com/a/51124754
score: 0
type: Comment

http://stackoverflow.com/a/443034
score: 16
downvote count: 1
upvote count: 17
has comment: http://stackoverflow.com/comment/264795
accepted answer of: http://stackoverflow.com/q/443010
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2566374
answers question: http://stackoverflow.com/q/443010
has comment: http://stackoverflow.com/comment/3696741
has comment: http://stackoverflow.com/comment/4378644
type: Answer
has body: Java Language Conversion Assistant. Optionally installed with (at least) Visual Studio 2005 Standard Edition. Select File/Open/Convert/Java Language Conversion Assistant. Remember to manually go over the code afterwards. It will have lots of issues.
has comment: http://stackoverflow.com/comment/264800
has comment: http://stackoverflow.com/comment/69132330

http://stackoverflow.com/comment/396983
comment on: http://stackoverflow.com/a/585042
score: 1
has text: What if the method goes to a webserver on the opposite hemishpere and you don't really want that, since you'd be better off with static mock data.
type: AnswerComment
type: Comment

http://stackoverflow.com/a/542910
upvote count: 4
answers question: http://stackoverflow.com/q/481705
type: Answer
score: 3
has body: Here's an article on integrating Guice with Stripes
downvote count: 1

http://stackoverflow.com/a/475224
has comment: http://stackoverflow.com/comment/292626
upvote count: 3
score: 3
has comment: http://stackoverflow.com/comment/292620
answers question: http://stackoverflow.com/q/475097
has body: If the implementation of a method can be expressed completely in terms of the public interface (without downcasting) of your class, then it may be a good candidate for a static "utility" method. This allows you to maintain a minimal interface while still providing the convenience methods that clients of the code may use a lot. As Scott Meyers explains, this approach encourages encapsulation by minimizing the amount of code impacted by a change to the internal implementation of a class. Here's another interesting article by Herb Sutter picking apart std::basic_string deciding what methods should be members and what shouldn't. In a language like Java or C++, I'll admit that the static methods make the code less elegant so there's still a tradeoff. In C#, extension methods can give you the best of both worlds. If the operation will need to be overridden by a sub-class for some reason, then of course it must be an instance method in which case you'll need to think about all the factors that go into designing a class for inheritance.
downvote count: 0
has comment: http://stackoverflow.com/comment/292605
type: Answer

http://stackoverflow.com/a/36309671
upvote count: 11
score: 11
answers question: http://stackoverflow.com/q/466841
has body: Simple comparison of the content of two files with java.nio.file API. byte[] file1Bytes = Files.readAllBytes(Paths.get("Path to File 1")); byte[] file2Bytes = Files.readAllBytes(Paths.get("Path to File 2")); String file1 = new String(file1Bytes, StandardCharsets.UTF_8); String file2 = new String(file2Bytes, StandardCharsets.UTF_8); assertEquals("The content in the strings should match", file1, file2); Or if you want to compare individual lines: List&lt;String&gt; file1 = Files.readAllLines(Paths.get("Path to File 1")); List&lt;String&gt; file2 = Files.readAllLines(Paths.get("Path to File 2")); assertEquals(file1.size(), file2.size()); for(int i = 0; i &lt; file1.size(); i++) { System.out.println("Comparing line: " + i) assertEquals(file1.get(i), file2.get(i)); }
downvote count: 0
type: Answer

http://stackoverflow.com/comment/64939980
score: 4
type: Comment
comment on: http://stackoverflow.com/a/644719
has text: does this shrink the array as well?
type: AnswerComment

http://stackoverflow.com/a/726720
score: 39
type: Answer
answers question: http://stackoverflow.com/q/479565
has comment: http://stackoverflow.com/comment/98088935
has comment: http://stackoverflow.com/comment/89511949
has comment: http://stackoverflow.com/comment/110110443
downvote count: 1
has body: My suggestions (in decreasing order of preference): 1) Don't do it. Create the constants in the actual class where they are most relevant. Having a 'bag of constants' class/interface isn't really following OO best practices. I, and everyone else, ignore #1 from time to time. If you're going to do that then: 2) final class with private constructor This will at least prevent anyone from abusing your 'bag of constants' by extending/implementing it to get easy access to the constants. (I know you said you wouldn't do this -- but that doesn't mean someone coming along after you won't) 3) interface This will work, but not my preference giving the possible abuse mention in #2. In general, just because these are constants doesn't mean you shouldn't still apply normal oo principles to them. If no one but one class cares about a constant - it should be private and in that class. If only tests care about a constant - it should be in a test class, not production code. If a constant is defined in multiple places (not just accidentally the same) - refactor to eliminate duplication. And so on - treat them like you would a method.
upvote count: 40

http://stackoverflow.com/comment/39486334
comment on: http://stackoverflow.com/a/359771
type: AnswerComment
score: 0
has text: If open braces are always placed on lines by themselves, then an `if` which is followed by a single indented line may be visually recognized as controlling a single statement without need for any braces. The open-brace-by-itself style thus saves whitespace in the situation where an `if` statement controls something that is semantically a single action (as distinct from a sequence of steps that happens to only contain a single step). For example, `if (someCondition)` / ` throw new SomeException(...)`.
type: Comment

http://stackoverflow.com/a/580048
has comment: http://stackoverflow.com/comment/392651
downvote count: 0
answers question: http://stackoverflow.com/q/579993
type: Answer
has comment: http://stackoverflow.com/comment/391981
score: 1
upvote count: 1
has body: Just add a listener for scrolling viewport change events and issue a repaint(). I think I would advise against Steve Moyer's answer, since painting should only be done as part of a paint event. And if the scrolled component is large enough you should just repaint the part of your JPanel which is visible within the viewport component (your JScrollPane). Edit To track the movement of the viewport, use JScrollPane getViewport() and JViewport addChangeListener(). Then use the methods of JViewport to identify what part of the view is visible when determining the region to paint in the painting method. Note that this should be an optimization applied only after the painting is working properly by repainting the entire view in each paint event.

http://stackoverflow.com/comment/232131
type: Comment
has text: Do you conceptually want the variable to live for the duration of the loop instead of separately per iteration? I rarely do. Write code which reveals your intention as clearly as possible, unless you've got a very, very good reason to do otherwise.
comment on: http://stackoverflow.com/a/407298
score: 12
type: AnswerComment

http://stackoverflow.com/a/484439
has body: For me, it depends on how badly written the Perl is (I've never seen Perl that I would say was "WELL" written), and whether you'll ever need to READ the Perl. Perl is often a Write Once, Read Never language. If it all works, and you're not likely to need to alter it, I would say don't touch it.
has comment: http://stackoverflow.com/comment/305524
answers question: http://stackoverflow.com/q/484355
type: Answer
downvote count: 9
upvote count: 5
has comment: http://stackoverflow.com/comment/7435993
score: -4
has comment: http://stackoverflow.com/comment/553052

http://stackoverflow.com/a/410460
type: AcceptedAnswer
type: Answer
score: 52
downvote count: 0
upvote count: 52
accepted answer of: http://stackoverflow.com/q/410437
has body: Stopwatch benchmarking is fine, provided you measure enough iterations to be meaningful. Typically, I require a total elapsed time of some number of single digit seconds. Otherwise, your results are easily significantly skewed by scheduling, and other O/S interruptions to your process. For this I use a little set of static methods I built a long time ago, which are based on System.currentTimeMillis(). For the profiling work I have used jProfiler for a number of years and have found it very good. I have recently looked over YourKit, which seems great from the WebSite, but I've not used it at all, personally. To answer the question on scheduling interruptions, I find that doing repeated runs until consistency is achieved/observed works in practice to weed out anomalous results from process scheduling. I also find that thread scheduling has no practical impact for runs of between 5 and 30 seconds. Lastly, after you pass the few seconds threshold scheduling has, in my experience, negligible impact on the results - I find that a 5 second run consistently averages out the same as a 5 minute run for time/iteration. You may also want to consider prerunning the tested code about 10,000 times to "warm up" the JIT, depending on the number of times you expect the tested code to run over time in real life.
answers question: http://stackoverflow.com/q/410437

http://stackoverflow.com/a/529397
score: 2
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/521692
downvote count: 0
answers question: http://stackoverflow.com/q/521692
type: Answer
has body: I added the following line to setup of the unittest System.setProperty("javax.xml.transform.TransformerFactory", "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"); I figured out what to do with a bit of RTFM. http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/transform/TransformerFactory.html#newInstance()
upvote count: 2

http://stackoverflow.com/comment/447138
type: AnswerComment
score: 0
has text: Thanks! Your pointer to java.lang.Enum (Enum<E extends Enum<E>> helped me to find more useful info on this subject.
type: Comment
comment on: http://stackoverflow.com/a/632041

http://stackoverflow.com/comment/277960
type: AnswerComment
comment on: http://stackoverflow.com/a/458599
has text: yes i was quite misguided in my first attempt. thank you for the tip. at least i learned a bit from these comments.
type: Comment
score: 1

http://stackoverflow.com/comment/50123175
comment on: http://stackoverflow.com/a/376284
type: AnswerComment
score: 0
type: Comment
has text: With the correct connector(unsupported for now) jdb can connect to a running process.

http://stackoverflow.com/a/550893
has body: Yes, you are right. Implementation for these interfaces can be found in the database JDBC drivers.
answers question: http://stackoverflow.com/q/550884
score: 2
downvote count: 0
upvote count: 2
type: Answer

http://stackoverflow.com/a/532272
score: 6
answers question: http://stackoverflow.com/q/531694
downvote count: 0
type: Answer
upvote count: 6
has body: Have you tried rebooting since you set the environment variable? It appears that Windows keeps it's environment variable in some sort of cache, and rebooting is one method to refresh it. I'm not sure but there may be a different method, but if you are not going to be changing your variable value too often this may be good enough.

http://stackoverflow.com/a/445307
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/445070
type: Answer
accepted answer of: http://stackoverflow.com/q/445070
score: 3
downvote count: 0
has body: It looks like your call to Thread.sleep doesn't do what you intended, but I don't think it's the source of your trouble. You have: Thread.sleep(Math.max(0, startTime - System.currentTimeMillis())); startTime will always be less than System.currentTimeMillis(), so startTime - System.currentTimeMillis() will always be negative and thus your sleep will always be for 0 milliseconds. It's different from the example you showed because the example increments startTime by 40 milliseconds before doing the calculation. It is calculating how long to sleep for to pad out the drawing time to 40 milliseconds. Anyway, back to your problem. I'd recommend measurement to figure out where your time is being spent. There's no point optimising until you know what's slow. You already know how to use System.currentTimeMillis(). Try using that to measure where all the time goes. Is it all spent drawing the walls? EDIT - I see this got marked as accepted, so should I infer that the problem went away when you fixed the sleep time? I don't have a lot of Java GUI experience, but I can speculate that perhaps your code was starving out other important threads. By setting your thread to have maximum priority and only ever calling sleep(0), you pretty much guarantee that no other thread in your process can do anything. Here's a post from Raymond Chen's blog that explains why.
upvote count: 3

http://stackoverflow.com/comment/343326
type: Comment
comment on: http://stackoverflow.com/q/529457
score: 2
has text: @Calyth That is wrong, there are more efficient methods than O(n^3) using a divide and conquer approach.
type: QuestionComment

http://stackoverflow.com/comment/18297331
type: Comment
has text: It's a nice trick but even that is not always equivalent to calling the unavilable, yet needed) super.super and that is because the super.super call would carry the context of C (C+B+A) whereas your answers creates an instance of A without the context of B and C. So this answer will not work if every doThat called getContext(), for example, and getContext was implemented differently in each class. in your answer it would use A's getContext() whereas calling the unavailable super.super would have resulted in using C's getContext.
score: 6
comment on: http://stackoverflow.com/a/2692379
type: AnswerComment

http://stackoverflow.com/a/610928
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/610918
type: Answer
has body: Split the GUI out from the business logic altogether. Wrap up the GUI as it's own class and attach the actionlisteners in the constructor, and maybe pass in whatever handles the actual business logic. Something like this: if (confirmDrivers()) { new GUI(someBusinessLogicController); }
score: 1

http://stackoverflow.com/comment/300565
comment on: http://stackoverflow.com/a/483949
score: 0
type: Comment
has text: exactly the right answer - classpath containers are pretty easy to write, but you need to deliver a plugin for the rest of your team to use
type: AnswerComment

http://stackoverflow.com/a/397732
has body: Exceptions are apparently 'exceptional' events. In .net's paradigms, exceptions should never occur (that's why you have methods like TryParse, ...), so it makes little sense to be forced to handle events that shouldn't occur anyways.
downvote count: 0
answers question: http://stackoverflow.com/q/385913
type: Answer
has comment: http://stackoverflow.com/comment/224001
has comment: http://stackoverflow.com/comment/4183761
score: 1
upvote count: 1

http://stackoverflow.com/a/578141
score: 6
accepted answer of: http://stackoverflow.com/q/578000
answers question: http://stackoverflow.com/q/578000
has body: As you discovered, theDocument.getText() takes a start and length, not a start and end argument. I thought I'd provide an answer and a link to the JavaDoc for others reading your question who might not look in the comments.
has comment: http://stackoverflow.com/comment/389982
has comment: http://stackoverflow.com/comment/390234
type: AcceptedAnswer
downvote count: 0
type: Answer
upvote count: 6

http://stackoverflow.com/q/556110
type: Question
tagged with: spring-security
accepted answer: http://stackoverflow.com/a/556136
score: 0
has body: When I configure method security under Spring Security I get the error shown above (see stack trace below). I am running Spring 2.5.6, Spring Security 2.0.4 under Eclipse 3.4 with a Tomcat 6 runtime. I need any suggestion as to what to look at to get this working. My security configuration file is as follows: &lt;beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd"&gt; &lt;http auto-config='true'&gt; &lt;intercept-url pattern="/**" access="ROLE_USER" /&gt; &lt;/http&gt; &lt;authentication-provider&gt; &lt;user-service&gt; &lt;user name="admin" password="admin" authorities="ROLE_USER, ROLE_ADMIN" /&gt; &lt;user name="user" password="user" authorities="ROLE_USER" /&gt; &lt;/user-service&gt; &lt;/authentication-provider&gt; &lt;global-method-security jsr250-annotations="enabled"/&gt; And the exception stack trace: ERROR [2009-02-17 20:07:34,828] main org.springframework.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Cannot locate 'org.springframework.security.annotation.Jsr250MethodDefinitionSource' Offending resource: ServletContext resource [/WEB-INF/securityApplicationContext.xml] at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68) at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85) at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:72) at org.springframework.security.config.GlobalMethodSecurityBeanDefinitionParser.validatePresent(GlobalMethodSecurityBeanDefinitionPars…
answer count: 1
has answer: http://stackoverflow.com/a/556136
tagged with: spring
type: AnsweredQuestion
tagged with: java
has title: Cannot locate 'org.springframework.security.annotation.Jsr250MethodDefinitionSource'

http://stackoverflow.com/comment/427551
has text: @codecraig, given your spec that you can have anything between delimiters (including empty strings) and the fact that you don't need "|COL-DELIM||ROW-DELIM|" at the end of each row, the only real check is that the string ends in a row delim (and maybe number of columns is right and/or consistent).
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/614507

http://stackoverflow.com/a/1680095
type: AcceptedAnswer
type: Answer
has body: For the sake of completeness, I ended up writing my own very simple generic interface: public interface IDiagnosticContextHandler { void Set(string name, string value); } then implemented a Log4Net specific version: public class Log4NetDiagnosticContextHandler : IDiagnosticContextHandler { private readonly Assembly assembly; private readonly Type mdcType; public Log4NetDiagnosticContextHandler() { this.assembly = Assembly.Load("log4net"); this.mdcType = this.assembly.GetType("log4net.MDC", true); } public void Set(string name, string value) { this.mdcType.InvokeMember("Set", BindingFlags.InvokeMethod, null, null, new object[] { name, value }); } } I then used an IoC container (Spring.Net) to bring in the correct implementation. If a different logging framework was later required it'd be a simple matter of writing a different implementation of that interface changing the IoC configuration.
accepted answer of: http://stackoverflow.com/q/390115
answers question: http://stackoverflow.com/q/390115
score: 0

http://stackoverflow.com/a/487121
answers question: http://stackoverflow.com/q/487107
upvote count: 21
score: 20
has comment: http://stackoverflow.com/comment/303397
has comment: http://stackoverflow.com/comment/303393
type: Answer
has comment: http://stackoverflow.com/comment/1147849
downvote count: 1
has body: y = Math.round(x / 0.0025) * 0.0025

http://stackoverflow.com/a/625810
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/443531
has comment: http://stackoverflow.com/comment/655401
score: 32
type: Answer
has comment: http://stackoverflow.com/comment/89361482
answers question: http://stackoverflow.com/q/625420
has comment: http://stackoverflow.com/comment/438526
downvote count: 0
has comment: http://stackoverflow.com/comment/442427
has comment: http://stackoverflow.com/comment/438504
has comment: http://stackoverflow.com/comment/89385930
has comment: http://stackoverflow.com/comment/438515
accepted answer of: http://stackoverflow.com/q/625420
has body: A memory mapped file will be fastest... something like this: final File file; final FileChannel channel; final MappedByteBuffer buffer; file = new File(fileName); fin = new FileInputStream(file); channel = fin.getChannel(); buffer = channel.map(MapMode.READ_ONLY, 0, file.length()); and then proceed to read from the byte buffer. This will be significantly faster than FileInputStream or FileReader. EDIT: After a bit of investigation with this it turns out that, depending on your OS, you might be better off using a new BufferedInputStream(new FileInputStream(file)) instead. However reading the whole thing all at once into a char[] the size of the file sounds like the worst way. So BufferedInputStream should give roughly consistent performance on all platforms, while the memory mapped file may be slow or fast depending on the underlying OS. As with everything that is performance critical you should test your code and see what works best. EDIT: Ok here are some tests (the first one is done twice to get the files into the disk cache). I ran it on the rt.jar class files, extracted to the hard drive, this is under Windows 7 beta x64. That is 16784 files with a total of 94,706,637 bytes. First the results... (remember the first is repeated to get the disk cache setup) ArrayTest time = 83016 bytes = 118641472 ArrayTest time = 46570 bytes = 118641472 DataInputByteAtATime time = 74735 bytes = 118641472 DataInputReadFully time = 8953 bytes = 118641472 MemoryMapped time = 2320 bytes = 118641472 Here is the code... import java.io.BufferedInputStream; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; import java.nio.channels.FileChannel.MapMode; import java.util.HashSet; import java.util.Set; public class Main { public static void main(final String[] argv) { ArrayTest.main(argv); ArrayTest.main(argv); DataInputByteAtATime…
has comment: http://stackoverflow.com/comment/442432
upvote count: 32
has comment: http://stackoverflow.com/comment/105018453
has comment: http://stackoverflow.com/comment/439927
has comment: http://stackoverflow.com/comment/439951

http://stackoverflow.com/comment/68033132
score: 0
comment on: http://stackoverflow.com/a/35165138
type: AnswerComment
has text: @Michael also I am not sure what you mean about making destructor virtual more oop friendly. OOP is not about subclassing, it's about giving you the control over the direction of dependencies by strategically placing interfaces in between source code dependencies to make the source code dependencies be plugins into your system rather than coupled to your system. You only need virtual destructors if you expect the class to be subclassed, and Point has no need to ever be subclassed by any sane system, you can delegate it if you wish though.
type: Comment

http://stackoverflow.com/a/26219882
answers question: http://stackoverflow.com/q/467815
score: 5
has body: The following section from the C++ Draft Standard N3337 specifies when a name can be overloaded. 13 Overloading 1 When two or more different declarations are specified for a single name in the same scope, that name is said to be overloaded. By extension, two declarations in the same scope that declare the same name but with different types are called overloaded declarations. Only function and function template declarations can be overloaded; variable and type declarations cannot be overloaded. When you define a class as: class Test { bool isVal() const { return isVal; } private: bool isVal; }; you are overloading the name isVal within the scope of the class. Such an overload is allowed only when isVal is a member function. It is not allowed when isVal is a member variable.
upvote count: 5
type: Answer
downvote count: 0

http://stackoverflow.com/comment/273739
comment on: http://stackoverflow.com/a/453067
score: 0
type: Comment
has text: Ive benchmarked it with and without the buffered inputstream, and it is afaster when using it.
type: AnswerComment

http://stackoverflow.com/comment/385389
score: 0
has text: This is actually a bad example, since any language with coercing (like Java) doesn't require a distinct version for (e.g. int+int+int vs. short+short+short). With coercing, this entire set can be represented as four methods (scalar or float X three or four args).
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/573598

http://stackoverflow.com/comment/331908
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/518363
type: Comment
has text: The other day my 4 GB Vista machine ran out of memory despite appearing to show less than 1 GB used by applications.

http://stackoverflow.com/a/753748
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/433110
has body: Try logFaces, it should be helpful. Disclosure: I am the author of this product.
downvote count: 0

quicktime
tags question: http://stackoverflow.com/q/642242
tag name: quicktime
type: Tag

http://stackoverflow.com/q/383600
has answer: http://stackoverflow.com/a/2083255
answer count: 5
type: UnansweredQuestion
has title: Converting MySql DateTime type into something more friendly
score: 3
upvote count: 3
tagged with: java
has body: I have a Java web app that reads a MySql db and returns DateTime fields. What is the best way to convert the DateTime fields returned in the resultset into something more readable? Currently the DateTime fields print as: 2008-12-14 16:30:00 but I would like something more user friendly like: 14 Dec 2008 at 16:30 I am populating an ArrayList with these dateTimes from a pojo. I would like to format them before adding to the arrayList, so then I can just print the contents of the arrayList in the JSP.
tagged with: mysql
has answer: http://stackoverflow.com/a/383612
type: Question
downvote count: 0
tagged with: jsp
tagged with: pojo
has answer: http://stackoverflow.com/a/383624
has answer: http://stackoverflow.com/a/383703
favorite count: 0
has answer: http://stackoverflow.com/a/2083215